From b1cd6c5ecf3c745e4953f312decc9602ba5f3f87 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 26 Jan 2021 16:18:50 +0100 Subject: [PATCH 001/173] mo line is line so no fetchLines --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 274782a14ea..1d04852efea 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1487,7 +1487,7 @@ class MoLine extends CommonObjectLine public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + return $result; } From 060ddff88389a8ecfa2264afb47cb5383fe7e009 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 30 Jan 2021 17:27:16 +0100 Subject: [PATCH 002/173] Add missing pmp valorisation to MO production. (Issue #16072) --- htdocs/mrp/mo_movements.php | 6 ++- htdocs/mrp/mo_production.php | 76 +++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index b4dbed059bc..8a54a8b0cbd 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -119,7 +119,7 @@ $arrayfields = array( 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1, 'position'=>48), 'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0, 'position'=>50), 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1, 'position'=>60), - 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'enabled'=>0, 'checked'=>0, 'position'=>62), + 'm.price'=>array('label'=>$langs->trans("UnitCost"), 'enabled'=>0, 'checked'=>0, 'position'=>62), //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); @@ -139,7 +139,11 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $permissiontoproduce = $permissiontoadd; +$permissiontoupdatecost = $user->rights->bom->write; // User who can define cost must have knowledge of pricing +if ($permissiontoupdatecost) { + $arrayfields['m.price']['enabled'] = 1; +} /* * Actions diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index c1b6fa64ec8..eb40b1d6f8b 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/bom/class/bom.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); // Load translation files required by the page @@ -88,6 +89,7 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $permissiontoproduce = $permissiontoadd; +$permissiontoupdatecost = $user->rights->bom->write; // User who can define cost must have knowledge of pricing /* @@ -149,7 +151,7 @@ if (empty($reshook)) $moline->fk_mo = $object->id; $moline->qty = GETPOST('qtytoadd', 'int'); ; $moline->fk_product = GETPOST('productidtoadd', 'int'); - $moline->role = 'toconsume'; + $moline->role = 'toconsumef'; // free consume line $moline->position = 0; $resultline = $moline->create($user, false); // Never use triggers here @@ -168,10 +170,10 @@ if (empty($reshook)) $codemovement = GETPOST('inventorycode', 'alphanohtml'); $db->begin(); - + $pos = 0; // Process line to consume foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { + if (preg_match('/toconsume/', $line->role)) { $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); @@ -207,7 +209,6 @@ if (empty($reshook)) } if (!$error) { - $pos = 0; // Record consumption $moline = new MoLine($db); $moline->fk_mo = $object->id; @@ -237,6 +238,7 @@ if (empty($reshook)) } // Process line to produce + $pos = 0; foreach ($object->lines as $line) { if ($line->role == 'toproduce') { $tmpproduct = new Product($db); @@ -245,6 +247,7 @@ if (empty($reshook)) $i = 1; while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); + $pricetoprocess = GETPOST('pricetoproduce-'.$line->id.'-'.$i) ? price2num(GETPOST('pricetoproduce-'.$line->id.'-'.$i)) : 0; if ($qtytoprocess != 0) { // Check warehouse is set if we should have to @@ -266,7 +269,7 @@ if (empty($reshook)) // Record stock movement $id_product_batch = 0; $stockmove->origin = $object; - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); if ($idstockmove < 0) { $error++; setEventMessages($stockmove->error, $stockmove->errors, 'errors'); @@ -274,7 +277,6 @@ if (empty($reshook)) } if (!$error) { - $pos = 0; // Record production $moline = new MoLine($db); $moline->fk_mo = $object->id; @@ -309,7 +311,7 @@ if (empty($reshook)) if (GETPOST('autoclose', 'int')) { foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { + if (preg_match('/toconsume/', $line->role)) { $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); $alreadyconsumed = 0; foreach ($arrayoflines as $line2) { @@ -677,12 +679,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show object lines $object->fetchLines(); + $bomcost = 0; + if ($object->fk_bom > 0) { + $bom = new Bom($db); + $res = $bom->fetch($object->fk_bom); + if ($res > 0) { + $bomcost = $bom->unit_cost; + } + } + + // consumtion + print '
'; print '
'; print '
'; $newlinetext = ''; - if ($action != 'consumeorproduce' && $action != 'consumeandproduceall') { + if (($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; } print load_fiche_titre($langs->trans('Consumption'), '', '', 0, '', '', $newlinetext); @@ -693,6 +706,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("Product").''; print ''.$langs->trans("Qty").''; + if ($permissiontoupdatecost) print ''.$langs->trans("PMPValue").''; print ''.$langs->trans("QtyAlreadyConsumed").''; print ''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); @@ -711,6 +725,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); print ''; print ''; + if ($permissiontoupdatecost) print ''; print ''; print ''; print ''; @@ -734,12 +749,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $nblinetoconsumecursor = 0; foreach ($object->lines as $line) { - if ($line->role == 'toconsume') { + if (preg_match('/toconsume/', $line->role)) { $nblinetoconsumecursor++; $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); + if (!empty($bomcost) && $line->role == 'toconsumef' && $object->qty > 0) { + // add free consume line cost to bomcost + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($db); + $linecost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + if (empty($linecost)) { + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0){ + $linecost = $productFournisseur->fourn_unitprice; + } + } + $bomcost += price2num(($line->qty * $linecost) / $object->qty, 'MT'); + } + $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); $alreadyconsumed = 0; foreach ($arrayoflines as $line2) { @@ -760,6 +788,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $line->qty; } print ''; + if ($permissiontoupdatecost) { + print ''; + print price($tmpproduct->pmp); + print ''; + } print ''; if ($alreadyconsumed) { print '';*/ + + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto); + + print '
'; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + // Set some default values + //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; + + //dol_set_focus('input[name="ref"]'); +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("ConferenceOrBooth"), '', 'object_'.$object->picto); + + print '
'; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $res = $object->fetch_optionals(); + + $head = conferenceorboothPrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') { + $formquestion = array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) { + //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; + $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 .= '
'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + + /* + * Lines + */ + + if (!empty($object->table_element_line)) { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) { + // Send + if (empty($user->socid)) { + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + } + + // Back to draft + if ($object->status == $object::STATUS_VALIDATED) { + print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); + } + + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); + + // Validate + if ($object->status == $object::STATUS_DRAFT) { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { + print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); + } else { + $langs->load("errors"); + //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0); + print ''.$langs->trans("Validate").''; + } + } + + // Clone + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); + + /* + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ENABLED) { + print ''.$langs->trans("Disable").''."\n"; + } else { + print ''.$langs->trans("Enable").''."\n"; + } + } + if ($permissiontoadd) { + if ($object->status == $object::STATUS_VALIDATED) { + print ''.$langs->trans("Cancel").''."\n"; + } else { + print ''.$langs->trans("Re-Open").''."\n"; + } + } + */ + + // Delete (need delete permission, or if draft, just need create/modify permission) + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
'; + print ''; // ancre + + $includedocgeneration = 0; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->eventorganization->conferenceorbooth->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->eventorganization->conferenceorbooth->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('eventorganization:ConferenceOrBooth', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('conferenceorbooth')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'conferenceorbooth'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->eventorganization->dir_output; + $trackid = 'conferenceorbooth'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php new file mode 100644 index 00000000000..792fa77d087 --- /dev/null +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -0,0 +1,85 @@ +. + */ + +/** + * \file lib/eventorganization_conferenceorbooth.lib.php + * \ingroup eventorganization + * \brief Library files with common functions for ConferenceOrBooth + */ + +/** + * Prepare array of tabs for ConferenceOrBooth + * + * @param ConferenceOrBooth $object ConferenceOrBooth + * @return array Array of tabs + */ +function conferenceorboothPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("eventorganization@eventorganization"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/eventorganization/conferenceorbooth_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$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->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization', 'remove'); + + return $head; +} diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 26e06731c72..713a7f31a4f 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -32,9 +32,9 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'recruitment','recruitmentcandidature_send','',0,null,null,'(AnswerCandidature)' ,100,'$conf->recruitment->enabled',1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourCandidature)__', '__(Hello)__ __CANDIDATE_FULLNAME__,

\n\n__(YourCandidatureAnswerMessage)__
__ONLINE_INTERVIEW_SCHEDULER_TEXT_AND_URL__\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBulkMailToAttendes)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 4f1f6c6a59c..5a88439e7de 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -167,12 +167,12 @@ ALTER TABLE llx_tva ADD COLUMN fk_account integer; ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0; -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBulkMailToAttendes)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOragnisationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -- Uniformize field total_ht, total_tva, total_ttc ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 247663135db..7dacefa4d56 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -43,15 +43,17 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction # EventOrganizationConfOrBooth= Conference Or Booth ManageOrganizeEvent = Manage event organisation +ConferenceOrBooth = Conference Or Booth +ConferenceOrBoothTab = Conference Or Booth # # Template Mail # -YourOragnisationEventConfRequestWasReceived = Your request for conference was received -YourOragnisationEventBoothRequestWasReceived = Your request for booth was received +YourOrganizationEventConfRequestWasReceived = Your request for conference was received +YourOrganizationEventBoothRequestWasReceived = Your request for booth was received EventOrganizationEmailAskConf = Request for conference EventOrganizationEmailAskBooth = Request for booth EventOrganizationEmailSubsBooth = Subscription for booth EventOrganizationEmailSubsEvent = Subscription for an event -EventOrganizationMassEmailAttendes = Communication to attendes +EventOrganizationMassEmailAttendees = Communication to attendes EventOrganizationMassEmailSpeakers = Communication to speakers From be34fb454178f800bda438004ba3bc26e6ba8799 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 21 Feb 2021 12:32:16 +0100 Subject: [PATCH 021/173] tab event ok --- htdocs/core/lib/project.lib.php | 2 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 5 + htdocs/install/mysql/tables/llx_projet.sql | 4 + htdocs/langs/en_US/eventorganization.lang | 13 + htdocs/projet/card.php | 18 +- htdocs/projet/class/project.class.php | 27 +- htdocs/projet/event.php | 346 ++++++++++++++++++ htdocs/projet/list.php | 96 +++++ 8 files changed, 500 insertions(+), 11 deletions(-) create mode 100644 htdocs/projet/event.php diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 866a94149c9..c11cc4a74d6 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -125,7 +125,7 @@ function project_prepare_head(Project $project) $langs->load('eventorganization'); //TODO : Count $nbConfOrBooth = 1; - $head[$h][0] = DOL_URL_ROOT . '/eventorganisation/conferenceorbooth_card.php?id=' . $project->id; + $head[$h][0] = DOL_URL_ROOT . '/projet/event.php?id=' . $project->id; $head[$h][1] = $langs->trans("ConferenceOrBoothTab"); if ($nbContact > 0) $head[$h][1] .= '' . $nbConfOrBooth . ''; $head[$h][2] = 'eventorganisation'; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 5a88439e7de..c3b8ab2fea8 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -174,5 +174,10 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +ALTER TABLE llx_projet ADD COLUMN allow_unknown_people_conf integer DEFAULT 0; +ALTER TABLE llx_projet ADD COLUMN allow_unknown_people_booth integer DEFAULT 0; +ALTER TABLE llx_projet ADD COLUMN price_registration double(24,8); +ALTER TABLE llx_projet ADD COLUMN price_booth double(24,8); + -- Uniformize field total_ht, total_tva, total_ttc ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 76d254aafd3..e6dccbaf233 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -48,6 +48,10 @@ create table llx_projet usage_task integer DEFAULT 1, -- Set to 1 if project is used to manage tasks and/or record timesheet usage_bill_time integer DEFAULT 0, -- Set to 1 if time spent must be converted into invoices usage_organize_event integer DEFAULT 0, -- Set to 1 if you want to use project to organize an event, receive attendees subscription + allow_unknown_people_conf integer DEFAULT 0, -- Set to 1 if you want to allow unknown people to suggest conferences + allow_unknown_people_booth integer DEFAULT 0, -- Set to 1 if you want to Allow unknown people to suggest booth + price_registration double(24,8), + price_booth double(24,8), model_pdf varchar(255), last_main_doc varchar(255), -- relative filepath+filename of last main generated document import_key varchar(14) -- Import key diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 7dacefa4d56..0c7e4f047ce 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -57,3 +57,16 @@ EventOrganizationEmailSubsBooth = Subscription for booth EventOrganizationEmailSubsEvent = Subscription for an event EventOrganizationMassEmailAttendees = Communication to attendes EventOrganizationMassEmailSpeakers = Communication to speakers + +# +# Event +# +AllowUnknownPeopleSuggestConf=Allow unknown people to suggest conferences +AllowUnknownPeopleSuggestConfHelp=Allow unknown people to suggest conferences +AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth +AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth +PriceOfRegistration=Price of registration +PriceOfRegistrationHelp=Price of registration +PriceOfBooth=Price of subscription +PriceOfBoothHelp=Price of subscription +EventOrganizationICSLink=Link ICS for events diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0462f9d3391..5370dcfa8f9 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -228,7 +228,7 @@ if (empty($reshook)) } } - if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) + if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) { $error = 0; @@ -1132,7 +1132,7 @@ if ($action == 'create' && $user->rights->projet->creer) if ($action == 'edit' && $userWrite > 0) { print '
'; - print '     '; + print '     '; print ''; print '
'; } @@ -1223,14 +1223,14 @@ if ($action == 'create' && $user->rights->projet->creer) // Send if (empty($user->socid)) { - if ($object->statut != 2) + if ($object->statut != Project::STATUS_CLOSED) { print ''.$langs->trans('SendMail').''; } } // Modify - if ($object->statut != 2 && $user->rights->projet->creer) + if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { @@ -1241,7 +1241,7 @@ if ($action == 'create' && $user->rights->projet->creer) } // Validate - if ($object->statut == 0 && $user->rights->projet->creer) + if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) { if ($userWrite > 0) { @@ -1252,7 +1252,7 @@ if ($action == 'create' && $user->rights->projet->creer) } // Close - if ($object->statut == 1 && $user->rights->projet->creer) + if ($object->statut == Project::STATUS_VALIDATED && $user->rights->projet->creer) { if ($userWrite > 0) { @@ -1263,7 +1263,7 @@ if ($action == 'create' && $user->rights->projet->creer) } // Reopen - if ($object->statut == 2 && $user->rights->projet->creer) + if ($object->statut == Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { @@ -1340,9 +1340,9 @@ if ($action == 'create' && $user->rights->projet->creer) } // Delete - if ($user->rights->projet->supprimer || ($object->statut == 0 && $user->rights->projet->creer)) + if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { - if ($userDelete > 0 || ($object->statut == 0 && $user->rights->projet->creer)) + if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { print ''.$langs->trans("Delete").''; } else { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ff4be5e8d77..878a491de49 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -201,6 +201,10 @@ class Project extends CommonObject 'usage_opportunity' =>array('type'=>'integer', 'label'=>'UsageOpportunity', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'usage_task' =>array('type'=>'integer', 'label'=>'UsageTasks', 'enabled'=>1, 'visible'=>-1, 'position'=>140), 'usage_organize_event' =>array('type'=>'integer', 'label'=>'UsageOrganizeEvent', 'enabled'=>1, 'visible'=>-1, 'position'=>145), + 'allow_unknown_people_conf' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestConf', 'enabled'=>1, 'visible'=>-1, 'position'=>146), + 'allow_unknown_people_booth' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>147), + 'price_registration' =>array('type'=>'double(24,8)', 'label'=>'PriceOfRegistration', 'enabled'=>1, 'visible'=>-1, 'position'=>148), + 'price_booth' =>array('type'=>'double(24,8)', 'label'=>'PriceOfBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>149), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), @@ -257,6 +261,10 @@ class Project extends CommonObject if (empty($conf->eventorganization->enabled)) { $this->fields['usage_organize_event']['visible'] = 0; + $this->fields['allow_unknown_people_conf']['enabled'] = 0; + $this->fields['allow_unknown_people_booth']['enabled'] = 0; + $this->fields['price_registration']['enabled'] = 0; + $this->fields['price_booth']['enabled'] = 0; } } @@ -316,6 +324,10 @@ class Project extends CommonObject $sql .= ", usage_task"; $sql .= ", usage_bill_time"; $sql .= ", usage_organize_event"; + $sql .= ", allow_unknown_people_conf"; + $sql .= ", allow_unknown_people_booth"; + $sql .= ", price_registration"; + $sql .= ", price_booth"; $sql .= ", email_msgid"; $sql .= ", note_private"; $sql .= ", note_public"; @@ -339,6 +351,10 @@ class Project extends CommonObject $sql .= ", ".($this->usage_task ? 1 : 0); $sql .= ", ".($this->usage_bill_time ? 1 : 0); $sql .= ", ".($this->usage_organize_event ? 1 : 0); + $sql .= ", ".($this->allow_unknown_people_conf ? 1 : 0); + $sql .= ", ".($this->allow_unknown_people_booth ? 1 : 0); + $sql .= ", ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : 'null'); + $sql .= ", ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : 'null'); $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); @@ -442,6 +458,10 @@ class Project extends CommonObject $sql .= ", usage_task = ".($this->usage_task ? 1 : 0); $sql .= ", usage_bill_time = ".($this->usage_bill_time ? 1 : 0); $sql .= ", usage_organize_event = ".($this->usage_organize_event ? 1 : 0); + $sql .= ", allow_unknown_people_conf = ".($this->allow_unknown_people_conf ? 1 : 0); + $sql .= ", allow_unknown_people_booth = ".($this->allow_unknown_people_booth ? 1 : 0); + $sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null"); + $sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null"); $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -531,7 +551,8 @@ class Project extends CommonObject $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; - $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid"; + $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; + $sql .= " allow_unknown_people_conf, allow_unknown_people_booth, price_registration, price_booth"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; if (!empty($id)) { @@ -588,6 +609,10 @@ class Project extends CommonObject $this->usage_task = (int) $obj->usage_task; $this->usage_bill_time = (int) $obj->usage_bill_time; $this->usage_organize_event = (int) $obj->usage_organize_event; + $this->allow_unknown_people_conf = (int) $obj->allow_unknown_people_conf; + $this->allow_unknown_people_booth = (int) $obj->allow_unknown_people_booth; + $this->price_registration = $obj->price_registration; + $this->price_booth = $obj->price_booth; $this->email_msgid = $obj->email_msgid; $this->db->free($resql); diff --git a/htdocs/projet/event.php b/htdocs/projet/event.php new file mode 100644 index 00000000000..2aa0b29190a --- /dev/null +++ b/htdocs/projet/event.php @@ -0,0 +1,346 @@ + + * Copyright (C) 2012 Laurent Destailleur + * Copyright (C) 2021 florian.henry@scopen.fr + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/projet/event.php + * \ingroup project + * \brief Tab event organization + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + +// Load translation files required by the page +$langs->load('projects','enevntorganization'); + +$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects + +$object = new Project($db); + +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once + +// Security check +$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. +$result = restrictedArea($user, 'eventorganization', $id); + +$permissiontoread = $user->rights->eventorganization->read; +$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); + +/* + * Actions + */ + +if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) { + $error = 0; + $object->oldcopy = clone $object; + + $object->allow_unknown_people_conf=(GETPOST('allow_unknown_people_conf', 'alpha') == 'on' ? 1 : 0); + $object->allow_unknown_people_booth=(GETPOST('allow_unknown_people_booth', 'alpha') == 'on' ? 1 : 0); + $object->price_registration=price2num(GETPOST('price_registration', 'alphanohtml'));; + $object->price_booth=price2num(GETPOST('price_booth', 'alphanohtml'));; + + $result = $object->update($user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + if (GETPOST('socid', 'int') > 0) $object->fetch_thirdparty(GETPOST('socid', 'int')); + else unset($object->thirdparty); + $action=''; + } +} + + + +/* + * View + */ + +$title = $langs->trans("Project").' - '.$langs->trans("ConferenceOrBoothTab").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); +//TODO Make wiki docs +$help_url = ''; +llxHeader("", $title, $help_url); + +$form = new Form($db); +$userstatic = new User($db); + +$now = dol_now(); + +if ($id > 0 || !empty($ref)) +{ + + $head = project_prepare_head($object); + print dol_get_fiche_head($head, 'eventorganisation', $langs->trans('ConferenceOrBoothTab'), -1); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Title + $morehtmlref .= $object->title; + // Thirdparty + if ($object->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + + print ''; + + // Usage + print ''; + print ''; + + // Visibility + print ''; + + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) + { + // Opportunity status + print ''; + + // Opportunity percent + print ''; + + // Opportunity Amount + print ''; + + // Opportunity Weighted Amount + print ''; + } + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + + if (!empty($conf->eventorganization->enabled)) + { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
'.$langs->trans("Visibility").''; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("OpportunityStatus").''; + $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print '
'.$langs->trans("OpportunityProbability").''; + if (strcmp($object->opp_percent, '')) print price($object->opp_percent, 0, $langs, 1, 0).' %'; + print '
'.$langs->trans("OpportunityAmount").''; + /*if ($object->opp_status) + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + print '
'.$langs->trans('OpportunityWeightedAmount').''; + if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($object->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($object->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($object->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("Budget").''; + if (strcmp($object->budget_amount, '')) print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + print '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + if ($action == 'edit') { + print '
'; + print ''; + print ''; + print ''; + } + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + if ($action == 'edit' && $permissiontoadd) { + //Allow unknown people to suggest conferences + print '"; + + //Allow unknown people to suggest booth + print '"; + + //Price of registration + print '"; + + //Price of registration + print '"; + } else { + //Allow unknown people to suggest conferences + print '"; + + //Allow unknown people to suggest booth + print '"; + + //Price of registration + print '"; + + //Price of registration + print '"; + } + + //ICS Link + print '"; + + print '
'.$langs->trans("Description").''; + print dol_htmlentitiesbr($object->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); + print "
' . $langs->trans("AllowUnknownPeopleSuggestConf") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestConfHelp")) . ''; + print 'allow_unknown_people_conf ? ' checked="checked"' : '')) . '"> '; + print "
' . $langs->trans("AllowUnknownPeopleSuggestBooth") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestBoothHelp")) . ''; + print 'allow_unknown_people_booth ? ' checked="checked"' : '')) . '"> '; + print "
' . $langs->trans("PriceOfRegistration") . ''; + print ''; + print "
' . $langs->trans("PriceOfBooth") . ''; + print ''; + print "
' . $langs->trans("AllowUnknownPeopleSuggestConf") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestConfHelp")) . ''; + print 'allow_unknown_people_conf ? ' checked="checked"' : '')) . '"> '; + print "
' . $langs->trans("AllowUnknownPeopleSuggestBooth") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestBoothHelp")) . ''; + print 'allow_unknown_people_booth ? ' checked="checked"' : '')) . '"> '; + print "
' . $langs->trans("PriceOfRegistration") . ''; + if (strcmp($object->price_registration, '')) print price($object->price_registration, 0, $langs, 1, 0, 0, $conf->currency); + print "
' . $langs->trans("PriceOfBooth") . ''; + if (strcmp($object->price_booth, '')) print price($object->price_booth, 0, $langs, 1, 0, 0, $conf->currency); + print "
'.$langs->trans("EventOrganizationICSLink").''; + //TODO ICS Link + //print 'ICS'; + print "
'; + + print ''; + + print '
'; + print '
'; + print '
'; + + print '
'; + +} + +print dol_get_fiche_end(); + +if ($action == 'edit' && $permissiontoadd > 0) +{ + print '
'; + print '     '; + print ''; + print '
'; + + print ''; +} + + +/* + * Actions Buttons + */ +print '
'; +$parameters = array(); +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been +// modified by hook +if (empty($reshook)) +{ + // Modify + if ($object->statut != Project::STATUS_CLOSED && $action=='') + { + if ($permissiontoadd > 0) + { + print ''.$langs->trans("Modify").''; + } else { + print ''.$langs->trans('Modify').''; + } + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c51713d1cce..2ba0569b892 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -43,6 +43,9 @@ if (!empty($conf->categorie->enabled)) // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); +if ($conf->eventorganization->enabled) { + $langs->loadLangs(array('eventorganization')); +} $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); @@ -93,6 +96,10 @@ $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int'); $search_usage_task = GETPOST('search_usage_task', 'int'); $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int'); $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int'); +$search_allow_unknown_people_conf = GETPOST('search_allow_unknown_people_conf', 'int'); +$search_allow_unknown_people_booth = GETPOST('search_allow_unknown_people_booth', 'int'); +$search_price_registration = GETPOST("search_price_registration", 'alpha'); +$search_price_booth = GETPOST("search_price_booth", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; @@ -209,6 +216,10 @@ if (empty($reshook)) $search_usage_task = ''; $search_usage_bill_time = ''; $search_usage_event_organization = ''; + $search_allow_unknown_people_conf = ''; + $search_allow_unknown_people_booth = ''; + $search_price_registration = ''; + $search_price_booth = ''; $toselect = ''; $search_array_options = array(); $search_category_array = array(); @@ -304,6 +315,7 @@ $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat"; $sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount "; $sql .= ", p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event"; +$sql .= ", allow_unknown_people_conf, allow_unknown_people_booth, price_registration, price_booth"; $sql .= ", s.rowid as socid, s.nom as name, s.email"; $sql .= ", cls.code as opp_status_code"; // Add fields from extrafields @@ -373,6 +385,10 @@ if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= n if ($search_usage_task != '' && $search_usage_task >= 0) $sql .= natural_search('p.usage_task', $search_usage_task, 2); if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2); if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2); +if ($search_allow_unknown_people_conf != '' && $search_allow_unknown_people_conf >= 0) $sql .= natural_search('p.allow_unknown_people_conf', $search_allow_unknown_people_conf, 2); +if ($search_allow_unknown_people_booth != '' && $search_allow_unknown_people_booth >= 0) $sql .= natural_search('p.allow_unknown_people_booth', $search_allow_unknown_people_booth, 2); +if ($search_price_registration != '') $sql .= natural_search('p.price_registration', $search_price_registration, 1); +if ($search_price_booth != '') $sql .= natural_search('p.price_booth', $search_price_booth, 1); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -450,6 +466,10 @@ if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($s if ($search_usage_task != '') $param .= '&search_usage_task='.urlencode($search_usage_task); if ($search_usage_bill_time != '') $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time); if ($search_usage_event_organization != '') $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization); +if ($search_allow_unknown_people_conf != '') $param .= '&search_allow_unknown_people_conf='.urlencode($search_allow_unknown_people_conf); +if ($search_allow_unknown_people_booth != '') $param .= '&search_allow_unknown_people_booth='.urlencode($search_allow_unknown_people_booth); +if ($search_price_registration != '') $param .= '&search_price_registration='.urlencode($search_price_registration); +if ($search_price_booth != '') $param .= '&search_price_booth='.urlencode($search_price_booth); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -663,6 +683,30 @@ if (!empty($arrayfields['p.usage_organize_event']['checked'])) print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1); print ''; } +if (!empty($arrayfields['p.allow_unknown_people_conf']['checked'])) +{ + print ''; + print $form->selectyesno('search_allow_unknown_people_conf', $search_allow_unknown_people_conf, 1, false, 1); + print ''; +} +if (!empty($arrayfields['p.allow_unknown_people_booth']['checked'])) +{ + print ''; + print $form->selectyesno('search_allow_unknown_people_booth', $search_allow_unknown_people_booth, 1, false, 1); + print ''; +} +if (!empty($arrayfields['p.price_registration']['checked'])) +{ + print ''; + print ''; + print ''; +} +if (!empty($arrayfields['p.price_booth']['checked'])) +{ + print ''; + print ''; + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -717,6 +761,10 @@ if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_ti if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['p.usage_organize_event']['checked'])) print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.allow_unknown_people_conf']['checked'])) print_liste_field_titre($arrayfields['p.allow_unknown_people_conf']['label'], $_SERVER["PHP_SELF"], 'p.allow_unknown_people_conf', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.allow_unknown_people_booth']['checked'])) print_liste_field_titre($arrayfields['p.allow_unknown_people_booth']['label'], $_SERVER["PHP_SELF"], 'p.allow_unknown_people_booth', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.price_registration']['checked'])) print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.price_booth']['checked'])) print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -952,6 +1000,54 @@ while ($i < min($num, $limit)) print ''; if (!$i) $totalarray['nbfield']++; } + // Allow unknown people to suggest conferences + if (!empty($arrayfields['p.allow_unknown_people_conf']['checked'])) + { + print ''; + if ($obj->allow_unknown_people_conf) + { + print yn($obj->allow_unknown_people_conf); + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Allow unknown people to suggest booth + if (!empty($arrayfields['p.allow_unknown_people_booth']['checked'])) + { + print ''; + if ($obj->allow_unknown_people_booth) + { + print yn($obj->allow_unknown_people_booth); + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Price of registration + if (!empty($arrayfields['p.price_registration']['checked'])) + { + print ''; + if ($obj->price_registration != '') + { + print price($obj->price_registration, 1, $langs, 1, -1, -1); + $totalarray['val']['p.price_registration'] += $obj->price_registration; + } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; + } + // PriceOfBooth + if (!empty($arrayfields['p.price_booth']['checked'])) + { + print ''; + if ($obj->price_booth != '') + { + print price($obj->price_booth, 1, $langs, 1, -1, -1); + $totalarray['val']['p.price_booth'] += $obj->price_booth; + } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook From 67e84dc4920227e535ffcf099ca109b2ccec7b85 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 21 Feb 2021 12:33:07 +0100 Subject: [PATCH 022/173] =?UTF-8?q?=09nouveau=20fichier=C2=A0:=20conferenc?= =?UTF-8?q?eorbooth=5Fagenda.php=20=09nouveau=20fichier=C2=A0:=20conferenc?= =?UTF-8?q?eorbooth=5Fcontact.php=20=09nouveau=20fichier=C2=A0:=20conferen?= =?UTF-8?q?ceorbooth=5Fdocument.php=20=09nouveau=20fichier=C2=A0:=20confer?= =?UTF-8?q?enceorbooth=5Flist.php=20=09nouveau=20fichier=C2=A0:=20conferen?= =?UTF-8?q?ceorbooth=5Fnote.php=20=09nouveau=20fichier=C2=A0:=20eventorgan?= =?UTF-8?q?izationindex.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conferenceorbooth_agenda.php | 287 ++++++++ .../conferenceorbooth_contact.php | 197 +++++ .../conferenceorbooth_document.php | 234 ++++++ .../conferenceorbooth_list.php | 678 ++++++++++++++++++ .../conferenceorbooth_note.php | 184 +++++ .../eventorganizationindex.php | 225 ++++++ 6 files changed, 1805 insertions(+) create mode 100644 htdocs/eventorganization/conferenceorbooth_agenda.php create mode 100644 htdocs/eventorganization/conferenceorbooth_contact.php create mode 100644 htdocs/eventorganization/conferenceorbooth_document.php create mode 100644 htdocs/eventorganization/conferenceorbooth_list.php create mode 100644 htdocs/eventorganization/conferenceorbooth_note.php create mode 100644 htdocs/eventorganization/eventorganizationindex.php diff --git a/htdocs/eventorganization/conferenceorbooth_agenda.php b/htdocs/eventorganization/conferenceorbooth_agenda.php new file mode 100644 index 00000000000..1583c0acbd2 --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_agenda.php @@ -0,0 +1,287 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_agenda.php + * \ingroup eventorganization + * \brief Tab of events on ConferenceOrBooth + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); + + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) { + $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)); +} +$search_agenda_label = GETPOST('search_agenda_label'); + +$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 (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothagenda', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; +} + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'eventorganization', $object->id); + +$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php + + +/* + * Actions + */ + +$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)) { + header("Location: ".$backtopage); + exit; + } + + // 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 = ''; + } +} + + + +/* + * View + */ + +$form = new Form($db); + +if ($object->id > 0) { + $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; + $help_url = ''; + llxHeader('', $title, $help_url); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + $head = conferenceorboothPrepareHead($object); + + + print dol_get_fiche_head($head, 'agenda', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + $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.='
'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $object->info($object->id); + dol_print_object_info($object, 1); + + print '
'; + + print dol_get_fiche_end(); + + + + // Actions buttons + + $objthirdparty = $object; + $objcon = new stdClass(); + + $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; + $out .= '&backtopage='.urlencode($urlbacktopage); + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + + print '
'; + + if (!empty($conf->agenda->enabled)) { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + print ''.$langs->trans("AddAction").''; + } else { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + + 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); + } + + + //print load_fiche_titre($langs->trans("ActionsOnConferenceOrBooth"), '', ''); + + // List of all actions + $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, $object->module); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php new file mode 100644 index 00000000000..b2a80de902c --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -0,0 +1,197 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_contact.php + * \ingroup eventorganization + * \brief Tab for contacts linked to ConferenceOrBooth + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); + +$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$ref = GETPOST('ref', 'alpha'); +$lineid = GETPOST('lineid', 'int'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'eventorganization', $object->id); + +$permission = $user->rights->eventorganization->conferenceorbooth->write; + +/* + * Add a new contact + */ + +if ($action == 'addcontact' && $permission) { + $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); + + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} elseif ($action == 'swapstatut' && $permission) { + // Toggle the status of a contact + $result = $object->swapContactStatus(GETPOST('ligne')); +} elseif ($action == 'deletecontact' && $permission) { + // Deletes a contact + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } else { + dol_print_error($db); + } +} + + +/* + * View + */ + +$title = $langs->trans('ConferenceOrBooth')." - ".$langs->trans('ContactsAddresses'); +$help_url = ''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +$form = new Form($db); +$formcompany = new FormCompany($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); + + +/* *************************************************************************** */ +/* */ +/* View and edit mode */ +/* */ +/* *************************************************************************** */ + +if ($object->id) { + /* + * Show tabs + */ + $head = conferenceorboothPrepareHead($object); + + print dol_get_fiche_head($head, 'contact', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $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.='
'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + + print dol_get_fiche_end(); + + 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) { + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) { + break; + } + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php new file mode 100644 index 00000000000..7ad8088c127 --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -0,0 +1,234 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_document.php + * \ingroup eventorganization + * \brief Tab for documents linked to ConferenceOrBooth + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +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/class/html.formfile.class.php'; +dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); + + +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Get parameters +$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 (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object); +} + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'eventorganization', $object->id); + +$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php + + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files"); +$help_url = ''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) { + /* + * Show tabs + */ + $head = conferenceorboothPrepareHead($object); + + print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + + // 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) { + $totalsize += $file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $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.='
'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + print dol_get_fiche_end(); + + $modulepart = 'eventorganization'; + //$permission = $user->rights->eventorganization->conferenceorbooth->write; + $permission = 1; + //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; + $permtoedit = 1; + $param = '&id='.$object->id; + + //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} else { + accessforbidden('', 0, 1); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php new file mode 100644 index 00000000000..737e69f67e6 --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -0,0 +1,678 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_list.php + * \ingroup eventorganization + * \brief List page for conferenceorbooth + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// load eventorganization libraries +require_once __DIR__.'/class/conferenceorbooth.class.php'; + +// for other modules +//dol_include_once('/othermodule/class/otherobject.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "other")); + +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothlist'; // 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') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothlist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Initialize array of search criterias +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +} + +// Definition of array of fields for columns +$arrayfields = array(); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval($val['visible'], 1); + $arrayfields['t.'.$key] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=>$val['help'] + ); + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + +$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read; +$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; +$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete; + +// Security check +if (empty($conf->eventorganization->enabled)) accessforbidden('Module not enabled'); +$socid = 0; +if ($user->socid > 0) { // Protection if external user + //$socid = $user->socid; + accessforbidden(); +} +//$result = restrictedArea($user, 'eventorganization', $id, ''); +//if (!$permissiontoread) accessforbidden(); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + +$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)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // 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 + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'ConferenceOrBooth'; + $objectlabel = 'ConferenceOrBooth'; + $uploaddir = $conf->eventorganization->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form = new Form($db); + +$now = dol_now(); + +//$help_url="EN:Module_ConferenceOrBooth|FR:Module_ConferenceOrBooth_FR|ES:Módulo_ConferenceOrBooth"; +$help_url = ''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBooths")); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach ($object->fields as $key => $val) { + $sql .= 't.'.$key.', '; +} +// 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.', ' : ''); + } +} +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +} +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { + if (in_array($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } + } + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} +//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); +// 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, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY "; +foreach($object->fields as $key => $val) { + $sql.='t.'.$key.', '; +} +// 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.', ' : ''); +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/,\s*$/','', $sql); +*/ + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { + $num = $nbtotalofrecords; +} else { + if ($limit) $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$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) { + 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); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +print '
'."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendConferenceOrBoothRef"; +$modelmail = "conferenceorbooth"; +$objecttmp = new ConferenceOrBooth($db); +$trackid = 'xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine = 0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < ($limit ? min($num, $limit) : $num)) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + $totalarray['val']['t.'.$key] += $object->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''."\n"; + + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); + } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print ''; + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } + print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_note.php b/htdocs/eventorganization/conferenceorbooth_note.php new file mode 100644 index 00000000000..c34b01df436 --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_note.php @@ -0,0 +1,184 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_note.php + * \ingroup eventorganization + * \brief Tab for notes on ConferenceOrBooth + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothnote', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'eventorganization', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; +} + +$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url = ''; +llxHeader('', $langs->trans('ConferenceOrBooth'), $help_url); + +if ($id > 0 || !empty($ref)) { + $object->fetch_thirdparty(); + + $head = conferenceorboothPrepareHead($object); + + print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $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.='
'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass = "titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/eventorganizationindex.php b/htdocs/eventorganization/eventorganizationindex.php new file mode 100644 index 00000000000..655da7813e6 --- /dev/null +++ b/htdocs/eventorganization/eventorganizationindex.php @@ -0,0 +1,225 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Jean-François Ferry + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file eventorganization/eventorganizationindex.php + * \ingroup eventorganization + * \brief Home page of eventorganization top menu + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization")); + +$action = GETPOST('action', 'aZ09'); + + +// Security check +// if (! $user->rights->eventorganization->myobject->read) { +// accessforbidden(); +// } +$socid = GETPOST('socid', 'int'); +if (isset($user->socid) && $user->socid > 0) { + $action = ''; + $socid = $user->socid; +} + +$max = 5; +$now = dol_now(); + + +/* + * Actions + */ + +// None + + +/* + * View + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +llxHeader("", $langs->trans("EventOrganizationArea")); + +print load_fiche_titre($langs->trans("EventOrganizationArea"), '', 'eventorganization.png@eventorganization'); + +print '
'; + + +/* BEGIN MODULEBUILDER DRAFT MYOBJECT +// Draft MyObject +if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read) +{ + $langs->load("orders"); + + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande 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.fk_statut = 0"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + $var = true; + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + + print '"; + } + } + else + { + + print ''; + } + print "
'.$langs->trans("DraftMyObjects").($num?''.$num.'':'').'
'; + + $myobjectstatic->id=$obj->rowid; + $myobjectstatic->ref=$obj->ref; + $myobjectstatic->ref_client=$obj->ref_client; + $myobjectstatic->total_ht = $obj->total_ht; + $myobjectstatic->total_tva = $obj->total_tva; + $myobjectstatic->total_ttc = $obj->total_ttc; + + print $myobjectstatic->getNomUrl(1); + print ''; + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'

"; + + $db->free($resql); + } + else + { + dol_print_error($db); + } +} +END MODULEBUILDER DRAFT MYOBJECT */ + + +print '
'; + + +$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; +$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + +/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT +// Last modified myobject +if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read) +{ + $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."eventorganization_myobject as s"; + //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")"; + //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 s.tms DESC"; + $sql .= $db->plimit($max, 0); + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $myobjectstatic->id=$objp->rowid; + $myobjectstatic->ref=$objp->ref; + $myobjectstatic->label=$objp->label; + $myobjectstatic->status = $objp->status; + + print ''; + print ''; + print '"; + print '"; + print ''; + $i++; + } + + $db->free($resql); + } else { + print ''; + } + print "
'; + print $langs->trans("BoxTitleLatestModifiedMyObjects", $max); + print ''.$langs->trans("DateModificationShort").'
'.$myobjectstatic->getNomUrl(1).''; + print "'.dol_print_date($db->jdate($objp->tms), 'day')."
'.$langs->trans("None").'

"; + } +} +*/ + +print '
'; + +// End of page +llxFooter(); +$db->close(); From 565fb392b4c99e4dec6fbbe2dc3912ecdd1cb027 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 21 Feb 2021 11:36:58 +0000 Subject: [PATCH 023/173] Fixing style errors. --- htdocs/projet/event.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/projet/event.php b/htdocs/projet/event.php index 2aa0b29190a..1a9a325161a 100644 --- a/htdocs/projet/event.php +++ b/htdocs/projet/event.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page -$langs->load('projects','enevntorganization'); +$langs->load('projects', 'enevntorganization'); $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -97,7 +97,6 @@ $now = dol_now(); if ($id > 0 || !empty($ref)) { - $head = project_prepare_head($object); print dol_get_fiche_head($head, 'eventorganisation', $langs->trans('ConferenceOrBoothTab'), -1); @@ -304,7 +303,6 @@ if ($id > 0 || !empty($ref)) print '
'; print '
'; - } print dol_get_fiche_end(); From 0e96093def5f337bc559f0451a1fd599bc733ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 21 Feb 2021 21:51:26 +0100 Subject: [PATCH 024/173] add log for token reclaimed --- htdocs/main.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 15dfc85c8d2..c0d19648ab3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -416,14 +416,16 @@ if ((!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VE } // Creation of a token against CSRF vulnerabilities -if (!defined('NOTOKENRENEWAL')) -{ +if (!defined('NOTOKENRENEWAL')) { // Rolling token at each call ($_SESSION['token'] contains token of previous page) - if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; + if (isset($_SESSION['newtoken'])) { + $_SESSION['token'] = $_SESSION['newtoken']; + } // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; + dol_syslog("NEW TOKEN reclaimed by : " . $_SERVER['PHP_SELF'], LOG_INFO); } //dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']); From 3256a17280a80d9cef5067ed372eb4aaa682cad3 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Sun, 21 Feb 2021 23:52:22 +0100 Subject: [PATCH 025/173] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d0881f6679..b4cedc5f4e2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6381,11 +6381,16 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : ''); - $datedelivery = dol_getdate($object->date_livraison, true); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['mday']) : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['mon']) : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? $datedelivery['year'] : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['hours']) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%S") : ''); + + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date("%H", $object->date_livraison) : ''); $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['minutes']) : ''); $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['seconds']) : ''); From 1971f5197325a7b20002507199183a2950014517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 11:24:21 +0100 Subject: [PATCH 026/173] Update main.inc.php --- htdocs/main.inc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c0d19648ab3..85a02aa1467 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -425,7 +425,7 @@ if (!defined('NOTOKENRENEWAL')) { // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; - dol_syslog("NEW TOKEN reclaimed by : " . $_SERVER['PHP_SELF'], LOG_INFO); + dol_syslog("NEW TOKEN reclaimed by : " . $_SERVER['PHP_SELF'], LOG_DEBUG); } //dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']); @@ -459,8 +459,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl } } - if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $_SESSION['token']) - { + if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $_SESSION['token']) { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused due to invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); From 566c3ada556ab679796b1ff5799484e31a933895 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 22 Feb 2021 11:30:00 +0100 Subject: [PATCH 027/173] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b4cedc5f4e2..4b90af1c594 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6381,18 +6381,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : ''); - $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%d") : ''); - $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%A") : ''); - $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%m") : ''); - $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%b") : ''); - $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%Y") : ''); - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%H") : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%M") : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison,"%S") : ''); - - $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date("%H", $object->date_livraison) : ''); - $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['minutes']) : ''); - $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? sprintf("%02d", $datedelivery['seconds']) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : ''); // For backward compatibility $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); From a0031901e42bf12981dbfdb8937b75c3c3c7708a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 11:36:03 +0100 Subject: [PATCH 028/173] complete doaction hook --- htdocs/adherents/subscription.php | 107 +++++++++++++++++------------- 1 file changed, 62 insertions(+), 45 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index a532c8c7e55..e19f01779aa 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify @@ -116,10 +116,12 @@ $paymentdate = -1; */ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Create third party from a member -if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { +if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // Creation of thirdparty $company = new Societe($db); @@ -136,7 +138,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } } -if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { +if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error = 0; if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { @@ -155,7 +157,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights } } -if ($action == 'setsocid') { +if (empty($reshook) && $action == 'setsocid') { $error = 0; if (!$error) { if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database @@ -215,7 +217,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $emetteur_nom = $_POST["chqemetteur"]; $emetteur_banque = $_POST["chqbank"]; $option = $_POST["paymentsave"]; - if (empty($option)) $option = 'none'; + if (empty($option)) { + $option = 'none'; + } $sendalsoemail = GETPOST("sendmail", 'alpha'); // Check parameters @@ -254,11 +258,19 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! } else { if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { if ($_POST["subscription"]) { - if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + if (!$_POST["label"]) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + } + if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + } + if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + } } else { - if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + if ($_POST["accountid"]) { + $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + } } if ($errmsg) { $error++; @@ -340,7 +352,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; @@ -586,8 +600,8 @@ if ($rowid > 0) { /* - * Action buttons - */ + * Action buttons + */ // Button to create a new subscription if member no draft neither resiliated if ($user->rights->adherent->cotisation->creer) { @@ -602,8 +616,8 @@ if ($rowid > 0) { } /* - * List of subscriptions - */ + * List of subscriptions + */ if ($action != 'addsubscription' && $action != 'create_thirdparty') { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; $sql .= " c.rowid as crowid, c.subscription,"; @@ -723,8 +737,8 @@ if ($rowid > 0) { } /* - * Add new subscription form - */ + * Add new subscription form + */ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { print '
'; @@ -750,31 +764,31 @@ if ($rowid > 0) { //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); print "\n".''."\n"; @@ -925,8 +939,9 @@ if ($rowid > 0) { print 'fk_soc)) print ' disabled'; print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { + if ($object->fk_soc) { + print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + } else { print ' ('; if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); print $langs->trans("NoThirdPartyAssociatedToMember"); @@ -1005,7 +1020,9 @@ if ($rowid > 0) { $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; From 8c95bc399aa32fd8f99608c5f142da91dcb66a0e Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 22 Feb 2021 13:12:06 +0100 Subject: [PATCH 029/173] fix Notice error on install --- htdocs/install/inc.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 12bab777edb..f505302b65e 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -5,7 +5,8 @@ * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2012 Marcos García * Copyright (C) 2016 Raphaël Doursenaud - * + * Copyright (C) 2021 Charlene Benke +* * 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 * the Free Software Foundation; either version 3 of the License, or @@ -42,17 +43,14 @@ if (!defined('ADODB_PATH')) } require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once ADODB_PATH.'adodb-time.inc.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->syslog = new stdClass(); +// stdClass for $db +$conf = new Conf(new stdClass()); // Force $_REQUEST["logtohtml"] $_REQUEST["logtohtml"] = 1; From 84a5f698340e73c2159ff63e4ac722e7d7687453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 13:14:13 +0100 Subject: [PATCH 030/173] fix propal sqls --- htdocs/comm/card.php | 551 +++++++++++++++-------------- htdocs/comm/index.php | 155 +++++--- htdocs/comm/propal/index.php | 85 +++-- htdocs/comm/prospect/index.php | 93 ++--- htdocs/core/boxes/box_propales.php | 30 +- 5 files changed, 520 insertions(+), 394 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index d335e37b482..0858d412b94 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -38,29 +38,61 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.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->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +} +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.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->expedition->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +} +if (!empty($conf->contrat->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} +if (!empty($conf->adherent->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +} +if (!empty($conf->ficheinter->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('companies', 'banks')); -if (!empty($conf->contrat->enabled)) $langs->load("contracts"); -if (!empty($conf->commande->enabled)) $langs->load("orders"); -if (!empty($conf->expedition->enabled)) $langs->load("sendings"); -if (!empty($conf->facture->enabled)) $langs->load("bills"); -if (!empty($conf->projet->enabled)) $langs->load("projects"); -if (!empty($conf->ficheinter->enabled)) $langs->load("interventions"); -if (!empty($conf->notification->enabled)) $langs->load("mails"); +if (!empty($conf->contrat->enabled)) { + $langs->load("contracts"); +} +if (!empty($conf->commande->enabled)) { + $langs->load("orders"); +} +if (!empty($conf->expedition->enabled)) { + $langs->load("sendings"); +} +if (!empty($conf->facture->enabled)) { + $langs->load("bills"); +} +if (!empty($conf->projet->enabled)) { + $langs->load("projects"); +} +if (!empty($conf->ficheinter->enabled)) { + $langs->load("interventions"); +} +if (!empty($conf->notification->enabled)) { + $langs->load("mails"); +} // Security check $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -if ($user->socid > 0) $id = $user->socid; +if ($user->socid > 0) { + $id = $user->socid; +} $result = restrictedArea($user, 'societe', $id, '&societe'); $action = GETPOST('action', 'aZ09'); @@ -69,12 +101,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "nom"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "nom"; +} $cancelbutton = GETPOST('cancel', 'alpha'); $object = new Client($db); @@ -97,11 +135,12 @@ if ($object->id > 0) { $now = dol_now(); -if ($id > 0 && empty($object->id)) -{ +if ($id > 0 && empty($object->id)) { // Load data of third party $res = $object->fetch($id); - if ($object->id < 0) dol_print_error($db, $object->error, $object->errors); + if ($object->id < 0) { + dol_print_error($db, $object->error, $object->errors); + } } @@ -112,105 +151,115 @@ if ($id > 0 && empty($object->id)) $parameters = array('id' => $id, 'socid' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancelbutton) - { +if (empty($reshook)) { + if ($cancelbutton) { $action = ""; } // set accountancy code - if ($action == 'setcustomeraccountancycode') - { + if ($action == 'setcustomeraccountancycode') { $result = $object->fetch($id); $object->code_compta = $_POST["customeraccountancycode"]; $result = $object->update($object->id, $user, 1, 1, 0); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) - { + if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // mode de reglement - if ($action == 'setmode' && $user->rights->societe->creer) - { + if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) - { + if ($action == 'setbankaccount' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // customer preferred shipping method - if ($action == 'setshippingmethod' && $user->rights->societe->creer) - { + if ($action == 'setshippingmethod' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // assujetissement a la TVA - if ($action == 'setassujtva' && $user->rights->societe->creer) - { + if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); $object->tva_assuj = $_POST['assujtva_value']; $result = $object->update($object->id); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // set prospect level - if ($action == 'setprospectlevel' && $user->rights->societe->creer) - { + if ($action == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // set communication status - if ($action == 'setstcomm') - { + if ($action == 'setstcomm') { $object->fetch($id); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - else $result = $object->fetch($object->id); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + $result = $object->fetch($object->id); + } } // update outstandng limit - if ($action == 'setoutstanding_limit') - { + if ($action == 'setoutstanding_limit') { $object->fetch($id); $object->outstanding_limit = GETPOST('outstanding_limit'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // update order min amount - if ($action == 'setorder_min_amount') - { + if ($action == 'setorder_min_amount') { $object->fetch($id); $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha')); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Set sales representatives - if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) - { + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setSalesRep(GETPOST('commercial', 'array')); } @@ -222,22 +271,23 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; - if (!$error) - { + if ($ret < 0) { + $error++; + } + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } // warehouse - if ($action == 'setwarehouse' && $user->rights->societe->creer) - { + if ($action == 'setwarehouse' && $user->rights->societe->creer) { $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int')); } } @@ -253,13 +303,14 @@ $form = new Form($db); $formcompany = new FormCompany($db); $title = $langs->trans("CustomerCard"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->name; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($object->id > 0) -{ +if ($object->id > 0) { $head = societe_prepare_head($object); print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company'); @@ -279,15 +330,13 @@ if ($object->id > 0) print ''; // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans("Prefix").''; print ($object->prefix_comm ? $object->prefix_comm : ' '); print ''; } - if ($object->client) - { + if ($object->client) { $langs->load("compta"); print ''; @@ -324,17 +373,14 @@ if ($object->id > 0) print ''; */ - if ($mysoc->country_code == 'ES') - { + if ($mysoc->country_code == 'ES') { // Local Taxes - if ($mysoc->localtax1_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print ''; } - if ($mysoc->localtax1_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); print ''; @@ -352,11 +398,12 @@ if ($object->id > 0) print ''; + if (($action != 'editconditions') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentConditions'); print ''; - if (($action != 'editconditions') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print ''; - if ($action == 'editconditions') - { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none'); @@ -369,11 +416,12 @@ if ($object->id > 0) print ''; + if (($action != 'editmode') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentMode'); print ''; - if (($action != 'editmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'none'); @@ -381,18 +429,18 @@ if ($object->id > 0) print ""; print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // Compte bancaire par défaut print ''; print ''; + if (($action != 'editbankaccount') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentBankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print ''; - if ($action == 'editbankaccount') - { + if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1); } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none'); @@ -404,14 +452,12 @@ if ($object->id > 0) $isCustomer = ($object->client == 1 || $object->client == 3); // Relative discounts (Discounts-Drawbacks-Rebates) - if ($isCustomer) - { + if ($isCustomer) { print ''; print '
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; @@ -424,24 +470,26 @@ if ($object->id > 0) print ''; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; print ''; $amount_discount = $object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db, $object->error); - if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + if ($amount_discount < 0) { + dol_print_error($db, $object->error); + } + if ($amount_discount > 0) { + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + } //else print $langs->trans("DiscountNone"); print ''; print ''; } // Max outstanding bill - if ($object->client) - { + if ($object->client) { print ''; print ''; print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); @@ -452,10 +500,8 @@ if ($object->id > 0) print ''; } - if ($object->client) - { - if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) - { + if ($object->client) { + if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''."\n"; print ''; print ''; @@ -469,27 +515,26 @@ if ($object->id > 0) // Multiprice level - if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print ''; print '
'; print $langs->trans("PriceLevel"); print ''; - if ($user->rights->societe->creer) - { + if ($user->rights->societe->creer) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print ''; print $object->price_level; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; - if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + if (!empty($conf->global->$keyforlabel)) { + print ' - '.$langs->trans($conf->global->$keyforlabel); + } print ""; print ''; } // Warehouse - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -511,11 +556,12 @@ if ($object->id > 0) print ''; + if (($action != 'editshipping') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('SendingMethod'); print ''; - if (($action != 'editshipping') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; - if ($action == 'editshipping') - { + if ($action == 'editshipping') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none'); @@ -524,8 +570,7 @@ if ($object->id > 0) print ''; } - if (!empty($conf->intracommreport->enabled)) - { + if (!empty($conf->intracommreport->enabled)) { // Transport mode by default print ''; print '"; @@ -584,8 +628,7 @@ if ($object->id > 0) print "
'; @@ -538,8 +583,7 @@ if ($object->id > 0) print ''; if ($action == 'edittransportmode') { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); - } - else { + } else { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); } print "
"; // Prospection level and status - if ($object->client == 2 || $object->client == 3) - { + if ($object->client == 2 || $object->client == 3) { print '
'; print '
'; @@ -596,11 +639,12 @@ if ($object->id > 0) print ''; + if ($action != 'editlevel' && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'), 1).'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; print ''; - if ($action == 'editlevel') - { + if ($action == 'editlevel') { $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1); } else { print $object->getLibProspLevel(); @@ -613,11 +657,14 @@ if ($object->id > 0) print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '     '; print '
'; - foreach ($object->cacheprospectstatus as $key => $val) - { + foreach ($object->cacheprospectstatus as $key => $val) { $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($object->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } } print '
'; print ""; @@ -636,8 +683,7 @@ if ($object->id > 0) $boxstat .= ''; $boxstat .= '
'; - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { // Box proposals $tmp = $object->getOutstandingProposals(); $outstandingOpened = $tmp['opened']; @@ -646,16 +692,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllProposals"); $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { // Box commandes $tmp = $object->getOutstandingOrders(); $outstandingOpened = $tmp['opened']; @@ -664,16 +713,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllOrders"); $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; @@ -683,28 +735,35 @@ if ($object->id > 0) $text = $langs->trans("OverAllInvoices"); $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } // Box outstanding bill $warn = ''; - if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) - { + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) { $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } $text = $langs->trans("CurrentOutstandingBill"); $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } $tmp = $object->getOutstandingBills('customer', 1); $outstandingOpenedLate = $tmp['opened']; @@ -716,12 +775,16 @@ if ($object->id > 0) $text = $langs->trans("CurrentOutstandingBillLate"); $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } } @@ -746,7 +809,7 @@ if ($object->id > 0) $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; $sql .= ", p.total_tva"; - $sql .= ", p.total as total_ttc"; + $sql .= ", p.total_ttc"; $sql .= ", p.ref, p.ref_client, p.remise"; $sql .= ", p.datep as dp, p.fin_validite as date_limit"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; @@ -756,13 +819,11 @@ if ($object->id > 0) $sql .= " ORDER BY p.datep DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $propal_static = new Propal($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -774,8 +835,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); print ''; @@ -797,8 +857,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -810,8 +869,7 @@ if ($object->id > 0) /* * Latest orders */ - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql = "SELECT s.nom, s.rowid"; $sql .= ", c.rowid as cid, c.total_ht"; $sql .= ", c.total_tva"; @@ -825,13 +883,11 @@ if ($object->id > 0) $sql .= " ORDER BY c.date_commande DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $commande_static = new Commande($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { // Check if there are orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; @@ -857,8 +913,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $commande_static->id = $objp->cid; @@ -879,8 +934,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -890,10 +944,9 @@ if ($object->id > 0) } /* - * Latest shipments - */ - if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) - { + * Latest shipments + */ + if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sql = 'SELECT e.rowid as id'; $sql .= ', e.ref'; $sql .= ', e.date_creation'; @@ -912,8 +965,7 @@ if ($object->id > 0) $sql .= " ORDER BY e.date_creation DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $sendingstatic = new Expedition($db); $num = $db->num_rows($resql); @@ -929,8 +981,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $sendingstatic->id = $objp->id; @@ -952,8 +1003,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print ""; print '
'; } @@ -965,8 +1015,7 @@ if ($object->id > 0) /* * Latest contracts */ - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; @@ -975,13 +1024,11 @@ if ($object->id > 0) $sql .= " ORDER BY c.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $contrat = new Contrat($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -994,8 +1041,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $contrat->id = $objp->id; @@ -1008,7 +1054,9 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) { + $late = img_warning($langs->trans("Late")); + } } } @@ -1029,8 +1077,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -1042,8 +1089,7 @@ if ($object->id > 0) /* * Latest interventions */ - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; @@ -1052,13 +1098,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.tms DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $fichinter_static = new Fichinter($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1070,8 +1114,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $fichinter_static->id = $objp->id; @@ -1091,8 +1134,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -1104,8 +1146,7 @@ if ($object->id > 0) /* * Latest invoices templates */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as id, f.titre as ref'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; @@ -1126,13 +1167,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.date_last_gen, f.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $invoicetemplate = new FactureRec($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1143,8 +1182,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $invoicetemplate->id = $objp->id; @@ -1162,12 +1200,10 @@ if ($object->id > 0) print ''; - if ($objp->frequency && $objp->date_last_gen > 0) - { + if ($objp->frequency && $objp->date_last_gen > 0) { print ''; } else { - if ($objp->dc > 0) - { + if ($objp->dc > 0) { print ''; } else { print ''; @@ -1177,8 +1213,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) - { + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; @@ -1193,8 +1228,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
'; print $invoicetemplate->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->date_last_gen), 'day').''.dol_print_date($db->jdate($objp->dc), 'day').'!!!'; print price($objp->total_ttc); print '
"; print '
'; } @@ -1206,8 +1240,7 @@ if ($object->id > 0) /* * Latest invoices */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; @@ -1225,13 +1258,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.datef DESC, f.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $facturestatic = new Facture($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1243,8 +1274,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $facturestatic->id = $objp->facid; @@ -1259,8 +1289,7 @@ if ($object->id > 0) print ''; - if ($objp->df > 0) - { + if ($objp->df > 0) { print ''; } else { print ''; @@ -1269,8 +1298,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) - { + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; @@ -1282,8 +1310,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
'; print $facturestatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->df), 'day').'!!!'; print price($objp->total_ttc); print '
"; print '
'; } @@ -1295,8 +1322,11 @@ if ($object->id > 0) // Allow external modules to add their own shortlist of recent objects $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - else print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } else { + print $hookmanager->resPrint; + } print ''; print '
'; @@ -1313,73 +1343,68 @@ if ($object->id > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - if (empty($reshook)) - { - if ($object->status != 1) - { + if (empty($reshook)) { + if ($object->status != 1) { print ''; } - if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) - { + if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) { $langs->load("propal"); print ''; } - if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) { $langs->load("orders"); print ''; } - if ($user->rights->contrat->creer && $object->status == 1) - { + if ($user->rights->contrat->creer && $object->status == 1) { $langs->load("contracts"); print ''; } - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) - { + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) { $langs->load("fichinter"); print ''; } // Add invoice - if ($user->socid == 0) - { - if (!empty($conf->deplacement->enabled) && $object->status == 1) - { + if ($user->socid == 0) { + if (!empty($conf->deplacement->enabled) && $object->status == 1) { $langs->load("trips"); print ''; } - if (!empty($conf->facture->enabled) && $object->status == 1) - { - if (empty($user->rights->facture->creer)) - { + if (!empty($conf->facture->enabled) && $object->status == 1) { + if (empty($user->rights->facture->creer)) { print ''; } else { $langs->loadLangs(array("orders", "bills")); - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { if ($object->client != 0 && $object->client != 2) { - if (!empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; - } else print ''; + if (!empty($orders2invoice) && $orders2invoice > 0) { + print ''; + } else { + print ''; + } + } else { + print ''; + } } - if ($object->client != 0 && $object->client != 2) print ''; - else print ''; + if ($object->client != 0 && $object->client != 2) { + print ''; + } else { + print ''; + } } } } // Add action - if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) - { - if ($user->rights->agenda->myactions->create) - { + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { + if ($user->rights->agenda->myactions->create) { print ''; } else { print ''; @@ -1389,14 +1414,12 @@ if ($object->id > 0) print ''; - if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) - { + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); // List of todo actions diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index e4d04ace6ae..899c9275d31 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -29,7 +29,9 @@ require '../main.inc.php'; -if (!$user->rights->societe->lire) accessforbidden(); +if (!$user->rights->societe->lire) { + accessforbidden(); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; @@ -73,10 +75,18 @@ $now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $companystatic = new Societe($db); -if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db); -if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db); -if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db); -if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) $supplierorderstatic = new CommandeFournisseur($db); +if (!empty($conf->propal->enabled)) { + $propalstatic = new Propal($db); +} +if (!empty($conf->supplier_proposal->enabled)) { + $supplierproposalstatic = new SupplierProposal($db); +} +if (!empty($conf->commande->enabled)) { + $orderstatic = new Commande($db); +} +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { + $supplierorderstatic = new CommandeFournisseur($db); +} llxHeader("", $langs->trans("CommercialArea")); @@ -118,10 +128,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print ''; $i = 0; foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -137,7 +151,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { * Draft customer proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total as total_ttc, p.fk_statut as status"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -145,12 +159,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT; - 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; + 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; + } $resql = $db->query($sql); if ($resql) { @@ -236,12 +256,18 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")"; $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT; $sql .= " AND p.fk_soc = s.rowid"; - 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; + 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; + } $resql = $db->query($sql); if ($resql) { @@ -326,12 +352,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT; $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $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; + } + if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -417,12 +449,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")"; $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT; $sql .= " AND cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND cf.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -509,11 +547,17 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $sql .= ", s.canvas"; $sql .= ", s.datec, s.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")"; - 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"; + 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 s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -521,11 +565,9 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { if ($resql) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $header = "BoxTitleLastCustomersOrProspects"; - } - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $header = "BoxTitleLastModifiedProspects"; - } - else { + } else { $header = "BoxTitleLastModifiedCustomers"; } @@ -559,12 +601,10 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $obj = $companystatic; $s = ''; - if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { + if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; } - if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; } /* @@ -603,11 +643,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", s.canvas"; $sql .= ", s.datec as dc, s.tms as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.fournisseur = ".Societe::SUPPLIER; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); @@ -649,8 +695,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; }*/ - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; @@ -704,12 +749,18 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_product = p.rowid"; - 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; + 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 c.tms DESC"; $sql .= $db->plimit($max + 1, 0); @@ -765,7 +816,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T * Opened (validated) proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -773,12 +824,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; - 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; + 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 p.rowid DESC"; $resql = $db->query($sql); @@ -883,12 +940,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")"; - 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; + 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 c.rowid DESC"; $resql = $db->query($sql); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index e496b8ab124..b02ac911bad 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -29,8 +29,7 @@ require '../../main.inc.php'; // Security check $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -66,8 +65,7 @@ print '
'; print '
'; // This is useless due to the global search combo -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) -{ +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print '
'; print '
'; print ''; @@ -97,16 +95,21 @@ $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::ST $sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; -if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND p.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " AND p.fk_statut IN (".implode(" ,", $listofstatus).")"; $sql .= " GROUP BY p.fk_statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; @@ -115,11 +118,9 @@ if ($resql) $colorseries = array(); $vals = array(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $vals[$obj->status] = $obj->nb; $totalinprocess += $obj->nb; @@ -140,11 +141,21 @@ if ($resql) foreach ($listofstatus as $status) { $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; - if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; - if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6; + if ($status == Propal::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Propal::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Propal::STATUS_SIGNED) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Propal::STATUS_NOTSIGNED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == Propal::STATUS_BILLED) { + $colorseries[$status] = $badgeStatus6; + } if (empty($conf->use_javascript_ajax)) { print '
'; @@ -202,12 +213,18 @@ if (!empty($conf->propal->enabled)) { $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut =".Propal::STATUS_DRAFT; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND p.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND p.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -271,12 +288,18 @@ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec"; $sql .= ", s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE c.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; //$sql.= " AND c.fk_statut > 2"; -if ($socid) $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; +if ($socid) { + $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.tms DESC"; $sql .= $db->plimit($max, 0); @@ -336,15 +359,21 @@ if ($resql) { */ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= ", p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; - 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; + 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 p.rowid DESC"; $resql = $db->query($sql); diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 7ae61362f09..a9681f199da 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; $langs->load("propal"); -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } @@ -53,8 +52,7 @@ print load_fiche_titre($langs->trans("ProspectionArea")); print '
'; -if (!empty($conf->propal->enabled)) -{ +if (!empty($conf->propal->enabled)) { $var = false; print ''; print ''; @@ -75,26 +73,27 @@ if (!empty($conf->propal->enabled)) $sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = st.id"; $sql .= " AND s.client IN (2, 3)"; $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY st.id"; $sql .= " ORDER BY st.id"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
'; print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '"; - if ($ok) - { + if ($ok) { print ''; } else { print ''; @@ -475,12 +448,11 @@ if ($action == "set") /*************************************************************************************** - * - * Load files data/*.sql - * - ***************************************************************************************/ - if ($ok && $createdata) - { + * + * Load files data/*.sql + * + ***************************************************************************************/ + if ($ok && $createdata) { // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax) $dir = "mysql/data/"; @@ -489,17 +461,15 @@ if ($action == "set") dolibarr_install_syslog("step2: open directory data ".$dir." handle=".$handle); $tablefound = 0; $tabledata = array(); - if (is_resource($handle)) - { - 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 (is_resource($handle)) { + 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. + } //print 'x'.$file.'-'.$createdata.'
'; - if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) - { + if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) { $tablefound++; $tabledata[] = $file; } @@ -510,33 +480,33 @@ 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); - if ($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. // Load all requests - while (!feof($fp)) - { + while (!feof($fp)) { $buffer = fgets($fp, 4096); $buffer = trim($buffer); - if ($buffer) - { - if (substr($buffer, 0, 2) == '--') continue; + if ($buffer) { + if (substr($buffer, 0, 2) == '--') { + continue; + } - if ($linefound && ($linefound % $sizeofgroup) == 0) - { + if ($linefound && ($linefound % $sizeofgroup) == 0) { $linegroup++; } - if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup] = $buffer; - else $arrayofrequests[$linegroup] .= " ".$buffer; + if (empty($arrayofrequests[$linegroup])) { + $arrayofrequests[$linegroup] = $buffer; + } else { + $arrayofrequests[$linegroup] .= " ".$buffer; + } $linefound++; } @@ -549,22 +519,18 @@ if ($action == "set") $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_') - { + if ($dolibarr_main_db_prefix != 'llx_') { $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } //dolibarr_install_syslog("step2: request: " . $buffer); $resql = $db->query($buffer, 1); - if ($resql) - { + if ($resql) { //$db->free($resql); // Not required as request we launch here does not return memory needs. } else { - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { //print ""; - if ($ok) - { + if ($ok) { print ''; } else { print ''; @@ -595,7 +563,9 @@ if ($action == "set") $ret = 0; -if (!$ok && isset($argv[1])) $ret = 1; +if (!$ok && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step2: end"); @@ -621,7 +591,11 @@ print $out; pFooter($ok ? 0 : 1, $setuplang); -if (isset($db) && is_object($db)) $db->close(); +if (isset($db) && is_object($db)) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index ca188ae4d5b..7d03c7b6fd0 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -40,7 +40,9 @@ $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"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -60,8 +62,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'); exit; @@ -77,8 +78,7 @@ print '
'.$langs->trans("ProspectsByStatus").'
'; @@ -112,31 +111,31 @@ if ($resql) /* * Liste des propal brouillons */ -if (!empty($conf->propal->enabled) && $user->rights->propale->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_statut = 0"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '
'.$langs->trans("ProposalsDraft").'
'; @@ -164,41 +163,45 @@ print '
'; /* * Actions commerciales a faire */ -if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10); +if (!empty($conf->agenda->enabled)) { + show_array_actions_to_do(10); +} /* * Dernieres propales ouvertes */ -if (!empty($conf->propal->enabled) && $user->rights->propale->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; - $sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; + $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = c.id"; $sql .= " AND p.fk_statut = 1"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - 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; + 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 p.rowid DESC"; $sql .= $db->plimit(5, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '"; } print "
'.$langs->trans("ProposalsOpened").'
'; @@ -218,8 +221,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total > 0) - { + if ($total > 0) { print '
'.$langs->trans("Total")."".price($total)."

"; @@ -235,25 +237,26 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) */ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = 1"; $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " ORDER BY s.tms ASC"; $sql .= $db->plimit(15, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '
'.$langs->trans("ProspectToContact").'
'; diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 747bae87cf7..a6a023952d4 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -83,26 +83,33 @@ class box_propales extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { + if ($user->rights->propale->lire) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total as total_ttc, p.tms"; + $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - 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 (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; - else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + 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 (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) { + $sql .= " ORDER BY p.datep DESC, p.ref DESC "; + } else { + $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + } $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $now = dol_now(); @@ -168,11 +175,12 @@ class box_propales extends ModeleBoxes $line++; } - if ($num == 0) + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProposals"), ); + } $this->db->free($result); } else { From 40d23c508278f62b358826418680e0b33aed4f3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Feb 2021 14:15:06 +0100 Subject: [PATCH 031/173] Update inc.php --- htdocs/install/inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index f505302b65e..03d1c41afbe 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -49,8 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once ADODB_PATH.'adodb-time.inc.php'; -// stdClass for $db -$conf = new Conf(new stdClass()); +$conf = new Conf(); // Force $_REQUEST["logtohtml"] $_REQUEST["logtohtml"] = 1; From 93aa12a573ced9b1463b90224cd2bb3c0b850f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 14:41:20 +0100 Subject: [PATCH 032/173] remove space and code syntax --- htdocs/install/inc.php | 311 +++++++++++++++++++++++++---------------- 1 file changed, 189 insertions(+), 122 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 03d1c41afbe..3f7cb019521 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -28,17 +28,22 @@ */ // Just to define version DOL_VERSION -if (!defined('DOL_INC_FOR_VERSION_ERROR')) define('DOL_INC_FOR_VERSION_ERROR', '1'); +if (!defined('DOL_INC_FOR_VERSION_ERROR')) { + define('DOL_INC_FOR_VERSION_ERROR', '1'); +} require_once '../filefunc.inc.php'; // Define DOL_DOCUMENT_ROOT and ADODB_PATH used for install/upgrade process -if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); -if (!defined('ADODB_PATH')) -{ +if (!defined('DOL_DOCUMENT_ROOT')) { + define('DOL_DOCUMENT_ROOT', '..'); +} +if (!defined('ADODB_PATH')) { $foundpath = DOL_DOCUMENT_ROOT.'/includes/adodbtime/'; - if (!is_dir($foundpath)) $foundpath = '/usr/share/php/adodb/'; + if (!is_dir($foundpath)) { + $foundpath = '/usr/share/php/adodb/'; + } define('ADODB_PATH', $foundpath); } @@ -49,15 +54,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once ADODB_PATH.'adodb-time.inc.php'; -$conf = new Conf(); +$conf = new Conf(); // Force $_REQUEST["logtohtml"] $_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"]) -{ +if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) { $_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"]; } @@ -76,19 +80,21 @@ $conffiletoshow = "htdocs/conf/conf.php"; // Load conf file if it is already defined -if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just 8) { // Test on filesize is to ensure that conf file is more that an empty template with just $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : ''; // Remove last / or \ on directories or url value - if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root); - if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root); - if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root); - if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt); - if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt); + if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) { + $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root); + } + if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) { + $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root); + } + if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) { + $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root); + } + if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) { + $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt); + } + if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) { + $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt); + } // Create conf object - if (!empty($dolibarr_main_document_root)) - { + if (!empty($dolibarr_main_document_root)) { $result = conf($dolibarr_main_document_root); } // Load database driver - if ($result) - { - if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) - { + if ($result) { + if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) { $result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php'; - if (!$result) - { + if (!$result) { $includeconferror = 'ErrorBadValueForDolibarrMainDBType'; } } @@ -130,7 +142,9 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Define prefix -if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix = 'llx_'; +if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) { + $dolibarr_main_db_prefix = 'llx_'; +} define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : '')); define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir @@ -138,42 +152,51 @@ define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_r define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* $suburi = strstr($uri, '/'); // $suburi contains url without domain -if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' +if ($suburi == '/') { + $suburi = ''; // If $suburi is /, it is now '' +} define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) -if (empty($conf->file->character_set_client)) $conf->file->character_set_client = "utf-8"; -if (empty($conf->db->character_set)) $conf->db->character_set = 'utf8'; -if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; -if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption = 0; -if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey = ''; -if (empty($conf->db->user)) $conf->db->user = ''; +if (empty($conf->file->character_set_client)) { + $conf->file->character_set_client = "utf-8"; +} +if (empty($conf->db->character_set)) { + $conf->db->character_set = 'utf8'; +} +if (empty($conf->db->dolibarr_main_db_collation)) { + $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; +} +if (empty($conf->db->dolibarr_main_db_encryption)) { + $conf->db->dolibarr_main_db_encryption = 0; +} +if (empty($conf->db->dolibarr_main_db_cryptkey)) { + $conf->db->dolibarr_main_db_cryptkey = ''; +} +if (empty($conf->db->user)) { + $conf->db->user = ''; +} // Define array of document root directories $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT); -if (!empty($dolibarr_main_document_root_alt)) -{ +if (!empty($dolibarr_main_document_root_alt)) { // dolibarr_main_document_root_alt contains several directories $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt); - foreach ($values as $value) - { + foreach ($values as $value) { $conf->file->dol_document_root[] = $value; } } // Security check (old method, when directory is renamed /install.lock) -if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"])) -{ - if (!is_object($langs)) - { +if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"])) { + if (!is_object($langs)) { $langs = new Translate('..', $conf); $langs->setDefaultLang('auto'); } $langs->load("install"); print $langs->trans("YouTryInstallDisabledByDirLock"); - if (!empty($dolibarr_main_url_root)) - { + if (!empty($dolibarr_main_url_root)) { print 'Click on following link, '; print $langs->trans("ClickHereToGoToApp"); print ''; @@ -187,17 +210,14 @@ if (constant('DOL_DATA_ROOT') === null) { // Try to detect any lockfile in the default documents path $lockfile = '../../documents/install.lock'; } -if (@file_exists($lockfile)) -{ - if (!isset($langs) || !is_object($langs)) - { +if (@file_exists($lockfile)) { + if (!isset($langs) || !is_object($langs)) { $langs = new Translate('..', $conf); $langs->setDefaultLang('auto'); } $langs->load("install"); print $langs->trans("YouTryInstallDisabledByFileLock"); - if (!empty($dolibarr_main_url_root)) - { + if (!empty($dolibarr_main_url_root)) { print $langs->trans("ClickOnLinkOrRemoveManualy").'
'; print ''; print $langs->trans("ClickHereToGoToApp"); @@ -212,42 +232,55 @@ if (@file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); -if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); -if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined -{ - if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); - elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); - elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); - elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp - elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others +if (!defined('SYSLOG_HANDLERS')) { + define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); +} +if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined + if (@is_writable('/tmp')) { + define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); + } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) { + define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); + } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) { + define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); + } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) { + define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp + } elseif (@is_writable('../../')) { + define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + } //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } -if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); -if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1); +if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); +} +if (!defined('SYSLOG_FILE_NO_ERROR')) { + define('SYSLOG_FILE_NO_ERROR', 1); +} // We init log handler for install $handlers = array('mod_syslog_file'); -foreach ($handlers as $handler) -{ +foreach ($handlers as $handler) { $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; - if (!file_exists($file)) - { + if (!file_exists($file)) { throw new Exception('Missing log handler file '.$handler.'.php'); } require_once $file; $loghandlerinstance = new $handler(); - if (!$loghandlerinstance instanceof LogHandlerInterface) - { + if (!$loghandlerinstance instanceof LogHandlerInterface) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance; + if (empty($conf->loghandlers[$handler])) { + $conf->loghandlers[$handler] = $loghandlerinstance; + } } // Define object $langs $langs = new Translate('..', $conf); -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); -else $langs->setDefaultLang('auto'); +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); +} else { + $langs->setDefaultLang('auto'); +} /** @@ -268,7 +301,9 @@ function conf($dolibarr_main_document_root) global $character_set_client; $return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php'; - if (!$return) return -1; + if (!$return) { + return -1; + } $conf = new Conf(); $conf->db->type = trim($dolibarr_main_db_type); @@ -279,51 +314,73 @@ function conf($dolibarr_main_document_root) $conf->db->pass = trim($dolibarr_main_db_pass); // Mysql driver support has been removed in favor of mysqli - if ($conf->db->type == 'mysql') $conf->db->type = 'mysqli'; - if (empty($character_set_client)) $character_set_client = "UTF-8"; + if ($conf->db->type == 'mysql') { + $conf->db->type = 'mysqli'; + } + if (empty($character_set_client)) { + $character_set_client = "UTF-8"; + } $conf->file->character_set_client = strtoupper($character_set_client); - if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); + if (empty($dolibarr_main_db_character_set)) { + $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); + } $conf->db->character_set = $dolibarr_main_db_character_set; - if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); + if (empty($dolibarr_main_db_collation)) { + $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); + } $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; - 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; // Force usage of log file for install and upgrades $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); - if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); - if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined - { - if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); - elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); - elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); - elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp - elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + if (!defined('SYSLOG_HANDLERS')) { + define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); + } + if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined + if (@is_writable('/tmp')) { + define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); + } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) { + define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); + } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) { + define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); + } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) { + define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp + } elseif (@is_writable('../../')) { + define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + } //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); - if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } + if (!defined('SYSLOG_FILE_NO_ERROR')) { + define('SYSLOG_FILE_NO_ERROR', 1); + } // We init log handler for install $handlers = array('mod_syslog_file'); - foreach ($handlers as $handler) - { + foreach ($handlers as $handler) { $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; - if (!file_exists($file)) - { + if (!file_exists($file)) { throw new Exception('Missing log handler file '.$handler.'.php'); } require_once $file; $loghandlerinstance = new $handler(); - if (!$loghandlerinstance instanceof LogHandlerInterface) - { + if (!$loghandlerinstance instanceof LogHandlerInterface) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance; + if (empty($conf->loghandlers[$handler])) { + $conf->loghandlers[$handler] = $loghandlerinstance; + } } return 1; @@ -351,8 +408,7 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl $jquerytheme = 'base'; - if ($forcejqueryurl) - { + if ($forcejqueryurl) { $jQueryCustomPath = $forcejqueryurl; $jQueryUiCustomPath = $forcejqueryurl; } else { @@ -373,14 +429,23 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl print ''."\n"; print ''."\n"; - if ($jQueryUiCustomPath) print ''."\n"; // JQuery - else print ''."\n"; // JQuery + if ($jQueryUiCustomPath) { + print ''."\n"; // JQuery + } else { + print ''."\n"; // JQuery + } print ''."\n"; - if ($jQueryCustomPath) print ''."\n"; - else print ''."\n"; - if ($jQueryUiCustomPath) print ''."\n"; - else print ''."\n"; + if ($jQueryCustomPath) { + print ''."\n"; + } else { + print ''."\n"; + } + if ($jQueryUiCustomPath) { + print ''."\n"; + } else { + print ''."\n"; + } print ''.$langs->trans("DolibarrSetup").''."\n"; print ''."\n"; @@ -399,7 +464,9 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -427,11 +494,9 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '
'."\n"; print '
'."\n"; - if (!$nonext || ($nonext == '2')) - { + if (!$nonext || ($nonext == '2')) { print '
'; - if ($nonext == '2') - { + if ($nonext == '2') { print ''; print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : ''); print ''; @@ -439,25 +504,26 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas } print '"'; - if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"'; + if ($jscheckfunction) { + print ' onClick="return '.$jscheckfunction.'();"'; + } print '>
'; - if ($withpleasewait) print ''; + if ($withpleasewait) { + print ''; + } } - if ($setuplang) - { + if ($setuplang) { print ''; } print ''."\n"; // If there is some logs in buffer to show - if (isset($conf->logbuffer) && count($conf->logbuffer)) - { + if (isset($conf->logbuffer) && count($conf->logbuffer)) { print "\n"; print "\n"; $resql = $db->query($buffer, 0, 'dml'); - if ($resql) - { + if ($resql) { $ok = 1; $db->free($resql); } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' - || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') - { + || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') { //print "Insert line : ".$buffer."
\n"; } else { $ok = 0; @@ -463,8 +437,7 @@ if ($action == "set") } print "
".$langs->trans("FunctionsCreation")."Ok
Error
Insertion ligne : $buffer"; } else { $ok = 0; @@ -574,14 +540,16 @@ if ($action == "set") } } - if ($okallfile) $db->commit(); - else $db->rollback(); + if ($okallfile) { + $db->commit(); + } else { + $db->rollback(); + } } } print "
".$langs->trans("ReferenceDataLoading")."Ok
Error
'; $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); -if ($db->ok) -{ +if ($db->ok) { print ''; print ''; print '
'; print '
'; @@ -87,15 +87,13 @@ if ($db->ok) print '
'; - if (isset($_GET["error"]) && $_GET["error"] == 1) - { + if (isset($_GET["error"]) && $_GET["error"] == 1) { print '
'; print '
'.$langs->trans("PasswordsMismatch").'
'; $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 2) - { + if (isset($_GET["error"]) && $_GET["error"] == 2) { print '
'; print '
'; print $langs->trans("PleaseTypePassword"); @@ -103,8 +101,7 @@ if ($db->ok) $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 3) - { + if (isset($_GET["error"]) && $_GET["error"] == 3) { print '
'; print '
'.$langs->trans("PleaseTypeALogin").'
'; $error = 0; // We show button @@ -112,7 +109,9 @@ if ($db->ok) } $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step4: end"); @@ -122,4 +121,6 @@ pFooter($error, $setuplang); $db->close(); // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index ed64de7cbb1..6ae3bffc59b 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -27,7 +27,9 @@ */ include_once 'inc.php'; -if (file_exists($conffile)) include_once $conffile; +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 @@ -42,13 +44,15 @@ $action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : (empty($argv[ // 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 -{ +if (!empty($action) && preg_match('/upgrade/i', $action)) { + // If it's an old 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 ($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 + } } } @@ -63,7 +67,9 @@ $success = 0; $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -110,27 +116,25 @@ 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'); exit; } -if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) -{ +if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { $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)) - { + 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 - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } $conf->db->type = $dolibarr_main_db_type; @@ -151,8 +155,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $ok = 0; // If first install - if ($action == "set") - { + if ($action == "set") { // Active module user $modName = 'modUser'; $file = $modName.".class.php"; @@ -160,13 +163,16 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) include_once DOL_DOCUMENT_ROOT."/core/modules/".$file; $objMod = new $modName($db); $result = $objMod->init(); - if (!$result) print 'ERROR in activating module file='.$file; + if (!$result) { + print 'ERROR in activating module file='.$file; + } - if ($db->connected) - { + 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 @@ -176,17 +182,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $numrows = $db->num_rows($resql); - if ($numrows == 0) - { + 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 - if (function_exists('password_hash')) + if (function_exists('password_hash')) { 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 + } else { + 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); @@ -208,13 +214,11 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $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) - { + if ($result > 0) { print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."
"; $success = 1; } else { - if ($newuser->error == 'ErrorLoginAlreadyExists') - { + if ($newuser->error == 'ErrorLoginAlreadyExists') { dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING); print '
'.$langs->trans("AdminLoginAlreadyExists", $login)."

"; $success = 1; @@ -224,14 +228,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) } } - if ($success) - { + if ($success) { // 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)"); - if ($resql) - { + if ($resql) { $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion; $db->commit(); } else { @@ -243,29 +245,36 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) 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'); + 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'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion; - if ($useforcedwizard) - { + 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'); + 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'); + 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 (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); + if (!empty($force_install_module)) { + if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) { + define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); + } $tmparray = explode(',', $force_install_module); - foreach ($tmparray as $modtoactivate) - { + foreach ($tmparray as $modtoactivate) { $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate); print $langs->trans("ActivateModule", $modtoactivatenew).'
'; @@ -274,46 +283,55 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $res = dol_include_once("/core/modules/".$file); $res = activateModule($modtoactivatenew, 1); - if (!empty($res['errors'])) print 'ERROR in activating module file='.$file; + 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'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $db->commit(); } } else { print $langs->trans("ErrorFailedToConnect")."
"; } - } - // If upgrade - elseif (empty($action) || preg_match('/upgrade/i', $action)) - { - if ($db->connected) - { + } elseif (empty($action) || preg_match('/upgrade/i', $action)) { + // If upgrade + 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; // 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. - else { + 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; + if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) { + $tagdatabase = true; + } } - if ($tagdatabase) - { + 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'); + 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'); + 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.'); @@ -337,31 +355,28 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) // Create lock file // If first install -if ($action == "set" && $success) -{ - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) - { +if ($action == "set" && $success) { + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { // Install is finished print $langs->trans("SystemIsInstalled")."
"; $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'; $fp = @fopen($lockfile, "w"); - if ($fp) - { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility + if ($fp) { + 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; } } - if (empty($createlock)) - { + if (empty($createlock)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } @@ -383,33 +398,29 @@ if ($action == "set" && $success) print ' '.$langs->trans("GoToUpgradePage"); print '
'; } -} -// If upgrade -elseif (empty($action) || preg_match('/upgrade/i', $action)) -{ - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) - { +} elseif (empty($action) || preg_match('/upgrade/i', $action)) { + // If upgrade + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { // Upgrade is finished print $langs->trans("SystemIsUpgraded")."
"; $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'; $fp = @fopen($lockfile, "w"); - if ($fp) - { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility + if ($fp) { + 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; } } - if (empty($createlock)) - { + if (empty($createlock)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } @@ -437,7 +448,9 @@ elseif (empty($action) || preg_match('/upgrade/i', $action)) clearstatcache(); $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step5: Dolibarr setup finished"); @@ -445,4 +458,6 @@ dolibarr_install_syslog("- step5: Dolibarr setup finished"); pFooter(1, $setuplang); // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 29b51746a14..db3ca2f4eb1 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -37,8 +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").'; } require_once $conffile; @@ -68,29 +67,35 @@ $ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion') $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__.'/'; - if (substr($sapi_type, 0, 3) == 'cli') - { + if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; } exit; @@ -102,8 +107,7 @@ pHeader('', "upgrade2", GETPOST('action', 'aZ09'), 'versionfrom='.$versionfrom.' $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; print '

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

'; @@ -112,15 +116,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $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)) - { + 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 - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf is already instancied inside inc.php @@ -132,9 +136,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $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); @@ -143,8 +151,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - if ($db->connected) - { + if ($db->connected) { print ''; print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); @@ -155,10 +162,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $ok = 0; } - if ($ok) - { - if ($db->database_selected) - { + if ($ok) { + if ($db->database_selected) { print ''; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); @@ -171,15 +176,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Affiche version - if ($ok) - { + if ($ok) { $version = $db->getVersion(); $versionarray = $db->getVersionArray(); print ''.$langs->trans("ServerVersion").''; print ''.$version.''; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion").": ".$version); - if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) - { + if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) { $tmparray = $db->db->get_charset(); print ''.$langs->trans("ClientCharset").''; print ''.$tmparray->charset.''; @@ -193,8 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $versionmindb = explode('.', $db::VERSIONMIN); //print join('.',$versionarray).' - '.join('.',$versionmindb); if (count($versionmindb) && count($versionarray) - && versioncompare($versionarray, $versionmindb) < 0) - { + && versioncompare($versionarray, $versionmindb) < 0) { // Warning: database version too low. print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); @@ -202,8 +204,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Test database version is not forbidden for migration - if (empty($ignoredbversion)) - { + if (empty($ignoredbversion)) { $dbversion_disallowed = array( array('type'=>'mysql', 'version'=>array(5, 5, 40)), array('type'=>'mysqli', 'version'=>array(5, 5, 40)) //, @@ -211,17 +212,16 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ //array('type'=>'mysqli','version'=>array(5,5,41)) ); $listofforbiddenversion = ''; - foreach ($dbversion_disallowed as $dbversion_totest) - { - if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']); + foreach ($dbversion_disallowed as $dbversion_totest) { + if ($dbversion_totest['type'] == $db->type) { + $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']); + } } - foreach ($dbversion_disallowed as $dbversion_totest) - { + 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) - ) - { + ) { // Warning: database version too low. print '
'.$langs->trans("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)."
".$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)); @@ -233,8 +233,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Force l'affichage de la progression - if ($ok) - { + if ($ok) { print ''.$langs->trans("PleaseBePatient").''; flush(); } @@ -243,12 +242,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ /* * Remove deprecated indexes and constraints for Mysql */ - if ($ok && preg_match('/mysql/', $db->type)) - { + if ($ok && preg_match('/mysql/', $db->type)) { $versioncommande = array(4, 0, 0); if (count($versioncommande) && count($versionarray) - && versioncompare($versioncommande, $versionarray) <= 0) // Si mysql >= 4.0 - { + && versioncompare($versioncommande, $versionarray) <= 0) { // Si mysql >= 4.0 dolibarr_install_syslog("Clean database from bad named constraints"); // Suppression vieilles contraintes sans noms et en doubles @@ -262,25 +259,20 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ ); $listtables = $db->DDLListTables($conf->db->name, ''); - foreach ($listtables as $val) - { + foreach ($listtables as $val) { // Database prefix filter - if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) - { + if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) { //print "x".$val."
"; $sql = "SHOW CREATE TABLE ".$val; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $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) - { + 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]; $resqldrop = $db->query($sqldrop); - if ($resqldrop) - { + if ($resqldrop) { print ''.$sqldrop.";\n"; } $createsql = preg_replace('/CONSTRAINT `'.$reg[1].'`/i', 'XXX', $createsql); @@ -288,8 +280,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } $db->free($resql); } else { - if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') - { + if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') { print ''.$sql.' : '.$db->lasterror()."\n"; } } @@ -299,12 +290,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } /* - * Load sql files - */ - if ($ok) - { + * Load sql files + */ + if ($ok) { $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver - if (!empty($dirmodule)) $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0); + 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 @@ -320,11 +312,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Get files list $filesindir = array(); $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/\.sql$/i', $file)) { + $filesindir[] = $file; + } } sort($filesindir); } else { @@ -332,27 +324,24 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Define which file to run - foreach ($filesindir as $file) - { - if (preg_match('/'.$from.'/i', $file)) - { + foreach ($filesindir as $file) { + if (preg_match('/'.$from.'/i', $file)) { $filelist[] = $file; - } elseif (preg_match('/'.$to.'/i', $file)) // First test may be false if we migrate from x.y.* to x.y.* - { + } elseif (preg_match('/'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* $filelist[] = $file; } } - if (count($filelist) == 0) - { + if (count($filelist) == 0) { print '
'.$langs->trans("ErrorNoMigrationFilesFoundForParameters").'
'; } else { $listoffileprocessed = array(); // Protection to avoid to process twice the same file // Loop on each migrate files - foreach ($filelist as $file) - { - if (in_array($dir.$file, $listoffileprocessed)) continue; + foreach ($filelist as $file) { + if (in_array($dir.$file, $listoffileprocessed)) { + continue; + } print '
'; print ''.$langs->trans("ChoosedMigrateScript").''.$file.''."\n"; @@ -364,18 +353,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // 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) - { + foreach ($conf->file->dol_document_root as $type => $dirroot) { $handlemodule = @opendir($dirroot); // $dirroot may be '..' - if (is_resource($handlemodule)) - { - 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. - { - //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; - if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) - { + if (is_resource($handlemodule)) { + 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. + //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; + if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) { $modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file; } } @@ -384,9 +368,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } } - foreach ($modulesfile as $modulefilelong => $modulefileshort) - { - if (in_array($modulefilelong, $listoffileprocessed)) continue; + foreach ($modulesfile as $modulefilelong => $modulefileshort) { + if (in_array($modulefilelong, $listoffileprocessed)) { + continue; + } print '
'; print ''.$langs->trans("ChoosedMigrateScript").' (external modules)'.$modulefileshort.''."\n"; @@ -401,24 +386,33 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print ''; - if ($db->connected) $db->close(); + if ($db->connected) { + $db->close(); + } } -if (empty($actiondone)) -{ +if (empty($actiondone)) { print '
'.$langs->trans("ErrorWrongParameters").'
'; } $ret = 0; -if (!$ok && isset($argv[1])) $ret = 1; +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; +if ($dirmodule) { + $nonext = 1; +} pFooter($nonext, $setuplang); -if ($db->connected) $db->close(); +if ($db->connected) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 1dc7180bc4b..d9656231a2c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -39,8 +39,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").'; } require_once $conffile; @@ -64,9 +63,11 @@ $error = 0; // Ne fonctionne que si on est pas en safe_mode. $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); +} else { + @set_time_limit(600); +} error_reporting($err); $setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto'; @@ -77,13 +78,21 @@ $enablemodules = GETPOST("enablemodules", 'alpha', 3) ?GETPOST("enablemodules", $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); +} @@ -91,16 +100,14 @@ if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initiali * View */ -if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) -{ +if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\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__.'/'; - if (substr($sapi_type, 0, 3) == 'cli') - { + if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; } exit; @@ -109,22 +116,21 @@ if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); -if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) -{ +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { print '

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

'; print ''; // 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)) - { + 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 - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf is already instancied inside inc.php @@ -142,47 +148,48 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('upgrade')); - if (!$db->connected) - { + if (!$db->connected) { print ''; dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); $error++; } - if (!$error) - { - if ($db->database_selected) - { + if (!$error) { + if ($db->database_selected) { dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); } else { $error++; } } - 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; // Chargement config - if (!$error) - { + if (!$error) { $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; } /*************************************************************************************** - * - * Migration of data - * - ***************************************************************************************/ + * + * Migration of data + * + ***************************************************************************************/ $db->begin(); - if (!$error) - { + if (!$error) { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); @@ -222,8 +229,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '2.0.0'); $beforeversionarray = explode('.', '2.7.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Script pour V2 -> V2.1 migrate_paiements($db, $langs, $conf); @@ -286,8 +292,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '2.7.9'); $beforeversionarray = explode('.', '2.8.9'); //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); @@ -312,8 +317,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 2.9 $afterversionarray = explode('.', '2.8.9'); $beforeversionarray = explode('.', '2.9.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_project_task_time($db, $langs, $conf); migrate_customerorder_shipping($db, $langs, $conf); @@ -326,16 +330,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.0 $afterversionarray = explode('.', '2.9.9'); $beforeversionarray = explode('.', '3.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Script for 3.1 $afterversionarray = explode('.', '3.0.9'); $beforeversionarray = explode('.', '3.1.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); migrate_actioncomm_element($db, $langs, $conf); @@ -344,8 +346,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.2 $afterversionarray = explode('.', '3.1.9'); $beforeversionarray = explode('.', '3.2.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_contrat($db, $langs, $conf); migrate_mode_reglement($db, $langs, $conf); @@ -356,8 +357,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.3 $afterversionarray = explode('.', '3.2.9'); $beforeversionarray = explode('.', '3.3.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_categorie_association($db, $langs, $conf); } @@ -367,32 +367,28 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Tasks to do always and only into last targeted version $afterversionarray = explode('.', '3.6.9'); // target is after this $beforeversionarray = explode('.', '3.7.9'); // target is before this - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_event_assignement($db, $langs, $conf); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_event_assignement($db, $langs, $conf); } // Scripts for 3.9 $afterversionarray = explode('.', '3.7.9'); $beforeversionarray = explode('.', '3.8.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Scripts for 4.0 $afterversionarray = explode('.', '3.9.9'); $beforeversionarray = explode('.', '4.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); } // Scripts for 5.0 $afterversionarray = explode('.', '4.0.9'); $beforeversionarray = explode('.', '5.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate to add entity value into llx_societe_remise migrate_remise_entity($db, $langs, $conf); @@ -403,15 +399,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 6.0 $afterversionarray = explode('.', '5.0.9'); $beforeversionarray = explode('.', '6.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - if (!empty($conf->multicompany->enabled)) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + if (!empty($conf->multicompany->enabled)) { global $multicompany_transverse_mode; // Only if the transverse mode is not used - if (empty($multicompany_transverse_mode)) - { + if (empty($multicompany_transverse_mode)) { // Migrate to add entity value into llx_user_rights migrate_user_rights_entity($db, $langs, $conf); @@ -424,8 +417,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 7.0 $afterversionarray = explode('.', '6.0.9'); $beforeversionarray = explode('.', '7.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate contact association migrate_event_assignement_contact($db, $langs, $conf); @@ -435,16 +427,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 8.0 $afterversionarray = explode('.', '7.0.9'); $beforeversionarray = explode('.', '8.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); } // Scripts for 9.0 $afterversionarray = explode('.', '8.0.9'); $beforeversionarray = explode('.', '9.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_user_photospath(); } @@ -460,8 +450,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Code executed only if migration is LAST ONE. Must always be done. - if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) - { + if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', @@ -502,14 +491,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (!$error && $enablemodules) - { + if (!$error && $enablemodules) { // Reload modules (this must be always done and only into last targeted version) $listofmodules = array(); $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); $tmplistofmodules = explode(',', $enablemodules); - foreach ($tmplistofmodules as $value) - { + foreach ($tmplistofmodules as $value) { $listofmodules[$value] = 'forceactivate'; } @@ -521,16 +508,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Can call a dedicated external upgrade process - if (!$error) - { + if (!$error) { $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); $object = new stdClass(); $action = "upgrade"; $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($hookmanager->resNbOfHooks > 0) - { - if ($reshook < 0) - { + if ($hookmanager->resNbOfHooks > 0) { + if ($reshook < 0) { print ''; @@ -587,16 +570,22 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade2: end"); pFooter($error ? 2 : 0, $setuplang); -if ($db->connected) $db->close(); +if ($db->connected) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} @@ -617,8 +606,7 @@ function migrate_paiements($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $sql = "SELECT p.rowid, p.fk_facture, p.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; $sql .= " WHERE p.fk_facture > 0"; @@ -626,14 +614,12 @@ function migrate_paiements($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_paiements"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $row[$i][0] = $obj->rowid; $row[$i][1] = $obj->fk_facture; @@ -644,15 +630,12 @@ function migrate_paiements($db, $langs, $conf) dol_print_error($db); } - if ($num) - { + if ($num) { print $langs->trans('MigrationPaymentsNumberToUpdate', $num)."
\n"; - if ($db->begin()) - { + if ($db->begin()) { $res = 0; $num = count($row); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; @@ -666,8 +649,7 @@ function migrate_paiements($db, $langs, $conf) } } - if ($res == (2 * count($row))) - { + if ($res == (2 * count($row))) { $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { @@ -703,8 +685,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql .= " bu2.url_id as socid"; @@ -719,16 +700,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1"); $row = array(); - if ($resql) - { + if ($resql) { $i = $j = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { + if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; @@ -743,16 +721,16 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) dol_print_error($db); } - if (count($row)) - { + if (count($row)) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)."
\n"; $db->begin(); $res = 0; $num = count($row); - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + for ($i = 0; $i < $num; $i++) { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) { + print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + } // On cherche facture sans lien paiement et du meme montant et pour meme societe. $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; @@ -762,12 +740,10 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { + if ($num >= 1) { $obj = $db->fetch_object($resql); $facid = $obj->rowid; @@ -783,8 +759,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) } } - if ($res > 0) - { + if ($res > 0) { print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; @@ -820,8 +795,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql .= " bu2.url_id as socid"; @@ -835,16 +809,13 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2"); $row = array(); - if ($resql) - { + if ($resql) { $i = $j = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { + if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; @@ -862,15 +833,15 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $nberr = 0; $num = count($row); - if ($num) - { + if ($num) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; $db->begin(); $res = 0; - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + for ($i = 0; $i < $num; $i++) { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) { + print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + } // On cherche facture sans lien paiement et du meme montant et pour meme societe. $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; @@ -880,12 +851,10 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { + if ($num >= 1) { $obj = $db->fetch_object($resql); $facid = $obj->rowid; @@ -901,8 +870,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) } } - if ($res > 0) - { + if ($res > 0) { print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; @@ -919,8 +887,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture"; $db->query($sql); - if (!$nberr) - { + if (!$nberr) { $db->commit(); } else { print 'ERROR'; @@ -962,19 +929,16 @@ function migrate_contracts_det($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_det"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print $langs->trans('MigrationContractsNumberToUpdate', $num)."
\n"; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; @@ -993,8 +957,7 @@ function migrate_contracts_det($db, $langs, $conf) $sql .= "null"; $sql .= ")"; - if ($db->query($sql)) - { + if ($db->query($sql)) { print $langs->trans('MigrationContractsLineCreation', $obj->cref)."
\n"; } else { dol_print_error($db); @@ -1004,8 +967,7 @@ function migrate_contracts_det($db, $langs, $conf) $i++; } - if (!$nberr) - { + if (!$nberr) { // $db->rollback(); $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; @@ -1050,19 +1012,16 @@ function migrate_links_transfert($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_links_transfert"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print $langs->trans('MigrationBankTransfertsToUpdate', $num)."
\n"; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; @@ -1075,8 +1034,7 @@ function migrate_links_transfert($db, $langs, $conf) print $sql.'
'; dolibarr_install_syslog("migrate_links_transfert"); - if (!$db->query($sql)) - { + if (!$db->query($sql)) { dol_print_error($db); $nberr++; } @@ -1084,8 +1042,7 @@ function migrate_links_transfert($db, $langs, $conf) $i++; } - if (!$nberr) - { + if (!$nberr) { // $db->rollback(); $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; @@ -1121,18 +1078,26 @@ function migrate_contracts_date1($db, $langs, $conf) $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; + } $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; + } print ''; } @@ -1162,22 +1127,18 @@ function migrate_contracts_date2($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $nbcontratsmodifie = 0; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->date_contrat > $obj->datemin) - { + if ($obj->date_contrat > $obj->datemin) { $datemin = $db->jdate($obj->datemin); print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; @@ -1185,7 +1146,9 @@ function migrate_contracts_date2($db, $langs, $conf) $sql .= " SET date_contrat='".$db->idate($datemin)."'"; $sql .= " WHERE rowid=".$obj->cref; $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + if (!$resql2) { + dol_print_error($db); + } $nbcontratsmodifie++; } @@ -1194,9 +1157,11 @@ function migrate_contracts_date2($db, $langs, $conf) $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; + if ($nbcontratsmodifie) { + print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; + } else { + print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; + } } } else { dol_print_error($db); @@ -1223,10 +1188,14 @@ function migrate_contracts_date3($db, $langs, $conf) $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; + } print ''; } @@ -1250,19 +1219,19 @@ function migrate_contracts_open($db, $langs, $conf) $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } if ($db->affected_rows($resql) > 0) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $nbcontratsmodifie = 0; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; @@ -1270,7 +1239,9 @@ function migrate_contracts_open($db, $langs, $conf) $sql .= " SET statut=1"; $sql .= " WHERE rowid=".$obj->cref; $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + if (!$resql2) { + dol_print_error($db); + } $nbcontratsmodifie++; @@ -1279,11 +1250,15 @@ function migrate_contracts_open($db, $langs, $conf) $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + if ($nbcontratsmodifie) { + print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; + } else { + print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } } - } else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } else { + print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } print ''; } @@ -1307,8 +1282,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn", "fk_facture_fourn"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $nb = 0; @@ -1318,15 +1292,13 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); $select_resql = $db->query($select_sql); - if ($select_resql) - { + if ($select_resql) { $select_num = $db->num_rows($select_resql); $i = 0; $var = true; // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (!$error)) - { + while (($i < $select_num) && (!$error)) { $var = !$var; $select_obj = $db->fetch_object($select_resql); @@ -1335,15 +1307,12 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_resql = $db->query($check_sql); - if ($check_resql) - { + if ($check_resql) { $check_num = $db->num_rows($check_resql); - if ($check_num == 0) - { + if ($check_num == 0) { $db->begin(); - if ($nb == 0) - { + if ($nb == 0) { print ''; print ''; } @@ -1357,8 +1326,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $insert_sql .= ' amount = \''.$select_obj->amount.'\''; $insert_resql = $db->query($insert_sql); - if ($insert_resql) - { + if ($insert_resql) { $nb++; print ''; } else { @@ -1376,10 +1344,8 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $error++; } - if (!$error) - { - if (!$nb) - { + if (!$error) { + if (!$nb) { print ''; } $db->commit(); @@ -1427,14 +1393,11 @@ function migrate_price_facture($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_facture"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1465,15 +1428,12 @@ function migrate_price_facture($db, $langs, $conf) /* On touche a facture mere uniquement si total_ttc = 0 */ - if (!$total_ttc_f) - { + if (!$total_ttc_f) { $facture = new Facture($db); $facture->id = $obj->facid; - if ($facture->fetch($facture->id) >= 0) - { - if ($facture->update_price() > 0) - { + if ($facture->fetch($facture->id) >= 0) { + if ($facture->update_price() > 0) { //print $facture->id; } else { print "Error id=".$facture->id; @@ -1516,7 +1476,7 @@ function migrate_price_facture($db, $langs, $conf) */ function migrate_price_propal($db, $langs, $conf) { - $tmpmysoc = new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1535,14 +1495,11 @@ function migrate_price_propal($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_propal"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1572,24 +1529,24 @@ function migrate_price_propal($db, $langs, $conf) /* On touche pas a propal mere - $propal = new Propal($db); - $propal->id=$obj->rowid; - if ( $propal->fetch($propal->id) >= 0 ) - { - if ( $propal->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$propal->id; - } - } - else - { - print "Error #3"; - } - */ + $propal = new Propal($db); + $propal->id=$obj->rowid; + if ( $propal->fetch($propal->id) >= 0 ) + { + if ( $propal->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$propal->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1622,9 +1579,11 @@ function migrate_price_contrat($db, $langs, $conf) { $db->begin(); - $tmpmysoc = new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) { + $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. + } print ''; @@ -3421,26 +3269,20 @@ function migrate_mode_reglement($db, $langs, $conf) function migrate_clean_association($db, $langs, $conf) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association"); - if ($result) // result defined for version 3.2 or - - { + if ($result) { // result defined for version 3.2 or - $obj = $db->fetch_object($result); - if ($obj) // It table categorie_association exists - { + if ($obj) { // It table categorie_association exists $couples = array(); $filles = array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - while ($obj = $db->fetch_object($resql)) - { - if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). - { - if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) - { + while ($obj = $db->fetch_object($resql)) { + if (!isset($filles[$obj->fk_categorie_fille])) { // Only one record as child (a child has only on parent). + if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { $filles[$obj->fk_categorie_fille] = 1; // Set record for this child $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } @@ -3450,8 +3292,7 @@ function migrate_clean_association($db, $langs, $conf) dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); // If there is duplicates couples or child with two parents - if (count($couples) > 0 && $num > count($couples)) - { + if (count($couples) > 0 && $num > count($couples)) { $error = 0; $db->begin(); @@ -3460,21 +3301,20 @@ function migrate_clean_association($db, $langs, $conf) $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: delete association"); $resqld = $db->query($sql); - if ($resqld) - { + if ($resqld) { // And we insert only each record once - foreach ($couples as $key => $val) - { + foreach ($couples as $key => $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; dolibarr_install_syslog("upgrade: insert association"); $resqli = $db->query($sql); - if (!$resqli) $error++; + if (!$resqli) { + $error++; + } } } - if (!$error) - { + if (!$error) { print ''; print ''; $db->commit(); @@ -3510,8 +3350,7 @@ function migrate_categorie_association($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association")) { dolibarr_install_syslog("upgrade2::migrate_categorie_association"); $db->begin(); @@ -3520,15 +3359,12 @@ function migrate_categorie_association($db, $langs, $conf) $sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET "; @@ -3536,8 +3372,7 @@ function migrate_categorie_association($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3548,8 +3383,7 @@ function migrate_categorie_association($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { // TODO DROP table in the next release /* $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association"; @@ -3607,23 +3441,19 @@ function migrate_event_assignement($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; $sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3634,8 +3464,7 @@ function migrate_event_assignement($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3678,23 +3507,19 @@ function migrate_event_assignement_contact($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; $sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3705,8 +3530,7 @@ function migrate_event_assignement_contact($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3752,34 +3576,28 @@ function migrate_reset_blocked_log($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Process entity '.$obj->entity; $sqlSearch = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."blockedlog WHERE action = 'MODULE_SET' and entity = ".$obj->entity; $resqlSearch = $db->query($sqlSearch); - if ($resqlSearch) - { + if ($resqlSearch) { $objSearch = $db->fetch_object($resqlSearch); //var_dump($objSearch); - if ($objSearch && $objSearch->nb == 0) - { + if ($objSearch && $objSearch->nb == 0) { print ' - Record for entity must be reset...'; $sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog"; $sqlUpdate .= " WHERE entity = ".$obj->entity; $resqlUpdate = $db->query($sqlUpdate); - if (!$resqlUpdate) - { + if (!$resqlUpdate) { $error++; dol_print_error($db); } else { @@ -3812,8 +3630,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) print $langs->trans('NothingToDo')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3855,15 +3672,12 @@ function migrate_remise_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; @@ -3871,8 +3685,7 @@ function migrate_remise_entity($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3884,8 +3697,7 @@ function migrate_remise_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3924,26 +3736,21 @@ function migrate_remise_except_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); - if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) - { + if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) { $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; - } elseif (!empty($obj->fk_facture_line)) - { + } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; @@ -3955,10 +3762,8 @@ function migrate_remise_except_entity($db, $langs, $conf) } $resql2 = $db->query($sqlSelect2); - if ($resql2) - { - if ($db->num_rows($resql2) > 0) - { + if ($resql2) { + if ($db->num_rows($resql2) > 0) { $obj2 = $db->fetch_object($resql2); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; @@ -3966,8 +3771,7 @@ function migrate_remise_except_entity($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3984,8 +3788,7 @@ function migrate_remise_except_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4025,15 +3828,12 @@ function migrate_user_rights_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; @@ -4041,8 +3841,7 @@ function migrate_user_rights_entity($db, $langs, $conf) $sqlUpdate .= " WHERE fk_user = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -4054,8 +3853,7 @@ function migrate_user_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4095,15 +3893,12 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; @@ -4111,8 +3906,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -4124,8 +3918,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4153,8 +3946,7 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) - { + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) { dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); } @@ -4296,12 +4088,16 @@ function migrate_delete_old_dir($db, $langs, $conf) */ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0) { - if (count($listofmodule) == 0) return; + if (count($listofmodule) == 0) { + return; + } dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); foreach ($listofmodule as $moduletoreload => $reloadmode) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) { + continue; // Discard reload if module not enabled + } $mod = null; @@ -4485,10 +4281,8 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } else { // Other generic cases/modules $reg = array(); $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); - if (!empty($reg[1])) - { - if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase - { + if (!empty($reg[1])) { + if (strtoupper($moduletoreload) == $moduletoreload) { // If key is un uppercase $moduletoreloadshort = ucfirst(strtolower($reg[1])); } else // If key is a mix of up and low case { @@ -4525,8 +4319,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } } - if (!empty($mod) && is_object($mod)) - { + if (!empty($mod) && is_object($mod)) { print ''; print ''; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d2853d48034..730546e0e6b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1356,6 +1356,8 @@ abstract class CommonObject if ($resql) { $num = $this->db->num_rows($resql); if ($num > 0) { + $langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal")); + while ($obj = $this->db->fetch_object($resql)) { $modulename = $obj->element; if (strpos($obj->element, 'project') !== false) { @@ -1371,11 +1373,15 @@ abstract class CommonObject } if ($conf->{$modulename}->enabled) { $libelle_element = $langs->trans('ContactDefault_'.$obj->element); - $transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code; + $tmpelement = $obj->element; + $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); - if (empty($option)) + if (empty($option)) { $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; - else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; + } + else { + $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; + } } } } diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index ce5bdf0425a..2617cdfe9e9 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -52,3 +52,6 @@ SupplierProposalsToClose=Vendor proposals to close SupplierProposalsToProcess=Vendor proposals to process LastSupplierProposals=Latest %s price requests AllPriceRequests=All requests +TypeContact_supplier_proposal_external_SHIPPING=Vendor contact for delivery +TypeContact_supplier_proposal_external_BILLING=Vendor contact for billing +TypeContact_supplier_proposal_external_SERVICE=Representative following-up proposal From 7fd2ac6618e7d7295f2f7d07b374bc5f6a208299 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Feb 2021 16:20:13 +0100 Subject: [PATCH 036/173] Fix link to show line in pending account --- htdocs/accountancy/bookkeeping/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 882c51f40c0..bef8ece1d39 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -110,7 +110,7 @@ $form = new Form($db); if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { - if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values')) + if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; From b674ebad8816de322aa981ca2abc6bda32857c28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Feb 2021 16:21:05 +0100 Subject: [PATCH 037/173] Responsive --- htdocs/core/class/html.formcompany.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 8cff096e56a..1ed2af9aa2d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -824,7 +824,7 @@ class FormCompany extends Form } if (count($newselected) > 0) $selected = $newselected; } - return $this->multiselectarray($htmlname, $contactType, $selected); + return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, 'minwidth500'); } return 'ErrorBadValueForParameterRenderMode'; // Should not happened From 29b1f10fd44c06b1d681a8e3be896b61801afd6e Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 22 Feb 2021 17:33:54 +0100 Subject: [PATCH 038/173] Fix #16096 #16085 missing CSRF token --- htdocs/core/js/lib_head.js.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 391a5359846..ee95a13208f 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -574,11 +574,12 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#set_" + key).hide(); $("#del_" + key).show(); - $.get( url, { + $.post( url, { action: "set", name: key, value: value, - entity: entity + entity: entity, + token: token }); }); } @@ -644,10 +645,11 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke $.each(data, function(key, value) { $("#del_" + value).hide(); $("#set_" + value).show(); - $.get( url, { + $.post( url, { action: "del", name: value, - entity: entity + entity: entity, + token: token }); }); } From 6f93deae402cebe91e168dd924f18c8470a4f1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 18:21:12 +0100 Subject: [PATCH 039/173] fix propal fetch --- htdocs/comm/propal/class/propal.class.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b3da95919e8..b14c7c31431 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -1467,10 +1467,8 @@ class Propal extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -1481,12 +1479,12 @@ class Propal extends CommonObject $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO deprecated + $this->total = $obj->total_ttc; // TODO deprecated $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total; + $this->total_ttc = $obj->total_ttc; $this->socid = $obj->fk_soc; $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty @@ -1553,8 +1551,7 @@ class Propal extends CommonObject $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if ($obj->fk_statut == self::STATUS_DRAFT) - { + if ($obj->fk_statut == self::STATUS_DRAFT) { $this->brouillon = 1; } From 95524abd226f72ddd34e7df8cebd0dbd4df9cd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 18:38:03 +0100 Subject: [PATCH 040/173] code syntax --- htdocs/asset/admin/assets_extrafields.php | 17 +- .../asset/admin/assets_type_extrafields.php | 17 +- htdocs/asset/admin/setup.php | 13 +- htdocs/asset/card.php | 78 +++-- htdocs/asset/class/asset.class.php | 60 ++-- htdocs/asset/class/asset_type.class.php | 85 +++-- htdocs/asset/document.php | 27 +- htdocs/asset/info.php | 6 +- htdocs/asset/list.php | 315 +++++++++++------- htdocs/asset/note.php | 69 ++-- htdocs/asset/type.php | 137 ++++---- htdocs/asterisk/cidlookup.php | 12 +- htdocs/asterisk/wrapper.php | 82 +++-- 13 files changed, 511 insertions(+), 407 deletions(-) diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 3334610b927..9a68f99fe06 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -35,13 +35,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'don'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -74,8 +78,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -88,8 +91,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "
"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -101,8 +103,7 @@ if ($action == 'create') /* Edit 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/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index e17d421437d..6d2799e0228 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -34,13 +34,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -72,8 +76,7 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -86,8 +89,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "
"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -99,8 +101,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/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 42a5888c537..c6cd45a0cc5 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -32,7 +32,9 @@ global $langs, $user; $langs->loadLangs(array("admin", "assets")); // Access control -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Parameters $action = GETPOST('action', 'aZ09'); @@ -63,8 +65,7 @@ $head = asset_admin_prepare_head(); print dol_get_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic'); -if ($action == 'edit') -{ +if ($action == 'edit') { print '
'; print ''; print ''; @@ -72,8 +73,7 @@ if ($action == 'edit') print '
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'; print ''.$langs->trans('UpgradeExternalModule').': '; print $hookmanager->error; @@ -544,8 +528,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } } else { //if (! empty($conf->modules)) - if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done - { + if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done print '
'; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); print '
'.$langs->trans('SuppliersInvoices').'
fk_paiementfournfk_facturefourn'.$langs->trans('Amount').' 
'.$langs->trans("OK").'
'.$langs->trans("AlreadyDone").'
'; @@ -1640,14 +1599,11 @@ function migrate_price_contrat($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_contrat"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1724,14 +1680,11 @@ function migrate_price_commande($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_commande"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1760,24 +1713,24 @@ function migrate_price_commande($db, $langs, $conf) $commandeligne->update_total(); /* On touche pas a facture mere - $commande = new Commande($db); - $commande->id = $obj->rowid; - if ( $commande->fetch($commande->id) >= 0 ) - { - if ( $commande->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$commande->id; - } - } - else - { - print "Error #3"; - } - */ + $commande = new Commande($db); + $commande->id = $obj->rowid; + if ( $commande->fetch($commande->id) >= 0 ) + { + if ( $commande->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$commande->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1787,14 +1740,14 @@ function migrate_price_commande($db, $langs, $conf) $db->free($resql); /* - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; - $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0"; - $resql=$db->query($sql); - if (! $resql) - { - dol_print_error($db); - } - */ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; + $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0"; + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + } + */ $db->commit(); } else { @@ -1837,14 +1790,11 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1873,24 +1823,24 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne->update_total(); /* On touche pas a facture mere - $commande = new Commande($db); - $commande->id = $obj->rowid; - if ( $commande->fetch($commande->id) >= 0 ) - { - if ( $commande->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$commande->id; - } - } - else - { - print "Error #3"; - } - */ + $commande = new Commande($db); + $commande->id = $obj->rowid; + if ( $commande->fetch($commande->id) >= 0 ) + { + if ( $commande->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$commande->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1900,14 +1850,14 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $db->free($resql); /* - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; - $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; - $resql=$db->query($sql); - if (! $resql) - { - dol_print_error($db); - } - */ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; + $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + } + */ $db->commit(); } else { @@ -1936,42 +1886,42 @@ function migrate_modeles($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $modellist = ModelePDFFactures::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $modellist = ModelePDFCommandes::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } - if (!empty($conf->expedition->enabled)) - { + if (!empty($conf->expedition->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; $modellist = ModelePDFExpedition::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } @@ -1998,31 +1948,26 @@ function migrate_commande_expedition($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2031,8 +1976,7 @@ function migrate_commande_expedition($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande"; print $langs->trans('FieldRenamed')."
\n"; @@ -2069,8 +2013,7 @@ function migrate_commande_livraison($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2080,23 +2023,19 @@ function migrate_commande_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $delivery_date = $db->jdate($obj->delivery_date); $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -2104,8 +2043,7 @@ function migrate_commande_livraison($db, $langs, $conf) $sqlu .= ", date_livraison='".$db->idate($delivery_date)."'"; $sqlu .= " WHERE rowid = ".$obj->rowid; $resql3 = $db->query($sqlu); - if (!$resql3) - { + if (!$resql3) { $error++; dol_print_error($db); } @@ -2118,8 +2056,7 @@ function migrate_commande_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande"; print $langs->trans('FieldRenamed')."
\n"; @@ -2158,8 +2095,7 @@ function migrate_detail_livraison($db, $langs, $conf) // If not this means migration was already done. $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2169,15 +2105,12 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; @@ -2188,15 +2121,13 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $sql = "SELECT total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; $sql .= " WHERE rowid = ".$obj->fk_livraison; $resql3 = $db->query($sql); - if ($resql3) - { + if ($resql3) { $obju = $db->fetch_object($resql3); $total_ht = $obju->total_ht + $obj->total_ht; @@ -2204,8 +2135,7 @@ function migrate_detail_livraison($db, $langs, $conf) $sqlu .= " total_ht='".$db->escape($total_ht)."'"; $sqlu .= " WHERE rowid=".$obj->fk_livraison; $resql4 = $db->query($sqlu); - if (!$resql4) - { + if (!$resql4) { $error++; dol_print_error($db); } @@ -2222,8 +2152,7 @@ function migrate_detail_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer"; print $langs->trans('FieldRenamed')."
\n"; @@ -2238,8 +2167,7 @@ function migrate_detail_livraison($db, $langs, $conf) } else { $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line"); $obj = $db->fetch_object($result); - if (!$obj) - { + if (!$obj) { $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison"; $db->query($sql); } @@ -2273,15 +2201,12 @@ function migrate_stocks($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; @@ -2289,8 +2214,7 @@ function migrate_stocks($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_product; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2300,8 +2224,7 @@ function migrate_stocks($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2334,8 +2257,7 @@ function migrate_menus($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) { $db->begin(); $sql = "SELECT m.rowid, mc.action"; @@ -2343,14 +2265,11 @@ function migrate_menus($db, $langs, $conf) $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; @@ -2359,8 +2278,7 @@ function migrate_menus($db, $langs, $conf) $sql .= " AND enabled = '1'"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2370,8 +2288,7 @@ function migrate_menus($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2407,8 +2324,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) { $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; @@ -2418,15 +2334,12 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -2434,8 +2347,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_expedition; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2446,8 +2358,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2476,10 +2387,8 @@ function migrate_restore_missing_links($db, $langs, $conf) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links"); - if (($db->type == 'mysql' || $db->type == 'mysqli')) - { - if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) - { + if (($db->type == 'mysql' || $db->type == 'mysqli')) { + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; } @@ -2506,15 +2415,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; @@ -2523,18 +2429,18 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } //print ". "; $i++; } - } else print $langs->trans('AlreadyDone')."
\n"; + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2566,15 +2472,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; @@ -2583,8 +2486,7 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2595,8 +2497,7 @@ function migrate_restore_missing_links($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2628,23 +2529,19 @@ function migrate_project_user_resp($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); $sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2661,11 +2558,9 @@ function migrate_project_user_resp($db, $langs, $conf) $sql2 .= ", ".$obj->fk_user_resp; $sql2 .= ")"; - if ($obj->fk_user_resp > 0) - { + if ($obj->fk_user_resp > 0) { $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2676,11 +2571,9 @@ function migrate_project_user_resp($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2715,23 +2608,19 @@ function migrate_project_task_actors($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationProjectTaskActors')."
\n"; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) { $error = 0; $db->begin(); $sql = "SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2750,8 +2639,7 @@ function migrate_project_task_actors($db, $langs, $conf) $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2760,11 +2648,9 @@ function migrate_project_task_actors($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2804,8 +2690,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); @@ -2814,15 +2699,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2838,8 +2720,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -2850,11 +2731,9 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2897,22 +2776,18 @@ function migrate_project_task_time($db, $langs, $conf) $sql = "SELECT rowid, fk_task, task_duration"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $totaltime = array(); $oldtime = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->task_duration > 0) - { + if ($obj->task_duration > 0) { // convert to second // only for int time and float time ex: 1,75 for 1h45 list($hour, $min) = explode('.', $obj->task_duration); @@ -2925,36 +2800,37 @@ function migrate_project_task_time($db, $langs, $conf) $sql2 .= " WHERE rowid = ".$obj->rowid; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } print ". "; $oldtime++; - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; - else $totaltime[$obj->fk_task] = $newtime; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $newtime; + } else { + $totaltime[$obj->fk_task] = $newtime; + } } else { - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; - else $totaltime[$obj->fk_task] = $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $obj->task_duration; + } else { + $totaltime[$obj->fk_task] = $obj->task_duration; + } } $i++; } - if ($error == 0) - { - if ($oldtime > 0) - { - foreach ($totaltime as $taskid => $total_duration) - { + if ($error == 0) { + if ($oldtime > 0) { + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " duration_effective = ".$total_duration; $sql .= " WHERE rowid = ".$taskid; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; dol_print_error($db); } @@ -2972,8 +2848,7 @@ function migrate_project_task_time($db, $langs, $conf) dol_print_error($db); } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -3003,8 +2878,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery"); $obj1 = $db->fetch_object($result1); $obj2 = $db->fetch_object($result2); - if (!$obj1 && !$obj2) - { + if (!$obj1 && !$obj2) { dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping"); $db->begin(); @@ -3012,8 +2886,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity"; $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition"; - if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) - { + if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date"; $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; @@ -3022,15 +2895,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -3039,8 +2909,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3051,8 +2920,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3092,8 +2960,7 @@ function migrate_shipping_delivery($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_shipping_delivery"); $db->begin(); @@ -3103,15 +2970,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -3127,14 +2991,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if ($result) - { + if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3149,8 +3011,7 @@ function migrate_shipping_delivery($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'"; $db->query($sqlDelete); @@ -3209,15 +3070,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -3226,8 +3084,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3238,8 +3095,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3277,12 +3133,10 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach ($elements as $type => $field) - { + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); @@ -3294,8 +3148,7 @@ function migrate_actioncomm_element($db, $langs, $conf) $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $db->commit(); // DDL commands must not be inside a transaction @@ -3338,8 +3191,7 @@ function migrate_mode_reglement($db, $langs, $conf) ); $count = 0; - foreach ($elements['old_id'] as $key => $old_id) - { + foreach ($elements['old_id'] as $key => $old_id) { $error = 0; dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); @@ -3350,11 +3202,9 @@ function migrate_mode_reglement($db, $langs, $conf) $sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $count++; $db->begin(); @@ -3371,25 +3221,21 @@ function migrate_mode_reglement($db, $langs, $conf) $sql .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sql); - if ($resqla && $resql) - { - foreach ($elements['tables'] as $table) - { + if ($resqla && $resql) { + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); $error++; } print ". "; } - if (!$error) - { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -3403,7 +3249,9 @@ function migrate_mode_reglement($db, $langs, $conf) } } - if ($count == 0) print $langs->trans('AlreadyDone')."
\n"; + if ($count == 0) { + print $langs->trans('AlreadyDone')."
\n"; + } print '
'.$langs->trans("MigrationCategorieAssociation").''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')
'; print ''.$langs->trans('Upgrade').': '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated @@ -4557,13 +4350,11 @@ function migrate_reload_menu($db, $langs, $conf) // Define list of menu handlers to initialize $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' - || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') - { + || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } - foreach ($listofmenuhandler as $key => $val) - { + foreach ($listofmenuhandler as $key => $val) { print '
'; //print "x".$key; @@ -4573,8 +4364,7 @@ function migrate_reload_menu($db, $langs, $conf) // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT."/core/menus/"; $file = 'init_menu_'.$key.'.sql'; - if (file_exists($dir.$file)) - { + if (file_exists($dir.$file)) { $result = run_sql($dir.$file, 1, '', 1, $key); } @@ -4598,14 +4388,14 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (!is_object($user)) $user = $fuser; // To avoid error during migration + if (!is_object($user)) { + $user = $fuser; // To avoid error during migration + } $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $fuser->fetch($obj->uid); //echo '
'.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); @@ -4615,8 +4405,7 @@ function migrate_user_photospath() $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } - if ($dir) - { + if ($dir) { //print "Process user id ".$fuser->id."
\n"; $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path $destin = $dir.'/'.$fuser->id; @@ -4626,26 +4415,23 @@ function migrate_user_photospath() dol_mkdir($destin); //echo '
'.$origin.' -> '.$destin; - if (dol_is_dir($origin)) - { + if (dol_is_dir($origin)) { $handle = opendir($origin_osencoded); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if ($file == '.' || $file == '..') continue; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if ($file == '.' || $file == '..') { + continue; + } - if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs') - { + if (dol_is_dir($origin.'/'.$file)) { // it is a dir (like 'thumbs') $thumbs = opendir($origin_osencoded.'/'.$file); - if (is_resource($thumbs)) - { - dol_mkdir($destin.'/'.$file); - while (($thumb = readdir($thumbs)) !== false) - { - if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) - { - if ($thumb == '.' || $thumb == '..') continue; + if (is_resource($thumbs)) { + dol_mkdir($destin.'/'.$file); + while (($thumb = readdir($thumbs)) !== false) { + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) { + if ($thumb == '.' || $thumb == '..') { + continue; + } //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n"; print '.'; @@ -4657,8 +4443,7 @@ function migrate_user_photospath() } } else // it is a file { - if (!dol_is_file($destin.'/'.$file)) - { + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; print '.'; dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); From eac95a1a29f450da7db84274dbb57eb5f2bf586b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 22 Feb 2021 14:18:47 +0000 Subject: [PATCH 034/173] Fixing style errors. --- htdocs/install/check.php | 2 +- htdocs/install/step1.php | 2 +- htdocs/install/upgrade.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index c0df1709bc7..7594ead39a4 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -454,7 +454,7 @@ if (!file_exists($conffile)) { if ($ok) { if (count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known - // Now we check if this is the first qualified choice + // Now we check if this is the first qualified choice if ($allowupgrade && empty($foundrecommandedchoice) && (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2) ) { diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 80c51e8a438..e841a352b40 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -311,7 +311,7 @@ if (!$error && $db->connected) { // Define $defaultCharacterSet and $defaultDBSortingCollation if (!$error && $db->connected) { if (!empty($db_create_database)) { // If we create database, we force default value - // Default values come from the database handler + // Default values come from the database handler $defaultCharacterSet = $db->forcecharset; $defaultDBSortingCollation = $db->forcecollate; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index db3ca2f4eb1..25e3b95af84 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -358,7 +358,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if (is_resource($handlemodule)) { 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. - //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; + //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) { $modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file; } From c010cab47e85f9823d87570087caadfc77cb72c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Feb 2021 15:51:00 +0100 Subject: [PATCH 035/173] Fix translation of default value for contacts --- htdocs/contact/card.php | 2 +- htdocs/core/class/commonobject.class.php | 12 +++++++++--- htdocs/langs/en_US/supplier_proposal.lang | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 7bd88436e31..3e3e1894a75 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -843,7 +843,7 @@ else print '
'.$langs->trans("ContactByDefaultFor").''; $contactType = $object->listeTypeContacts('external', '', 1); - print $form->multiselectarray('roles', $contactType); + print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500'); print '
'; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print ''; @@ -91,8 +91,7 @@ if ($action == 'edit') print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); print '
'; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print ''; diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 96cb7baff73..cb57581a6be 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -55,18 +55,23 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'asset', $id); $permissiontoread = $user->rights->asset->read; @@ -83,10 +88,11 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object- $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/asset/list.php', 1); @@ -109,12 +115,10 @@ if (empty($reshook)) // Action to build doc include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - if ($action == 'set_thirdparty' && $permissiontoadd) - { + if ($action == 'set_thirdparty' && $permissiontoadd) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); } - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } @@ -138,15 +142,18 @@ $help_url = ''; llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewAsset"), '', 'accountancy'); print ''; print ''; print ''; - if ($backtopage) print ''; - if ($backtopageforcancel) print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print dol_get_fiche_head(array(), ''); @@ -174,8 +181,7 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("Assets")); print ''; @@ -183,8 +189,12 @@ if (($id || $ref) && $action == 'edit') print ''; print ''; print ''; - if ($backtopage) print ''; - if ($backtopageforcancel) print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print dol_get_fiche_head(); @@ -208,8 +218,7 @@ if (($id || $ref) && $action == 'edit') } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); $head = asset_prepare_head($object); @@ -218,16 +227,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = ''; // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAsset'), 'confirm_delete', '', 0, 1); } // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -274,24 +285,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* * Buttons */ - if ($user->socid == 0) - { + if ($user->socid == 0) { print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - if ($user->rights->asset->write) - { + if (empty($reshook)) { + if ($user->rights->asset->write) { print ''.$langs->trans("Modify").''."\n"; } else { print ''.$langs->trans('Modify').''."\n"; } - if ($user->rights->asset->delete) - { + if ($user->rights->asset->delete) { print ''.$langs->trans('Delete').''."\n"; } else { print ''.$langs->trans('Delete').''."\n"; @@ -300,8 +307,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print "
"; } - if ($action != 'presend') - { + if ($action != 'presend') { print '
'; print ''; // ancre diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index f4823ae9b6f..984dde7389b 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -170,8 +170,12 @@ class Asset extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled)) { + $this->fields['entity']['enabled'] = 0; + } } /** @@ -304,7 +308,9 @@ class Asset 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 = ''; @@ -315,33 +321,40 @@ class Asset extends CommonObject $url = dol_buildpath('/asset/card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowAssets"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $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)) : ''); @@ -381,7 +394,9 @@ class Asset extends CommonObject $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); $statusType = 'status0'; - if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status4'; + } return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode); } @@ -399,28 +414,23 @@ class Asset extends CommonObject $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)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 5af5f3d7591..d0fa0a9c585 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -131,27 +131,25 @@ class AssetType extends CommonObject dol_syslog("Asset_type::create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type"); $result = $this->update($user, 1); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -3; } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('ASSET_TYPE_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -193,30 +191,27 @@ class AssetType extends CommonObject $sql .= " WHERE rowid =".$this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $action = 'update'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ASSET_TYPE_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -246,11 +241,12 @@ class AssetType extends CommonObject $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('ASSET_TYPE_DELETE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -2; } + if ($result < 0) { + $error++; $this->db->rollback(); return -2; + } // End call triggers $this->db->commit(); @@ -277,10 +273,8 @@ class AssetType extends CommonObject dol_syslog("Asset_type::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -317,15 +311,12 @@ class AssetType extends CommonObject $sql .= " WHERE entity IN (".getEntity('asset_type').")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $nump = $this->db->num_rows($resql); - if ($nump) - { + if ($nump) { $i = 0; - while ($i < $nump) - { + while ($i < $nump) { $obj = $this->db->fetch_object($resql); $assettypes[$obj->rowid] = $langs->trans($obj->label); @@ -357,18 +348,16 @@ class AssetType extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."asset as a"; $sql .= " WHERE a.entity IN (".getEntity('asset').")"; $sql .= " AND a.fk_asset_type = ".$this->id; - if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; + if (!empty($excludefilter)) { + $sql .= ' AND ('.$excludefilter.')'; + } dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { - if (!array_key_exists($obj->rowid, $ret)) - { - if ($mode < 2) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if (!array_key_exists($obj->rowid, $ret)) { + if ($mode < 2) { $assetstatic = new Asset($this->db); if ($mode == 1) { $assetstatic->fetch($obj->rowid, '', '', '', false, false); @@ -376,7 +365,9 @@ class AssetType extends CommonObject $assetstatic->fetch($obj->rowid); } $ret[$obj->rowid] = $assetstatic; - } else $ret[$obj->rowid] = $obj->rowid; + } else { + $ret[$obj->rowid] = $obj->rowid; + } } } @@ -410,8 +401,12 @@ class AssetType extends CommonObject $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 .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); + 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 .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); + } $result .= $linkend; return $result; diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 32a4163dd12..e5db1465fb6 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -41,8 +41,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) -{ +if ($user->socid) { $socid = $user->socid; } $result=restrictedArea($user, 'asset', $id, ''); @@ -52,16 +51,21 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Asset($db); -if ($object->fetch($id)) -{ +if ($object->fetch($id)) { $upload_dir = $conf->asset->dir_output."/".dol_sanitizeFileName($object->ref); } @@ -85,10 +89,8 @@ $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $upload_dir = $conf->asset->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = asset_prepare_head($object); @@ -97,8 +99,7 @@ if ($id > 0 || !empty($ref)) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index d211cf0dbad..f6d34454ad4 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -29,12 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load translation files required by the page $langs->loadLangs(array("asset")); -$id = GETPOST('id', 'int'); +$id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'asset', $id); $object = new Asset($db); diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index cffcc8a962d..9cd00f181c1 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -68,14 +70,20 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check $socid = 0; -if ($user->socid) $socid = $user->socid; -if ($user->socid > 0) // Protection if external user -{ +if ($user->socid) { + $socid = $user->socid; +} +if ($user->socid > 0) { + // Protection if external user //$socid = $user->socid; accessforbidden(); } @@ -86,30 +94,31 @@ $result = restrictedArea($user, 'asset', $id); // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of fields for list $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -132,31 +141,33 @@ $permissiontodelete = $user->rights->asset->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -185,13 +196,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + 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(); @@ -199,20 +211,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +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 (t.rowid = ef.fk_object)"; +} +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -225,7 +249,7 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY " foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql.='t.'.$key.', '; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -242,26 +266,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -270,8 +292,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/asset/card.php?id='.$id); @@ -302,14 +323,24 @@ jQuery(document).ready(function() { $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) -{ - 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 (!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 ($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'; @@ -318,12 +349,18 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''."\n"; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -342,9 +379,10 @@ $objecttmp = new Asset($db); $trackid = 'asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } @@ -355,11 +393,13 @@ $moreforfilter.= '
';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; @@ -376,20 +416,26 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); print ''.$conf->global->$key.'
'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } } @@ -411,15 +457,18 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -436,11 +485,11 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -449,37 +498,50 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); // Show here line of result print ''; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if ($key == 'status') print $object->getLibStatut(5); - else print $object->showOutputField($val, $key, $object->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -492,14 +554,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; @@ -510,10 +575,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } @@ -529,10 +597,11 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index 514e05bff72..752591ade9e 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -52,10 +52,14 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; +} // Security check -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'asset', $id); $permissionnote = 1; @@ -79,8 +83,7 @@ $form = new Form($db); $help_url = ''; llxHeader('', $langs->trans('Assets'), $help_url); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = asset_prepare_head($object); @@ -101,35 +104,35 @@ if ($id > 0 || !empty($ref)) // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->asset->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $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.=''; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->asset->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $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.=''; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } }*/ $morehtmlref .= ''; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 38969d65182..5955548b5e2 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -26,9 +26,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.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/lib/accounting.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'; +} // Load translation files required by the page $langs->load("assets"); @@ -44,12 +50,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "a.label"; } +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "a.label"; +} $label = GETPOST("label", "alpha"); $accountancy_code_asset = GETPOST('accountancy_code_asset', 'string'); @@ -67,8 +79,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -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 $type = ""; $sall = ""; } @@ -86,15 +97,13 @@ $permissiontoadd = $user->rights->asset->setup_advance; if ($cancel) { $action = ''; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } } -if ($action == 'add' && $user->rights->asset->write) -{ +if ($action == 'add' && $user->rights->asset->write) { $object->label = trim($label); $object->accountancy_code_asset = trim($accountancy_code_asset); $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); @@ -103,7 +112,9 @@ if ($action == 'add' && $user->rights->asset->write) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (empty($object->label)) { $error++; @@ -121,11 +132,9 @@ if ($action == 'add' && $user->rights->asset->write) } } - if (!$error) - { + if (!$error) { $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -137,8 +146,7 @@ if ($action == 'add' && $user->rights->asset->write) } } -if ($action == 'update' && $user->rights->asset->write) -{ +if ($action == 'update' && $user->rights->asset->write) { $object->fetch($rowid); $object->oldcopy = clone $object; @@ -151,12 +159,13 @@ if ($action == 'update' && $user->rights->asset->write) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } $ret = $object->update($user); - if ($ret >= 0 && !count($object->errors)) - { + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("AssetTypeModified"), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -166,13 +175,11 @@ if ($action == 'update' && $user->rights->asset->write) exit; } -if ($action == 'confirm_delete' && $user->rights->asset->write) -{ +if ($action == 'confirm_delete' && $user->rights->asset->write) { $object->fetch($rowid); $res = $object->delete(); - if ($res > 0) - { + if ($res > 0) { setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -194,8 +201,7 @@ llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl); // List of asset type -if (!$rowid && $action != 'create' && $action != 'edit') -{ +if (!$rowid && $action != 'create' && $action != 'edit') { //print dol_get_fiche_head(''); $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; @@ -203,8 +209,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $sql .= " WHERE d.entity IN (".getEntity('asset_type').")"; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $nbtotalofrecords = $num; @@ -213,7 +218,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') $param = ''; print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -241,8 +248,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $assettype = new AssetType($db); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $assettype->id = $objp->rowid; @@ -257,8 +263,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; print ''; - if ($user->rights->asset->write) + if ($user->rights->asset->write) { print ''; - else print ''; + } else { + print ''; + } print ""; $i++; } @@ -313,10 +318,11 @@ if (!$rowid && $action != 'create' && $action != 'edit') /* Creation mode */ /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { $object = new AssetType($db); - if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); + } print load_fiche_titre($langs->trans("NewAssetType")); @@ -331,8 +337,7 @@ if ($action == 'create') print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; print ''; @@ -398,10 +402,8 @@ if ($action == 'create') /* View mode */ /* */ /* ************************************************************************** */ -if ($rowid > 0) -{ - if ($action != 'edit') - { +if ($rowid > 0) { + if ($action != 'edit') { $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -409,8 +411,7 @@ if ($rowid > 0) /* * Confirmation suppression */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAnAssetType"), $langs->trans("ConfirmDeleteAssetType", $object->label), "confirm_delete", '', 0, 1); } @@ -437,8 +438,7 @@ if ($rowid > 0) print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; print ''; print ''; From 5199e3da5b6fbfd4825d0a2b47473383e31fbaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 18:50:45 +0100 Subject: [PATCH 042/173] code syntax --- htdocs/admin/workstation.php | 188 ++++----- .../workstation/class/workstation.class.php | 228 +++++------ .../class/workstationresource.class.php | 22 +- .../class/workstationusergroup.class.php | 22 +- .../lib/workstation_workstation.lib.php | 19 +- htdocs/workstation/workstation_agenda.php | 104 ++--- htdocs/workstation/workstation_card.php | 140 +++---- htdocs/workstation/workstation_document.php | 62 +-- htdocs/workstation/workstation_list.php | 364 ++++++++++-------- htdocs/workstation/workstation_note.php | 48 +-- 10 files changed, 565 insertions(+), 632 deletions(-) diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 98d72bf9f00..c0b4055ba5b 100755 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -17,7 +17,7 @@ */ /** - * \file workstation/admin/setup.php + * \file htdocs/admin/workstation.php * \ingroup workstation * \brief Workstation setup page. */ @@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT . '/workstation/lib/workstation.lib.php'; //require_once "../class/myclass.class.php"; // Translations -$langs->loadLangs(array("admin", "workstation@workstation")); +$langs->loadLangs(array("admin", "workstation")); // Access control -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Parameters $action = GETPOST('action', 'aZ09'); @@ -55,28 +57,28 @@ $setupnotempty = 0; * Actions */ -if ((float) DOL_VERSION >= 6) -{ +if ((float) DOL_VERSION >= 6) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; } -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconstorder = GETPOST('maskconstWorkstation', 'alpha'); $maskorder = GETPOST('maskWorkstation', 'alpha'); - if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconstorder) { + $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') -{ +} elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); $tmpobjectkey = GETPOST('object'); @@ -86,25 +88,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($tmpobject, $langs) > 0) - { + if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); return; } else { @@ -115,31 +113,24 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $tmpobjectkey = GETPOST('object'); $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity); + if ($conf->global->$constforval == "$value") { + dolibarr_del_const($db, $constforval, $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ +} elseif ($action == 'setdoc') { + // Set default model $tmpobjectkey = GETPOST('object'); $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; - if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) - { + if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view $conf->global->$constforval = $value; @@ -147,12 +138,10 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated // by calling method canBeActivated $tmpobjectkey = GETPOST('object'); @@ -186,8 +175,7 @@ print dol_get_fiche_head($head, 'settings', '', -1, "workstation@workstation"); //echo ''.$langs->trans("WorkstationSetupPage").'

'; -if ($action == 'edit') -{ +if ($action == 'edit') { print ''; print ''; print ''; @@ -195,8 +183,7 @@ if ($action == 'edit') print '
'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print ''; + } print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans("NoRecordFound").'
'.dol_escape_htmltag($objp->label).''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objp->accountancy_code_asset, 1); @@ -269,8 +274,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1); @@ -281,8 +285,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1); @@ -292,9 +295,11 @@ if (!$rowid && $action != 'create' && $action != 'edit') } print 'rowid.'">'.img_edit().'  
'.$langs->trans("Label").'
'.$langs->trans("AccountancyCodeAsset").''; @@ -375,8 +380,7 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } print '
'; print $langs->trans("AccountancyCodeAsset"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code_asset, 1); @@ -453,8 +453,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationAsset"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1); @@ -469,8 +468,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationExpense"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1); @@ -499,14 +497,12 @@ if ($rowid > 0) print '
'; // Edit - if ($user->rights->asset->write) - { + if ($user->rights->asset->write) { print ''; } // Delete - if ($user->rights->asset->write) - { + if ($user->rights->asset->write) { print ''; } @@ -519,12 +515,13 @@ if ($rowid > 0) /* */ /* ************************************************************************** */ - if ($action == 'edit') - { + if ($action == 'edit') { $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); - if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); + } $head = asset_type_prepare_head($object); @@ -541,8 +538,7 @@ if ($rowid > 0) print '
'.$langs->trans("Label").'
'.$langs->trans("AccountancyCodeAsset").''; @@ -585,8 +581,7 @@ if ($rowid > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index 7a3660e350e..716057198f8 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -33,15 +33,13 @@ $phone = GETPOST('phone'); $notfound = $langs->trans("Unknown"); // Security check -if (empty($conf->clicktodial->enabled)) -{ +if (empty($conf->clicktodial->enabled)) { print "Error: Module Click to dial is not enabled.\n"; exit; } // Check parameters -if (empty($phone)) -{ +if (empty($phone)) { print "Error: Url must be called with parameter phone=phone to search\n"; exit; } @@ -57,11 +55,9 @@ $sql .= $db->plimit(1); dol_syslog('cidlookup search information with phone '.$phone, LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $found = $obj->name; } else { $found = $notfound; diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 0a9ac82ce23..77a00aed302 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -28,13 +28,27 @@ * write = system,call,log,verbose,command,agent,user */ -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('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'); +} /** * Empty header @@ -67,23 +81,40 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Security check -if (empty($conf->clicktodial->enabled)) -{ +if (empty($conf->clicktodial->enabled)) { accessforbidden(); exit; } // Define Asterisk setup -if (!isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_HOST = "127.0.0.1"; -if (!isset($conf->global->ASTERISK_TYPE)) $conf->global->ASTERISK_TYPE = "SIP/"; -if (!isset($conf->global->ASTERISK_INDICATIF)) $conf->global->ASTERISK_INDICATIF = "0"; -if (!isset($conf->global->ASTERISK_PORT)) $conf->global->ASTERISK_PORT = 5038; -if ($conf->global->ASTERISK_INDICATIF == 'NONE') $conf->global->ASTERISK_INDICATIF = ''; -if (!isset($conf->global->ASTERISK_CONTEXT)) $conf->global->ASTERISK_CONTEXT = "from-internal"; -if (!isset($conf->global->ASTERISK_WAIT_TIME)) $conf->global->ASTERISK_WAIT_TIME = "30"; -if (!isset($conf->global->ASTERISK_PRIORITY)) $conf->global->ASTERISK_PRIORITY = "1"; -if (!isset($conf->global->ASTERISK_MAX_RETRY)) $conf->global->ASTERISK_MAX_RETRY = "2"; +if (!isset($conf->global->ASTERISK_HOST)) { + $conf->global->ASTERISK_HOST = "127.0.0.1"; +} +if (!isset($conf->global->ASTERISK_TYPE)) { + $conf->global->ASTERISK_TYPE = "SIP/"; +} +if (!isset($conf->global->ASTERISK_INDICATIF)) { + $conf->global->ASTERISK_INDICATIF = "0"; +} +if (!isset($conf->global->ASTERISK_PORT)) { + $conf->global->ASTERISK_PORT = 5038; +} +if ($conf->global->ASTERISK_INDICATIF == 'NONE') { + $conf->global->ASTERISK_INDICATIF = ''; +} +if (!isset($conf->global->ASTERISK_CONTEXT)) { + $conf->global->ASTERISK_CONTEXT = "from-internal"; +} +if (!isset($conf->global->ASTERISK_WAIT_TIME)) { + $conf->global->ASTERISK_WAIT_TIME = "30"; +} +if (!isset($conf->global->ASTERISK_PRIORITY)) { + $conf->global->ASTERISK_PRIORITY = "1"; +} +if (!isset($conf->global->ASTERISK_MAX_RETRY)) { + $conf->global->ASTERISK_MAX_RETRY = "2"; +} $login = GETPOST('login'); @@ -127,11 +158,9 @@ $sql .= $db->plimit(1); dol_syslog('click to dial search information with phone '.$called, LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $found = $obj->name; } else { $found = $notfound; @@ -144,16 +173,13 @@ if ($resql) $number = strtolower($called); $pos = strpos($number, "local"); -if (!empty($number)) -{ - if ($pos === false) - { +if (!empty($number)) { + if ($pos === false) { $errno = 0; $errstr = 0; $strCallerId = "Dolibarr call $found <".strtolower($number).">"; $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); - if (!$oSocket) - { + if (!$oSocket) { print ''."\n"; $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; print $txt; From 8c1902be1bc667b85898d48c817ea6300aac22e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Feb 2021 18:40:15 +0100 Subject: [PATCH 041/173] Missing space --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 44097c84f49..c871304905f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3596,7 +3596,7 @@ if ($action == 'create') if (is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1) { setEventMessages('WarningBillExist', null, 'warnings'); - echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')'; + echo ' ('.$langs->trans('LatestRelatedBill').' '.end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')'; } echo '
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print ''; print ''; print ''; print ''; print ''; print ''; $cats = $object->get_filles(); -if ($cats < 0) -{ +if ($cats < 0) { dol_print_error($db, $object->error, $object->errors); -} elseif (count($cats) < 1) -{ +} elseif (count($cats) < 1) { print ''; print ''; print ''; @@ -362,19 +344,25 @@ if ($cats < 0) $fulltree = $categstatic->get_full_arbo($type, $object->id, 1); // Load possible missing includes - if ($conf->global->CATEGORY_SHOW_COUNTS) - { - if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + if ($conf->global->CATEGORY_SHOW_COUNTS) { + if ($type == Categorie::TYPE_MEMBER) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + } + if ($type == Categorie::TYPE_ACCOUNT) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + } + if ($type == Categorie::TYPE_PROJECT) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + } + if ($type == Categorie::TYPE_USER) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + } } // 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) - { + foreach ($fulltree as $key => $val) { $categstatic->id = $val['id']; $categstatic->ref = $val['label']; $categstatic->color = $val['color']; @@ -382,8 +370,7 @@ if ($cats < 0) $desc = dol_htmlcleanlastbr($val['description']); $counter = ''; - if ($conf->global->CATEGORY_SHOW_COUNTS) - { + if ($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database $elements = $type == Categorie::TYPE_ACCOUNT ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" @@ -421,8 +408,7 @@ if ($cats < 0) } $nbofentries = (count($data) - 1); - if ($nbofentries > 0) - { + if ($nbofentries > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print "\n"; $societestatic = new Societe($db); - if ($num) - { + if ($num) { $i = 0; $total = $total_ttc = $totalam = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -1219,7 +1257,9 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -1232,7 +1272,9 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if ($othernb) { $colspan = 6; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print ''; } else { $colspan = 6; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); @@ -211,13 +198,11 @@ if ($action == 'edit') print ''; print '
'; } else { - if (!empty($arrayofparameters)) - { + if (!empty($arrayofparameters)) { print ''; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { $setupnotempty++; print ''."\n"; print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print ''; + print ''; print ''; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 45246dcc412..1060c02ce96 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -413,7 +413,7 @@ PaymentCondition14DENDMONTH=Within 14 days following the end of the month FixAmount=Fixed amount - 1 line with label '%s' VarAmount=Variable amount (%% tot.) VarAmountOneLine=Variable amount (%% tot.) - 1 line with label '%s' -VarAmountAllLines=Variable amount (%% tot.) - all same lines +VarAmountAllLines=Variable amount (%% tot.) - all lines from origin # PaymentType PaymentTypeVIR=Bank transfer PaymentTypeShortVIR=Bank transfer diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 545fcdb62fb..9e56c5f5c3a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -258,6 +258,8 @@ ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation ErrorDateIsInFuture=Error, the date can't be in the future +ErrorAnAmountWithoutTaxIsRequired=Error, amount is mandatory +ErrorAPercentIsRequired=Error, please fill in the percentage correctly # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index f7c55df211f..67544b46328 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -389,6 +389,8 @@ AmountTotal=Total amount AmountAverage=Average amount PriceQtyMinHT=Price quantity min. (excl. tax) PriceQtyMinHTCurrency=Price quantity min. (excl. tax) (currency) +PercentOfOriginalObject=Percent of original object +AmountOrPercent=Amount or percent Percentage=Percentage Total=Total SubTotal=Subtotal From 2642e1d1b38af42409ebdfc57067ea7a519ac21a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Feb 2021 15:35:16 +0100 Subject: [PATCH 054/173] Code syntax --- htdocs/compta/facture/card.php | 695 +++++++++++++-------------------- 1 file changed, 281 insertions(+), 414 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 41178def47d..62a40082a78 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -50,8 +50,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.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'; @@ -154,12 +155,9 @@ $parameters = array('socid' => $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)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -173,8 +171,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) - { + if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); @@ -230,8 +227,7 @@ if (empty($reshook)) } } } // Delete line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) - { + elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); $object->fetch_thirdparty(); @@ -262,14 +258,12 @@ if (empty($reshook)) $action = ''; } } // Delete link of credit note to invoice - elseif ($action == 'unlinkdiscount' && $usercancreate) - { + elseif ($action == 'unlinkdiscount' && $usercancreate) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(GETPOST("discountid")); $discount->unlink_invoice(); } // Validation - elseif ($action == 'valid' && $usercancreate) - { + elseif ($action == 'valid' && $usercancreate) { $object->fetch($id); // On verifie signe facture @@ -306,13 +300,11 @@ 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]; - if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) - { + if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { if ($object->type == $object::TYPE_DEPOSIT) { $langs->load("errors"); // Using negative lines on deposit lead to headach and blocking problems when you want to consume them. @@ -335,18 +327,15 @@ if (empty($reshook)) } } - elseif ($action == 'classin' && $usercancreate) - { + elseif ($action == 'classin' && $usercancreate) { $object->fetch($id); $object->setProject($_POST['projectid']); - } elseif ($action == 'setmode' && $usercancreate) - { + } elseif ($action == 'setmode' && $usercancreate) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) - { + } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { $object->fetch($id); $object->retained_warranty_fk_cond_reglement = 0; // To clean property $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); @@ -368,11 +357,9 @@ if (empty($reshook)) $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } elseif ($action == 'setinvoicedate' && $usercancreate) { $object->fetch($id); @@ -400,8 +387,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setconditions' && $usercancreate) - { + } elseif ($action == 'setconditions' && $usercancreate) { $object->fetch($id); $object->cond_reglement_code = 0; // To clean property $object->cond_reglement_id = 0; // To clean property @@ -435,8 +421,7 @@ if (empty($reshook)) } else { $db->commit(); } - } elseif ($action == 'setpaymentterm' && $usercancreate) - { + } elseif ($action == 'setpaymentterm' && $usercancreate) { $object->fetch($id); $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); if ($object->date_lim_reglement < $object->date) { @@ -447,8 +432,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setrevenuestamp' && $usercancreate) - { + } elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); $object->revenuestamp = GETPOST('revenuestamp'); $result = $object->update($user); @@ -475,11 +459,9 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } - } // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { + } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { // Set incoterm $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } // bank account - elseif ($action == 'setbankaccount' && $usercancreate) { + } elseif ($action == 'setbankaccount' && $usercancreate) { // bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); @@ -500,8 +482,7 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (GETPOST("remise_id_for_payment", 'int') > 0) - { + if (GETPOST("remise_id_for_payment", 'int') > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch(GETPOST("remise_id_for_payment", 'int')); @@ -515,8 +496,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { setEventMessages($discount->error, $discount->errors, 'errors'); @@ -524,8 +504,7 @@ if (empty($reshook)) } } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); @@ -539,12 +518,10 @@ if (empty($reshook)) $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'setref' && $usercancreate) - { + } elseif ($action == 'setref' && $usercancreate) { $object->fetch($id); $object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY'); - } elseif ($action == 'setref_client' && $usercancreate) - { + } elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); $object->set_ref_client(GETPOST('ref_client')); } // Classify to validated @@ -559,16 +536,13 @@ if (empty($reshook)) // Check for mandatory fields in thirdparty (defined into setup) $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); - foreach ($array_to_check as $key) - { + foreach ($array_to_check as $key) { $keymin = strtolower($key); $i = (int) preg_replace('/[^0-9]/', '', $key); $vallabel = $object->thirdparty->$keymin; - if ($i > 0) - { - if ($object->thirdparty->isACompany()) - { + if ($i > 0) { + if ($object->thirdparty->isACompany()) { // Check for mandatory prof id (but only if country is other than ours) if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { @@ -583,11 +557,9 @@ if (empty($reshook)) } } else { //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); - if ($key == 'EMAIL') - { + if ($key == 'EMAIL') { // Check for mandatory - if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) - { + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors'); @@ -598,15 +570,13 @@ if (empty($reshook)) // Check for mandatory fields in invoice $array_to_check = array('REF_CUSTOMER'=>'RefCustomer'); - foreach ($array_to_check as $key => $val) - { + foreach ($array_to_check as $key => $val) { $keymin = strtolower($key); $vallabel = $object->$keymin; // Check for mandatory $keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; - if (!$vallabel && !empty($conf->global->$keymandatory)) - { + if (!$vallabel && !empty($conf->global->$keymandatory)) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); @@ -614,8 +584,7 @@ if (empty($reshook)) } // Check for warehouse - if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); @@ -623,8 +592,7 @@ if (empty($reshook)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if ($qualified_for_stock_change) - { + if ($qualified_for_stock_change) { if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -633,11 +601,9 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $result = $object->validate($user, '', $idwarehouse); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -663,16 +629,14 @@ if (empty($reshook)) } } } // Go back to draft status (unvalidate) - elseif ($action == 'confirm_modif' && $usercanunvalidate) - { + elseif ($action == 'confirm_modif' && $usercanunvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); $object->fetch($id); $object->fetch_thirdparty(); // Check parameters - if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); @@ -680,8 +644,7 @@ if (empty($reshook)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if ($qualified_for_stock_change) - { + if ($qualified_for_stock_change) { if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -716,16 +679,13 @@ if (empty($reshook)) $ventilExportCompta = $object->getVentilExportCompta(); // On verifie si aucun paiement n'a ete effectue - if ($ventilExportCompta == 0) - { - if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) - { + if ($ventilExportCompta == 0) { + if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { $result = $object->setDraft($user, $idwarehouse); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); @@ -744,14 +704,12 @@ if (empty($reshook)) } } } // Classify "paid" - elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) - { + elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) { $object->fetch($id); $result = $object->setPaid($user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Classif "paid partialy" - elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) - { + elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) { $object->fetch($id); $close_code = GETPOST("close_code", 'restricthtml'); $close_note = GETPOST("close_note", 'restricthtml'); @@ -773,8 +731,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } } // Convertir en reduc - elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) - { + elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); $object->fetch_thirdparty(); //$object->fetch_lines(); // Already done into fetch @@ -786,8 +743,8 @@ if (empty($reshook)) $canconvert = 0; if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) - if ($canconvert) - { + + if ($canconvert) { $db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); @@ -795,10 +752,8 @@ if (empty($reshook)) // Loop on each vat rate $i = 0; - foreach ($object->lines as $line) - { - if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null - { + foreach ($object->lines as $line) { + if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); $amount_ht[$keyforvatrate] += $line->total_ht; @@ -830,13 +785,13 @@ if (empty($reshook)) // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); - if ($object->type == Facture::TYPE_CREDIT_NOTE) + if ($object->type == Facture::TYPE_CREDIT_NOTE) { $discount->description = '(CREDIT_NOTE)'; - elseif ($object->type == Facture::TYPE_DEPOSIT) + } elseif ($object->type == Facture::TYPE_DEPOSIT) { $discount->description = '(DEPOSIT)'; - elseif ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) + } elseif ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) { $discount->description = '(EXCESS RECEIVED)'; - else { + } else { setEventMessages($langs->trans('CantConvertToReducAnInvoiceOfThisType'), null, 'errors'); } $discount->fk_soc = $object->socid; @@ -844,8 +799,7 @@ if (empty($reshook)) $error = 0; - if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) - { + if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT // Total payments @@ -872,7 +826,9 @@ if (empty($reshook)) while ($obj = $db->fetch_object($resql)) { $total_creditnote_and_deposit += $obj->amount_ttc; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -880,15 +836,12 @@ if (empty($reshook)) $discount->vat_src_code = ''; $result = $discount->create($user); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) - { - foreach ($amount_ht as $tva_tx => $xxx) - { + if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); @@ -909,21 +862,18 @@ if (empty($reshook)) $discount->vat_src_code = $vat_src_code; $result = $discount->create($user); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } } - if (empty($error)) - { + if (empty($error)) { if ($object->type != Facture::TYPE_DEPOSIT) { // Classe facture $result = $object->setPaid($user); - if ($result >= 0) - { + if ($result >= 0) { $db->commit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -938,11 +888,9 @@ if (empty($reshook)) } } } // Delete payment - elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) - { + elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) - { + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { $paiement = new Paiement($db); $result = $paiement->fetch(GETPOST('paiement_id')); if ($result > 0) { @@ -956,9 +904,10 @@ if (empty($reshook)) } /* * Insert new invoice in database */ - elseif ($action == 'add' && $usercancreate) - { - if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + elseif ($action == 'add' && $usercancreate) { + if ($socid > 0) { + $object->socid = GETPOST('socid', 'int'); + } $selectedLines = GETPOST('toselect', 'array'); $db->begin(); @@ -970,8 +919,7 @@ if (empty($reshook)) if ($ret < 0) $error++; // Replacement invoice - if (GETPOST('type') == Facture::TYPE_REPLACEMENT) - { + if (GETPOST('type') == Facture::TYPE_REPLACEMENT) { $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1014,7 +962,7 @@ if (empty($reshook)) $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Proprietes particulieres a facture de remplacement - $object->fk_facture_source = $_POST['fac_replacement']; + $object->fk_facture_source = GETPOST('fac_replacement', 'int'); $object->type = Facture::TYPE_REPLACEMENT; $id = $object->createFromCurrent($user); @@ -1025,11 +973,9 @@ if (empty($reshook)) } // Credit note invoice - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) - { + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir', 'int'); - if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) - { + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); $action = 'create'; @@ -1077,10 +1023,8 @@ if (empty($reshook)) $object->type = Facture::TYPE_CREDIT_NOTE; $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source) > 0) - { - if ($facture_source->type == Facture::TYPE_SITUATION) - { + if ($facture_source->fetch($object->fk_facture_source) > 0) { + if ($facture_source->type == Facture::TYPE_SITUATION) { $object->situation_counter = $facture_source->situation_counter; $object->situation_cycle_ref = $facture_source->situation_cycle_ref; $facture_source->fetchPreviousNextSituationInvoice(); @@ -1113,22 +1057,18 @@ if (empty($reshook)) } - if ($facture_source->type == Facture::TYPE_SITUATION) - { + if ($facture_source->type == Facture::TYPE_SITUATION) { $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($facture_source->tab_previous_situation_invoice)) - { + if (!empty($facture_source->tab_previous_situation_invoice)) { // search the last standard invoice in cycle and the possible credit note between this last and facture_source // TODO Move this out of loop of $facture_source->lines $tab_jumped_credit_notes = array(); $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { + while ($searchPreviousInvoice) { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { $searchPreviousInvoice = false; // find, exit; break; } else { @@ -1140,10 +1080,8 @@ if (empty($reshook)) } $maxPrevSituationPercent = 0; - foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $source_fk_prev_id) - { + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { + if ($prevLine->id == $source_fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); //$line->subprice = $line->subprice - $prevLine->subprice; @@ -1168,10 +1106,8 @@ if (empty($reshook)) // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) $maxPrevSituationPercent = 0; foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) - { - if ($prevLine->fk_prev_id == $source_fk_prev_id) - { + foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) { + if ($prevLine->fk_prev_id == $source_fk_prev_id) { $maxPrevSituationPercent = $prevLine->situation_percent; $line->total_ht -= $prevLine->total_ht; @@ -1225,10 +1161,8 @@ if (empty($reshook)) } } - if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) - { - if ($facture_source->fetch($object->fk_facture_source) > 0) - { + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); $totaldeposits = $facture_source->getSumDepositsUsed(); @@ -1253,8 +1187,7 @@ if (empty($reshook)) } // Standard invoice or Deposit invoice, created from a Predefined template invoice - if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) - { + if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1268,8 +1201,7 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (!$error) - { + if (!$error) { $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); $object->ref = GETPOST('ref'); @@ -1299,8 +1231,7 @@ if (empty($reshook)) } // Standard or deposit invoice, not from a Predefined template invoice - if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT || GETPOST('type') == Facture::TYPE_PROFORMA || (GETPOST('type') == Facture::TYPE_SITUATION && !GETPOST('situations'))) && GETPOST('fac_rec') <= 0) - { + if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT || GETPOST('type') == Facture::TYPE_PROFORMA || (GETPOST('type') == Facture::TYPE_SITUATION && !GETPOST('situations'))) && GETPOST('fac_rec') <= 0) { $typeamount = GETPOST('typedeposit', 'aZ09'); $valuestandardinvoice = price2num(str_replace('%', '', GETPOST('valuestandardinvoice', 'alpha')), 'MU'); $valuedeposit = price2num(str_replace('%', '', GETPOST('valuedeposit', 'alpha')), 'MU'); @@ -1331,8 +1262,7 @@ if (empty($reshook)) $action = 'create'; } } elseif (GETPOST('type') == Facture::TYPE_DEPOSIT) { - if ($typeamount && !empty($origin) && !empty($originid)) - { + if ($typeamount && !empty($origin) && !empty($originid)) { if ($typeamount == 'amount' && $valuedeposit <= 0) { setEventMessages($langs->trans("ErrorAnAmountWithoutTaxIsRequired"), null, 'errors'); $error++; @@ -1351,8 +1281,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { // Si facture standard $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); @@ -1398,8 +1327,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { $regs = array(); // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1445,15 +1373,13 @@ if (empty($reshook)) } } - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) - { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } $id = $object->create($user); // This include class to add_object_linked() and add add_contact() - if ($id > 0) - { + if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); @@ -1463,45 +1389,45 @@ if (empty($reshook)) $result = $srcobject->fetch($object->origin_id); // If deposit invoice - down payment with 1 line (fixed amount or percent) - if (GETPOST('type') == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable'))) - { + if (GETPOST('type') == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable'))) { // Define the array $amountdeposit $amountdeposit = array(); - if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) - { - if ($typeamount == 'amount') $amount = $valuedeposit; - else $amount = $srcobject->total_ttc * ($valuedeposit / 100); + if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) { + if ($typeamount == 'amount') { + $amount = $valuedeposit; + } else { + $amount = $srcobject->total_ttc * ($valuedeposit / 100); + } $TTotalByTva = array(); - foreach ($srcobject->lines as &$line) - { + foreach ($srcobject->lines as &$line) { if (!empty($line->special_code)) continue; $TTotalByTva[$line->tva_tx] += $line->total_ttc; } - foreach ($TTotalByTva as $tva => &$total) - { + foreach ($TTotalByTva as $tva => &$total) { $coef = $total / $srcobject->total_ttc; // Calc coef $am = $amount * $coef; $amount_ttc_diff += $am; $amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline } } else { - if ($typeamount == 'amount') - { + if ($typeamount == 'amount') { $amountdeposit[0] = $valuedeposit; - } elseif ($typeamount == 'variable') - { - if ($result > 0) - { + } elseif ($typeamount == 'variable') { + if ($result > 0) { $totalamount = 0; $lines = $srcobject->lines; $numlines = count($lines); for ($i = 0; $i < $numlines; $i++) { $qualified = 1; - if (empty($lines[$i]->qty)) $qualified = 0; // We discard qty=0, it is an option - if (!empty($lines[$i]->special_code)) $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...) + if (empty($lines[$i]->qty)) { + $qualified = 0; // We discard qty=0, it is an option + } + if (!empty($lines[$i]->special_code)) { + $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...) + } if ($qualified) { $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; @@ -1523,7 +1449,9 @@ if (empty($reshook)) foreach ($amountdeposit as $tva => $amount) { - if (empty($amount)) continue; + if (empty($amount)) { + continue; + } $arraylist = array( 'amount' => 'FixAmount', @@ -1568,8 +1496,7 @@ if (empty($reshook)) $diff = $object->total_ttc - $amount_ttc_diff; - if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) - { + if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); @@ -1579,11 +1506,9 @@ if (empty($reshook)) // standard invoice, credit note, or down payment from a percent of all lines if (GETPOST('type') != Facture::TYPE_DEPOSIT || (GETPOST('type') == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines')) { - if ($result > 0) - { + if ($result > 0) { $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } @@ -1610,15 +1535,22 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) { + continue; // Skip unselected lines + } // Don't add lines with qty 0 when coming from a shipment including all order lines - if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; + if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) { + continue; + } // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) - if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; - if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; + if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) { + $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; + } + if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) { + continue; + } $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); @@ -1649,23 +1581,29 @@ if (empty($reshook)) // Date start $date_start = false; - if ($lines[$i]->date_debut_prevue) + if ($lines[$i]->date_debut_prevue) { $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) + } + if ($lines[$i]->date_debut_reel) { $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) + } + if ($lines[$i]->date_start) { $date_start = $lines[$i]->date_start; + } - // Date end + // Date end $date_end = false; - if ($lines[$i]->date_fin_prevue) + if ($lines[$i]->date_fin_prevue) { $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) + } + if ($lines[$i]->date_fin_reel) { $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) + } + if ($lines[$i]->date_end) { $date_end = $lines[$i]->date_end; + } - // Reset fk_parent_line for no child products and special product + // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } @@ -1768,8 +1706,7 @@ if (empty($reshook)) } // Situation invoices - if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations')) - { + if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations')) { $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -2708,8 +2645,9 @@ if (empty($reshook)) } } - if ($error) + if ($error) { $action = 'edit_extras'; + } } if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { @@ -2753,8 +2691,9 @@ if (empty($reshook)) } } - if ($error) + if ($error) { $action = 'edit_extras'; + } } } @@ -2776,6 +2715,7 @@ $now = dol_now(); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Card'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; + llxHeader('', $title, $helpurl); // Mode creation @@ -2787,15 +2727,15 @@ if ($action == 'create') print load_fiche_titre($langs->trans('NewBill'), '', 'bill'); - if ($socid > 0) + if ($socid > 0) { $res = $soc->fetch($socid); + } $currency_code = $conf->currency; // Load objectsrc $remise_absolue = 0; - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; $regs = array(); @@ -2847,11 +2787,11 @@ if ($action == 'create') $projectid = (!empty($projectid) ? $projectid : $objectsrc->fk_project); $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : '')); - $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); // only if socid not filled else it's allready done upper - if (empty($socid)) + if (empty($socid)) { $soc = $objectsrc->thirdparty; + } $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); @@ -2925,8 +2865,7 @@ if ($action == 'create') print ajax_combobox('situations'); } - if ($origin == 'contrat') - { + if ($origin == 'contrat') { $langs->load("admin"); $text = $langs->trans("ToCreateARecurringInvoice"); $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); @@ -2960,14 +2899,12 @@ if ($action == 'create') $exampletemplateinvoice = new FactureRec($db); $invoice_predefined = new FactureRec($db); - if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) - { + if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); } // Thirdparty - if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) - { + if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) { // If thirdparty known and not a predefined invoiced without a recurring rule print ''; print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) -{ +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; //Line extrafield -if (!empty($extrafields)) -{ +if (!empty($extrafields)) { print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1, 'line'); } From 70446fe28ef59fb6a663a860399a16ed50da9a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 17:58:31 +0100 Subject: [PATCH 058/173] code syntax cashdesk directory --- htdocs/cashdesk/admin/cashdesk.php | 37 ++++--- htdocs/cashdesk/affContenu.php | 17 ++-- htdocs/cashdesk/affIndex.php | 6 +- htdocs/cashdesk/affPied.php | 3 +- htdocs/cashdesk/class/Auth.class.php | 25 +++-- htdocs/cashdesk/class/Facturation.class.php | 57 ++++------- htdocs/cashdesk/deconnexion.php | 16 ++- htdocs/cashdesk/facturation.php | 54 +++++----- htdocs/cashdesk/facturation_dhtml.php | 61 +++++++----- htdocs/cashdesk/facturation_verif.php | 89 ++++++++--------- htdocs/cashdesk/include/environnement.php | 4 +- htdocs/cashdesk/include/keypad.php | 4 +- htdocs/cashdesk/index.php | 39 +++++--- htdocs/cashdesk/index_verif.php | 24 ++--- htdocs/cashdesk/tpl/facturation1.tpl.php | 57 ++++++----- htdocs/cashdesk/tpl/liste_articles.tpl.php | 11 +-- htdocs/cashdesk/tpl/menu.tpl.php | 18 ++-- htdocs/cashdesk/tpl/ticket.tpl.php | 76 +++++++-------- htdocs/cashdesk/tpl/validation1.tpl.php | 15 +-- htdocs/cashdesk/tpl/validation2.tpl.php | 3 +- htdocs/cashdesk/validation_ticket.php | 3 +- htdocs/cashdesk/validation_verif.php | 103 ++++++++++---------- 22 files changed, 357 insertions(+), 365 deletions(-) diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 21e10c05fc7..382dd062131 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -27,16 +27,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // If socid provided by ajax company selector -if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) -{ +if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); } // Security check -if (!$user->admin) -accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "cashdesk")); @@ -45,11 +45,12 @@ $langs->loadLangs(array("admin", "cashdesk")); /* * Actions */ -if (GETPOST('action', 'alpha') == 'set') -{ +if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; + if (GETPOST('socid', 'int') < 0) { + $_POST["socid"] = ''; + } $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity); @@ -62,10 +63,11 @@ if (GETPOST('action', 'alpha') == 'set') dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -93,8 +95,7 @@ print '
'; print ''; print ''; -if (!empty($conf->service->enabled)) -{ +if (!empty($conf->service->enabled)) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; @@ -243,7 +228,9 @@ $myTmpObjects['workstation'] = array('includerefgeneration'=>1, 'includedocgener foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { - if ($myTmpObjectKey == 'MyObject') continue; + if ($myTmpObjectKey == 'MyObject') { + continue; + } if ($myTmpObjectArray['includerefgeneration']) { /* * Orders Numbering model @@ -263,19 +250,14 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { clearstatcache(); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/".$moduledir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.'/'.$file.'.php'; @@ -283,11 +265,14 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) 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()) - { + if ($module->isEnabled()) { dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); print '
'.$module->name."\n"; @@ -300,14 +285,16 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '
'; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) - { + if ($conf->global->$constforvar == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -327,8 +314,9 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $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.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -366,12 +354,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -392,31 +378,23 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { clearstatcache(); - foreach ($dirmodels as $reldir) - { - foreach (array('', '/doc') as $valdir) - { + foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/".$moduledir.$valdir; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -424,21 +402,26 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print '
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -453,8 +436,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $name) - { + if ($conf->global->$constforvar == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -464,8 +446,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; @@ -480,8 +461,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'generic').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 31497cbc919..e96056688e4 100755 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -184,8 +184,12 @@ class Workstation extends CommonObject $this->fields['ref']['default'] = $this->getNextNumRef(); - 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; + } // Example to show how to set values of fields definition dynamically /*if ($user->rights->workstation->workstation->read) { @@ -194,23 +198,17 @@ class Workstation extends CommonObject }*/ // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -233,7 +231,9 @@ class Workstation extends CommonObject // Usergroups $groups = GETPOST('groups'); - if (empty($groups)) $groups = $this->usergroups; // createFromClone + if (empty($groups)) { + $groups = $this->usergroups; // createFromClone + } if (!empty($groups)) { foreach ($groups as $id_group) { $ws_usergroup = new WorkstationUserGroup($db); @@ -246,7 +246,9 @@ class Workstation extends CommonObject // Resources $resources = GETPOST('resources'); - if (empty($resources)) $resources = $this->resources; // createFromClone + if (empty($resources)) { + $resources = $this->resources; // createFromClone + } if (!empty($resources)) { foreach ($resources as $id_resource) { $ws_resource = new WorkstationResource($db); @@ -280,7 +282,9 @@ class Workstation extends CommonObject // Load source object $result = $object->fetch($fromid); - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } // get lines so they will be clone //foreach($this->lines as $line) @@ -292,21 +296,28 @@ class Workstation extends CommonObject unset($object->import_key); // Clear fields - if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; - if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; - if (property_exists($object, 'status')) { $object->status = self::STATUS_DISABLED; } - if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); } - if (property_exists($object, 'date_modification')) { $object->date_modification = null; } + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DISABLED; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -322,22 +333,19 @@ class Workstation extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { - if ($this->copy_linked_contact($object, 'external') < 0) + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { $error++; + } } } @@ -367,7 +375,9 @@ class Workstation extends CommonObject $this->usergroups = WorkstationUserGroup::getAllGroupsOfWorkstation($this->id); $this->resources = WorkstationResource::getAllResourcesOfWorkstation($this->id); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -407,8 +417,11 @@ class Workstation extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -441,8 +454,7 @@ class Workstation extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) - { + while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -526,8 +538,7 @@ class Workstation extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -552,8 +563,7 @@ class Workstation extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -571,8 +581,7 @@ class Workstation extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef(); } else { $num = $this->ref; @@ -584,57 +593,58 @@ class Workstation extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " status = ".self::STATUS_VALIDATED; - if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; - if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('WORKSTATION_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'workstation/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'workstation/".$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($num); $dirsource = $conf->workstation->dir_output.'/workstation/'.$oldref; $dirdest = $conf->workstation->dir_output.'/workstation/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->workstation->dir_output.'/workstation/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -647,14 +657,12 @@ class Workstation extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -677,8 +685,11 @@ class Workstation extends CommonObject $this->status = $status; - if (empty($status)) return $this->setDisabled($user, $notrigger); - else return $this->setEnabled($user, $notrigger); + if (empty($status)) { + return $this->setDisabled($user, $notrigger); + } else { + return $this->setEnabled($user, $notrigger); + } } @@ -721,7 +732,9 @@ class Workstation extends CommonObject { global $conf, $langs, $hookmanager; - 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 = ''; @@ -734,25 +747,28 @@ class Workstation extends CommonObject $url = dol_buildpath('/workstation/workstation_card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowWorkstation"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; @@ -761,7 +777,9 @@ class Workstation extends CommonObject $result .= $linkstart; if (empty($this->showphoto_on_popup)) { - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } } else { if ($withpicto) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -787,7 +805,9 @@ class Workstation extends CommonObject } } - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -796,8 +816,11 @@ class Workstation extends CommonObject $hookmanager->initHooks(array('workstationdao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -824,8 +847,7 @@ class Workstation extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("workstation@workstation"); $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled'); @@ -852,28 +874,23 @@ class Workstation extends CommonObject $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)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -913,8 +930,7 @@ class Workstation extends CommonObject $objectline = new WorkstationLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_workstation = '.$this->id)); - if (is_numeric($result)) - { + if (is_numeric($result)) { $this->error = $this->error; $this->errors = $this->errors; return $result; @@ -938,8 +954,7 @@ class Workstation extends CommonObject $conf->global->WORKSTATION_WORKSTATION_ADDON = 'mod_workstation_standard'; } - if (!empty($conf->global->WORKSTATION_WORKSTATION_ADDON)) - { + if (!empty($conf->global->WORKSTATION_WORKSTATION_ADDON)) { $mybool = false; $file = $conf->global->WORKSTATION_WORKSTATION_ADDON.".php"; @@ -947,16 +962,14 @@ class Workstation extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/workstation/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -965,8 +978,7 @@ class Workstation extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($this); - if ($numref != '' && $numref != '-1') - { + if ($numref != '' && $numref != '-1') { return $numref; } else { $this->error = $obj->error; diff --git a/htdocs/workstation/class/workstationresource.class.php b/htdocs/workstation/class/workstationresource.class.php index 6e6860f2230..72fb91cfe85 100644 --- a/htdocs/workstation/class/workstationresource.class.php +++ b/htdocs/workstation/class/workstationresource.class.php @@ -65,23 +65,17 @@ class WorkstationResource extends CommonObject $this->db = $db; // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -95,7 +89,7 @@ class WorkstationResource extends CommonObject * @param int $fk_workstation Id of workstation we need to get linked resources * @return array Array of record */ - static public function getAllResourcesOfWorkstation($fk_workstation) + public static function getAllResourcesOfWorkstation($fk_workstation) { global $db; $obj = new self($db); @@ -108,7 +102,7 @@ class WorkstationResource extends CommonObject * @param int $fk_workstation Id of workstation we need to remove linked resources * @return int <0 if KO, 0 if nothing done, >0 if OK and something done */ - static public function deleteAllResourcesOfWorkstation($fk_workstation) + public static function deleteAllResourcesOfWorkstation($fk_workstation) { global $db; $obj = new self($db); diff --git a/htdocs/workstation/class/workstationusergroup.class.php b/htdocs/workstation/class/workstationusergroup.class.php index 920fb896bdc..86fdda7ce66 100644 --- a/htdocs/workstation/class/workstationusergroup.class.php +++ b/htdocs/workstation/class/workstationusergroup.class.php @@ -64,23 +64,17 @@ class WorkstationUserGroup extends CommonObject $this->db = $db; // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -94,7 +88,7 @@ class WorkstationUserGroup extends CommonObject * @param int $fk_workstation id of workstation we need to get linked usergroups * @return array Array of record */ - static public function getAllGroupsOfWorkstation($fk_workstation) + public static function getAllGroupsOfWorkstation($fk_workstation) { global $db; @@ -108,7 +102,7 @@ class WorkstationUserGroup extends CommonObject * @param int $fk_workstation Id of workstation we need to remove linked usergroups * @return int <0 if KO, 0 if nothing done, >0 if OK and something done */ - static public function deleteAllGroupsOfWorkstation($fk_workstation) + public static function deleteAllGroupsOfWorkstation($fk_workstation) { global $db; diff --git a/htdocs/workstation/lib/workstation_workstation.lib.php b/htdocs/workstation/lib/workstation_workstation.lib.php index cc7fcc58f89..a0cd7736d88 100755 --- a/htdocs/workstation/lib/workstation_workstation.lib.php +++ b/htdocs/workstation/lib/workstation_workstation.lib.php @@ -41,14 +41,19 @@ function workstationPrepareHead($object) $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) - { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $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_buildpath('/workstation/workstation_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + if ($nbNote > 0) { + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + } $head[$h][2] = 'note'; $h++; } @@ -60,7 +65,9 @@ function workstationPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/workstation/workstation_document.php", 1).'?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/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index e2951554488..385aa3c41f1 100755 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -22,47 +22,13 @@ * \brief Tab of events on Workstation */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/workstation/class/workstation.class.php'); -dol_include_once('/workstation/lib/workstation_workstation.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; // Load translation files required by the page @@ -77,7 +43,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -87,12 +55,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} // Initialize technical objects $object = new Workstation($db); @@ -104,7 +78,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -120,20 +96,19 @@ $permissiontoadd = $user->rights->workstation->workstation->write; // Used by th $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // 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 $actioncode = ''; $search_agenda_label = ''; } @@ -147,14 +122,15 @@ if (empty($reshook)) $form = new Form($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $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; $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = workstationPrepareHead($object); @@ -228,10 +204,11 @@ if ($object->id > 0) $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); @@ -241,10 +218,8 @@ if ($object->id > 0) print ''; - 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); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } //print load_fiche_titre($langs->trans("ActionsOnWorkstation"), '', ''); diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index e5d51b20c84..2378741c140 100755 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -22,49 +22,15 @@ * \brief Page to create/edit/view workstation */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; -dol_include_once('/workstation/class/workstation.class.php'); -dol_include_once('/workstation/lib/workstation_workstation.lib.php'); -dol_include_once('/workstation/class/workstationusergroup.class.php'); +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php'; // Load translation files required by the page $langs->loadLangs(array("workstation@workstation", "other")); @@ -96,12 +62,15 @@ $hookmanager->initHooks(array('workstationcard', 'globalcard')); // Note that co // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -119,7 +88,9 @@ $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $obje //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'workstation', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -if (!$permissiontoread) accessforbidden(); +if (!$permissiontoread) { + accessforbidden(); +} /* @@ -128,18 +99,22 @@ if (!$permissiontoread) accessforbidden(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/workstation/workstation_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/workstation/workstation_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/workstation/workstation_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } } } @@ -161,9 +136,13 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'confirm_enable' && $confirm == "yes" && $permissiontoadd) { - if (!empty($object->id)) $object->setStatus(1); + if (!empty($object->id)) { + $object->setStatus(1); + } } elseif ($action == 'confirm_disable' && $confirm == "yes" && $permissiontoadd) { - if (!empty($object->id)) $object->setStatus(0); + if (!empty($object->id)) { + $object->setStatus(0); + } } } @@ -191,10 +170,10 @@ llxHeader('', $title, $help_url); jQuery(document).ready(function() { jQuery("#type").change(function() { if($(this).val() === 'MACHINE') { - $('#usergroups').hide(); - $('#nb_operators_required').parent('td').parent('tr').hide(); + $('#usergroups').hide(); + $('#nb_operators_required').parent('td').parent('tr').hide(); $('#wsresources').show(); - } else if($(this).val() === 'HUMAN') { + } else if($(this).val() === 'HUMAN') { $('#wsresources').hide(); $('#nb_operators_required').parent('td').parent('tr').show(); $('#usergroups').show(); @@ -212,15 +191,18 @@ llxHeader('', $title, $help_url); trans("NewObject", $langs->transnoentitiesnoconv("Workstation")), '', 'object_'.$object->picto); print '
'; print ''; print ''; - if ($backtopage) print ''; - if ($backtopageforcancel) print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print dol_get_fiche_head(array(), ''); @@ -268,16 +250,19 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("Workstation"), '', 'object_'.$object->picto); print ''; print ''; print ''; print ''; - if ($backtopage) print ''; - if ($backtopageforcancel) print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print dol_get_fiche_head(); @@ -318,8 +303,7 @@ if (($id || $ref) && $action == 'edit') } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); $head = workstationPrepareHead($object); @@ -339,19 +323,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of action xxxx - if ($action == 'enable') - { + if ($action == 'enable') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('EnableAWorkstation'), $langs->trans("ConfirmEnableWorkstation", $object->ref), 'confirm_enable', $formquestion, 0, 1, 220); - } elseif ($action == 'disable') - { + } elseif ($action == 'disable') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DisableAWorkstation'), $langs->trans("ConfirmDisableWorkstation", $object->ref), 'confirm_disable', $formquestion, 0, 1, 220); } // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -413,7 +398,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner - if ($object->type === 'MACHINE') $object->fields['nb_operators_required']['visible'] = 0; + if ($object->type === 'MACHINE') { + $object->fields['nb_operators_required']['visible'] = 0; + } include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Groups @@ -460,10 +447,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Modify if ($permissiontoadd) { print ''.$langs->trans("Modify").''."\n"; @@ -477,8 +465,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } - if ($permissiontoadd) - { + if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { print ''.$langs->trans("Disable").''."\n"; } else { @@ -488,8 +475,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Delete (need delete permission, or if draft, just need create/modify permission) - if ($permissiontodelete) - { + if ($permissiontodelete) { print ''.$langs->trans('Delete').''."\n"; } else { print ''.$langs->trans('Delete').''."\n"; diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index b06bf3540a4..a85dd8e0e31 100755 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -22,48 +22,14 @@ * \brief Tab for documents linked to Workstation */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 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/class/html.formfile.class.php'; -dol_include_once('/workstation/class/workstation.class.php'); -dol_include_once('/workstation/lib/workstation_workstation.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; // Load translation files required by the page $langs->loadLangs(array("workstation@workstation", "companies", "other", "mails")); @@ -79,12 +45,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $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"; +} //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects @@ -98,7 +70,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->workstation->multidir_output[$object->entity ? $object->entity : $conf->entity]."/workstation/".get_exdir(0, 0, 0, 1, $object); +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->workstation->multidir_output[$object->entity ? $object->entity : $conf->entity]."/workstation/".get_exdir(0, 0, 0, 1, $object); +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -127,8 +101,7 @@ $help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($object->id) -{ +if ($object->id) { /* * Show tabs */ @@ -140,8 +113,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 996e7dc34fd..7803139ef6d 100755 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -22,42 +22,8 @@ * \brief List page for workstation */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -66,11 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; // load workstation libraries require_once __DIR__.'/class/workstation.class.php'; -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - // Load translation files required by the page -$langs->loadLangs(array("workstation@workstation", "other")); +$langs->loadLangs(array("workstation", "other")); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -89,7 +52,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -107,17 +72,24 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Initialize array of search criterias $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); - if (in_array($key, array('type', 'status')) && GETPOST('search_'.$key, 'alpha') == -1) $search[$key] = ''; +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (in_array($key, array('type', 'status')) && GETPOST('search_'.$key, 'alpha') == -1) { + $search[$key] = ''; + } } $groups = GETPOST('groups'); @@ -125,15 +97,15 @@ $resources = GETPOST('resources'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { $visible = dol_eval($val['visible'], 1); @@ -174,10 +146,12 @@ $permissiontoadd = $user->rights->workstation->workstation->write; $permissiontodelete = $user->rights->workstation->workstation->delete; // Security check -if (empty($conf->workstation->enabled)) accessforbidden('Module not enabled'); +if (empty($conf->workstation->enabled)) { + accessforbidden('Module not enabled'); +} $socid = 0; -if ($user->socid > 0) // Protection if external user -{ +if ($user->socid > 0) { + // Protection if external user //$socid = $user->socid; accessforbidden(); } @@ -190,23 +164,26 @@ if ($user->socid > 0) // Protection if external user * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $groups=$resources=array(); @@ -214,8 +191,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -245,13 +221,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + 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(); @@ -259,34 +236,54 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if (!empty($groups)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'workstation_workstation_usergroup wug ON (wug.fk_workstation = t.rowid)'; -if (!empty($resources)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'workstation_workstation_resource wr ON (wr.fk_workstation = t.rowid)'; +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 (t.rowid = ef.fk_object)"; +} +if (!empty($groups)) { + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'workstation_workstation_usergroup wug ON (wug.fk_workstation = t.rowid)'; +} +if (!empty($resources)) { + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'workstation_workstation_resource wr ON (wr.fk_workstation = t.rowid)'; +} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields // usergroups -if (!empty($groups)) $sql.= ' AND wug.fk_usergroup IN('.implode(',', $groups).')'; +if (!empty($groups)) { + $sql.= ' AND wug.fk_usergroup IN('.implode(',', $groups).')'; +} // resources -if (!empty($resources)) $sql.= ' AND wr.fk_resource IN('.implode(',', $resources).')'; +if (!empty($resources)) { + $sql.= ' AND wr.fk_resource IN('.implode(',', $resources).')'; +} include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -315,26 +312,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -343,8 +338,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/workstation/workstation_card.php', 1).'?id='.$id); @@ -375,14 +369,24 @@ jQuery(document).ready(function() { $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) -{ - 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 (!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 ($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'; // Add $param from hooks @@ -397,12 +401,18 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''."\n"; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -421,9 +431,10 @@ $objecttmp = new Workstation($db); $trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } @@ -434,11 +445,13 @@ $moreforfilter.= '
';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; @@ -456,20 +469,26 @@ print ''; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } } @@ -506,15 +525,18 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -542,11 +564,11 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -555,10 +577,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); @@ -567,28 +590,40 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Show here line of result print ''; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if ($key == 'status') print $object->getLibStatut(5); - else print $object->showOutputField($val, $key, $object->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -626,14 +661,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; @@ -644,10 +682,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } @@ -663,10 +704,11 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index a9d8a7f3fc2..6cc6a36a3fd 100755 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -22,47 +22,14 @@ * \brief Tab for notes on Workstation */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +require '../main.inc.php'; -dol_include_once('/workstation/class/workstation.class.php'); -dol_include_once('/workstation/lib/workstation_workstation.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("workstation@workstation", "companies")); +$langs->loadLangs(array("workstation", "companies")); // Get parameters $id = GETPOST('id', 'int'); @@ -86,7 +53,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; +} $permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php @@ -110,8 +79,7 @@ $form = new Form($db); $help_url = ''; llxHeader('', $langs->trans('Workstation'), $help_url); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = workstationPrepareHead($object); From bb276566c6fe8d2843668dd374c7285c8722c4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 19:05:32 +0100 Subject: [PATCH 043/173] code syntax --- htdocs/barcode/codeinit.php | 103 +++++++++++++++------------------- htdocs/barcode/printsheet.php | 102 +++++++++++++++------------------ 2 files changed, 90 insertions(+), 115 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 52a11e78bdd..f35547523c9 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -52,27 +52,21 @@ $maxperinit = 1000; */ // Define barcode template for products -if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) -{ +if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - foreach ($dirbarcodenum as $dirroot) - { + foreach ($dirbarcodenum as $dirroot) { $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) { $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -85,28 +79,23 @@ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) } } -if ($action == 'initbarcodeproducts') -{ - if (!is_object($modBarCodeProduct)) - { +if ($action == 'initbarcodeproducts') { + if (!is_object($modBarCodeProduct)) { $error++; setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors'); } - if (!$error) - { + if (!$error) { $productstatic = new Product($db); $db->begin(); $nbok = 0; - if (!empty($eraseallbarcode)) - { + if (!empty($eraseallbarcode)) { $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql .= " SET barcode = NULL"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs'); } else { $error++; @@ -121,16 +110,13 @@ if ($action == 'initbarcodeproducts') dol_syslog("codeinit", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $nbok = $nbtry = 0; - while ($i < min($num, $maxperinit)) - { + while ($i < min($num, $maxperinit)) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $productstatic->id = $obj->rowid; $productstatic->ref = $obj->ref; $productstatic->type = $obj->fk_product_type; @@ -140,7 +126,9 @@ if ($action == 'initbarcodeproducts') $result = $productstatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'PRODUCT_MODIFY'); $nbtry++; - if ($result > 0) $nbok++; + if ($result > 0) { + $nbok++; + } } $i++; @@ -150,14 +138,12 @@ if ($action == 'initbarcodeproducts') dol_print_error($db); } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); } } - if (!$error) - { + if (!$error) { //$db->rollback(); $db->commit(); } else { @@ -174,8 +160,12 @@ if ($action == 'initbarcodeproducts') * View */ -if (!$user->admin) accessforbidden(); -if (empty($conf->barcode->enabled)) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} +if (empty($conf->barcode->enabled)) { + accessforbidden(); +} $form = new Form($db); @@ -198,8 +188,7 @@ print ''; print '
'; // For thirdparty -if ($conf->societe->enabled) -{ +if ($conf->societe->enabled) { $nbno = $nbtotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company'); @@ -207,19 +196,21 @@ if ($conf->societe->enabled) print '
'."\n"; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $nbno = $obj->nb; - } else dol_print_error($db); + } else { + dol_print_error($db); + } $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $nbtotal = $obj->nb; - } else dol_print_error($db); + } else { + dol_print_error($db); + } print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n"; @@ -231,8 +222,7 @@ if ($conf->societe->enabled) // For products -if ($conf->product->enabled || $conf->product->service) -{ +if ($conf->product->enabled || $conf->product->service) { // Example 1 : Adding jquery code print ''; $tmp = $tmp.''; $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); - print '
'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print ''; + } print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans("NoRecordFound").'
'; + print ''; + print ''; if (($origin == 'propal') || ($origin == 'commande')) { - print ''; - print ''; } - print '
'; print $desc; print ''; + print ''; $arraylist = array( 'amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')), @@ -3090,9 +3164,11 @@ if ($action == 'create') ); print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1); print ''.$langs->trans('Value').':'; + print ''; + print ''.$langs->trans("AmountOrPercent").''; + print '
'; + print '
'; print ''; } @@ -3570,6 +3646,8 @@ if ($action == 'create') // Lines from source (TODO Show them also when creating invoice from template invoice) if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { + $langs->loadLangs(array('orders', 'propal')); + // TODO for compatibility if ($origin == 'contrat') { // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva @@ -3578,13 +3656,12 @@ if ($action == 'create') $objectsrc->update_price(1, - 1, 1); } - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; + print "\n\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; switch (get_class($objectsrc)) { case 'Propal': @@ -3606,13 +3683,16 @@ if ($action == 'create') $newclassname = get_class($objectsrc); } - print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1); + // Ref of origin + print '
'.$langs->trans($newclassname).''; + print $objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, '', 'facture'); if (is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1) { setEventMessages('WarningBillExist', null, 'warnings'); - echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')'; + echo ' - '.$langs->trans('LatestRelatedBill').' '.end($objectsrc->linkedObjects['facture'])->getNomUrl(1); } echo '
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('Customer').''; @@ -2990,8 +2927,7 @@ if ($action == 'create') print ''; print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. - if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) - { + if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print ''; $text = ''; $text .= ' '; $text = ' '; @@ -3286,24 +3214,19 @@ if ($action == 'create') } - if (empty($origin)) - { - if ($socid > 0) - { + if (empty($origin)) { + if ($socid > 0) { // Credit note - if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) - { + if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note $facids = $facturestatic->list_qualified_avoir_invoices($soc->id); - if ($facids < 0) - { + if ($facids < 0) { dol_print_error($db, $facturestatic); exit; } $optionsav = ""; $newinvoice_static = new Facture($db); - foreach ($facids as $key => $valarray) - { + foreach ($facids as $key => $valarray) { $newinvoice_static->id = $key; $newinvoice_static->ref = $valarray ['ref']; $newinvoice_static->statut = $valarray ['status']; @@ -3321,7 +3244,9 @@ if ($action == 'create') print '
'; $tmp = 'global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp .= ' disabled'; + if ((!$optionsav && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) { + $tmp .= ' disabled'; + } $tmp .= '> '; // Show credit note options only if we checked credit note print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index bc8506b2151..fff9d077a08 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -35,8 +35,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; } @@ -44,11 +43,21 @@ if (empty($object) || !is_object($object)) global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax; -if (empty($dateSelector)) $dateSelector = 0; -if (empty($forceall)) $forceall = 0; -if (empty($senderissupplier)) $senderissupplier = 0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; -if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax = 0; +if (empty($dateSelector)) { + $dateSelector = 0; +} +if (empty($forceall)) { + $forceall = 0; +} +if (empty($senderissupplier)) { + $senderissupplier = 0; +} +if (empty($inputalsopricewithtax)) { + $inputalsopricewithtax = 0; +} +if (empty($outputalsopricetotalwithtax)) { + $outputalsopricetotalwithtax = 0; +} // add html5 elements $domData = ' data-element="'.$line->element.'"'; @@ -79,8 +88,7 @@ $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price print '
'; $label = $tmpproduct->getLabelOfUnit('long'); if ($label !== '') { @@ -159,8 +167,7 @@ if ($action == 'selectlines') { print '
'; print ''; print ''; @@ -121,8 +122,7 @@ print ''; -if (!empty($conf->banque->enabled)) -{ +if (!empty($conf->banque->enabled)) { print ''; print ''; } -if (!empty($conf->stock->enabled)) -{ +if (!empty($conf->stock->enabled)) { print ''; // Force warehouse (this is not a default value) print ''; // Force warehouse (this is not a default value) print ' - + - + - - - - + @@ -130,8 +132,8 @@ for ($i = 0; $i < $nbtoshow; $i++) - - + +
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("CashDeskThirdParty print ''; print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0); print '
'.$langs->trans("CashDeskBankAccountForSell").''; $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1); @@ -141,8 +141,7 @@ if (!empty($conf->banque->enabled)) print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { @@ -161,8 +160,7 @@ if (!empty($conf->stock->enabled)) print '
'.$langs->trans("CashDeskIdWareHouse").''; - if (!$disabled) - { + if (!$disabled) { print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled); print ' ('.$langs->trans("Create").')'; } else { @@ -172,8 +170,7 @@ if (!empty($conf->stock->enabled)) } // Use Dolibarr Receipt Printer -if (!empty($conf->receiptprinter->enabled)) -{ +if (!empty($conf->receiptprinter->enabled)) { print '
'; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; print ''; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 72cb99123a4..384e3490fa1 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -25,15 +25,13 @@ require_once 'class/Facturation.class.php'; // Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles) -if ($_GET['id'] == 'NOUV') -{ +if ($_GET['id'] == 'NOUV') { unset($_SESSION['serObjFacturation']); unset($_SESSION['poscart']); } // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... -if (isset($_SESSION['serObjFacturation'])) -{ +if (isset($_SESSION['serObjFacturation'])) { $obj_facturation = unserialize($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']); } else { @@ -58,17 +56,18 @@ print '
'; print '
'; $page = GETPOST('menutpl', 'alpha'); -if (empty($page)) $page = 'facturation'; +if (empty($page)) { + $page = 'facturation'; +} if (in_array( - $page, - array( + $page, + array( 'deconnexion', 'index', 'index_verif', 'facturation', 'facturation_verif', 'facturation_dhtml', 'validation', 'validation_ok', 'validation_ticket', 'validation_verif', ) - )) -{ +)) { include $page.'.php'; } else { dol_print_error('', 'menu param '.$page.' is not inside allowed list'); diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index 1e3bddf1df7..931bcd76f6f 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -30,8 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/keypad.php'; $error = GETPOST('error'); // Test if already logged -if ($_SESSION['uid'] <= 0) -{ +if ($_SESSION['uid'] <= 0) { header('Location: index.php'); exit; } @@ -53,8 +52,7 @@ top_htmlhead($head, $langs->trans("CashDesk"), 0, 0, $arrayofjs, $arrayofcss); print ''."\n"; -if (!empty($error)) -{ +if (!empty($error)) { dol_htmloutput_events(); } diff --git a/htdocs/cashdesk/affPied.php b/htdocs/cashdesk/affPied.php index b3108217346..1a7c9c5b6a7 100644 --- a/htdocs/cashdesk/affPied.php +++ b/htdocs/cashdesk/affPied.php @@ -27,8 +27,7 @@ use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) -{ +if (!empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) { print "\n\n"; print ''); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index 45ce3857068..0c0281e5414 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -42,36 +42,31 @@ $bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0) ?GETPOST("CASHD $bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CB", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB; // Check username -if (empty($username)) -{ +if (empty($username)) { $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); exit; } // Check third party id -if (!($thirdpartyid > 0)) -{ +if (!($thirdpartyid > 0)) { $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); exit; } // If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. -if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) -{ +if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) { $retour = $langs->trans("CashDeskYouDidNotDisableStockDecease"); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); exit; } // If stock decrease on bill validation, check user has stock edit permissions -if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) -{ +if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) { $testuser = new User($db); $testuser->fetch(0, $username); $testuser->getrights('stock'); - if (empty($testuser->rights->stock->creer)) - { + if (empty($testuser->rights->stock->creer)) { $retour = $langs->trans("UserNeedPermissionToEditStockToUsePos"); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); exit; @@ -83,8 +78,7 @@ if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_S $auth = new Auth($db); $retour = $auth->verif($username, $password); -if ($retour >= 0) -{ +if ($retour >= 0) { $return = array(); $sql = "SELECT rowid, lastname, firstname"; @@ -93,12 +87,10 @@ if ($retour >= 0) $sql .= " AND entity IN (0,".$conf->entity.")"; $result = $db->query($sql); - if ($result) - { + if ($result) { $tab = $db->fetch_array($res); - foreach ($tab as $key => $value) - { + foreach ($tab as $key => $value) { $return[$key] = $value; } diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d48fc544eb0..41a0f0b757e 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -21,8 +21,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; } @@ -64,10 +63,11 @@ $id = $obj_facturation->id(); // Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ... $nbtoshow = $nbr_enreg; -if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes; +if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) { + $nbtoshow = $conf_taille_listes; +} -for ($i = 0; $i < $nbtoshow; $i++) -{ +for ($i = 0; $i < $nbtoshow; $i++) { if ($id == $tab_designations[$i]['rowid']) { $selected = 'selected'; } else { @@ -96,9 +96,9 @@ for ($i = 0; $i < $nbtoshow; $i++)
trans("Qty"); ?> trans("PriceUHT"); ?> trans("Discount"); ?> (%)trans("VATRate"); ?>trans("VATRate"); ?>
@@ -106,20 +106,22 @@ for ($i = 0; $i < $nbtoshow; $i++) + + - - + + + vatrate; // To get vat rate we just have selected $buyer = new Societe($db); - if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); + if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) { + $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); + } echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); ?> -
trans("TotalHT"); ?>
@@ -165,25 +167,28 @@ for ($i = 0; $i < $nbtoshow; $i++)
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) - { + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } else print ''; + } else { + print ''; + } print '
'; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) - { + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } else print ''; + } else { + print ''; + } print '
'; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) - { + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk")).'" />'; - } else print ''; + } else { + print ''; + } print '
'; print '
'; print '
'; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index e3c3c285966..74be200945f 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -18,8 +18,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; } @@ -48,10 +47,10 @@ $societe->fetch($thirdpartyid); $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab_size = count($tab); -if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; -else { - for ($i = 0; $i < $tab_size; $i++) - { +if ($tab_size <= 0) { + print '
'.$langs->trans("NoArticle").'

'; +} else { + for ($i = 0; $i < $tab_size; $i++) { echo ('
'."\n"); echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php index 1e347f4d01e..67891aa67cf 100644 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ b/htdocs/cashdesk/tpl/menu.tpl.php @@ -20,8 +20,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; } @@ -37,27 +36,23 @@ include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); $companyLink = $company->getNomUrl(1); }*/ -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) -{ +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { $bankcash = new Account($db); $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); $bankcash->label = $bankcash->ref; $bankcashLink = $bankcash->getNomUrl(1); } -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) -{ +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { $bankcb = new Account($db); $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); $bankcbLink = $bankcb->getNomUrl(1); } -if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) -{ +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { $bankcheque = new Account($db); $bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]); $bankchequeLink = $bankcheque->getNomUrl(1); } -if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) -{ +if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) { $warehouse = new Entrepot($db); $warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]); $warehouseLink = $warehouse->getNomUrl(1); @@ -87,8 +82,7 @@ print ''; print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'
'; print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'
';*/ print '
'; -if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) -{ +if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { print $langs->trans("CashDeskWarehouse").': '.$warehouseLink; } print '
'; diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index 101ea687e7b..9220e3daad4 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -18,8 +18,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; } @@ -38,82 +37,81 @@ $object->fetch($facid); ?> - - <?php echo $langs->trans('PrintTicket') ?> - + + <?php echo $langs->trans('PrintTicket') ?> +
- -
-

name; ?>
-
-

+ +
+

name; ?>
+
+

-

'; print $object->ref; ?>

-
+

- + - - - - - + + + + + - - - + + - - - - - - - - + + + + + + + - +
trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>
currency); ?>
currency); ?>
- - + + - + - +
trans("TotalHT"); ?>amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>trans("TotalHT"); ?>amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
trans("TotalVAT").''.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>trans("TotalVAT").''.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
trans("TotalTTC").''.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>trans("TotalTTC").''.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?>
trans("Close"); ?> diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index cc558cca058..c2a9124f300 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -17,8 +17,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; } @@ -47,25 +46,27 @@ if ($obj_facturation->amountVat()) {
trans("TotalTTC"); ?> amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?>
trans("PaymentMode"); ?> getSetPaymentMode()) - { + switch ($obj_facturation->getSetPaymentMode()) { case 'ESP': echo $langs->trans("Cash"); $filtre = 'courant=2'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; + } break; case 'CB': echo $langs->trans("CreditCard"); $filtre = 'courant=1'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; + } break; case 'CHQ': echo $langs->trans("Cheque"); $filtre = 'courant=1'; - if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; + } break; case 'DIF': echo $langs->trans("Reported"); diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php index 8b3ca9c76d5..d89edfdc41a 100644 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ b/htdocs/cashdesk/tpl/validation2.tpl.php @@ -18,8 +18,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; } diff --git a/htdocs/cashdesk/validation_ticket.php b/htdocs/cashdesk/validation_ticket.php index 28ad91dc4e7..0c32dfa8c44 100644 --- a/htdocs/cashdesk/validation_ticket.php +++ b/htdocs/cashdesk/validation_ticket.php @@ -33,8 +33,7 @@ $hookmanager->initHooks(array('cashdeskTplTicket')); $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation); -if (empty($reshook)) -{ +if (empty($reshook)) { require 'tpl/ticket.tpl.php'; } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index da320c7d855..b9ad0d94a02 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -36,8 +36,7 @@ $obj_facturation = unserialize($_SESSION['serObjFacturation']); $action = GETPOST('action', 'aZ09'); $bankaccountid = GETPOST('cashdeskbank'); -switch ($action) -{ +switch ($action) { default: $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; break; @@ -55,15 +54,18 @@ switch ($action) // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here // and restore values just after $sav_FACTURE_ADDON = ''; - if (!empty($conf->global->POS_ADDON)) - { + if (!empty($conf->global->POS_ADDON)) { $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; $conf->global->FACTURE_ADDON = $conf->global->POS_ADDON; // To force prefix only for POS with terre module - if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX; + if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) { + $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX; + } // To force prefix only for POS with mars module - if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX; + if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) { + $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX; + } // To force rule only for POS with mercure //... } @@ -71,8 +73,7 @@ switch ($action) $num = $invoice->getNextNumRef($company); // Restore save values - if (!empty($sav_FACTURE_ADDON)) - { + if (!empty($sav_FACTURE_ADDON)) { $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; } @@ -120,14 +121,12 @@ switch ($action) $heure = dol_print_date($now, 'hour'); $note = ''; - if (!is_object($obj_facturation)) - { + if (!is_object($obj_facturation)) { dol_print_error('', 'Empty context'); exit; } - switch ($obj_facturation->getSetPaymentMode()) - { + switch ($obj_facturation->getSetPaymentMode()) { case 'DIF': $mode_reglement_id = 0; //$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid') @@ -151,8 +150,12 @@ switch ($action) $cond_reglement_id = 0; break; } - if (empty($mode_reglement_id)) $mode_reglement_id = 0; // If mode_reglement_id not found - if (empty($cond_reglement_id)) $cond_reglement_id = 0; // If cond_reglement_id not found + if (empty($mode_reglement_id)) { + $mode_reglement_id = 0; // If mode_reglement_id not found + } + if (empty($cond_reglement_id)) { + $cond_reglement_id = 0; // If cond_reglement_id not found + } $note .= $_POST['txtaNotes']; dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id); @@ -175,8 +178,7 @@ switch ($action) // Loop on each line into cart $tab_liste_size = count($tab_liste); - for ($i = 0; $i < $tab_liste_size; $i++) - { + for ($i = 0; $i < $tab_liste_size; $i++) { $tmp = getTaxesFromId($tab_liste[$i]['fk_tva']); $vat_rate = $tmp['rate']; $vat_npr = $tmp['npr']; @@ -218,32 +220,32 @@ switch ($action) //print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit; // Si paiement differe ... - if ($obj_facturation->getSetPaymentMode() == 'DIF') - { + if ($obj_facturation->getSetPaymentMode() == 'DIF') { $resultcreate = $invoice->create($user, 0, dol_stringtotime($obj_facturation->paiementLe())); - if ($resultcreate > 0) - { + if ($resultcreate > 0) { $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); - if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice + if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { + $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice + } $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); - if ($warehouseidtodecrease > 0) - { + if ($warehouseidtodecrease > 0) { // Decrease require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line $cpt = count($invoice->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($invoice->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($invoice->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($db); $mouvP->origin = &$invoice; // We decrease stock for product - if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) { + $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + } else { + $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + } if ($result < 0) { $error++; } @@ -258,29 +260,30 @@ switch ($action) $id = $invoice->id; } else { $resultcreate = $invoice->create($user, 0, 0); - if ($resultcreate > 0) - { + if ($resultcreate > 0) { $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); - if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice + if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { + $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice + } $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); - if ($warehouseidtodecrease > 0) - { + if ($warehouseidtodecrease > 0) { // Decrease require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line $cpt = count($invoice->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($invoice->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($invoice->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($db); $mouvP->origin = &$invoice; // We decrease stock for product - if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); - else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) { + $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + } else { + $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); + } if ($result < 0) { setEventMessages($mouvP->error, $mouvP->errors, 'errors'); $error++; @@ -301,26 +304,21 @@ switch ($action) $payment->num_payment = ''; $paiement_id = $payment->create($user); - if ($paiement_id > 0) - { - if (!$error) - { + if ($paiement_id > 0) { + if (!$error) { $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); - if (!$result > 0) - { + if (!$result > 0) { $errmsg = $paiement->error; $error++; } } - if (!$error) - { + if (!$error) { if ($invoice->total_ttc == $obj_facturation->amountWithTax() - && $obj_facturation->getSetPaymentMode() != 'DIFF') - { + && $obj_facturation->getSetPaymentMode() != 'DIFF') { // We set status to paid $result = $invoice->setPaid($user); - //print 'set paid';exit; + //print 'set paid';exit; } } } else { @@ -334,8 +332,7 @@ switch ($action) } - if (!$error) - { + if (!$error) { $db->commit(); $redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr } else { From 6fcb7a96a1afd058b627d6acd47e9c7a9a2d398a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 18:04:37 +0100 Subject: [PATCH 059/173] code syntax categorie collab directory --- htdocs/categories/admin/categorie.php | 23 +- .../admin/categorie_extrafields.php | 17 +- htdocs/categories/card.php | 111 +++---- .../categories/class/api_categories.class.php | 31 +- htdocs/categories/class/categorie.class.php | 156 ++++++--- htdocs/categories/edit.php | 13 +- htdocs/categories/index.php | 63 ++-- htdocs/categories/info.php | 10 +- htdocs/categories/photos.php | 85 +++-- htdocs/categories/traduction.php | 79 +++-- htdocs/categories/viewcat.php | 300 ++++++++---------- htdocs/collab/index.php | 86 +++-- 12 files changed, 505 insertions(+), 469 deletions(-) diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index 693a3e53a2a..bddeb9a771a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -27,8 +27,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; -if (!$user->admin) -accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("categories", "admin")); @@ -40,11 +41,9 @@ $action = GETPOST('action', 'aZ09'); */ $reg = array(); -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -52,11 +51,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) } } -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -100,12 +97,10 @@ print ''.$langs->trans("CategorieRecursiv").''.$form->textwithpicto('', $langs->trans("CategorieRecursivHelp"), 1, 'help').''; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ajax_constantonoff('CATEGORIE_RECURSIV_ADD'); } else { - if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) - { + if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index ff6a4ca7881..0d691995c29 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -37,13 +37,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'categorie'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -76,8 +80,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -103,8 +105,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/categories/card.php b/htdocs/categories/card.php index 74e16f9082d..5b54666b674 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -37,14 +37,16 @@ $langs->load("categories"); // Security check $socid = (int) GETPOST('socid', 'int'); -if (!$user->rights->categorie->lire) accessforbidden(); +if (!$user->rights->categorie->lire) { + accessforbidden(); +} -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $origin = GETPOST('origin', 'alpha'); $catorigin = (int) GETPOST('catorigin', 'int'); -$type = GETPOST('type', 'aZ09'); -$urlfrom = GETPOST('urlfrom', 'alpha'); +$type = GETPOST('type', 'aZ09'); +$urlfrom = GETPOST('urlfrom', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $label = (string) GETPOST('label', 'alphanohtml'); @@ -54,15 +56,29 @@ $visible = (int) GETPOST('visible', 'int'); $parent = (int) GETPOST('parent', 'int'); if ($origin) { - if ($type == Categorie::TYPE_PRODUCT) $idProdOrigin = $origin; - if ($type == Categorie::TYPE_SUPPLIER) $idSupplierOrigin = $origin; - if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin; - if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin; - if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin; - if ($type == Categorie::TYPE_PROJECT) $idProjectOrigin = $origin; + if ($type == Categorie::TYPE_PRODUCT) { + $idProdOrigin = $origin; + } + if ($type == Categorie::TYPE_SUPPLIER) { + $idSupplierOrigin = $origin; + } + if ($type == Categorie::TYPE_CUSTOMER) { + $idCompanyOrigin = $origin; + } + if ($type == Categorie::TYPE_MEMBER) { + $idMemberOrigin = $origin; + } + if ($type == Categorie::TYPE_CONTACT) { + $idContactOrigin = $origin; + } + if ($type == Categorie::TYPE_PROJECT) { + $idProjectOrigin = $origin; + } } -if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin; +if ($catorigin && $type == Categorie::TYPE_PRODUCT) { + $idCatOrigin = $catorigin; +} $object = new Categorie($db); @@ -80,13 +96,10 @@ $error = 0; */ // Add action -if ($action == 'add' && $user->rights->categorie->creer) -{ +if ($action == 'add' && $user->rights->categorie->creer) { // Action ajout d'une categorie - if ($cancel) - { - if ($urlfrom) - { + if ($cancel) { + if ($urlfrom) { header("Location: ".$urlfrom); exit; } elseif ($backtopage) { @@ -125,24 +138,25 @@ if ($action == 'add' && $user->rights->categorie->creer) $object->visible = $visible; $object->type = $type; - if ($parent != "-1") $object->fk_parent = $parent; + if ($parent != "-1") { + $object->fk_parent = $parent; + } $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$object->label) - { + if (!$object->label) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); $action = 'create'; } // Create category in database - if (!$error) - { + if (!$error) { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { $action = 'confirmed'; $_POST["addcat"] = ''; } else { @@ -152,41 +166,31 @@ if ($action == 'add' && $user->rights->categorie->creer) } // Confirm action -if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer) -{ +if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer) { // Action confirmation de creation categorie - if ($action == 'confirmed') - { - if ($urlfrom) - { + if ($action == 'confirmed') { + if ($urlfrom) { header("Location: ".$urlfrom); exit; - } elseif ($backtopage) - { + } elseif ($backtopage) { header("Location: ".$backtopage); exit; - } elseif ($idProdOrigin) - { + } elseif ($idProdOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } elseif ($idCompanyOrigin) - { + } elseif ($idCompanyOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } elseif ($idSupplierOrigin) - { + } elseif ($idSupplierOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } elseif ($idMemberOrigin) - { + } elseif ($idMemberOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } elseif ($idContactOrigin) - { + } elseif ($idContactOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } elseif ($idProjectOrigin) - { + } elseif ($idProjectOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } @@ -207,11 +211,9 @@ $formother = new FormOther($db); $helpurl = ''; llxHeader("", $langs->trans("Categories"), $helpurl); -if ($user->rights->categorie->creer) -{ +if ($user->rights->categorie->creer) { // Create or add - if ($action == 'create' || GETPOST("addcat") == 'addcat') - { + if ($action == 'create' || GETPOST("addcat") == 'addcat') { dol_set_focus('#label'); print '
'; @@ -222,8 +224,12 @@ if ($user->rights->categorie->creer) print ''; print ''; print ''; - if ($origin) print ''; - if ($catorigin) print ''; + if ($origin) { + print ''; + } + if ($catorigin) { + print ''; + } print load_fiche_titre($langs->trans("CreateCat")); @@ -257,8 +263,7 @@ if ($user->rights->categorie->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 03610100c9c..65483a561af 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -140,15 +140,12 @@ class Categories extends DolibarrApi $sql = "SELECT t.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; - if (!empty($type)) - { + if (!empty($type)) { $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -157,8 +154,7 @@ class Categories extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -167,13 +163,11 @@ class Categories extends DolibarrApi } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $category_static = new Categorie($this->db); if ($category_static->fetch($obj->rowid)) { @@ -181,8 +175,7 @@ class Categories extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror()); } if (!count($obj_ret)) { @@ -238,7 +231,9 @@ class Categories extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->category->$field = $value; } @@ -721,8 +716,9 @@ class Categories extends DolibarrApi { $category = array(); foreach (Categories::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $category[$field] = $data[$field]; } return $category; @@ -747,8 +743,7 @@ class Categories extends DolibarrApi throw new RestException(401); } - if (empty($type)) - { + if (empty($type)) { throw new RestException(500, 'The "type" parameter is required.'); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index a050c21c249..d83bc794baa 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -98,7 +98,7 @@ class Categorie extends CommonObject 8 => 'bank_line', 9 => 'warehouse', 10 => 'actioncomm', - 11 => 'website_page' + 11 => 'website_page' ); /** @@ -197,7 +197,7 @@ class Categorie extends CommonObject /** * @var string Category label */ - public $label; + public $label; /** * @var string description @@ -231,9 +231,9 @@ class Categorie extends CommonObject * @see Categorie::TYPE_PROJECT * @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_BANK_LINE - * @see Categorie::TYPE_WAREHOUSE - * @see Categorie::TYPE_ACTIONCOMM - * @see Categorie::TYPE_WEBSITE_PAGE + * @see Categorie::TYPE_WAREHOUSE + * @see Categorie::TYPE_ACTIONCOMM + * @see Categorie::TYPE_WEBSITE_PAGE */ public $type; @@ -266,9 +266,9 @@ class Categorie extends CommonObject $mapList = $hookmanager->resArray; $mapId = $mapList['id']; $mapCode = $mapList['code']; - self::$MAP_ID_TO_CODE[$mapId] = $mapCode; - $this->MAP_ID[$mapCode] = $mapId; - $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; + self::$MAP_ID_TO_CODE[$mapId] = $mapCode; + $this->MAP_ID[$mapCode] = $mapId; + $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; $this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table']; $this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class']; $this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table']; @@ -313,8 +313,12 @@ class Categorie extends CommonObject global $conf; // Check parameters - if (empty($id) && empty($label) && empty($ref_ext)) return -1; - if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type]; + if (empty($id) && empty($label) && empty($ref_ext)) { + return -1; + } + if (!is_null($type) && !is_numeric($type)) { + $type = $this->MAP_ID[$type]; + } $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; @@ -325,7 +329,9 @@ class Categorie extends CommonObject $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; - if (!is_null($type)) $sql .= " AND type = ".((int) $type); + if (!is_null($type)) { + $sql .= " AND type = ".((int) $type); + } } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -357,7 +363,9 @@ class Categorie extends CommonObject $this->db->free($resql); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); + if (!empty($conf->global->MAIN_MULTILANGS)) { + $this->getMultiLangs(); + } return 1; } else { @@ -387,7 +395,9 @@ class Categorie extends CommonObject $type = $this->type; - if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) { + $type = $this->MAP_ID[$type]; + } $error = 0; @@ -399,7 +409,9 @@ class Categorie extends CommonObject $this->color = trim($this->color); $this->import_key = trim($this->import_key); $this->ref_ext = trim($this->ref_ext); - if (empty($this->visible)) $this->visible = 0; + if (empty($this->visible)) { + $this->visible = 0; + } $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); if ($this->already_exists()) { @@ -463,7 +475,9 @@ class Categorie extends CommonObject if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -542,7 +556,9 @@ class Categorie extends CommonObject if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_MODIFY', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; $this->db->rollback(); return -1; + } // End call triggers } @@ -579,7 +595,9 @@ class Categorie extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CATEGORY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } @@ -649,9 +667,13 @@ class Categorie extends CommonObject $error = 0; - if ($this->id == -1) return -2; + if ($this->id == -1) { + return -2; + } - if (empty($type)) $type = $obj->element; + if (empty($type)) { + $type = $obj->element; + } $this->db->begin(); @@ -699,7 +721,9 @@ class Categorie extends CommonObject // Call trigger $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_LINK', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers if (!$error) { @@ -757,7 +781,9 @@ class Categorie extends CommonObject // Call trigger $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_UNLINK', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers if (!$error) { @@ -805,7 +831,9 @@ class Categorie extends CommonObject if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { $sql .= " AND o.rowid = ".$user->socid; } - if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); + if ($limit > 0 || $offset > 0) { + $sql .= $this->db->plimit($limit + 1, $offset); + } $sql .= $this->db->order($sortfield, $sortorder); dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); @@ -1037,7 +1065,9 @@ class Categorie extends CommonObject // phpcs:enable global $conf, $langs; - if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) { + $type = $this->MAP_ID[$type]; + } if (is_null($type)) { $this->error = 'BadValueForParameterType'; return -1; @@ -1063,9 +1093,13 @@ class Categorie extends CommonObject // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans"; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $sql .= ", t.label as label_trans, t.description as description_trans"; + } $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; + } $sql .= " WHERE c.entity IN (".getEntity('category').")"; $sql .= " AND c.type = ".(int) $type; @@ -1204,14 +1238,18 @@ class Categorie extends CommonObject public function get_all_categories($type = null, $parent = false) { // phpcs:enable - if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) { + $type = $this->MAP_ID[$type]; + } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE entity IN (".getEntity('category').")"; - if (!is_null($type)) + if (!is_null($type)) { $sql .= " AND type = ".(int) $type; - if ($parent) + } + if ($parent) { $sql .= " AND fk_parent = 0"; + } $res = $this->db->query($sql); if ($res) { @@ -1252,7 +1290,9 @@ class Categorie extends CommonObject // phpcs:enable $type = $this->type; - if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_numeric($type)) { + $type = $this->MAP_ID[$type]; + } /* We have to select any rowid from llx_categorie which category's mother and label * are equals to those of the calling category @@ -1318,7 +1358,9 @@ class Categorie extends CommonObject // Check contrast with background and correct text color $forced_color = 'categtextwhite'; if ($cat->color) { - if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; + if (colorIsLight($cat->color)) { + $forced_color = 'categtextblack'; + } } } } @@ -1399,8 +1441,9 @@ class Categorie extends CommonObject } } - if (count($ways) == 0) + if (count($ways) == 0) { $ways[0][0] = $this; + } return $ways; } @@ -1419,7 +1462,9 @@ class Categorie extends CommonObject { $cats = array(); - if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; + if (is_numeric($type)) { + $type = Categorie::$MAP_ID_TO_CODE[$type]; + } if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code after migration of llx_bank_categ into llx_categorie // Load bank categories @@ -1509,11 +1554,14 @@ class Categorie extends CommonObject $sql .= " WHERE type = ".$this->MAP_ID[$type]; $sql .= " AND entity IN (".getEntity('category').")"; if ($nom) { - if (!$exact) + if (!$exact) { $nom = '%'.str_replace('*', '%', $nom).'%'; - if (!$case) + } + if (!$case) { $sql .= " AND label LIKE '".$this->db->escape($nom)."'"; - else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; + } else { + $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; + } } if ($id) { $sql .= " AND rowid = '".$id."'"; @@ -1554,7 +1602,9 @@ class Categorie extends CommonObject // Check contrast with background and correct text color $forced_color = 'categtextwhite'; if ($this->color) { - if (colorIsLight($this->color)) $forced_color = 'categtextblack'; + if (colorIsLight($this->color)) { + $forced_color = 'categtextblack'; + } } $link = ''; @@ -1563,9 +1613,15 @@ class Categorie extends CommonObject $picto = 'category'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; + if ($withpicto) { + $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + } + if ($withpicto && $withpicto != 2) { + $result .= ' '; + } + if ($withpicto != 2) { + $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; + } return $result; } @@ -1653,13 +1709,18 @@ class Categorie extends CommonObject // Objet $obj = array(); $obj['photo'] = $photo; - if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; - else $obj['photo_vignette'] = ""; + if ($photo_vignette && is_file($dirthumb.$photo_vignette)) { + $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + } else { + $obj['photo_vignette'] = ""; + } $tabobj[$nbphoto - 1] = $obj; // On continue ou on arrete de boucler - if ($nbmax && $nbphoto >= $nbmax) break; + if ($nbmax && $nbphoto >= $nbmax) { + break; + } } } @@ -1764,8 +1825,9 @@ class Categorie extends CommonObject } // on ne sauvegarde pas des champs vides - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) { dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); + } if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; @@ -1876,7 +1938,9 @@ class Categorie extends CommonObject */ public static function getFilterJoinQuery($type, $rowIdName) { - if ($type == 'bank_account') $type = 'account'; + if ($type == 'bank_account') { + $type = 'account'; + } return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp ON ".$rowIdName." = cp.fk_".$type; } @@ -1891,7 +1955,9 @@ class Categorie extends CommonObject */ public static function getFilterSelectQuery($type, $rowIdName, $searchList) { - if ($type == 'bank_account') $type = 'account'; + if ($type == 'bank_account') { + $type = 'account'; + } if (empty($searchList) && !is_array($searchList)) { return ""; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index a5578032a3d..176b39ca008 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -62,7 +62,9 @@ if ($result <= 0) { } $type = $object->type; -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 +} $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); @@ -90,7 +92,7 @@ if ($cancel) { // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { $object->oldcopy = dol_clone($object); - $object->label = $label; + $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; $object->socid = ($socid > 0 ? $socid : 0); @@ -105,10 +107,11 @@ if ($action == 'update' && $user->rights->categorie->creer) { } if (!$error && empty($object->error)) { $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error && $object->update($user) > 0) - { + if (!$error && $object->update($user) > 0) { if ($backtopage) { header("Location: ".$backtopage); exit; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index ff897db86a7..aa2dc20e2b2 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->load("categories"); -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); @@ -42,7 +44,9 @@ $catname = GETPOST('catname', 'alpha'); $nosearch = GETPOST('nosearch', 'int'); $categstatic = new Categorie($db); -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 +} /* @@ -54,11 +58,15 @@ $form = new Form($db); $moreparam = ($nosearch ? '&nosearch=1' : ''); $typetext = $type; -if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea'); -elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea'); -elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea'); -elseif ($type == Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea'); -else { +if ($type == Categorie::TYPE_ACCOUNT) { + $title = $langs->trans('AccountsCategoriesArea'); +} elseif ($type == Categorie::TYPE_WAREHOUSE) { + $title = $langs->trans('StocksCategoriesArea'); +} elseif ($type == Categorie::TYPE_ACTIONCOMM) { + $title = $langs->trans('ActionCommCategoriesArea'); +} elseif ($type == Categorie::TYPE_WEBSITE_PAGE) { + $title = $langs->trans('WebsitePagesCategoriesArea'); +} else { $title = $langs->trans(ucfirst($type).'sCategoriesArea'); } @@ -100,15 +108,13 @@ if (empty($nosearch)) { /* * Categories found */ - if ($catname || $id > 0) - { + if ($catname || $id > 0) { $cats = $categstatic->rechercher($id, $catname, $typetext); print ''; print ''; - foreach ($cats as $cat) - { + foreach ($cats as $cat) { $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; print "\t".''."\n"; @@ -128,7 +134,9 @@ if (empty($nosearch)) { print "\t\n"; } print "
'.$langs->trans("FoundCats").'
"; - } else print ' '; + } else { + print ' '; + } print ''; } @@ -143,19 +151,25 @@ $cate_arbo = $categstatic->get_full_arbo($typetext); $fulltree = $cate_arbo; // Load possible missing includes -if ($conf->global->CATEGORY_SHOW_COUNTS) -{ - if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +if ($conf->global->CATEGORY_SHOW_COUNTS) { + if ($type == Categorie::TYPE_MEMBER) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + } + if ($type == Categorie::TYPE_ACCOUNT) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + } + if ($type == Categorie::TYPE_PROJECT) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + } + if ($type == Categorie::TYPE_USER) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + } } // 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) -{ +foreach ($fulltree as $key => $val) { $categstatic->id = $val['id']; $categstatic->ref = $val['label']; $categstatic->color = $val['color']; @@ -163,8 +177,7 @@ foreach ($fulltree as $key => $val) $desc = dol_htmlcleanlastbr($val['description']); $counter = ''; - if ($conf->global->CATEGORY_SHOW_COUNTS) - { + if ($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database $elements = $type == Categorie::TYPE_ACCOUNT ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" @@ -206,15 +219,13 @@ foreach ($fulltree as $key => $val) print ''; print ''; $nbofentries = (count($data) - 1); -if ($nbofentries > 0) -{ +if ($nbofentries > 0) { print ''; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 536b0c20a2c..5666664b848 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -20,7 +20,7 @@ /** * \file htdocs/categories/info.php * \ingroup categories - * \brief Category info page + * \brief Category info page */ require '../main.inc.php'; @@ -40,7 +40,9 @@ $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); @@ -50,7 +52,9 @@ if ($result <= 0) { } $type = $object->type; -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 +} /* * View diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 6bb5d79980c..cfc722df83f 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -38,11 +38,10 @@ $langs->loadlangs(array('categories', 'bills')); $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -if ($id == '' && $label == '') -{ +if ($id == '' && $label == '') { dol_print_error('', 'Missing parameter id'); exit(); } @@ -57,7 +56,9 @@ if ($result <= 0) { } $type = $object->type; -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 +} $upload_dir = $conf->categorie->multidir_output[$object->entity]; @@ -65,16 +66,12 @@ $upload_dir = $conf->categorie->multidir_output[$object->entity]; * Actions */ -if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ +if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { $file = $_FILES['userfile']; - if (is_array($file['name']) && count($file['name']) > 0) - { - foreach ($file['name'] as $i => $name) - { - if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) - { + if (is_array($file['name']) && count($file['name']) > 0) { + foreach ($file['name'] as $i => $name) { + if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) { setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); } @@ -87,13 +84,11 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen } } -if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer) -{ +if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer) { $object->delete_photo($upload_dir."/".$_GET["file"]); } -if ($action == 'addthumb' && $_GET["file"]) -{ +if ($action == 'addthumb' && $_GET["file"]) { $object->addThumbs($upload_dir."/".$_GET["file"]); } @@ -107,8 +102,7 @@ llxHeader("", "", $langs->trans("Categories")); $form = new Form($db); $formother = new FormOther($db); -if ($object->id) -{ +if ($object->id) { $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); @@ -119,8 +113,7 @@ if ($object->id) $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); - foreach ($ways as $way) - { + foreach ($ways as $way) { $morehtmlref .= $way."
\n"; } $morehtmlref .= '
'; @@ -130,8 +123,7 @@ if ($object->id) /* * Confirmation de la suppression de photo */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); } @@ -168,10 +160,8 @@ if ($object->id) print '
'."\n"; - if ($action != 'ajout_photo' && $user->rights->categorie->creer) - { - if (!empty($conf->global->MAIN_UPLOAD_DOC)) - { + if ($action != 'ajout_photo' && $user->rights->categorie->creer) { + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { print ''; print $langs->trans("AddPhoto").''; } else { @@ -185,16 +175,14 @@ if ($object->id) /* * Ajouter une photo */ - if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) - { + if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); } // Affiche photos - if ($action != 'ajout_photo') - { + if ($action != 'ajout_photo') { $nbphoto = 0; $nbbyrow = 5; @@ -206,23 +194,24 @@ if ($object->id) $listofphoto = $object->liste_photos($dir); - if (is_array($listofphoto) && count($listofphoto)) - { + if (is_array($listofphoto) && count($listofphoto)) { print '
'; print '
'.$langs->trans("Categories").''; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ''; } print '
'; tree_recur($data, $data[0], 0); print '
'; - foreach ($listofphoto as $key => $obj) - { + foreach ($listofphoto as $key => $obj) { $nbphoto++; - if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print ''; - if ($nbbyrow) print ''; + } + if ($nbbyrow) { + print ''; - if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print ''; + if ($nbbyrow) { + print ''; + } + if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) { + print ''; + } } // Ferme tableau - while ($nbphoto % $nbbyrow) - { + while ($nbphoto % $nbbyrow) { print ''; $nbphoto++; } @@ -266,8 +256,7 @@ if ($object->id) print '
'; + if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) { + print '
'; + } print ''; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine - if ($obj['photo_vignette']) - { + if ($obj['photo_vignette']) { $filename = $obj['photo_vignette']; } else { $filename = $obj['photo']; @@ -243,22 +232,23 @@ if ($object->id) print '
'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites - if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) - { + if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) { print '
'.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; } - if ($user->rights->categorie->creer) - { + if ($user->rights->categorie->creer) { print ''; print img_delete().''; } - if ($nbbyrow) print '
 
'; } - if ($nbphoto < 1) - { + if ($nbphoto < 1) { print '
'.$langs->trans("NoPhotoYet")."
"; } } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 898484d0d51..9f2ed6936ef 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -35,13 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('categories', 'languages')); -$id = GETPOST('id', 'int'); -$label = GETPOST('label', 'alpha'); +$id = GETPOST('id', 'int'); +$label = GETPOST('label', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); -if ($id == '' && $label == '') -{ +if ($id == '' && $label == '') { dol_print_error('', 'Missing parameter id'); exit(); } @@ -56,7 +55,9 @@ if ($result <= 0) { } $type = $object->type; -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 @@ -64,8 +65,7 @@ if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backwar $error = 0; // retour a l'affichage des traduction si annulation -if ($cancel == $langs->trans("Cancel")) -{ +if ($cancel == $langs->trans("Cancel")) { $action = ''; } @@ -73,8 +73,7 @@ if ($cancel == $langs->trans("Cancel")) // Validation de l'ajout if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && -($user->rights->categorie->creer)) -{ +($user->rights->categorie->creer)) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -106,7 +105,9 @@ $cancel != $langs->trans("Cancel") && // sauvegarde en base $res = $object->setMultiLangs($user); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } } @@ -121,13 +122,11 @@ $cancel != $langs->trans("Cancel") && // Validation de l'edition if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && -($user->rights->categorie->creer)) -{ +($user->rights->categorie->creer)) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); - foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet - { + foreach ($object->multilangs as $key => $value) { // enregistrement des nouvelles valeurs dans l'objet $libelle = GETPOST('libelle-'.$key, 'alpha'); $desc = GETPOST('desc-'.$key); @@ -147,7 +146,9 @@ $cancel != $langs->trans("Cancel") && if (!$error) { $res = $object->setMultiLangs($user); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } if ($error) { @@ -175,10 +176,8 @@ $head = categories_prepare_head($object, $type); // Calculate $cnt_trans $cnt_trans = 0; -if (!empty($object->multilangs)) -{ - foreach ($object->multilangs as $key => $value) - { +if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { $cnt_trans++; } } @@ -232,12 +231,12 @@ print dol_get_fiche_end(); print "\n
\n"; -if ($action == '') -{ - if ($user->rights->produit->creer || $user->rights->service->creer) - { +if ($action == '') { + if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.$langs->trans('Add').''; - if ($cnt_trans > 0) print ''.$langs->trans('Update').''; + if ($cnt_trans > 0) { + print ''.$langs->trans('Update').''; + } } } @@ -245,8 +244,7 @@ print "\n
\n"; -if ($action == 'edit') -{ +if ($action == 'edit') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -256,10 +254,8 @@ if ($action == 'edit') print ''; print ''; - if (!empty($object->multilangs)) - { - foreach ($object->multilangs as $key => $value) - { + if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { print "
".$langs->trans('Language_'.$key)." :
"; print ''; @@ -287,27 +283,27 @@ if ($action == 'edit') print ''; print ''; -} elseif ($action != 'add') -{ - if ($cnt_trans) print '
'; +} elseif ($action != 'add') { + if ($cnt_trans) { + print '
'; + } - if (!empty($object->multilangs)) - { - foreach ($object->multilangs as $key => $value) - { + if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { $s = picto_from_langcode($key); print '
'; print ''; print ''; print ''; - if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) - { + if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } print '
'.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'; } } - if (!$cnt_trans && $action != 'add') print '
'.$langs->trans('NoTranslation').'
'; + if (!$cnt_trans && $action != 'add') { + print '
'.$langs->trans('NoTranslation').'
'; + } } @@ -315,8 +311,7 @@ if ($action == 'edit') * Form to add a new translation */ -if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) -{ +if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 187691293e4..7f19194a3c3 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -49,7 +49,7 @@ $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'categorylist'; // 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') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Load variable for pagination @@ -57,13 +57,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if ($id == "" && $label == "") -{ +if ($id == "" && $label == "") { dol_print_error('', 'Missing parameter id'); exit(); } @@ -78,7 +79,9 @@ if ($result <= 0) { } $type = $object->type; -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 +} $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); @@ -90,8 +93,7 @@ $hookmanager->initHooks(array('categorycard', 'globalcard')); * Actions */ -if ($confirm == 'no') -{ +if ($confirm == 'no') { if ($backtopage) { header("Location: ".$backtopage); exit; @@ -101,26 +103,21 @@ if ($confirm == 'no') $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Remove element from category -if ($id > 0 && $removeelem > 0) -{ - if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) - { +if ($id > 0 && $removeelem > 0) { + if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $tmpobject = new Product($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'product'; - } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) - { + } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'supplier'; - } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) - { + } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'customer'; - } elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) - { + } elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); @@ -130,20 +127,17 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) - { + } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $tmpobject = new Account($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'account'; - } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) - { + } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $tmpobject = new Project($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) - { + } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); $result = $tmpobject->fetch($removeelem); @@ -151,13 +145,13 @@ if ($id > 0 && $removeelem > 0) } $result = $object->del_type($tmpobject, $elementtype); - if ($result < 0) dol_print_error('', $object->error); + if ($result < 0) { + dol_print_error('', $object->error); + } } -if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') -{ - if ($object->delete($user) >= 0) - { +if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { + if ($object->delete($user) >= 0) { if ($backtopage) { header("Location: ".$backtopage); exit; @@ -174,20 +168,16 @@ if ($elemid && $action == 'addintocategory' && (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) - )) -{ - if ($type == Categorie::TYPE_PRODUCT) - { + )) { + if ($type == Categorie::TYPE_PRODUCT) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $newobject = new Product($db); $elementtype = 'product'; - } elseif ($type == Categorie::TYPE_CUSTOMER) - { + } elseif ($type == Categorie::TYPE_CUSTOMER) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); $elementtype = 'customer'; - } elseif ($type == Categorie::TYPE_SUPPLIER) - { + } elseif ($type == Categorie::TYPE_SUPPLIER) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); $elementtype = 'supplier'; @@ -196,12 +186,10 @@ if ($elemid && $action == 'addintocategory' && // TODO Add into categ $result = $object->add_type($newobject, $elementtype); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); } else { - if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -233,8 +221,7 @@ $object->next_prev_filter = ' type = '.$object->type; $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); -foreach ($ways as $way) -{ +foreach ($ways as $way) { $morehtmlref .= $way."
\n"; } $morehtmlref .= '
'; @@ -246,8 +233,7 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la * Confirmation suppression */ -if ($action == 'delete') -{ +if ($action == 'delete') { if ($backtopage) { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2); } else { @@ -288,16 +274,16 @@ print dol_get_fiche_end(); print "
\n"; $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { - if ($user->rights->categorie->creer) - { + if ($user->rights->categorie->creer) { $socid = ($object->socid ? "&socid=".$object->socid : ""); print ''.$langs->trans("Modify").''; } - if ($user->rights->categorie->supprimer) - { + if ($user->rights->categorie->supprimer) { print 'id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").''; } } @@ -305,8 +291,7 @@ if (empty($reshook)) { print "
"; $newcardbutton = ''; -if (!empty($user->rights->categorie->creer)) -{ +if (!empty($user->rights->categorie->creer)) { $link = DOL_URL_ROOT.'/categories/card.php'; $link .= '?action=create'; $link .= '&type='.$type; @@ -335,8 +320,7 @@ print '
'.$langs->trans("SubCats").''; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print '
'; print ''.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").''; print " | "; @@ -348,11 +332,9 @@ print '
'.$langs->trans("NoSubCat").'
'; @@ -465,19 +451,16 @@ $typeid = $type; // List of products or services (type is type of category) -if ($type == Categorie::TYPE_PRODUCT) -{ +if ($type == Categorie::TYPE_PRODUCT) { $permission = ($user->rights->produit->creer || $user->rights->service->creer); $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($prods < 0) - { + if ($prods < 0) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category $showclassifyform = 1; - if ($showclassifyform) - { + if ($showclassifyform) { print '
'; print '
'; print ''; @@ -510,13 +493,13 @@ if ($type == Categorie::TYPE_PRODUCT) print ''."\n"; print ''."\n"; - if (count($prods) > 0) - { + if (count($prods) > 0) { $i = 0; - foreach ($prods as $prod) - { + foreach ($prods as $prod) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; print ''; print ''; - if ($num) - { + if ($num) { $i = 0; $tot_ttc = 0; $othernb = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -822,8 +836,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) /* * Customers orders to be billed */ -if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) -{ +if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { $commandestatic = new Commande($db); $langs->load("orders"); @@ -834,14 +847,20 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,"; $sql .= " cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ", ".MAIN_DB_PREFIX."commande as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'"; $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $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; + } + if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; + } $sql .= " AND c.fk_statut = ".Commande::STATUS_CLOSED; $sql .= " AND c.facture = 0"; // Add where from hooks @@ -852,12 +871,10 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_tva, c.total_ttc, cc.rowid, cc.code"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; $othernb = 0; @@ -872,7 +889,9 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -880,8 +899,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $tot_ht = $tot_ttc = $tot_tobill = 0; $societestatic = new Societe($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -930,7 +948,9 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -951,7 +971,9 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user } print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -967,8 +989,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user /* * Unpaid customers invoices */ -if (!empty($conf->facture->enabled) && $user->rights->facture->lire) -{ +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $tmpinvoice = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; @@ -980,11 +1001,17 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); @@ -995,8 +1022,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= " ORDER BY f.datef ASC, f.ref ASC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $othernb = 0; @@ -1013,17 +1039,17 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print ''; - if ($num) - { + if ($num) { $societestatic = new Societe($db); $total_ttc = $totalam = $total = 0; - while ($i < $num && $i < $conf->liste_limit) - { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -1079,7 +1105,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print $societestatic->getNomUrl(1, 'customer'); print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -1094,7 +1122,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if ($othernb) { $colspan = 6; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print ''; } else { $colspan = 6; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; } print '
'.$langs->trans("Ref").'
'; @@ -525,8 +508,7 @@ if ($type == Categorie::TYPE_PRODUCT) print ''.$prod->label."'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -544,19 +526,16 @@ if ($type == Categorie::TYPE_PRODUCT) } } -if ($type == Categorie::TYPE_CUSTOMER) -{ +if ($type == Categorie::TYPE_CUSTOMER) { $permission = $user->rights->societe->creer; $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($socs < 0) - { + if ($socs < 0) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category $showclassifyform = 1; - if ($showclassifyform) - { + if ($showclassifyform) { print '
'; print ''; print ''; @@ -588,13 +567,13 @@ if ($type == Categorie::TYPE_CUSTOMER) print ''."\n"; print ''."\n"; - if (count($socs) > 0) - { + if (count($socs) > 0) { $i = 0; - foreach ($socs as $key => $soc) - { + foreach ($socs as $key => $soc) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; print ''; print ''; - if ($num) - { + if ($num) { $total_ttc = $totalam = $total = 0; - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $objp = $db->fetch_object($result); if ($i >= $max) { @@ -694,7 +709,9 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) $donationstatic->status = $objp->status; $label = $donationstatic->getFullName($langs); - if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe; + if ($objp->societe) { + $label .= ($label ? ' - ' : '').$objp->societe; + } print ''; print ''; @@ -718,16 +735,16 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) print ''; } print '
'.$langs->trans("Name").'
'; @@ -602,8 +581,7 @@ if ($type == Categorie::TYPE_CUSTOMER) print "'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -622,19 +600,16 @@ if ($type == Categorie::TYPE_CUSTOMER) } -if ($type == Categorie::TYPE_SUPPLIER) -{ +if ($type == Categorie::TYPE_SUPPLIER) { $permission = $user->rights->societe->creer; $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($socs < 0) - { + if ($socs < 0) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category $showclassifyform = 1; - if ($showclassifyform) - { + if ($showclassifyform) { print '
'; print ''; print ''; @@ -666,13 +641,13 @@ if ($type == Categorie::TYPE_SUPPLIER) print ''."\n"; print '\n"; - if (count($socs) > 0) - { + if (count($socs) > 0) { $i = 0; - foreach ($socs as $soc) - { + foreach ($socs as $soc) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; $result .= ''; $result .= ''; - } - elseif ($total > 0) - { + } elseif ($total > 0) { $result .= ''; $result .= ''; $result .= ''; diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index f26f4ea0255..97646d56103 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -71,15 +71,14 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') + if ($user->rights->facture->creer) { + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $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 .= ''; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 6f3f8088a63..d45439286fb 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -59,9 +59,13 @@ $socid = GETPOST('socid', 'int'); $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $lineid = GETPOST('lineid', 'int'); $ref = GETPOST('ref', 'alpha'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $objecttype = 'facture_rec'; -if ($action == "create" || $action == "add") $objecttype = ''; +if ($action == "create" || $action == "add") { + $objecttype = ''; +} $result = restrictedArea($user, 'facture', $id, $objecttype); $search_ref = GETPOST('search_ref'); @@ -86,19 +90,23 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (!$sortorder) $sortorder = 'DESC'; -if (!$sortfield) $sortfield = 'f.titre'; +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'f.titre'; +} $pageprev = $page - 1; $pagenext = $page + 1; $object = new FactureRec($db); -if (($id > 0 || $ref) && $action != 'create' && $action != 'add') -{ +if (($id > 0 || $ref) && $action != 'create' && $action != 'add') { $ret = $object->fetch($id, $ref); - if (!$ret) - { + if (!$ret) { setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); } } @@ -143,37 +151,47 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if ($socid > 0) { $tmpthirdparty = new Societe($db); $res = $tmpthirdparty->fetch($socid); - if ($res > 0) $search_societe = $tmpthirdparty->name; + if ($res > 0) { + $search_societe = $tmpthirdparty->name; + } } if ($socid > 0) { $tmpthirdparty = new Societe($db); $res = $tmpthirdparty->fetch($socid); - if ($res > 0) $search_societe = $tmpthirdparty->name; + if ($res > 0) { + $search_societe = $tmpthirdparty->name; + } } /* * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array('socid' => $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if (GETPOST('cancel', 'alpha')) $action = ''; +if (empty($reshook)) { + if (GETPOST('cancel', 'alpha')) { + $action = ''; + } // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_ref = ''; $search_societe = ''; $search_montant_ht = ''; @@ -196,11 +214,11 @@ if (empty($reshook)) // Mass actions /*$objectclass='MyObject'; - $objectlabel='MyObject'; - $permissiontoread = $user->rights->mymodule->read; - $permissiontodelete = $user->rights->mymodule->delete; - $uploaddir = $conf->mymodule->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ + $objectlabel='MyObject'; + $permissiontoread = $user->rights->mymodule->read; + $permissiontodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ } @@ -212,7 +230,9 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $companystatic = new Societe($db); $invoicerectmp = new FactureRec($db); @@ -231,7 +251,9 @@ $sql .= " f.datec, f.tms,"; $sql .= " f.fk_cond_reglement, f.fk_mode_reglement"; // 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 : ''); + 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(); @@ -249,23 +271,52 @@ $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_ref) $sql .= natural_search('f.titre', $search_ref); -if ($socid) $sql .= ' AND s.rowid = '.(int) $socid; -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); -if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); -if (!empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); -if (!empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); -if ($search_recurring == '1') $sql .= ' AND f.frequency > 0'; -if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; -if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1); -if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); -if ($search_status != '' && $search_status >= -1) -{ - if ($search_status == 0) $sql .= ' AND frequency = 0 AND suspended = 0'; - if ($search_status == 1) $sql .= ' AND frequency != 0 AND suspended = 0'; - if ($search_status == -1) $sql .= ' AND suspended = 1'; +if ($search_ref) { + $sql .= natural_search('f.titre', $search_ref); +} +if ($socid) { + $sql .= ' AND s.rowid = '.(int) $socid; +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); +} +if ($search_montant_ht != '') { + $sql .= natural_search('f.total', $search_montant_ht, 1); +} +if ($search_montant_vat != '') { + $sql .= natural_search('f.tva', $search_montant_vat, 1); +} +if ($search_montant_ttc != '') { + $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +} +if (!empty($search_payment_mode) && $search_payment_mode != '-1') { + $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); +} +if (!empty($search_payment_term) && $search_payment_term != '-1') { + $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); +} +if ($search_recurring == '1') { + $sql .= ' AND f.frequency > 0'; +} +if ($search_recurring == '0') { + $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; +} +if ($search_frequency != '') { + $sql .= natural_search('f.frequency', $search_frequency, 1); +} +if ($search_unit_frequency != '') { + $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); +} +if ($search_status != '' && $search_status >= -1) { + if ($search_status == 0) { + $sql .= ' AND frequency = 0 AND suspended = 0'; + } + if ($search_status == 1) { + $sql .= ' AND frequency != 0 AND suspended = 0'; + } + if ($search_status == -1) { + $sql .= ' AND suspended = 1'; + } } $sql .= dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.date_when', $search_day_date_when, $search_month_date_when, $search_year_date_when); @@ -273,12 +324,10 @@ $sql .= dolSqlDateFilter('f.date_when', $search_day_date_when, $search_month_dat $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -287,32 +336,73 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($socid > 0) $param .= '&socid='.urlencode($socid); - if ($search_day) $param .= '&search_day='.urlencode($search_day); - if ($search_month) $param .= '&search_month='.urlencode($search_month); - if ($search_year) $param .= '&search_year='.urlencode($search_year); - if ($search_day_date_when) $param .= '&search_day_date_when='.urlencode($search_day_date_when); - if ($search_month_date_when) $param .= '&search_month_date_when='.urlencode($search_month_date_when); - if ($search_year_date_when) $param .= '&search_year_date_when='.urlencode($search_year_date_when); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); - if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); - if ($search_payment_term != '') $param .= '&search_payment_term='.urlencode($search_payment_term); - if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); - if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); - if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_day) { + $param .= '&search_day='.urlencode($search_day); + } + if ($search_month) { + $param .= '&search_month='.urlencode($search_month); + } + if ($search_year) { + $param .= '&search_year='.urlencode($search_year); + } + if ($search_day_date_when) { + $param .= '&search_day_date_when='.urlencode($search_day_date_when); + } + if ($search_month_date_when) { + $param .= '&search_month_date_when='.urlencode($search_month_date_when); + } + if ($search_year_date_when) { + $param .= '&search_year_date_when='.urlencode($search_year_date_when); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_societe) { + $param .= '&search_societe='.urlencode($search_societe); + } + if ($search_montant_ht != '') { + $param .= '&search_montant_ht='.urlencode($search_montant_ht); + } + if ($search_montant_vat != '') { + $param .= '&search_montant_vat='.urlencode($search_montant_vat); + } + if ($search_montant_ttc != '') { + $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + } + if ($search_payment_mode != '') { + $param .= '&search_payment_mode='.urlencode($search_payment_mode); + } + if ($search_payment_term != '') { + $param .= '&search_payment_term='.urlencode($search_payment_term); + } + if ($search_recurring != '' && $search_recurrning != '-1') { + $param .= '&search_recurring='.urlencode($search_recurring); + } + if ($search_frequency > 0) { + $param .= '&search_frequency='.urlencode($search_frequency); + } + if ($search_unit_frequency != '') { + $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -323,7 +413,9 @@ if ($resql) //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -348,93 +440,84 @@ if ($resql) // Filters lines print ''; // Ref - if (!empty($arrayfields['f.titre']['checked'])) - { + if (!empty($arrayfields['f.titre']['checked'])) { print ''; } // Thirpdarty - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (!empty($arrayfields['f.total']['checked'])) - { + if (!empty($arrayfields['f.total']['checked'])) { // Amount net print ''; } - if (!empty($arrayfields['f.tva']['checked'])) - { + if (!empty($arrayfields['f.tva']['checked'])) { // Amount Vat print ''; } - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { // Payment term print '"; } - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { // Payment mode print ''; } - if (!empty($arrayfields['recurring']['checked'])) - { + if (!empty($arrayfields['recurring']['checked'])) { // Recurring or not print ''; } - if (!empty($arrayfields['f.frequency']['checked'])) - { + if (!empty($arrayfields['f.frequency']['checked'])) { // Recurring or not print ''; } - if (!empty($arrayfields['f.unit_frequency']['checked'])) - { + if (!empty($arrayfields['f.unit_frequency']['checked'])) { // Frequency unit print ''; } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) - { + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { // Nb generation print ''; } // Date invoice - if (!empty($arrayfields['f.date_last_gen']['checked'])) - { + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; } // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) - { + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; @@ -447,20 +530,17 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } // Status - if (!empty($arrayfields['status']['checked'])) - { + if (!empty($arrayfields['status']['checked'])) { print '\n"; print ''; - if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.titre']['checked'])) { + print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total']['checked'])) { + print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.tva']['checked'])) { + print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['recurring']['checked'])) { + print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.unit_frequency']['checked'])) { + print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { + print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date_last_gen']['checked'])) { + print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date_when']['checked'])) { + print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['status']['checked'])) { + print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - if ($num > 0) - { + if ($num > 0) { $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - if (empty($objp)) break; + if (empty($objp)) { + break; + } $companystatic->id = $objp->socid; $companystatic->name = $objp->name; @@ -521,115 +633,137 @@ if ($resql) print ''; - if (!empty($arrayfields['f.titre']['checked'])) - { + if (!empty($arrayfields['f.titre']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.total']['checked'])) - { + if (!empty($arrayfields['f.total']['checked'])) { print ''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; + } $totalarray['val']['f.total'] += $objp->total; } - if (!empty($arrayfields['f.tva']['checked'])) - { + if (!empty($arrayfields['f.tva']['checked'])) { print ''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; + } $totalarray['val']['f.tva'] += $objp->total_vat; } - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { print ''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['recurring']['checked'])) - { + if (!empty($arrayfields['recurring']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.frequency']['checked'])) - { + if (!empty($arrayfields['f.frequency']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.unit_frequency']['checked'])) - { + if (!empty($arrayfields['f.unit_frequency']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.nb_gen_done']['checked'])) - { + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date last generation - if (!empty($arrayfields['f.date_last_gen']['checked'])) - { + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date next generation - if (!empty($arrayfields['f.date_when']['checked'])) - { + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } $obj = $objp; @@ -644,17 +778,16 @@ if ($resql) print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '"; print "\n"; @@ -672,7 +807,11 @@ if ($resql) } } else { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 249df885435..9f5281dc20b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -52,7 +52,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->commande->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('bills', 'companies', 'products', 'categories')); @@ -71,8 +73,7 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicelist'; -if ($contextpage == 'poslist') -{ +if ($contextpage == 'poslist') { $_GET['optioncss'] = 'print'; } @@ -129,17 +130,27 @@ $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 (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; -if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; -if (!$sortorder) $sortorder = 'DESC'; -if (!$sortfield) $sortfield = 'f.datef'; +if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') { + $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'f.datef'; +} $pageprev = $page - 1; $pagenext = $page + 1; // Security check $fieldid = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $diroutputmassaction = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id; @@ -169,7 +180,9 @@ $fieldstosearchall = array( 's.town'=>"Town", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall["f.note_private"] = "NotePrivate"; +} $checkedtypetiers = 0; $arrayfields = array( @@ -219,8 +232,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_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); } @@ -235,18 +247,23 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) // All tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) { // All tests are required to be compatible with all browsers $search_user = ''; $search_sale = ''; $search_product_category = ''; @@ -292,8 +309,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_categ_cus = 0; } -if (empty($reshook)) -{ +if (empty($reshook)) { $objectclass = 'Facture'; $objectlabel = 'Invoices'; $permissiontoread = $user->rights->facture->lire; @@ -322,8 +338,7 @@ if ($massaction == 'makepayment') { $arrayofselected = is_array($toselect) ? $toselect : array(); $listofbills = array(); - foreach ($arrayofselected as $toselectid) - { + foreach ($arrayofselected as $toselectid) { $objecttmp = new Facture($db); $result = $objecttmp->fetch($toselectid); if ($result > 0) { @@ -355,8 +370,7 @@ if ($massaction == 'makepayment') { $rsql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($rsql); - if ($result_sql) - { + if ($result_sql) { $numprlv = $db->num_rows($result_sql); } @@ -373,15 +387,12 @@ if ($massaction == 'makepayment') { } //Massive withdraw request for request with no errors - if (!empty($listofbills)) - { + if (!empty($listofbills)) { $nbwithdrawrequestok = 0; - foreach ($listofbills as $aBill) - { + foreach ($listofbills as $aBill) { $db->begin(); $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'direct-debit', 'facture'); - if ($result > 0) - { + if ($result > 0) { $db->commit(); $nbwithdrawrequestok++; } else { @@ -389,8 +400,7 @@ if ($massaction == 'makepayment') { setEventMessages($aBill->error, $aBill->errors, 'errors'); } } - if ($nbwithdrawrequestok > 0) - { + if ($nbwithdrawrequestok > 0) { setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs'); } } @@ -416,7 +426,9 @@ $formcompany = new FormCompany($db); $thirdpartystatic = new Societe($db); $sql = 'SELECT'; -if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) { + $sql = 'SELECT DISTINCT'; +} $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.fk_user_author,'; @@ -433,11 +445,17 @@ $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label, $sql .= " u.login"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed'; -if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; +if (!$sall) { + $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed'; +} +if ($search_categ_cus) { + $sql .= ", cc.fk_categorie, cc.fk_soc"; +} // 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 : ''); + 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(); @@ -447,96 +465,196 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ_cus)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +} $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; -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 (f.rowid = ef.fk_object)"; -if (!$sall) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; -if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; -if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +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 (f.rowid = ef.fk_object)"; +} +if (!$sall) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; +} +if ($sall || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); -if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; -if ($userid) -{ - if ($userid == -1) $sql .= ' AND f.fk_user_author IS NULL'; - else $sql .= ' AND f.fk_user_author = '.$userid; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($filtre) -{ +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); +} +if ($socid > 0) { + $sql .= ' AND s.rowid = '.$socid; +} +if ($userid) { + if ($userid == -1) { + $sql .= ' AND f.fk_user_author IS NULL'; + } else { + $sql .= ' AND f.fk_user_author = '.$userid; + } +} +if ($filtre) { $aFilter = explode(',', $filtre); - foreach ($aFilter as $filter) - { + foreach ($aFilter as $filter) { $filt = explode(':', $filter); $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } -if ($search_ref) $sql .= natural_search('f.ref', $search_ref); -if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); -if ($search_type != '' && $search_type != '-1') $sql .= " AND f.type IN (".$db->sanitize($db->escape($search_type)).")"; -if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); -if ($search_project) $sql .= natural_search('p.title', $search_project); -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias); -if ($search_town) $sql .= natural_search('s.town', $search_town); -if ($search_zip) $sql .= natural_search("s.zip", $search_zip); -if ($search_state) $sql .= natural_search("state.nom", $search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; -if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias); -if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); -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_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); -if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); -if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; -if ($search_status != '-1' && $search_status != '') -{ - if (is_numeric($search_status) && $search_status >= 0) - { - if ($search_status == '0') $sql .= " AND f.fk_statut = 0"; // draft - if ($search_status == '1') $sql .= " AND f.fk_statut = 1"; // unpayed - if ($search_status == '2') $sql .= " AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) - if ($search_status == '3') $sql .= " AND f.fk_statut = 3"; // abandonned +if ($search_ref) { + $sql .= natural_search('f.ref', $search_ref); +} +if ($search_refcustomer) { + $sql .= natural_search('f.ref_client', $search_refcustomer); +} +if ($search_type != '' && $search_type != '-1') { + $sql .= " AND f.type IN (".$db->sanitize($db->escape($search_type)).")"; +} +if ($search_project_ref) { + $sql .= natural_search('p.ref', $search_project_ref); +} +if ($search_project) { + $sql .= natural_search('p.title', $search_project); +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); +} +if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); +} +if ($search_town) { + $sql .= natural_search('s.town', $search_town); +} +if ($search_zip) { + $sql .= natural_search("s.zip", $search_zip); +} +if ($search_state) { + $sql .= natural_search("state.nom", $search_state); +} +if ($search_country) { + $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; +} +if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') { + $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} +if ($search_montant_ht != '') { + $sql .= natural_search('f.total', $search_montant_ht, 1); +} +if ($search_montant_vat != '') { + $sql .= natural_search('f.tva', $search_montant_vat, 1); +} +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_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); +} +if ($search_multicurrency_montant_ttc != '') { + $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +} +if ($search_login) { + $sql .= natural_search('u.login', $search_login); +} +if ($search_categ_cus > 0) { + $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +} +if ($search_categ_cus == -2) { + $sql .= " AND cc.fk_categorie IS NULL"; +} +if ($search_status != '-1' && $search_status != '') { + if (is_numeric($search_status) && $search_status >= 0) { + if ($search_status == '0') { + $sql .= " AND f.fk_statut = 0"; // draft + } + if ($search_status == '1') { + $sql .= " AND f.fk_statut = 1"; // unpayed + } + if ($search_status == '2') { + $sql .= " AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) + } + if ($search_status == '3') { + $sql .= " AND f.fk_statut = 3"; // abandonned + } } else { $sql .= " AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; // When search_status is '1,2' for example } } -if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); -if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); -if ($search_module_source) $sql .= natural_search("f.module_source", $search_module_source); -if ($search_pos_source) $sql .= natural_search("f.pos_source", $search_pos_source); -if ($search_date_start) $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; -if ($search_date_end) $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; -if ($search_date_valid_start) $sql .= " AND f.date_valid >= '".$db->idate($search_date_valid_start)."'"; -if ($search_date_valid_end) $sql .= " AND f.date_valid <= '".$db->idate($search_date_valid_end)."'"; -if ($search_datelimit_start) $sql .= " AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start)."'"; -if ($search_datelimit_end) $sql .= " AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end)."'"; -if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; -if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale; -if ($search_user > 0) -{ +if ($search_paymentmode > 0) { + $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); +} +if ($search_paymentterms > 0) { + $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); +} +if ($search_module_source) { + $sql .= natural_search("f.module_source", $search_module_source); +} +if ($search_pos_source) { + $sql .= natural_search("f.pos_source", $search_pos_source); +} +if ($search_date_start) { + $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +} +if ($search_date_valid_start) { + $sql .= " AND f.date_valid >= '".$db->idate($search_date_valid_start)."'"; +} +if ($search_date_valid_end) { + $sql .= " AND f.date_valid <= '".$db->idate($search_date_valid_end)."'"; +} +if ($search_datelimit_start) { + $sql .= " AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start)."'"; +} +if ($search_datelimit_end) { + $sql .= " AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end)."'"; +} +if ($option == 'late') { + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; +} +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale; +} +if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields @@ -546,8 +664,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if (!$sall) -{ +if (!$sall) { $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; $sql .= ' f.localtax1, f.localtax2,'; $sql .= ' f.datef, f.date_valid, f.date_lim_reglement, f.module_source, f.pos_source,'; @@ -562,10 +679,14 @@ if (!$sall) $sql .= ' country.code,'; $sql .= " p.rowid, p.ref, p.title,"; $sql .= " u.login"; - if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + if ($search_categ_cus) { + $sql .= ", cc.fk_categorie, cc.fk_soc"; + } // 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 : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + } } } else { $sql .= natural_search(array_keys($fieldstosearchall), $sall); @@ -574,16 +695,16 @@ if (!$sall) $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield); $listorder = explode(',', $sortorder); -foreach ($listfield as $key => $value) $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; +foreach ($listfield as $key => $value) { + $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; +} $sql .= ' f.rowid DESC '; $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -593,14 +714,12 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) - { + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->id; @@ -610,55 +729,138 @@ if ($resql) llxHeader('', $langs->trans('CustomersInvoices'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); - if ($socid) - { + if ($socid) { $soc = new Societe($db); $soc->fetch($socid); - if (empty($search_societe)) $search_societe = $soc->name; + if (empty($search_societe)) { + $search_societe = $soc->name; + } } $param = '&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= '&sall='.urlencode($sall); - if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); - if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); - if ($search_date_valid_start) $param .= '&search_date_valid_start='.urlencode($search_date_valid_start); - if ($search_date_valid_end) $param .= '&search_date_valid_end='.urlencode($search_date_valid_end); - if ($search_datelimit_start) $param .= '&search_datelimit_start='.urlencode($search_datelimit_start); - if ($search_datelimit_end) $param .= '&search_datelimit_end='.urlencode($search_datelimit_end); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); - if ($search_project_ref) $param .= '&search_project_ref='.urlencode($search_project_ref); - if ($search_project) $param .= '&search_project='.urlencode($search_project); - if ($search_type != '') $param .= '&search_type='.urlencode($search_type); - if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); - if ($search_societe_alias) $param .= '&search_societe_alias='.urlencode($search_societe_alias); - if ($search_town) $param .= '&search_town='.urlencode($search_town); - if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); - if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_login) $param .= '&search_login='.urlencode($search_login); - if ($search_product_category > 0) $param .= '&search_product_category='.urlencode($search_product_category); - if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); - if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); - if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); - if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); - if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode); - if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms); - if ($search_module_source) $param .= '&search_module_source='.urlencode($search_module_source); - if ($search_pos_source) $param .= '&search_pos_source='.urlencode($search_pos_source); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($option) $param .= "&search_option=".urlencode($option); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($search_date_start) { + $param .= '&search_date_start='.urlencode($search_date_start); + } + if ($search_date_end) { + $param .= '&search_date_end='.urlencode($search_date_end); + } + if ($search_date_valid_start) { + $param .= '&search_date_valid_start='.urlencode($search_date_valid_start); + } + if ($search_date_valid_end) { + $param .= '&search_date_valid_end='.urlencode($search_date_valid_end); + } + if ($search_datelimit_start) { + $param .= '&search_datelimit_start='.urlencode($search_datelimit_start); + } + if ($search_datelimit_end) { + $param .= '&search_datelimit_end='.urlencode($search_datelimit_end); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_refcustomer) { + $param .= '&search_refcustomer='.urlencode($search_refcustomer); + } + if ($search_project_ref) { + $param .= '&search_project_ref='.urlencode($search_project_ref); + } + if ($search_project) { + $param .= '&search_project='.urlencode($search_project); + } + if ($search_type != '') { + $param .= '&search_type='.urlencode($search_type); + } + if ($search_societe) { + $param .= '&search_societe='.urlencode($search_societe); + } + if ($search_societe_alias) { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); + } + if ($search_town) { + $param .= '&search_town='.urlencode($search_town); + } + if ($search_zip) { + $param .= '&search_zip='.urlencode($search_zip); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } + if ($search_product_category > 0) { + $param .= '&search_product_category='.urlencode($search_product_category); + } + if ($search_montant_ht != '') { + $param .= '&search_montant_ht='.urlencode($search_montant_ht); + } + if ($search_montant_vat != '') { + $param .= '&search_montant_vat='.urlencode($search_montant_vat); + } + if ($search_montant_localtax1 != '') { + $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + } + if ($search_montant_localtax2 != '') { + $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + } + if ($search_montant_ttc != '') { + $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + } + if ($search_multicurrency_code != '') { + $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + } + if ($search_multicurrency_tx != '') { + $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + } + if ($search_multicurrency_montant_ht != '') { + $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + } + if ($search_multicurrency_montant_vat != '') { + $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + } + if ($search_multicurrency_montant_ttc != '') { + $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_paymentmode > 0) { + $param .= '&search_paymentmode='.urlencode($search_paymentmode); + } + if ($search_paymentterms > 0) { + $param .= '&search_paymentterms='.urlencode($search_paymentterms); + } + if ($search_module_source) { + $param .= '&search_module_source='.urlencode($search_module_source); + } + if ($search_pos_source) { + $param .= '&search_pos_source='.urlencode($search_pos_source); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($option) { + $param .= "&search_option=".urlencode($option); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_categ_cus > 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -681,21 +883,26 @@ if ($resql) $arrayofmassactions['predelete'] = $langs->trans("Delete"); } } - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Show the new button only when this page is not opend from the Extended POS - if ($contextpage != 'poslist') - { + if ($contextpage != 'poslist') { $url = DOL_URL_ROOT.'/compta/facture/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->rights->facture->creer); } $i = 0; print ''."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -712,33 +919,31 @@ if ($resql) $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - // If the user can view prospects other than his' - $moreforfilter = ''; - if ($user->rights->societe->client->voir || $socid) - { - $langs->load("commercial"); - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter .= '
'; - } // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { + $moreforfilter = ''; + if ($user->rights->societe->client->voir || $socid) { + $langs->load("commercial"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; + } + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
'; $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter .= '
'; + $moreforfilter .= ''; } // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) - { + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -746,22 +951,23 @@ if ($resql) $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
'; } - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) - { + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter .= '
'; + $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; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if ($moreforfilter) - { - print '
'; + if ($moreforfilter) { + print '
'; print $moreforfilter; print '
'; } @@ -769,7 +975,9 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // Show the massaction checkboxes only when this page is not opend from the Extended POS - if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton && $contextpage != 'poslist') { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '
'; print '
'.$langs->trans("Name")."
'; @@ -680,8 +655,7 @@ if ($type == Categorie::TYPE_SUPPLIER) print "'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -701,15 +675,13 @@ if ($type == Categorie::TYPE_SUPPLIER) } // List of members -if ($type == Categorie::TYPE_MEMBER) -{ +if ($type == Categorie::TYPE_MEMBER) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $permission = $user->rights->adherent->creer; $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($prods < 0) - { + if ($prods < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -726,13 +698,13 @@ if ($type == Categorie::TYPE_MEMBER) print "\n"; print ''."\n"; - if (count($prods) > 0) - { + if (count($prods) > 0) { $i = 0; - foreach ($prods as $key => $member) - { + foreach ($prods as $key => $member) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; $result .= ''; - if ($num < 1) - { + if ($num < 1) { $result .= '
'.$langs->trans("Name").'
'; @@ -743,8 +715,7 @@ if ($type == Categorie::TYPE_MEMBER) print ''.$member->firstname."'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -762,13 +733,11 @@ if ($type == Categorie::TYPE_MEMBER) } // Categorie contact -if ($type == Categorie::TYPE_CONTACT) -{ +if ($type == Categorie::TYPE_CONTACT) { $permission = $user->rights->societe->creer; $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($contacts < 0) - { + if ($contacts < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -788,13 +757,13 @@ if ($type == Categorie::TYPE_CONTACT) print ''."\n"; print ''."\n"; - if (count($contacts) > 0) - { + if (count($contacts) > 0) { $i = 0; - foreach ($contacts as $key => $contact) - { + foreach ($contacts as $key => $contact) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; $result .= ''; $result .= ''; - } - elseif ($total > 0) - { + } elseif ($total > 0) { $result .= ''; $result .= ''; $result .= ''; @@ -325,17 +323,22 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $sql .= " f.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture').")"; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.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 f.tms DESC"; $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); } @@ -348,8 +351,7 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $result .= ''; $result .= ''; - if ($num < 1) - { + if ($num < 1) { $result .= '
'.$langs->trans("Ref").'
'; @@ -802,8 +771,7 @@ if ($type == Categorie::TYPE_CONTACT) print "'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -822,15 +790,13 @@ if ($type == Categorie::TYPE_CONTACT) } // List of bank accounts -if ($type == Categorie::TYPE_ACCOUNT) -{ +if ($type == Categorie::TYPE_ACCOUNT) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $permission = $user->rights->banque->creer; $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($accounts < 0) - { + if ($accounts < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -847,13 +813,13 @@ if ($type == Categorie::TYPE_ACCOUNT) print "\n"; print ''."\n"; - if (count($accounts) > 0) - { + if (count($accounts) > 0) { $i = 0; - foreach ($accounts as $key => $account) - { + foreach ($accounts as $key => $account) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; print ''; print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4597,7 +4729,9 @@ if ($action == 'create') print ''; print ''; print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4615,7 +4749,9 @@ if ($action == 'create') print ''; print ''; print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4629,12 +4765,16 @@ if ($action == 'create') foreach ($current_situation_counter as $sit) { $curSign = $sit > 0 ? '+' : '-'; $curType = $sit > 0 ? $langs->trans('situationInvoiceShortcode_S') : $langs->trans('situationInvoiceShortcode_AS'); - if ($i > 0) print ' '.$curSign.' '; + if ($i > 0) { + print ' '.$curSign.' '; + } print $curType.abs($sit); $i++; } print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4644,14 +4784,14 @@ if ($action == 'create') if (count($object->tab_next_situation_invoice) > 0) { // List of next invoices /*print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print '';*/ + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print '';*/ $total_next_ht = $total_next_ttc = 0; @@ -4664,7 +4804,9 @@ if ($action == 'create') print ''; print ''; print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4676,7 +4818,9 @@ if ($action == 'create') print ''; print ''; - if (!empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } print ''; print ''; print ''; @@ -4687,7 +4831,9 @@ if ($action == 'create') } $sign = 1; - if ($object->type == $object::TYPE_CREDIT_NOTE) $sign = -1; + if ($object->type == $object::TYPE_CREDIT_NOTE) { + $sign = -1; + } // List of payments already done @@ -4816,10 +4962,12 @@ if ($action == 'create') $invoice->fetch($obj->fk_facture_source); print ''; @@ -4828,10 +4976,12 @@ if ($action == 'create') print 'rowid.'">'.img_delete().''; print ''; $i++; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { $creditnoteamount += $obj->amount_ttc; - if ($invoice->type == Facture::TYPE_DEPOSIT) + } + if ($invoice->type == Facture::TYPE_DEPOSIT) { $depositamount += $obj->amount_ttc; + } } } else { dol_print_error($db); @@ -4871,8 +5021,9 @@ if ($action == 'create') if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'abandon') { print ''; print ''; print ''; @@ -5093,10 +5245,8 @@ if ($action == 'create') || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data - && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely) - { - if ($object->close_code != 'replaced' || (!$objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted - { + && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely) + if ($object->close_code != 'replaced' || (!$objectidnext)) { // Not replaced by another invoice or replaced but the replacement invoice has been deleted print ''.$langs->trans('ReOpen').''; } else { print ''.$langs->trans('ReOpen').''; @@ -5105,8 +5255,7 @@ if ($action == 'create') // Validate if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { - if ($usercanvalidate) - { + if ($usercanvalidate) { print ''.$langs->trans('Validate').''; } } @@ -5119,7 +5268,9 @@ if ($action == 'create') } else { if ($usercansend) { print ''.$langs->trans('SendMail').''; - } else print ''.$langs->trans('SendMail').''; + } else { + print ''.$langs->trans('SendMail').''; + } } } } @@ -5173,8 +5324,7 @@ if ($action == 'create') } // For standard invoice with excess received - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && $object->statut == Facture::STATUS_VALIDATED && empty($object->paye) && $resteapayer < 0 && $usercancreate && empty($discount->id)) - { + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && $object->statut == Facture::STATUS_VALIDATED && empty($object->paye) && $resteapayer < 0 && $usercancreate && empty($discount->id)) { print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note @@ -5192,23 +5342,19 @@ if ($action == 'create') // Classify paid if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) - ) - { + ) { print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment) - { + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment) { if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; } else { - if (empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) - { - if ($objectidnext) - { + if (empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) { + if ($objectidnext) { print ''.$langs->trans('ClassifyCanceled').''; } else { print ''.$langs->trans('ClassifyCanceled').''; @@ -5218,8 +5364,7 @@ if ($action == 'create') } // Create a credit note - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate) - { + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate) { if (!$objectidnext) { print ''.$langs->trans("CreateCreditNote").''; } @@ -5233,8 +5378,7 @@ if ($action == 'create') && !$objectidnext && $object->is_last_in_cycle() && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE - ) - { + ) { if ($usercanunvalidate) { print ''.$langs->trans("CreateCreditNote").''; } else { @@ -5243,30 +5387,26 @@ if ($action == 'create') } // Clone - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) - { + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { print ''.$langs->trans("ToClone").''; } // Clone as predefined / Create template - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) - { - if (!$objectidnext && count($object->lines) > 0) - { + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) { + if (!$objectidnext && count($object->lines) > 0) { print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; } } // Remove situation from cycle if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED)) - && $object->type == Facture::TYPE_SITUATION - && $usercancreate - && !$objectidnext - && $object->situation_counter > 1 - && $object->is_last_in_cycle() + && $object->type == Facture::TYPE_SITUATION + && $usercancreate + && !$objectidnext + && $object->situation_counter > 1 + && $object->is_last_in_cycle() && $usercanunvalidate - ) - { + ) { if (($object->total_ttc - $totalcreditnotes) == 0) { print ''.$langs->trans("RemoveSituationFromCycle").''; } else { @@ -5287,8 +5427,7 @@ if ($action == 'create') // Delete $isErasable = $object->is_erasable(); - if ($usercandelete || ($usercancreate && $isErasable == 1)) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) - { + if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); if ($isErasable == -4) { print ''.$langs->trans('Delete').''; @@ -5298,11 +5437,9 @@ if ($action == 'create') print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { print ''.$langs->trans('Delete').''; - } elseif ($isErasable <= 0) // Any other cases - { + } elseif ($isErasable <= 0) { // Any other cases print ''.$langs->trans('Delete').''; - } elseif ($objectidnext) - { + } elseif ($objectidnext) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; @@ -5330,9 +5467,27 @@ if ($action == 'create') $delallowed = $usercancreate; print $formfile->showdocuments( - 'facture', $filename, $filedir, $urlsource, $genallowed, - $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', - $soc->default_lang, '', $object, 0, 'remove_file_comfirm'); + 'facture', + $filename, + $filedir, + $urlsource, + $genallowed, + $delallowed, + $object->model_pdf, + 1, + 0, + 0, + 28, + 0, + '', + '', + '', + $soc->default_lang, + '', + $object, + 0, + 'remove_file_comfirm' + ); $somethingshown = $formfile->numoffiles; @@ -5342,8 +5497,7 @@ if ($action == 'create') $compatibleImportElementsList = false; if ($usercancreate && $object->statut == Facture::STATUS_DRAFT - && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) - { + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 444fca3155a..c16d79d2574 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -172,35 +172,52 @@ class Invoices 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) + 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."facture 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('invoice').')'; - 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 ((!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 + if ($search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } // Filter by status - if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; + if ($status == 'draft') { + $sql .= " AND t.fk_statut IN (0)"; + } + if ($status == 'unpaid') { + $sql .= " AND t.fk_statut IN (1)"; + } + if ($status == 'paid') { + $sql .= " AND t.fk_statut IN (2)"; + } + if ($status == 'cancelled') { + $sql .= " AND t.fk_statut IN (3)"; + } // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -208,10 +225,8 @@ class Invoices extends DolibarrApi } $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) - { - if ($page < 0) - { + if ($limit) { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -220,17 +235,14 @@ class Invoices extends DolibarrApi } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $invoice_static = new Facture($this->db); - if ($invoice_static->fetch($obj->rowid)) - { + if ($invoice_static->fetch($obj->rowid)) { // Get payment details $invoice_static->totalpaid = $invoice_static->getSommePaiement(); $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); @@ -274,13 +286,13 @@ class Invoices extends DolibarrApi $this->invoice->date = dol_now(); } /* We keep lines as an array - if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->invoice->lines = $lines; - }*/ + if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->invoice->lines = $lines; + }*/ if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); @@ -585,20 +597,22 @@ class Invoices extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->invoice->$field = $value; } // update bank account - if (!empty($this->invoice->fk_account)) - { + if (!empty($this->invoice->fk_account)) { if ($this->invoice->setBankAccount($this->invoice->fk_account) == 0) { throw new RestException(400, $this->invoice->error); } } - if ($this->invoice->update(DolibarrApiAccess::$user)) + if ($this->invoice->update(DolibarrApiAccess::$user)) { return $this->get($id); + } return false; } @@ -624,8 +638,7 @@ class Invoices extends DolibarrApi } $result = $this->invoice->delete(DolibarrApiAccess::$user); - if ($result < 0) - { + if ($result < 0) { throw new RestException(500); } @@ -1062,10 +1075,13 @@ class Invoices extends DolibarrApi $result = $discountcheck->fetch(0, $this->invoice->id); $canconvert = 0; - if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) - if ($canconvert) - { + if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) { + $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + } + if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) { + $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + } + if ($canconvert) { $this->db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); @@ -1073,10 +1089,9 @@ class Invoices extends DolibarrApi // Loop on each vat rate $i = 0; - foreach ($this->invoice->lines as $line) - { - if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 - { // no need to create discount if amount is null + foreach ($this->invoice->lines as $line) { + if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 + // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; @@ -1104,8 +1119,7 @@ class Invoices extends DolibarrApi $error = 0; - if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) - { + if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT // Total payments @@ -1116,7 +1130,9 @@ class Invoices extends DolibarrApi $sql .= ' AND pf.fk_paiement = p.rowid'; $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $this->db->query($sql); - if (!$resql) dol_print_error($this->db); + if (!$resql) { + dol_print_error($this->db); + } $res = $this->db->fetch_object($resql); $total_payments = $res->total_payments; @@ -1129,23 +1145,24 @@ class Invoices extends DolibarrApi $sql .= " WHERE fk_facture = ".$this->invoice->id; $resql = $this->db->query($sql); if (!empty($resql)) { - while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; - } else dol_print_error($this->db); + while ($obj = $this->db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else { + dol_print_error($this->db); + } $discount->amount_ht = $discount->amount_ttc = $total_payments + $total_creditnote_and_deposit - $this->invoice->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; $result = $discount->create(DolibarrApiAccess::$user); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_DEPOSIT) - { - foreach ($amount_ht as $tva_tx => $xxx) - { + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_DEPOSIT) { + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); @@ -1155,21 +1172,18 @@ class Invoices extends DolibarrApi $discount->tva_tx = abs($tva_tx); $result = $discount->create(DolibarrApiAccess::$user); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } } - if (empty($error)) - { + if (empty($error)) { if ($this->invoice->type != Facture::TYPE_DEPOSIT) { // Classe facture $result = $this->invoice->setPaid(DolibarrApiAccess::$user); - if ($result >= 0) - { + if ($result >= 0) { $this->db->commit(); } else { $this->db->rollback(); @@ -1417,8 +1431,7 @@ class Invoices extends DolibarrApi $paymentobj->note_private = $comment; $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($payment_id < 0) - { + if ($payment_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paymentobj->error); } @@ -1429,10 +1442,11 @@ class Invoices extends DolibarrApi if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); } @@ -1501,8 +1515,7 @@ class Invoices extends DolibarrApi $multicurrency_amounts = array(); // Loop on each invoice to pay - foreach ($arrayofamounts as $id => $amountarray) - { + foreach ($arrayofamounts as $id => $amountarray) { $result = $this->invoice->fetch($id); if (!$result) { $this->db->rollback(); @@ -1528,13 +1541,11 @@ class Invoices extends DolibarrApi $totaldeposits = $this->invoice->getSumDepositsUsed($is_multicurrency); $remainstopay = $amount = price2num($total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if (!$is_multicurrency && $amountarray["amount"] != 'remain') - { + if (!$is_multicurrency && $amountarray["amount"] != 'remain') { $amount = price2num($amountarray["amount"], 'MT'); } - if ($is_multicurrency && $amountarray["multicurrency_amount"] != 'remain') - { + if ($is_multicurrency && $amountarray["multicurrency_amount"] != 'remain') { $amount = price2num($amountarray["multicurrency_amount"], 'MT'); } @@ -1569,8 +1580,7 @@ class Invoices extends DolibarrApi $paymentobj->note_private = $comment; $paymentobj->ref_ext = $ref_ext; $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($payment_id < 0) - { + if ($payment_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paymentobj->error); } @@ -1579,10 +1589,11 @@ class Invoices extends DolibarrApi if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 13a58a3e075..ad880470b50 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -218,11 +218,12 @@ class FactureRec extends CommonInvoice $this->titre = trim(isset($this->titre) ? $this->titre : $this->title); // deprecated $this->title = trim($this->title); $this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice; - if (empty($this->suspended)) $this->suspended = 0; + if (empty($this->suspended)) { + $this->suspended = 0; + } // No frequency defined then no next date to execution - if (empty($this->frequency)) - { + if (empty($this->frequency)) { $this->frequency = 0; $this->date_when = null; } @@ -238,8 +239,7 @@ class FactureRec extends CommonInvoice // Charge facture modele $facsrc = new Facture($this->db); $result = $facsrc->fetch($facid); - if ($result > 0) - { + if ($result > 0) { // On positionne en mode brouillon la facture $this->brouillon = 1; @@ -301,8 +301,7 @@ class FactureRec extends CommonInvoice $sql .= ", ".$this->db->escape($this->suspended); $sql .= ")"; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec"); // Fields used into addline later @@ -312,10 +311,11 @@ class FactureRec extends CommonInvoice // Add lines $num = count($facsrc->lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $tva_tx = $facsrc->lines[$i]->tva_tx; - if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { + $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + } $result_insert = $this->addline( $facsrc->lines[$i]->desc, @@ -338,13 +338,11 @@ class FactureRec extends CommonInvoice $facsrc->lines[$i]->multicurrency_subprice ); - if ($result_insert < 0) - { + if ($result_insert < 0) { $error++; } else { $objectline = new FactureLigneRec($this->db); - if ($objectline->fetch($result_insert)) - { + if ($objectline->fetch($result_insert)) { // Extrafields if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->id); @@ -352,31 +350,24 @@ class FactureRec extends CommonInvoice } $result = $objectline->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } } } - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -385,8 +376,7 @@ class FactureRec extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -396,26 +386,22 @@ class FactureRec extends CommonInvoice if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILLREC_CREATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } // End call triggers } - if ($error) - { + if ($error) { $this->db->rollback(); } else { $this->db->commit(); @@ -453,23 +439,18 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { + if ($resql) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILLREC_UPDATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } @@ -512,18 +493,19 @@ class FactureRec extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; - if ($rowid) $sql .= ' AND f.rowid='.$rowid; - elseif ($ref) $sql .= " AND f.titre='".$this->db->escape($ref)."'"; + if ($rowid) { + $sql .= ' AND f.rowid='.$rowid; + } elseif ($ref) { + $sql .= " AND f.titre='".$this->db->escape($ref)."'"; + } /* This field are not used for template invoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; */ $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -584,7 +566,9 @@ class FactureRec extends CommonInvoice $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) { + $this->brouillon = 1; + } // Retrieve all extrafield // fetch optionals attributes and labels @@ -594,8 +578,7 @@ class FactureRec extends CommonInvoice * Lines */ $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->db->lasterror(); return -3; } @@ -638,8 +621,7 @@ class FactureRec extends CommonInvoice // Retrieve all extrafield for line // fetch optionals attributes and labels - if (!is_object($extrafields)) - { + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); } @@ -662,12 +644,10 @@ class FactureRec extends CommonInvoice dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new FactureLigneRec($this->db); @@ -764,18 +744,20 @@ class FactureRec extends CommonInvoice dol_syslog($sqlef); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); - if ($this->db->query($sqlef) && $this->db->query($sql)) - { + if ($this->db->query($sqlef) && $this->db->query($sql)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid; dol_syslog($sql); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error = -3; + if ($res < 0) { + $error = -3; + } // Delete extrafields $res = $this->deleteExtraFields(); - if ($res < 0) $error = -4; + if ($res < 0) { + $error = -4; + } } else { $this->error = $this->db->lasterror(); $error = -1; @@ -785,8 +767,7 @@ class FactureRec extends CommonInvoice $error = -2; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -833,23 +814,25 @@ class FactureRec extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - if ($this->brouillon) - { + if ($this->brouillon) { // Clean parameters $remise_percent = price2num($remise_percent); - if (empty($remise_percent)) $remise_percent = 0; + if (empty($remise_percent)) { + $remise_percent = 0; + } $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); @@ -858,13 +841,20 @@ class FactureRec extends CommonInvoice } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txtva)) $txtva = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($info_bits)) $info_bits = 0; + if (empty($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } + if (empty($info_bits)) { + $info_bits = 0; + } - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; @@ -890,8 +880,7 @@ class FactureRec extends CommonInvoice $pu_ht_devise = $tabprice[19]; $product_type = $type; - if ($fk_product) - { + if ($fk_product) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; @@ -967,8 +956,7 @@ class FactureRec extends CommonInvoice $sql .= ")"; dol_syslog(get_class($this)."::addline", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); $this->id = $facid; $this->update_price(); @@ -1019,35 +1007,51 @@ class FactureRec extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; + if (empty($remise_percent)) { + $remise_percent = 0; + } // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } - if ($this->brouillon) - { + if ($this->brouillon) { // Clean parameters $remise_percent = price2num($remise_percent); $qty = price2num($qty); - if (empty($info_bits)) $info_bits = 0; + if (empty($info_bits)) { + $info_bits = 0; + } $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $pu_ht_devise = price2num($pu_ht_devise); - if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' - } + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->multicurrency_subprice)) { + $this->multicurrency_subprice = 0; + } + if (empty($this->multicurrency_total_ht)) { + $this->multicurrency_total_ht = 0; + } + if (empty($this->multicurrency_total_tva)) { + $this->multicurrency_total_tva = 0; + } + if (empty($this->multicurrency_total_ttc)) { + $this->multicurrency_total_ttc = 0; + } - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; @@ -1061,9 +1065,8 @@ class FactureRec extends CommonInvoice // Clean vat code $vat_src_code = ''; - $reg = array(); - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + $reg = array(); + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -1086,8 +1089,7 @@ class FactureRec extends CommonInvoice $pu_ht_devise = $tabprice[19]; $product_type = $type; - if ($fk_product) - { + if ($fk_product) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; @@ -1129,8 +1131,7 @@ class FactureRec extends CommonInvoice $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->id = $facid; $this->update_price(); return 1; @@ -1149,7 +1150,9 @@ class FactureRec extends CommonInvoice */ public function getNextDate() { - if (empty($this->date_when)) return false; + if (empty($this->date_when)) { + return false; + } return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); } @@ -1161,7 +1164,9 @@ class FactureRec extends CommonInvoice public function isMaxNbGenReached() { $ret = false; - if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true; + if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) { + $ret = true; + } return $ret; } @@ -1209,8 +1214,9 @@ class FactureRec extends CommonInvoice $sql .= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql .= ' AND suspended = 0'; $sql .= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here - if ($restrictioninvoiceid > 0) + if ($restrictioninvoiceid > 0) { $sql .= ' AND rowid = '.$restrictioninvoiceid; + } $sql .= $this->db->order('entity', 'ASC'); //print $sql;exit; $parameters = array( @@ -1220,19 +1226,19 @@ class FactureRec extends CommonInvoice $reshook = $hookmanager->executeHooks('beforeCreationOfRecurringInvoices', $parameters, $sql); // note that $sql might be modified by hooks $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $this->db->num_rows($resql); - if ($num) + if ($num) { $this->output .= $langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; - else $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + } else { + $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + } $saventity = $conf->entity; - while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. - { + while ($i < $num) { // Loop on each template invoice. If $num = 0, test is false at first pass. $line = $this->db->fetch_object($resql); $this->db->begin(); @@ -1243,8 +1249,7 @@ class FactureRec extends CommonInvoice $facturerec = new FactureRec($this->db); $facturerec->fetch($line->rowid); - if ($facturerec->id > 0) - { + if ($facturerec->id > 0) { // Set entity context $conf->entity = $facturerec->entity; @@ -1260,24 +1265,20 @@ class FactureRec extends CommonInvoice $facture->socid = $facturerec->socid; $invoiceidgenerated = $facture->create($user); - if ($invoiceidgenerated <= 0) - { + if ($invoiceidgenerated <= 0) { $this->errors = $facture->errors; $this->error = $facture->error; $error++; } - if (!$error && ($facturerec->auto_validate || $forcevalidation)) - { + if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); - if ($result <= 0) - { + if ($result <= 0) { $this->errors = $facture->errors; $this->error = $facture->error; $error++; } } - if (!$error && $facturerec->generate_pdf) - { + if (!$error && $facturerec->generate_pdf) { // We refresh the object in order to have all necessary data (like date_lim_reglement) $facture->fetch($facture->id); $result = $facture->generateDocument($facturerec->model_pdf, $langs); @@ -1294,8 +1295,7 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity); } - if (!$error && $invoiceidgenerated >= 0) - { + if (!$error && $invoiceidgenerated >= 0) { $this->db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; @@ -1318,7 +1318,9 @@ class FactureRec extends CommonInvoice } $conf->entity = $saventity; // Restore entity context - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } $this->output = trim($this->output); @@ -1357,28 +1359,39 @@ class FactureRec extends CommonInvoice if (!empty($this->date_when)) { $label .= '
'.$langs->trans('NextDateToExecution').': '; $label .= (empty($this->suspended) ? '' : '').dol_print_date($this->date_when, 'day').(empty($this->suspended) ? '' : ''); // No hour for this property - if (!empty($this->suspended)) $label .= ' ('.$langs->trans("Disabled").')'; + if (!empty($this->suspended)) { + $label .= ' ('.$langs->trans("Disabled").')'; + } } } $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; - if ($short) return $url; + if ($short) { + return $url; + } - if ($option != 'nolink') - { + 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'; + 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 = ''; $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; return $result; @@ -1417,11 +1430,9 @@ class FactureRec extends CommonInvoice $statusType = 'status0'; //print "$recur,$status,$mode,$alreadypaid,$type"; - if ($mode == 0) - { + if ($mode == 0) { $prefix = ''; - if ($recur) - { + if ($recur) { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); } else { @@ -1434,11 +1445,9 @@ class FactureRec extends CommonInvoice $labelStatus = $langs->trans("Draft"); } } - } elseif ($mode == 1) - { + } elseif ($mode == 1) { $prefix = 'Short'; - if ($recur) - { + if ($recur) { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); } else { @@ -1451,10 +1460,8 @@ class FactureRec extends CommonInvoice $labelStatus = $langs->trans("Draft"); } } - } elseif ($mode == 2) - { - if ($recur) - { + } elseif ($mode == 2) { + if ($recur) { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); @@ -1471,10 +1478,8 @@ class FactureRec extends CommonInvoice $labelStatus = $langs->trans('Draft'); } } - } elseif ($mode == 3) - { - if ($recur) - { + } elseif ($mode == 3) { + if ($recur) { $prefix = 'Short'; if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; @@ -1492,11 +1497,9 @@ class FactureRec extends CommonInvoice $labelStatus = $langs->trans('Draft'); } } - } elseif ($mode == 4) - { + } elseif ($mode == 4) { $prefix = ''; - if ($recur) - { + if ($recur) { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); @@ -1513,12 +1516,12 @@ class FactureRec extends CommonInvoice $labelStatus = $langs->trans('Draft'); } } - } elseif ($mode == 5 || $mode == 6) - { + } elseif ($mode == 5 || $mode == 6) { $prefix = ''; - if ($mode == 5) $prefix = 'Short'; - if ($recur) - { + if ($mode == 5) { + $prefix = 'Short'; + } + if ($recur) { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); @@ -1537,7 +1540,9 @@ class FactureRec extends CommonInvoice } } - if (empty($labelStatusShort)) $labelStatusShort = $labelStatus; + if (empty($labelStatusShort)) { + $labelStatusShort = $labelStatus; + } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } @@ -1568,12 +1573,10 @@ class FactureRec extends CommonInvoice $sql .= $this->db->plimit(100); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_prods = $this->db->num_rows($resql); $i = 0; - while ($i < $num_prods) - { + while ($i < $num_prods) { $i++; $row = $this->db->fetch_row($resql); $prodids[$i] = $row[0]; @@ -1598,13 +1601,11 @@ class FactureRec extends CommonInvoice $this->fk_incoterms = 0; $this->location_incoterms = ''; - if (empty($option) || $option != 'nolines') - { + if (empty($option) || $option != 'nolines') { // Lines $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new FactureLigne($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->qty = 1; @@ -1613,23 +1614,20 @@ class FactureRec extends CommonInvoice $line->localtax1_tx = 0; $line->localtax2_tx = 0; $line->remise_percent = 0; - if ($xnbp == 1) // Qty is negative (product line) - { + if ($xnbp == 1) { // Qty is negative (product line) $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; $line->qty = -1; $line->total_ht = -100; $line->total_ttc = -119.6; $line->total_tva = -19.6; - } elseif ($xnbp == 2) // UP is negative (free line) - { + } elseif ($xnbp == 2) { // UP is negative (free line) $line->subprice = -100; $line->total_ht = -100; $line->total_ttc = -119.6; $line->total_tva = -19.6; $line->remise_percent = 0; - } elseif ($xnbp == 3) // Discount is 50% (product line) - { + } elseif ($xnbp == 3) { // Discount is 50% (product line) $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; $line->total_ht = 50; @@ -1723,7 +1721,9 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; + if (!empty($unit)) { + $this->unit_frequency = $unit; + } return 1; } else { dol_print_error($this->db); @@ -1740,21 +1740,23 @@ class FactureRec extends CommonInvoice */ public function setNextDate($date, $increment_nb_gen_done = 0) { - if (!$this->table_element) - { + if (!$this->table_element) { dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + if ($increment_nb_gen_done > 0) { + $sql .= ', nb_gen_done = nb_gen_done + 1'; + } $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->date_when = $date; - if ($increment_nb_gen_done > 0) $this->nb_gen_done++; + if ($increment_nb_gen_done > 0) { + $this->nb_gen_done++; + } return 1; } else { dol_print_error($this->db); @@ -1770,21 +1772,21 @@ class FactureRec extends CommonInvoice */ public function setMaxPeriod($nb) { - if (!$this->table_element) - { + if (!$this->table_element) { dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); return -1; } - if (empty($nb)) $nb = 0; + if (empty($nb)) { + $nb = 0; + } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET nb_gen_max = '.$nb; $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->nb_gen_max = $nb; return 1; } else { @@ -1801,8 +1803,7 @@ class FactureRec extends CommonInvoice */ public function setAutoValidate($validate) { - if (!$this->table_element) - { + if (!$this->table_element) { dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); return -1; } @@ -1812,8 +1813,7 @@ class FactureRec extends CommonInvoice $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->auto_validate = $validate; return 1; } else { @@ -1830,8 +1830,7 @@ class FactureRec extends CommonInvoice */ public function setGeneratePdf($validate) { - if (!$this->table_element) - { + if (!$this->table_element) { dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); return -1; } @@ -1841,8 +1840,7 @@ class FactureRec extends CommonInvoice $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->generate_pdf = $validate; return 1; } else { @@ -1859,8 +1857,7 @@ class FactureRec extends CommonInvoice */ public function setModelPdf($model) { - if (!$this->table_element) - { + if (!$this->table_element) { dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); return -1; } @@ -1870,8 +1867,7 @@ class FactureRec extends CommonInvoice $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->model_pdf = $model; return 1; } else { @@ -1918,21 +1914,21 @@ class FactureLigneRec extends CommonInvoiceLine if (!$notrigger) { // Call triggers $result = $this->call_trigger('LINEBILLREC_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } // Do also here what you must do to rollback action if trigger fail // End call triggers } } - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; $res = $this->db->query($sql); @@ -1974,8 +1970,7 @@ class FactureLigneRec extends CommonInvoiceLine dol_syslog('FactureRec::fetch', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $objp = $this->db->fetch_object($result); $this->id = $objp->rowid; @@ -2075,23 +2070,18 @@ class FactureLigneRec extends CommonInvoiceLine dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { + if ($resql) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); - if ($result < 0) - { + if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7f686accb4e..983e42f5ff5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -45,8 +45,12 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.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'; +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'; +} /** * Class to manage invoices @@ -428,20 +432,28 @@ class Facture extends CommonInvoice $error = 0; // Clean parameters - if (empty($this->type)) $this->type = self::TYPE_STANDARD; + if (empty($this->type)) { + $this->type = self::TYPE_STANDARD; + } $this->ref_client = trim($this->ref_client); $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); $this->note_public = trim($this->note_public); - if (!$this->cond_reglement_id) $this->cond_reglement_id = 0; - if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; + if (!$this->cond_reglement_id) { + $this->cond_reglement_id = 0; + } + if (!$this->mode_reglement_id) { + $this->mode_reglement_id = 0; + } $this->brouillon = 1; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); - else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; @@ -450,16 +462,14 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::create user=".$user->id." date=".$this->date); // Check parameters - if (empty($this->date)) - { + if (empty($this->date)) { $this->error = "Try to create an invoice with an empty parameter (date)"; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -3; } $soc = new Societe($this->db); $result = $soc->fetch($this->socid); - if ($result < 0) - { + if ($result < 0) { $this->error = "Failed to fetch company: ".$soc->error; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; @@ -474,8 +484,7 @@ class Facture extends CommonInvoice $previousdaynextdatewhen = null; // Create invoice from a template recurring invoice - if ($this->fac_rec > 0) - { + if ($this->fac_rec > 0) { $this->fk_fac_rec_source = $this->fac_rec; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; @@ -488,8 +497,7 @@ class Facture extends CommonInvoice $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); - if (!empty($_facrec->frequency)) // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. - { + if (!empty($_facrec->frequency)) { // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. $this->socid = $_facrec->socid; } $this->entity = $_facrec->entity; // Invoice created in same entity than template @@ -514,7 +522,9 @@ class Facture extends CommonInvoice $this->location_incoterms = $_facrec->location_incoterms; // Clean parameters - if (!$this->type) $this->type = self::TYPE_STANDARD; + if (!$this->type) { + $this->type = self::TYPE_STANDARD; + } $this->ref_client = trim($this->ref_client); $this->note_public = trim($this->note_public); $this->note_private = trim($this->note_private); @@ -523,7 +533,9 @@ class Facture extends CommonInvoice $this->array_options = $_facrec->array_options; //if (! $this->remise) $this->remise = 0; - if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; + if (!$this->mode_reglement_id) { + $this->mode_reglement_id = 0; + } $this->brouillon = 1; $this->linked_objects = $_facrec->linkedObjectsIds; @@ -533,10 +545,11 @@ class Facture extends CommonInvoice $forceduedate = $this->calculate_date_lim_reglement(); // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice - if ($_facrec->frequency > 0) - { + if ($_facrec->frequency > 0) { dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); - if (empty($_facrec->date_when)) $_facrec->date_when = $now; + if (empty($_facrec->date_when)) { + $_facrec->date_when = $now; + } $next_date = $_facrec->getNextDate(); // Calculate next date $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. @@ -547,10 +560,13 @@ class Facture extends CommonInvoice $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang = $this->default_lang; // for thirdparty - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) { + $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) { + $newlang = $this->default_lang; // for thirdparty + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -585,9 +601,9 @@ class Facture extends CommonInvoice if (empty($forceduedate)) { $duedate = $this->calculate_date_lim_reglement(); /*if ($duedate < 0) { Regression, a date can be negative if before 1970. - dol_syslog(__METHOD__ . ' Error in calculate_date_lim_reglement. We got ' . $duedate, LOG_ERR); - return -1; - }*/ + dol_syslog(__METHOD__ . ' Error in calculate_date_lim_reglement. We got ' . $duedate, LOG_ERR); + return -1; + }*/ $this->date_lim_reglement = $duedate; } else { $this->date_lim_reglement = $forceduedate; @@ -662,8 +678,7 @@ class Facture extends CommonInvoice $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); // Update ref with new one @@ -671,25 +686,21 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -698,8 +709,7 @@ class Facture extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -708,23 +718,22 @@ class Facture extends CommonInvoice } // Propagate contacts - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object - { + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) { // Get contact from origin object $originforcontact = $this->origin; $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { + if ($originforcontact == 'shipping') { // shipment and order share the same contacts. If creating from shipment we take data of order require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { + if (count($exp->linkedObjectsIds['commande']) > 0) { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - if (is_object($value)) $originidforcontact = $value->id; - else $originidforcontact = $value; + if (is_object($value)) { + $originidforcontact = $value->id; + } else { + $originidforcontact = $value; + } break; // We take first one } } @@ -734,26 +743,24 @@ class Facture extends CommonInvoice $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { + if ($resqlcontact) { + while ($objcontact = $this->db->fetch_object($resqlcontact)) { //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } - } else dol_print_error($resqlcontact); + } else { + dol_print_error($resqlcontact); + } } /* * Insert lines of invoices, if not from template invoice, into database */ - if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) - { + if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) { // If this->lines is array of InvoiceLines (preferred mode) $fk_parent_line = 0; dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); - foreach ($this->lines as $i => $val) - { + foreach ($this->lines as $i => $val) { $newinvoiceline = $this->lines[$i]; $newinvoiceline->fk_facture = $this->id; @@ -761,17 +768,14 @@ class Facture extends CommonInvoice $newinvoiceline->origin_id = $this->lines[$i]->id; // Auto set date of service ? - if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only - { + if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) { // $originaldatewhen is defined when generating from recurring invoice only $newinvoiceline->date_start = $originaldatewhen; } - if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) // $previousdaynextdatewhen is defined when generating from recurring invoice only - { + if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) { // $previousdaynextdatewhen is defined when generating from recurring invoice only $newinvoiceline->date_end = $previousdaynextdatewhen; } - if ($result >= 0) - { + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { $fk_parent_line = 0; @@ -794,30 +798,28 @@ class Facture extends CommonInvoice $fk_parent_line = $result; } } - if ($result < 0) - { + if ($result < 0) { $this->error = $newinvoiceline->error; $this->errors = $newinvoiceline->errors; $error++; break; } } - } elseif (!$error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays - { + } elseif (!$error && empty($this->fac_rec)) { // If this->lines is an array of invoice line arrays $fk_parent_line = 0; dol_syslog("There is ".count($this->lines)." lines that are array lines"); - foreach ($this->lines as $i => $val) - { + foreach ($this->lines as $i => $val) { $line = $this->lines[$i]; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (!is_object($line)) $line = (object) $line; + if (!is_object($line)) { + $line = (object) $line; + } - if ($result >= 0) - { + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; @@ -825,7 +827,9 @@ class Facture extends CommonInvoice // Complete vat rate with code $vatrate = $line->tva_tx; - if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + 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; @@ -872,8 +876,7 @@ class Facture extends CommonInvoice $line->multicurrency_subprice, $line->ref_ext ); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->db->lasterror(); dol_print_error($this->db); $this->db->rollback(); @@ -891,12 +894,9 @@ class Facture extends CommonInvoice /* * Insert lines of template invoices */ - if (!$error && $this->fac_rec > 0) - { - foreach ($_facrec->lines as $i => $val) - { - if ($_facrec->lines[$i]->fk_product) - { + if (!$error && $this->fac_rec > 0) { + foreach ($_facrec->lines as $i => $val) { + if ($_facrec->lines[$i]->fk_product) { $prod = new Product($this->db); $res = $prod->fetch($_facrec->lines[$i]->fk_product); } @@ -911,15 +911,16 @@ class Facture extends CommonInvoice */ $tva_tx = $_facrec->lines[$i]->tva_tx.($_facrec->lines[$i]->vat_src_code ? '('.$_facrec->lines[$i]->vat_src_code.')' : ''); $tva_npr = $_facrec->lines[$i]->info_bits; - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ?null:$_facrec->lines[$i]->fk_product_fournisseur_price; $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; // If buyprice not defined from template invoice, we try to guess the best value - if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) - { + if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $producttmp = new ProductFournisseur($this->db); $producttmp->fetch($_facrec->lines[$i]->fk_product); @@ -927,13 +928,13 @@ class Facture extends CommonInvoice // If margin module defined on costprice, we try the costprice // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price // else we get the best supplier price - if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; - elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) $buyprice = $producttmp->pmp; - else { - if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) - { - if ($producttmp->product_fourn_price_id > 0) - { + if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) { + $buyprice = $producttmp->cost_price; + } elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) { + $buyprice = $producttmp->pmp; + } else { + if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) { + if ($producttmp->product_fourn_price_id > 0) { $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent / 100) + $producttmp->fourn_remise, 'MU'); } } @@ -972,8 +973,7 @@ class Facture extends CommonInvoice $_facrec->lines[$i]->multicurrency_subprice ); - if ($result_insert < 0) - { + if ($result_insert < 0) { $error++; $this->error = $this->db->error(); break; @@ -981,30 +981,29 @@ class Facture extends CommonInvoice } } - if (!$error) - { + if (!$error) { $result = $this->update_price(1); - if ($result > 0) - { + if ($result > 0) { $action = 'create'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILL_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -1087,11 +1086,9 @@ class Facture extends CommonInvoice // Loop on each line of new invoice - foreach ($facture->lines as $i => $tmpline) - { + foreach ($facture->lines as $i => $tmpline) { $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; - if ($invertdetail) - { + if ($invertdetail) { $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; $facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht; $facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva; @@ -1105,18 +1102,14 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::createFromCurrent invertdetail=".$invertdetail." socid=".$this->socid." nboflines=".count($facture->lines)); $facid = $facture->create($user); - if ($facid <= 0) - { + if ($facid <= 0) { $this->error = $facture->error; $this->errors = $facture->errors; - } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) - { + } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { $this->fetchObjectLinked('', '', $this->id, 'facture'); - foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) - { - foreach ($Tfk_object as $fk_object) - { + foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) { + foreach ($Tfk_object as $fk_object) { $facture->add_object_linked($typeObject, $fk_object); } } @@ -1148,12 +1141,10 @@ class Facture extends CommonInvoice $object->fetch($fromid); // Change socid if needed - if (!empty($this->socid) && $this->socid != $object->socid) - { + if (!empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($this->socid) > 0) - { + if ($objsoc->fetch($this->socid) > 0) { $object->socid = $objsoc->id; $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); @@ -1187,10 +1178,8 @@ class Facture extends CommonInvoice } // Loop on each line of new invoice - foreach ($object->lines as $i => $line) - { - if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts - { + foreach ($object->lines as $i => $line) { + if (($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts unset($object->lines[$i]); } @@ -1224,37 +1213,36 @@ class Facture extends CommonInvoice // Create clone $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); - if ($result < 0) $error++; - else { + if ($result < 0) { + $error++; + } else { // copy internal contacts - if ($object->copy_linked_contact($this, 'internal') < 0) + if ($object->copy_linked_contact($this, 'internal') < 0) { $error++; - - // copy external contacts if same company - elseif ($this->socid == $object->socid) - { - if ($object->copy_linked_contact($this, 'external') < 0) + } elseif ($this->socid == $object->socid) { + // copy external contacts if same company + if ($object->copy_linked_contact($this, 'external') < 0) { $error++; + } } } - if (!$error) - { + if (!$error) { // Hook of thirdparty module - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('objFrom'=>$this); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + if ($reshook < 0) { + $error++; + } } } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -1281,8 +1269,7 @@ class Facture extends CommonInvoice $this->source = 0; $num = count($object->lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $line = new FactureLigne($this->db); $line->libelle = $object->lines[$i]->libelle; // deprecated @@ -1345,8 +1332,7 @@ class Facture extends CommonInvoice $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; - if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) - { + if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) { $this->note_private = $object->note_private; $this->note_public = $object->note_public; } @@ -1361,13 +1347,13 @@ class Facture extends CommonInvoice // get extrafields from original line $object->fetch_optionals(); - foreach ($object->array_options as $options_key => $value) + foreach ($object->array_options as $options_key => $value) { $this->array_options[$options_key] = $value; + } // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) - { + if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1380,13 +1366,18 @@ class Facture extends CommonInvoice $parameters = array('objFrom'=>$object); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + if ($reshook < 0) { + $error++; + } - if (!$error) - { + if (!$error) { return 1; - } else return -1; - } else return -1; + } else { + return -1; + } + } else { + return -1; + } } /** @@ -1407,65 +1398,98 @@ class Facture extends CommonInvoice { global $langs, $conf, $user, $mysoc; - 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 = ''; - if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; - else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; - - if (!$user->rights->facture->lire) - $option = 'nolink'; - - 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'; + if ($option == 'withdraw') { + $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; + } else { + $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; } - if ($short) return $url; + if (!$user->rights->facture->lire) { + $option = 'nolink'; + } + + 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'; + } + } + + if ($short) { + return $url; + } $picto = $this->picto; - if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice + if ($this->type == self::TYPE_REPLACEMENT) { + $picto .= 'r'; // Replacement invoice + } + if ($this->type == self::TYPE_CREDIT_NOTE) { + $picto .= 'a'; // Credit note + } + if ($this->type == self::TYPE_DEPOSIT) { + $picto .= 'd'; // Deposit invoice + } $label = ''; if ($user->rights->facture->lire) { $label = img_picto('', $picto).' '.$langs->trans("Invoice").''; - if ($this->type == self::TYPE_REPLACEMENT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("ReplacementInvoice").''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("CreditNote").''; - if ($this->type == self::TYPE_DEPOSIT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("Deposit").''; - if ($this->type == self::TYPE_SITUATION) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("InvoiceSituation").''; + if ($this->type == self::TYPE_REPLACEMENT) { + $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("ReplacementInvoice").''; + } + if ($this->type == self::TYPE_CREDIT_NOTE) { + $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("CreditNote").''; + } + if ($this->type == self::TYPE_DEPOSIT) { + $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("Deposit").''; + } + if ($this->type == self::TYPE_SITUATION) { + $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("InvoiceSituation").''; + } if (isset($this->statut) && isset($this->alreadypaid)) { $label .= ' '.$this->getLibStatut(5, $this->alreadypaid); } - if (!empty($this->ref)) + if (!empty($this->ref)) { $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->ref_client)) + } + if (!empty($this->ref_client)) { $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - if (!empty($this->date)) - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - if (!empty($this->total_ht)) + } + if (!empty($this->date)) { + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + } + if (!empty($this->total_ht)) { $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) + } + if (!empty($this->total_tva)) { $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' + } + if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) { // We keep test != 0 because $this->total_localtax1 can be '0.00000000' $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) + } + if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) { $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) + } + if (!empty($this->total_ttc)) { $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label .= ' - '.$moretitle; + } + if ($moretitle) { + $label .= ' - '.$moretitle; + } } $linkclose = ($target ? ' target="'.$target.'"' : ''); - if (empty($notooltip) && $user->rights->facture->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip) && $user->rights->facture->lire) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Invoice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -1483,15 +1507,17 @@ class Facture extends CommonInvoice } $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); + } $result .= $linkend; - if ($addlinktonotes) - { + if ($addlinktonotes) { $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) - { + if ($txttoshow) { //$notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); $notetoshow = $langs->trans("ViewPrivateNote").':
'.$txttoshow; $result .= ' '; @@ -1521,7 +1547,9 @@ class Facture extends CommonInvoice { global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext)) { + return -1; + } $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc'; $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; @@ -1548,20 +1576,25 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - if ($rowid) $sql .= " WHERE f.rowid=".$rowid; - else { + if ($rowid) { + $sql .= " WHERE f.rowid=".$rowid; + } else { $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 ($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 + } } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -1633,7 +1666,7 @@ class Facture extends CommonInvoice $this->location_incoterms = $obj->location_incoterms; $this->label_incoterms = $obj->label_incoterms; - $this->module_source = $obj->module_source; + $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; // Multicurrency @@ -1644,12 +1677,13 @@ class Facture extends CommonInvoice $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) - { + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } - if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) { + $this->brouillon = 1; + } // Retrieve all extrafield // fetch optionals attributes and labels @@ -1659,8 +1693,7 @@ class Facture extends CommonInvoice $this->lines = array(); $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->db->error(); return -3; } @@ -1708,12 +1741,10 @@ class Facture extends CommonInvoice dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new FactureLigne($this->db); @@ -1819,17 +1850,13 @@ class Facture extends CommonInvoice dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); $result = $this->db->query($sql); - if ($result && $this->db->num_rows($result) > 0) - { - while ($objp = $this->db->fetch_object($result)) - { + if ($result && $this->db->num_rows($result) > 0) { + while ($objp = $this->db->fetch_object($result)) { $invoice = new Facture($this->db); - if ($invoice->fetch($objp->rowid) > 0) - { + if ($invoice->fetch($objp->rowid) > 0) { if ($objp->situation_counter < $this->situation_counter || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes - ) - { + ) { $this->tab_previous_situation_invoice[] = $invoice; } else { $this->tab_next_situation_invoice[] = $invoice; @@ -1853,19 +1880,45 @@ class Facture extends CommonInvoice $error = 0; // Clean parameters - if (empty($this->type)) $this->type = self::TYPE_STANDARD; - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); - if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); - if (isset($this->increment)) $this->increment = trim($this->increment); - if (isset($this->close_code)) $this->close_code = trim($this->close_code); - if (isset($this->close_note)) $this->close_note = trim($this->close_note); - if (isset($this->note) || isset($this->note_private)) $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); - if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); + if (empty($this->type)) { + $this->type = self::TYPE_STANDARD; + } + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } + if (isset($this->ref_ext)) { + $this->ref_ext = trim($this->ref_ext); + } + if (isset($this->ref_client)) { + $this->ref_client = trim($this->ref_client); + } + if (isset($this->increment)) { + $this->increment = trim($this->increment); + } + if (isset($this->close_code)) { + $this->close_code = trim($this->close_code); + } + if (isset($this->close_note)) { + $this->close_note = trim($this->close_note); + } + if (isset($this->note) || isset($this->note_private)) { + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + } + if (isset($this->note) || isset($this->note_private)) { + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + } + if (isset($this->note_public)) { + $this->note_public = trim($this->note_public); + } + if (isset($this->model_pdf)) { + $this->model_pdf = trim($this->model_pdf); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } + if (isset($this->retained_warranty)) { + $this->retained_warranty = floatval($this->retained_warranty); + } // Check parameters @@ -1922,28 +1975,25 @@ class Facture extends CommonInvoice $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -1976,10 +2026,8 @@ class Facture extends CommonInvoice $remise = new DiscountAbsolute($this->db); $result = $remise->fetch($idremise); - if ($result > 0) - { - if ($remise->fk_facture) // Protection against multiple submission - { + if ($result > 0) { + if ($remise->fk_facture) { // Protection against multiple submission $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; @@ -1999,8 +2047,7 @@ class Facture extends CommonInvoice $facligne->info_bits = 2; // Get buy/cost price of invoice that is source of discount - if ($remise->fk_facture_source > 0) - { + if ($remise->fk_facture_source > 0) { $srcinvoice = new Facture($this->db); $srcinvoice->fetch($remise->fk_facture_source); include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject @@ -2019,15 +2066,12 @@ class Facture extends CommonInvoice $facligne->multicurrency_total_ttc = -$remise->multicurrency_amount_ttc; $lineid = $facligne->insert(); - if ($lineid > 0) - { + if ($lineid > 0) { $result = $this->update_price(1); - if ($result > 0) - { + if ($result > 0) { // Create link between discount and invoice line $result = $remise->link_to_invoice($lineid, 0); - if ($result < 0) - { + if ($result < 0) { $this->error = $remise->error; $this->db->rollback(); return -4; @@ -2069,41 +2113,40 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - if (empty($ref_client)) + if (empty($ref_client)) { $sql .= ' SET ref_client = NULL'; - else $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; + } else { + $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; + } $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$error) - { + if (!$error) { $this->ref_client = $ref_client; } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->ref_client = $ref_client; $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -2132,39 +2175,41 @@ class Facture extends CommonInvoice // Test to avoid invoice deletion (allowed if draft) $result = $this->is_erasable(); - if ($result <= 0) return 0; + if ($result <= 0) { + return 0; + } $error = 0; $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILL_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } // Removed extrafields if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' WHERE fk_facture_source = '.$rowid; @@ -2174,21 +2219,18 @@ class Facture extends CommonInvoice // If invoice has consumned discounts $this->fetch_lines(); $list_rowid_det = array(); - foreach ($this->lines as $key => $invoiceline) - { + foreach ($this->lines as $key => $invoiceline) { $list_rowid_det[] = $invoiceline->id; } // Consumned discounts are freed - if (count($list_rowid_det)) - { + if (count($list_rowid_det)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; $sql .= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->error()." sql=".$sql; $this->errors[] = $this->error; $this->db->rollback(); @@ -2197,21 +2239,21 @@ class Facture extends CommonInvoice } // If we decrease stock on invoice validation, we increase back if a warehouse id was provided - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) - { + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); $num = count($this->lines); - for ($i = 0; $i < $num; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $num; $i++) { + if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); - else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + if ($this->type == self::TYPE_CREDIT_NOTE) { + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); + } else { + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + } } } } @@ -2225,30 +2267,25 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sqlef) && $this->db->query($sql) && $this->delete_linked_contact()) - { + if ($this->db->query($sqlef) && $this->db->query($sql) && $this->delete_linked_contact()) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive $this->deleteEcmFiles(); // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); - if ($conf->facture->dir_output && !empty($this->ref)) - { + if ($conf->facture->dir_output && !empty($this->ref)) { $dir = $conf->facture->dir_output."/".$ref; $file = $conf->facture->dir_output."/".$ref."/".$ref.".pdf"; - if (file_exists($file)) // We must delete all files before deleting directory - { + if (file_exists($file)) { // We must delete all files before deleting directory $ret = dol_delete_preview($this); - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteFile", $file); $this->errors[] = $this->error; @@ -2256,10 +2293,8 @@ class Facture extends CommonInvoice return 0; } } - if (file_exists($dir)) - { - if (!dol_delete_dir_recursive($dir)) // For remove dir and meta - { + if (file_exists($dir)) { + if (!dol_delete_dir_recursive($dir)) { // For remove dir and meta $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); $this->errors[] = $this->error; @@ -2321,8 +2356,7 @@ class Facture extends CommonInvoice { $error = 0; - if ($this->paye != 1) - { + if ($this->paye != 1) { $this->db->begin(); $now = dol_now(); @@ -2331,27 +2365,33 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql .= ' fk_statut='.self::STATUS_CLOSED; - if (!$close_code) $sql .= ', paye=1'; - if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + if (!$close_code) { + $sql .= ', paye=1'; + } + if ($close_code) { + $sql .= ", close_code='".$this->db->escape($close_code)."'"; + } + if ($close_note) { + $sql .= ", close_note='".$this->db->escape($close_note)."'"; + } $sql .= ', fk_user_closing = '.$user->id; $sql .= ", date_closing = '".$this->db->idate($now)."'"; $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('BILL_PAYED', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; $this->error = $this->db->lasterror(); } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -2404,11 +2444,12 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('BILL_UNPAYED', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; @@ -2416,8 +2457,7 @@ class Facture extends CommonInvoice dol_print_error($this->db); } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -2465,13 +2505,16 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql .= ' fk_statut='.self::STATUS_ABANDONED; - if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + if ($close_code) { + $sql .= ", close_code='".$this->db->escape($close_code)."'"; + } + if ($close_note) { + $sql .= ", close_note='".$this->db->escape($close_note)."'"; + } $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // On desaffecte de la facture les remises liees // car elles n'ont pas ete utilisees vu que la facture est abandonnee. $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; @@ -2479,12 +2522,10 @@ class Facture extends CommonInvoice $sql .= ' WHERE fk_facture = '.$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('BILL_CANCEL', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -2540,20 +2581,17 @@ class Facture extends CommonInvoice $this->fetch_lines(); // Check parameters - if (!$this->brouillon) - { + if (!$this->brouillon) { dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; } - if (count($this->lines) <= 0) - { + if (count($this->lines) <= 0) { $langs->load("errors"); $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) - { + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { $this->error = 'Permission denied'; dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); return -1; @@ -2562,11 +2600,9 @@ class Facture extends CommonInvoice $this->db->begin(); // Check parameters - if ($this->type == self::TYPE_REPLACEMENT) // if this is a replacement invoice - { + if ($this->type == self::TYPE_REPLACEMENT) { // if this is a replacement invoice // Check that source invoice is known - if ($this->fk_facture_source <= 0) - { + if ($this->fk_facture_source <= 0) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); $this->db->rollback(); return -10; @@ -2575,8 +2611,7 @@ class Facture extends CommonInvoice // Load source invoice that has been replaced $facreplaced = new Facture($this->db); $result = $facreplaced->fetch($this->fk_facture_source); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $langs->trans("ErrorBadInvoice"); $this->db->rollback(); return -11; @@ -2584,8 +2619,7 @@ class Facture extends CommonInvoice // Check that source invoice not already replaced by another one. $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); - if ($idreplacement && $idreplacement != $this->id) - { + if ($idreplacement && $idreplacement != $this->id) { $facreplacement = new Facture($this->db); $facreplacement->fetch($idreplacement); $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); @@ -2594,8 +2628,7 @@ class Facture extends CommonInvoice } $result = $facreplaced->setCanceled($user, self::CLOSECODE_REPLACED, ''); - if ($result < 0) - { + if ($result < 0) { $this->error = $facreplaced->error; $this->db->rollback(); return -13; @@ -2603,13 +2636,10 @@ class Facture extends CommonInvoice } // Define new ref - if ($force_number) - { + if ($force_number) { $num = $force_number; - } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { - if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date - { + } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date $this->date = dol_now(); $this->date_lim_reglement = $this->calculate_date_lim_reglement(); } @@ -2619,15 +2649,13 @@ class Facture extends CommonInvoice } $this->newref = dol_sanitizeFileName($num); - if ($num) - { + if ($num) { $this->update_price(1); // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; - if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date - { + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date $sql .= ", datef='".$this->db->idate($this->date)."'"; $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; } @@ -2635,35 +2663,29 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $error++; } // On verifie si la facture etait une provisoire - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne } - if (!$error) - { + if (!$error) { // Define third party as a customer $result = $this->thirdparty->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) - { + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product @@ -2706,13 +2728,15 @@ class Facture extends CommonInvoice } foreach ($batchList as $batch) { - if ($batch->qty <= 0) continue; // try to decrement only batches have positive quantity first + if ($batch->qty <= 0) { + continue; // try to decrement only batches have positive quantity first + } // enough quantity in this batch if ($batch->qty >= $product_qty_remain) { $product_batch_qty = $product_qty_remain; - } // not enough (take all in batch) - else { + } else { + // not enough (take all in batch) $product_batch_qty = $batch->qty; } $result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch); @@ -2724,7 +2748,9 @@ class Facture extends CommonInvoice $product_qty_remain -= $product_batch_qty; // all product quantity was decremented - if ($product_qty_remain <= 0) break; + if ($product_qty_remain <= 0) { + break; + } } if (!$error && $product_qty_remain > 0) { @@ -2762,43 +2788,41 @@ class Facture extends CommonInvoice } // Trigger calls - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILL_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'facture/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$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($num); $dirsource = $conf->facture->dir_output.'/'.$oldref; $dirdest = $conf->facture->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -2810,17 +2834,14 @@ class Facture extends CommonInvoice } } - if (!$error && !$this->is_last_in_cycle()) - { - if (!$this->updatePriceNextInvoice($langs)) - { + if (!$error && !$this->is_last_in_cycle()) { + if (!$this->updatePriceNextInvoice($langs)) { $error++; } } // Set new ref and define current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->ref = $num; $this->statut = self::STATUS_VALIDATED; @@ -2828,8 +2849,7 @@ class Facture extends CommonInvoice $this->date_validation = $now; $i = 0; - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $final = true; $nboflines = count($this->lines); while (($i < $nboflines) && $final) { @@ -2837,8 +2857,11 @@ class Facture extends CommonInvoice $i++; } - if (empty($final)) $this->situation_final = 0; - else $this->situation_final = 1; + if (empty($final)) { + $this->situation_final = 0; + } else { + $this->situation_final = 1; + } $this->setFinal($user); } @@ -2847,8 +2870,7 @@ class Facture extends CommonInvoice $error++; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -2865,28 +2887,42 @@ class Facture extends CommonInvoice */ public function updatePriceNextInvoice(&$langs) { - foreach ($this->tab_next_situation_invoice as $next_invoice) - { + foreach ($this->tab_next_situation_invoice as $next_invoice) { $is_last = $next_invoice->is_last_in_cycle(); - if ($next_invoice->statut == self::STATUS_DRAFT && $is_last != 1) - { + if ($next_invoice->statut == self::STATUS_DRAFT && $is_last != 1) { $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); return false; } $next_invoice->brouillon = 1; - foreach ($next_invoice->lines as $line) - { + foreach ($next_invoice->lines as $line) { $result = $next_invoice->updateline( - $line->id, $line->desc, $line->subprice, $line->qty, $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->id, + $line->desc, + $line->subprice, + $line->qty, + $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) - { + if ($result < 0) { $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); return false; } @@ -2912,8 +2948,7 @@ class Facture extends CommonInvoice $error = 0; - if ($this->statut == self::STATUS_DRAFT) - { + if ($this->statut == self::STATUS_DRAFT) { dol_syslog(__METHOD__." already draft status", LOG_WARNING); return 0; } @@ -2927,43 +2962,39 @@ class Facture extends CommonInvoice $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); - if ($result) - { - if (!$error) - { + if ($result) { + if (!$error) { $this->oldcopy = clone $this; } // If we decrease stock on invoice validation, we increase back - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); $num = count($this->lines); - for ($i = 0; $i < $num; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $num; $i++) { + if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); - else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + if ($this->type == self::TYPE_CREDIT_NOTE) { + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + } else { + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + } } } } - if ($error == 0) - { + if ($error == 0) { $old_statut = $this->statut; $this->brouillon = 1; $this->statut = self::STATUS_DRAFT; // Call trigger $result = $this->call_trigger('BILL_UNVALIDATE', $user); - if ($result < 0) - { + if ($result < 0) { $error++; $this->statut = $old_statut; $this->brouillon = 0; @@ -2974,8 +3005,7 @@ class Facture extends CommonInvoice return -1; } - if ($error == 0) - { + if ($error == 0) { $this->db->commit(); return 1; } else { @@ -3071,23 +3101,46 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); - if ($this->statut == self::STATUS_DRAFT) - { + if ($this->statut == self::STATUS_DRAFT) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; - if (empty($qty)) $qty = 0; - if (empty($info_bits)) $info_bits = 0; - if (empty($rang)) $rang = 0; - if (empty($ventil)) $ventil = 0; - if (empty($txtva)) $txtva = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; - if (empty($fk_prev_id)) $fk_prev_id = 'null'; - if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - if (empty($ref_ext)) $ref_ext = ''; + if (empty($remise_percent)) { + $remise_percent = 0; + } + if (empty($qty)) { + $qty = 0; + } + if (empty($info_bits)) { + $info_bits = 0; + } + if (empty($rang)) { + $rang = 0; + } + if (empty($ventil)) { + $ventil = 0; + } + if (empty($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } + if (empty($fk_parent_line) || $fk_parent_line < 0) { + $fk_parent_line = 0; + } + if (empty($fk_prev_id)) { + $fk_prev_id = 'null'; + } + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') { + $situation_percent = 100; + } + if (empty($ref_ext)) { + $ref_ext = ''; + } $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3101,15 +3154,16 @@ class Facture extends CommonInvoice $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; } // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -3120,8 +3174,7 @@ class Facture extends CommonInvoice $this->db->begin(); $product_type = $type; - if (!empty($fk_product)) - { + if (!empty($fk_product)) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; @@ -3139,8 +3192,7 @@ class Facture extends CommonInvoice // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -3167,8 +3219,7 @@ class Facture extends CommonInvoice // Rank to use $ranktouse = $rang; - if ($ranktouse == -1) - { + if ($ranktouse == -1) { $rangmax = $this->line_max($fk_parent_line); $ranktouse = $rangmax + 1; } @@ -3234,16 +3285,16 @@ class Facture extends CommonInvoice } $result = $this->line->insert(); - if ($result > 0) - { + if ($result > 0) { // Reorder if child line - if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) { + $this->line_order(true, 'DESC'); + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return $this->line->id; } else { @@ -3307,13 +3358,12 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - if ($this->brouillon) - { - if (!$this->is_last_in_cycle() && empty($this->error)) - { - if (!$this->checkProgressLine($rowid, $situation_percent)) - { - if (!$this->error) $this->error = $langs->trans('invoiceLineProgressError'); + if ($this->brouillon) { + if (!$this->is_last_in_cycle() && empty($this->error)) { + if (!$this->checkProgressLine($rowid, $situation_percent)) { + if (!$this->error) { + $this->error = $langs->trans('invoiceLineProgressError'); + } return -3; } } @@ -3327,11 +3377,21 @@ class Facture extends CommonInvoice $this->db->begin(); // Clean parameters - if (empty($qty)) $qty = 0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; - if (empty($special_code) || $special_code == 3) $special_code = 0; - if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - if (empty($ref_ext)) $ref_ext = ''; + if (empty($qty)) { + $qty = 0; + } + if (empty($fk_parent_line) || $fk_parent_line < 0) { + $fk_parent_line = 0; + } + if (empty($special_code) || $special_code == 3) { + $special_code = 0; + } + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') { + $situation_percent = 100; + } + if (empty($ref_ext)) { + $ref_ext = ''; + } $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3345,7 +3405,9 @@ class Facture extends CommonInvoice $txlocaltax2 = price2num($txlocaltax2); // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker @@ -3356,8 +3418,7 @@ class Facture extends CommonInvoice // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -3382,8 +3443,7 @@ class Facture extends CommonInvoice // Old properties: $price, $remise (deprecated) $price = $pu; $remise = 0; - if ($remise_percent > 0) - { + if ($remise_percent > 0) { $remise = round(($pu * $remise_percent / 100), 2); $price = ($pu - $remise); } @@ -3394,8 +3454,7 @@ class Facture extends CommonInvoice $line->fetch($rowid); $line->fetch_optionals(); - if (!empty($line->fk_product)) - { + if (!empty($line->fk_product)) { $product = new Product($this->db); $result = $product->fetch($line->fk_product); $product_type = $product->type; @@ -3415,8 +3474,7 @@ class Facture extends CommonInvoice $this->line->context = $this->context; // Reorder if fk_parent_line change - if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) - { + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { $rangmax = $this->line_max($fk_parent_line); $this->line->rang = $rangmax + 1; } @@ -3469,10 +3527,11 @@ class Facture extends CommonInvoice } $result = $this->line->update($user, $notrigger); - if ($result > 0) - { + if ($result > 0) { // Reorder if child line - if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) { + $this->line_order(true, 'DESC'); + } // Mise a jour info denormalisees au niveau facture $this->update_price(1); @@ -3504,16 +3563,18 @@ class Facture extends CommonInvoice AND f.fk_statut <> 0'; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->error = $this->db->error(); return false; } $obj = $this->db->fetch_object($result); - if ($obj === null) return true; - else return $situation_percent < $obj->situation_percent; + if ($obj === null) { + return true; + } else { + return $situation_percent < $obj->situation_percent; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3530,15 +3591,16 @@ class Facture extends CommonInvoice global $mysoc, $user; // Progress should never be changed for discount lines - if (($line->info_bits & 2) == 2) - { + if (($line->info_bits & 2) == 2) { return; } include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Cap percentages to 100 - if ($percent > 100) $percent = 100; + if ($percent > 100) { + $percent = 100; + } $line->situation_percent = $percent; $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); $line->total_ht = $tabprice[0]; @@ -3565,8 +3627,7 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); - if (!$this->brouillon) - { + if (!$this->brouillon) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -1; } @@ -3580,8 +3641,7 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3593,14 +3653,14 @@ class Facture extends CommonInvoice // For triggers $result = $line->fetch($rowid); - if (!($result > 0)) dol_print_error($this->db, $line->error, $line->errors); + if (!($result > 0)) { + dol_print_error($this->db, $line->error, $line->errors); + } - if ($line->delete($user) > 0) - { + if ($line->delete($user) > 0) { $result = $this->update_price(1); - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return 1; } else { @@ -3644,10 +3704,11 @@ class Facture extends CommonInvoice public function setDiscount($user, $remise, $notrigger = 0) { // Clean parameters - if (empty($remise)) $remise = 0; + if (empty($remise)) { + $remise = 0; + } - if ($user->rights->facture->creer) - { + if ($user->rights->facture->creer) { $remise = price2num($remise); $error = 0; @@ -3661,30 +3722,28 @@ class Facture extends CommonInvoice dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->remise_percent = $remise; $this->update_price(1); $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -3707,10 +3766,11 @@ class Facture extends CommonInvoice public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - if (empty($remise)) $remise = 0; + if (empty($remise)) { + $remise = 0; + } - if ($user->rights->facture->creer) - { + if ($user->rights->facture->creer) { $error = 0; $this->db->begin(); @@ -3724,34 +3784,31 @@ class Facture extends CommonInvoice dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$error) - { + if (!$error) { $this->oldcopy = clone $this; $this->remise_absolue = $remise; $this->update_price(1); } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -3781,7 +3838,9 @@ class Facture extends CommonInvoice $addonConstName = 'TAKEPOS_REF_ADDON'; // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->TAKEPOS_REF_ADDON)) $conf->global->TAKEPOS_REF_ADDON = 'mod_takepos_ref_simple'; + if (empty($conf->global->TAKEPOS_REF_ADDON)) { + $conf->global->TAKEPOS_REF_ADDON = 'mod_takepos_ref_simple'; + } $addon = $conf->global->TAKEPOS_REF_ADDON; } else { @@ -3792,9 +3851,13 @@ class Facture extends CommonInvoice $addonConstName = 'FACTURE_ADDON'; // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + if (empty($conf->global->FACTURE_ADDON)) { + $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + } elseif ($conf->global->FACTURE_ADDON == 'terre') { + $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + } elseif ($conf->global->FACTURE_ADDON == 'mercure') { + $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + } $addon = $conf->global->FACTURE_ADDON; } @@ -3876,26 +3939,21 @@ class Facture extends CommonInvoice $sql .= ' WHERE c.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_closing) - { + if ($obj->fk_user_closing) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_closing); $this->user_closing = $cluser; @@ -3936,37 +3994,41 @@ class Facture extends CommonInvoice $sql = "SELECT s.rowid, s.nom as name, s.client,"; $sql .= " f.rowid as fid, f.ref as ref, f.datef as df"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user"; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) //restriction - { + if (!$user->rights->societe->client->voir && !$socid) { //restriction $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($socid) $sql .= " AND s.rowid = ".$socid; - if ($draft) $sql .= " AND f.fk_statut = ".self::STATUS_DRAFT; - if (is_object($excluser)) $sql .= " AND f.fk_user_author <> ".$excluser->id; + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } + if ($draft) { + $sql .= " AND f.fk_statut = ".self::STATUS_DRAFT; + } + if (is_object($excluser)) { + $sql .= " AND f.fk_user_author <> ".$excluser->id; + } $sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->plimit($limit, $offset); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $numc = $this->db->num_rows($result); - if ($numc) - { + if ($numc) { $i = 0; - while ($i < $numc) - { + while ($i < $numc) { $obj = $this->db->fetch_object($result); - if ($shortlist == 1) - { + if ($shortlist == 1) { $ga[$obj->fid] = $obj->ref; - } elseif ($shortlist == 2) - { + } elseif ($shortlist == 2) { $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; } else { $ga[$i]['id'] = $obj->fid; @@ -4010,15 +4072,15 @@ class Facture extends CommonInvoice $sql .= " AND f.paye = 0"; // Pas classee payee completement $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($socid > 0) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $return[$obj->rowid] = array('id' => $obj->rowid, 'ref' => $obj->ref, 'status' => $obj->fk_statut); @@ -4075,20 +4137,23 @@ class Facture extends CommonInvoice $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir } - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($socid > 0) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $qualified = 0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; - if ($qualified) - { + if ($obj->fk_statut == self::STATUS_VALIDATED) { + $qualified = 1; + } + if ($obj->fk_statut == self::STATUS_CLOSED) { + $qualified = 1; + } + if ($qualified) { //$ref=$obj->ref; $paymentornot = ($obj->fk_paiement ? 1 : 0); $return[$obj->rowid] = array('ref'=>$obj->ref, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); @@ -4119,8 +4184,7 @@ class Facture extends CommonInvoice $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + if (!$user->rights->societe->client->voir && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; @@ -4128,11 +4192,12 @@ class Facture extends CommonInvoice $sql .= $clause." f.paye=0"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; - if ($user->socid) $sql .= " AND f.fk_soc = ".$user->socid; + if ($user->socid) { + $sql .= " AND f.fk_soc = ".$user->socid; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $langs->load("bills"); $now = dol_now(); @@ -4145,8 +4210,7 @@ class Facture extends CommonInvoice $generic_facture = new Facture($this->db); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); $generic_facture->statut = $obj->fk_statut; @@ -4216,12 +4280,10 @@ class Facture extends CommonInvoice $sql .= $this->db->plimit(100); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_prods = $this->db->num_rows($resql); $i = 0; - while ($i < $num_prods) - { + while ($i < $num_prods) { $i++; $row = $this->db->fetch_row($resql); $prodids[$i] = $row[0]; @@ -4258,13 +4320,11 @@ class Facture extends CommonInvoice $this->fk_incoterms = 0; $this->location_incoterms = ''; - if (empty($option) || $option != 'nolines') - { + if (empty($option) || $option != 'nolines') { // Lines $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new FactureLigne($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->qty = 1; @@ -4273,8 +4333,7 @@ class Facture extends CommonInvoice $line->localtax1_tx = 0; $line->localtax2_tx = 0; $line->remise_percent = 0; - if ($xnbp == 1) // Qty is negative (product line) - { + if ($xnbp == 1) { // Qty is negative (product line) $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; $line->qty = -1; @@ -4284,8 +4343,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ht = -200; $line->multicurrency_total_ttc = -239.2; $line->multicurrency_total_tva = -39.2; - } elseif ($xnbp == 2) // UP is negative (free line) - { + } elseif ($xnbp == 2) { // UP is negative (free line) $line->subprice = -100; $line->total_ht = -100; $line->total_ttc = -119.6; @@ -4294,8 +4352,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ht = -200; $line->multicurrency_total_ttc = -239.2; $line->multicurrency_total_tva = -39.2; - } elseif ($xnbp == 3) // Discount is 50% (product line) - { + } elseif ($xnbp == 3) { // Discount is 50% (product line) $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; $line->total_ht = 50; @@ -4374,8 +4431,7 @@ class Facture extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -4383,10 +4439,8 @@ class Facture extends CommonInvoice $sql .= " ".$clause." f.entity IN (".getEntity('invoice').")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["invoices"] = $obj->nb; } $this->db->free($resql); @@ -4425,8 +4479,7 @@ class Facture extends CommonInvoice $outputlangs->loadLangs(array("bills", "products")); - if (!dol_strlen($modele)) - { + if (!dol_strlen($modele)) { $modele = 'crabe'; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type; @@ -4457,8 +4510,7 @@ class Facture extends CommonInvoice $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { - if ($resql->num_rows > 0) - { + if ($resql->num_rows > 0) { $res = $this->db->fetch_array($resql); $ref = $res['max(situation_cycle_ref)']; $ref++; @@ -4536,27 +4588,25 @@ class Facture extends CommonInvoice dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('BILL_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -4626,21 +4676,19 @@ class Facture extends CommonInvoice $now = dol_now(); // Paid invoices have status STATUS_CLOSED - if ($this->statut != Facture::STATUS_VALIDATED) return false; + if ($this->statut != Facture::STATUS_VALIDATED) { + return false; + } $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); - if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) - { + if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { $totalpaye = $this->getSommePaiement(); $totalpaye = floatval($totalpaye); $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); - if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) - { - if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) - { + if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) { + if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; - } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) - { + } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; } else { $hasDelay = 0; @@ -4703,8 +4751,7 @@ class Facture extends CommonInvoice $retainedWarrantyAmount = 0; // Billed - retained warranty - if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) - { + if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) { $displayWarranty = true; // Check if this situation invoice is 100% for real if (!empty($this->lines)) { @@ -4716,8 +4763,7 @@ class Facture extends CommonInvoice } } - if ($displayWarranty && !empty($this->situation_final)) - { + if ($displayWarranty && !empty($this->situation_final)) { $this->fetchPreviousNextSituationInvoice(); $TPreviousIncoice = $this->tab_previous_situation_invoice; @@ -4756,15 +4802,13 @@ class Facture extends CommonInvoice public function setRetainedWarranty($value) { dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')'); - if ($this->statut >= 0) - { + if ($this->statut >= 0) { $fieldname = 'retained_warranty'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.floatval($value); $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->retained_warranty = floatval($value); return 1; } else { @@ -4795,15 +4839,13 @@ class Facture extends CommonInvoice dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); - if ($this->statut >= 0) - { + if ($this->statut >= 0) { $fieldname = 'retained_warranty_date_limit'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.(strval($timestamp) != '' ? '\''.$this->db->idate($timestamp).'\'' : 'null'); $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->retained_warranty_date_limit = $timestamp; return 1; } else { @@ -4917,8 +4959,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ' WHERE fd.rowid = '.$rowid; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; @@ -5002,34 +5043,74 @@ class FactureLigne extends CommonInvoiceLine // Clean parameters $this->desc = trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) $this->localtax1_type = 0; - if (empty($this->localtax2_type)) $this->localtax2_type = 0; - if (empty($this->total_localtax1)) $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) $this->total_localtax2 = 0; - if (empty($this->rang)) $this->rang = 0; - if (empty($this->remise_percent)) $this->remise_percent = 0; - if (empty($this->info_bits)) $this->info_bits = 0; - if (empty($this->subprice)) $this->subprice = 0; - if (empty($this->ref_ext)) $this->ref_ext = ''; - if (empty($this->special_code)) $this->special_code = 0; - if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; - if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; - if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (empty($this->tva_tx)) { + $this->tva_tx = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } + if (empty($this->localtax1_type)) { + $this->localtax1_type = 0; + } + if (empty($this->localtax2_type)) { + $this->localtax2_type = 0; + } + if (empty($this->total_localtax1)) { + $this->total_localtax1 = 0; + } + if (empty($this->total_localtax2)) { + $this->total_localtax2 = 0; + } + if (empty($this->rang)) { + $this->rang = 0; + } + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } + if (empty($this->info_bits)) { + $this->info_bits = 0; + } + if (empty($this->subprice)) { + $this->subprice = 0; + } + if (empty($this->ref_ext)) { + $this->ref_ext = ''; + } + if (empty($this->special_code)) { + $this->special_code = 0; + } + if (empty($this->fk_parent_line)) { + $this->fk_parent_line = 0; + } + if (empty($this->fk_prev_id)) { + $this->fk_prev_id = 0; + } + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { + $this->situation_percent = 100; + } - if (empty($this->pa_ht)) $this->pa_ht = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->pa_ht)) { + $this->pa_ht = 0; + } + if (empty($this->multicurrency_subprice)) { + $this->multicurrency_subprice = 0; + } + if (empty($this->multicurrency_total_ht)) { + $this->multicurrency_total_ht = 0; + } + if (empty($this->multicurrency_total_tva)) { + $this->multicurrency_total_tva = 0; + } + if (empty($this->multicurrency_total_ttc)) { + $this->multicurrency_total_ttc = 0; + } // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { + if ($this->pa_ht == 0 && $pa_ht_isemptystring) { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; } else { $this->pa_ht = $result; @@ -5037,17 +5118,14 @@ class FactureLigne extends CommonInvoiceLine } // Check parameters - if ($this->product_type < 0) - { + if ($this->product_type < 0) { $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (!empty($this->fk_product)) - { + if (!empty($this->fk_product)) { // Check product exists $result = Product::isExistingObject('product', $this->fk_product); - if ($result <= 0) - { + if ($result <= 0) { $this->error = 'ErrorProductIdDoesNotExists'; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); return -1; @@ -5113,36 +5191,28 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); $this->rowid = $this->id; // For backward compatibility - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } // Si fk_remise_except defini, on lie la remise a la facture // ce qui la flague comme "consommee". - if ($this->fk_remise_except) - { + if ($this->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $result = $discount->fetch($this->fk_remise_except); - if ($result >= 0) - { + if ($result >= 0) { // Check if discount was found - if ($result > 0) - { + if ($result > 0) { // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) - { - if (empty($noerrorifdiscountalreadylinked)) - { + if ($discount->fk_facture_line > 0) { + if (empty($noerrorifdiscountalreadylinked)) { $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); @@ -5150,8 +5220,7 @@ class FactureLigne extends CommonInvoiceLine } } else { $result = $discount->link_to_invoice($this->rowid, 0); - if ($result < 0) - { + if ($result < 0) { $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); @@ -5172,12 +5241,10 @@ class FactureLigne extends CommonInvoiceLine } } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINEBILL_INSERT', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } @@ -5210,35 +5277,73 @@ class FactureLigne extends CommonInvoiceLine // Clean parameters $this->desc = trim($this->desc); - if (empty($this->ref_ext)) $this->ref_ext = ''; - if (empty($this->tva_tx)) $this->tva_tx = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) $this->localtax1_type = 0; - if (empty($this->localtax2_type)) $this->localtax2_type = 0; - if (empty($this->total_localtax1)) $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) $this->total_localtax2 = 0; - if (empty($this->remise_percent)) $this->remise_percent = 0; - if (empty($this->info_bits)) $this->info_bits = 0; - if (empty($this->special_code)) $this->special_code = 0; - if (empty($this->product_type)) $this->product_type = 0; - if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; - if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->ref_ext)) { + $this->ref_ext = ''; + } + if (empty($this->tva_tx)) { + $this->tva_tx = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } + if (empty($this->localtax1_type)) { + $this->localtax1_type = 0; + } + if (empty($this->localtax2_type)) { + $this->localtax2_type = 0; + } + if (empty($this->total_localtax1)) { + $this->total_localtax1 = 0; + } + if (empty($this->total_localtax2)) { + $this->total_localtax2 = 0; + } + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } + if (empty($this->info_bits)) { + $this->info_bits = 0; + } + if (empty($this->special_code)) { + $this->special_code = 0; + } + if (empty($this->product_type)) { + $this->product_type = 0; + } + if (empty($this->fk_parent_line)) { + $this->fk_parent_line = 0; + } + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { + $this->situation_percent = 100; + } + if (empty($this->pa_ht)) { + $this->pa_ht = 0; + } - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->multicurrency_subprice)) { + $this->multicurrency_subprice = 0; + } + if (empty($this->multicurrency_total_ht)) { + $this->multicurrency_total_ht = 0; + } + if (empty($this->multicurrency_total_tva)) { + $this->multicurrency_total_tva = 0; + } + if (empty($this->multicurrency_total_ttc)) { + $this->multicurrency_total_ttc = 0; + } // Check parameters - if ($this->product_type < 0) return -1; + if ($this->product_type < 0) { + return -1; + } // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0 && $pa_ht_isemptystring) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { + if ($this->pa_ht == 0 && $pa_ht_isemptystring) { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; } else { $this->pa_ht = $result; @@ -5254,8 +5359,11 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; - else $sql .= ", fk_remise_except=null"; + if ($this->fk_remise_except) { + $sql .= ", fk_remise_except=".$this->fk_remise_except; + } else { + $sql .= ", fk_remise_except=null"; + } $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; $sql .= ", tva_tx=".price2num($this->tva_tx).""; $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; @@ -5268,8 +5376,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", product_type=".$this->product_type; $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; - if (empty($this->skip_update_total)) - { + if (empty($this->skip_update_total)) { $sql .= ", total_ht=".price2num($this->total_ht); $sql .= ", total_tva=".price2num($this->total_tva); $sql .= ", total_ttc=".price2num($this->total_ttc); @@ -5279,7 +5386,9 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); - if (!empty($this->rang)) $sql .= ", rang=".$this->rang; + if (!empty($this->rang)) { + $sql .= ", rang=".$this->rang; + } $sql .= ", situation_percent=".$this->situation_percent; $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql .= ", fk_user_modif =".$user->id; @@ -5294,24 +5403,19 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { + if ($resql) { + if (!$error) { $this->id = $this->rowid; $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEBILL_UPDATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } @@ -5340,8 +5444,7 @@ class FactureLigne extends CommonInvoiceLine // Call trigger $result = $this->call_trigger('LINEBILL_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -5349,16 +5452,14 @@ class FactureLigne extends CommonInvoiceLine // extrafields $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->db->commit(); return 1; } else { @@ -5382,8 +5483,12 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::update_total", LOG_DEBUG); // Clean parameters - if (empty($this->total_localtax1)) $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->total_localtax1)) { + $this->total_localtax1 = 0; + } + if (empty($this->total_localtax2)) { + $this->total_localtax2 = 0; + } // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; @@ -5397,8 +5502,7 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::update_total", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -5429,7 +5533,9 @@ class FactureLigne extends CommonInvoiceLine $invoicecache[$invoiceid] = new Facture($this->db); $invoicecache[$invoiceid]->fetch($invoiceid); } - if ($invoicecache[$invoiceid]->type != Facture::TYPE_SITUATION) return 0; + if ($invoicecache[$invoiceid]->type != Facture::TYPE_SITUATION) { + return 0; + } $sql = 'SELECT situation_percent FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid='.$this->fk_prev_id; $resql = $this->db->query($sql); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index e6c4a5a9c22..47644e4b13e 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -67,16 +67,14 @@ class FactureStats extends Stats $this->cachefilesuffix = $mode; $this->join = ''; - if ($mode == 'customer') - { + if ($mode == 'customer') { $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'; } - if ($mode == 'supplier') - { + if ($mode == 'supplier') { $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"; @@ -87,24 +85,30 @@ class FactureStats extends Stats $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) - if ($this->socid) - { + 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; } - 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)"; + } - if ($typentid) - { + if ($typentid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc'; $this->where .= ' AND s.fk_typent = '.$typentid; } - if ($categid) - { + if ($categid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; $this->where .= ' AND c.rowid = '.$categid; @@ -125,7 +129,9 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $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; @@ -149,7 +155,9 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; @@ -172,7 +180,9 @@ class FactureStats extends Stats $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"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $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; @@ -196,7 +206,9 @@ class FactureStats extends Stats $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"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $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; @@ -217,7 +229,9 @@ class FactureStats extends Stats $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"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; @@ -239,7 +253,9 @@ class FactureStats extends Stats $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"; + if (!$user->rights->societe->client->voir && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 97297582081..4795a9b2062 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -88,14 +88,30 @@ class PaymentTerm // extends CommonObject // Clean parameters - if (isset($this->code)) $this->code = trim($this->code); - if (isset($this->sortorder)) $this->sortorder = trim($this->sortorder); - if (isset($this->active)) $this->active = trim($this->active); - if (isset($this->libelle)) $this->libelle = trim($this->libelle); - if (isset($this->libelle_facture)) $this->libelle_facture = trim($this->libelle_facture); - if (isset($this->type_cdr)) $this->type_cdr = trim($this->type_cdr); - if (isset($this->nbjour)) $this->nbjour = trim($this->nbjour); - if (isset($this->decalage)) $this->decalage = trim($this->decalage); + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->sortorder)) { + $this->sortorder = trim($this->sortorder); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + if (isset($this->libelle)) { + $this->libelle = trim($this->libelle); + } + if (isset($this->libelle_facture)) { + $this->libelle_facture = trim($this->libelle_facture); + } + if (isset($this->type_cdr)) { + $this->type_cdr = trim($this->type_cdr); + } + if (isset($this->nbjour)) { + $this->nbjour = trim($this->nbjour); + } + if (isset($this->decalage)) { + $this->decalage = trim($this->decalage); + } // Check parameters @@ -126,20 +142,19 @@ class PaymentTerm // extends CommonObject $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_payment_term"); } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -180,10 +195,8 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -201,7 +214,7 @@ class PaymentTerm // extends CommonObject return 1; } else { - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -226,12 +239,12 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - if ($obj) $ret = $obj->rowid; + if ($obj) { + $ret = $obj->rowid; + } } $this->db->free($resql); return $ret; @@ -257,14 +270,30 @@ class PaymentTerm // extends CommonObject // Clean parameters - if (isset($this->code)) $this->code = trim($this->code); - if (isset($this->sortorder)) $this->sortorder = trim($this->sortorder); - if (isset($this->active)) $this->active = trim($this->active); - if (isset($this->libelle)) $this->libelle = trim($this->libelle); - if (isset($this->libelle_facture)) $this->libelle_facture = trim($this->libelle_facture); - if (isset($this->type_cdr)) $this->type_cdr = trim($this->type_cdr); - if (isset($this->nbjour)) $this->nbjour = trim($this->nbjour); - if (isset($this->decalage)) $this->decalage = trim($this->decalage); + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->sortorder)) { + $this->sortorder = trim($this->sortorder); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + if (isset($this->libelle)) { + $this->libelle = trim($this->libelle); + } + if (isset($this->libelle_facture)) { + $this->libelle_facture = trim($this->libelle_facture); + } + if (isset($this->type_cdr)) { + $this->type_cdr = trim($this->type_cdr); + } + if (isset($this->nbjour)) { + $this->nbjour = trim($this->nbjour); + } + if (isset($this->decalage)) { + $this->decalage = trim($this->decalage); + } @@ -287,13 +316,13 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -325,13 +354,13 @@ class PaymentTerm // extends CommonObject 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -373,8 +402,7 @@ class PaymentTerm // extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $error++; } @@ -382,8 +410,7 @@ class PaymentTerm // extends CommonObject unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 6b8758bc472..dc1fe1e7c45 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -45,7 +45,9 @@ $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'facture', $id); $object = new Facture($db); @@ -55,47 +57,39 @@ $object = new Facture($db); * Add a new contact */ -if ($action == 'addcontact' && $user->rights->facture->creer) -{ +if ($action == 'addcontact' && $user->rights->facture->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} // Toggle the status of a contact -elseif ($action == 'swapstatut' && $user->rights->facture->creer) -{ - if ($object->fetch($id)) - { +} elseif ($action == 'swapstatut' && $user->rights->facture->creer) { + // Toggle the status of a contact + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } -} // Deletes a contact -elseif ($action == 'deletecontact' && $user->rights->facture->creer) -{ +} elseif ($action == 'deletecontact' && $user->rights->facture->creer) { + // Deletes a contact $object->fetch($id); $result = $object->delete_contact($lineid); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -124,10 +118,8 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $head = facture_prepare_head($object); @@ -147,12 +139,10 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { + if ($user->rights->facture->creer) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; @@ -192,10 +182,11 @@ if ($id > 0 || !empty($ref)) // 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) - { + foreach ($dirtpls as $reldir) { $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + if ($res) { + break; + } } } else { // Record not found diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index cbf6b045e85..c44aeae67ca 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -49,8 +49,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) -{ +if ($user->socid) { $socid = $user->socid; } $result = restrictedArea($user, 'facture', $id, ''); @@ -60,16 +59,21 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Facture($db); -if ($object->fetch($id)) -{ +if ($object->fetch($id)) { $object->fetch_thirdparty(); $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); } @@ -92,10 +96,8 @@ llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); @@ -108,8 +110,7 @@ if ($id > 0 || !empty($ref)) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -125,15 +126,14 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') + if ($user->rights->facture->creer) { + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $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 .= ''; diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index e96371ad4f4..4939fbb6a95 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -34,8 +34,7 @@ $langs->load('bills'); // Filter to show only result of one customer $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -58,8 +57,7 @@ print '
'; print '
'; // This is useless due to the global search combo -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) -{ +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print getAreaSearchFrom(); print '
'; } @@ -129,16 +127,21 @@ function getPieChart($socid = 0) $sql = "SELECT count(f.rowid), f.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture').")"; - if ($user->socid) $sql .= ' AND f.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) { + $sql .= ' AND f.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $sql .= " GROUP BY f.fk_statut"; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -149,11 +152,9 @@ function getPieChart($socid = 0) $total = 0; $vals = []; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); - if ($row) - { + if ($row) { $vals[$row[1]] = $row[0]; $total += $row[0]; } @@ -173,14 +174,12 @@ function getPieChart($socid = 0) $array = [Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED]; $dataseries = []; - foreach ($array as $status) - { + foreach ($array as $status) { $objectstatic->statut = $status; $objectstatic->paye = $status == Facture::STATUS_CLOSED ? -1 : 0; $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)]; - if (!$conf->use_javascript_ajax) - { + if (!$conf->use_javascript_ajax) { $result .= '
'; $result .= ''; $result .= ''; @@ -188,8 +187,7 @@ function getPieChart($socid = 0) } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); $dolgraph->setShowLegend(2); @@ -227,17 +225,22 @@ function getDraftTable($maxCount = 500, $socid = 0) $sql = "SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total as total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture').")"; $sql .= " AND f.fk_statut = ".Facture::STATUS_DRAFT; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -256,8 +259,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $result .= ''; $result .= ''; - if ($num < 1) - { + if ($num < 1) { $result .= '
'.$langs->trans("Ref").'
'; @@ -863,8 +829,7 @@ if ($type == Categorie::TYPE_ACCOUNT) print ''.$account->number."'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -882,15 +847,13 @@ if ($type == Categorie::TYPE_ACCOUNT) } // List of Project -if ($type == Categorie::TYPE_PROJECT) -{ +if ($type == Categorie::TYPE_PROJECT) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $permission = $user->rights->projet->creer; $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($objects < 0) - { + if ($objects < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -908,13 +871,13 @@ if ($type == Categorie::TYPE_PROJECT) print "\n"; print ''."\n"; - if (count($objects) > 0) - { + if (count($objects) > 0) { $i = 0; - foreach ($objects as $key => $project) - { + foreach ($objects as $key => $project) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) - { + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; print ''; print '
'.$langs->trans("Ref").'
'; @@ -924,8 +887,7 @@ if ($type == Categorie::TYPE_PROJECT) print ''.$project->title."'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -943,13 +905,11 @@ if ($type == Categorie::TYPE_PROJECT) } // List of users -if ($type == Categorie::TYPE_USER) -{ +if ($type == Categorie::TYPE_USER) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $users = $object->getObjectsInCateg($type); - if ($users < 0) - { + if ($users < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -969,11 +929,9 @@ if ($type == Categorie::TYPE_USER) print "\n"; print ''."\n"; - if (count($users) > 0) - { + if (count($users) > 0) { // Use "$userentry" here, because "$user" is the current user - foreach ($users as $key => $userentry) - { + foreach ($users as $key => $userentry) { print "\t".''."\n"; print ''; // Status - Percent $withstatus = 0; - if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') - { + if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { $withstatus = 1; - if ($event->percentage >= 0) $withstatus = 2; + if ($event->percentage >= 0) { + $withstatus = 2; + } } print '
'.$langs->trans("Users").' '.$num.'
'; print $userentry->getNomUrl(1); @@ -982,8 +940,7 @@ if ($type == Categorie::TYPE_USER) // Link to delete from category print ''; - if ($user->rights->user->user->creer) - { + if ($user->rights->user->user->creer) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); @@ -1002,15 +959,13 @@ if ($type == Categorie::TYPE_USER) // List of warehouses -if ($type == Categorie::TYPE_WAREHOUSE) -{ +if ($type == Categorie::TYPE_WAREHOUSE) { $permission = $user->rights->stock->creer; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($objects < 0) - { + if ($objects < 0) { dol_print_error($db, $object->error, $object->errors); } else { print ''; @@ -1028,13 +983,13 @@ if ($type == Categorie::TYPE_WAREHOUSE) print "\n"; print ''."\n"; - if (count($objects) > 0) - { + if (count($objects) > 0) { $i = 0; - foreach ($objects as $key => $project) - { + foreach ($objects as $key => $project) { $i++; - if ($i > $limit) break; + if ($i > $limit) { + break; + } print "\t".''."\n"; print '\n"; // Link to delete from category print ''; $i = 0; - while ($i < 7) - { + while ($i < 7) { print ' '."\n"; $i++; } @@ -1283,15 +1365,11 @@ if (empty($action) || $action == 'show_month') // View by month for ($iter_week = 0; $iter_week < 6; $iter_week++) { echo " \n"; // Get date of the current day, format 'yyyy-mm-dd' - if ($tmpday <= 0) // If number of the current day is in previous month - { + if ($tmpday <= 0) { // If number of the current day is in previous month $currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday); - } - elseif ($tmpday <= $max_day_in_month) // If number of the current day is in current month - { + } elseif ($tmpday <= $max_day_in_month) { // If number of the current day is in current month $currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday); - } - else // If number of the current day is in next month + } else // If number of the current day is in next month { $currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month); } @@ -1304,7 +1382,9 @@ if (empty($action) || $action == 'show_month') // View by month if ($tmpday <= 0) { /* Show days before the beginning of the current month (previous month) */ $style = 'cal_other_month cal_past'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; + if ($iter_day == 6) { + $style .= ' cal_other_month_right'; + } echo ' \n"; @@ -1312,11 +1392,19 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days of the current month */ $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); $style = 'cal_current_month'; - if ($iter_day == 6) $style .= ' cal_current_month_right'; + if ($iter_day == 6) { + $style .= ' cal_current_month_right'; + } $today = 0; - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; - if ($today) $style = 'cal_today'; - if ($curtime < $todaytms) $style .= ' cal_past'; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) { + $today = 1; + } + if ($today) { + $style = 'cal_today'; + } + if ($curtime < $todaytms) { + $style .= ' cal_past'; + } //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); echo ' \n"; @@ -1376,12 +1466,18 @@ if (empty($action) || $action == 'show_month') // View by month $tmpyear = dol_print_date($curtime, '%Y', 'tzuserrel'); $style = 'cal_current_month'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; + if ($iter_day == 6) { + $style .= ' cal_other_month_right'; + } $today = 0; $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; - if ($today) $style = 'cal_today'; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { + $today = 1; + } + if ($today) { + $style = 'cal_today'; + } echo ' \n"; /* - echo '
'; - echo '
'; - echo '
'; - echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); - echo '
'."\n"; - echo "
\n"; + echo '
'; + echo '
'; + echo '
'; + echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); + echo '
'."\n"; + echo "
\n"; */ echo '
'.$langs->trans("Ref").'
'; @@ -1044,8 +999,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) print ''.$project->title."'; - if ($permission) - { + if ($permission) { print ""; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index e5fe22c9168..296e0f3852f 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "website")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $conf->dol_hide_leftmenu = 1; // Force hide of left menu. @@ -41,17 +43,37 @@ $page = GETPOST('page', 'alpha'); $pageid = GETPOST('pageid', 'int'); $action = GETPOST('action', 'aZ09'); -if (GETPOST('delete')) { $action = 'delete'; } -if (GETPOST('preview')) $action = 'preview'; -if (GETPOST('create')) { $action = 'create'; } -if (GETPOST('editmedia')) { $action = 'editmedia'; } -if (GETPOST('editcss')) { $action = 'editcss'; } -if (GETPOST('editmenu')) { $action = 'editmenu'; } -if (GETPOST('setashome')) { $action = 'setashome'; } -if (GETPOST('editmeta')) { $action = 'editmeta'; } -if (GETPOST('editcontent')) { $action = 'editcontent'; } +if (GETPOST('delete')) { + $action = 'delete'; +} +if (GETPOST('preview')) { + $action = 'preview'; +} +if (GETPOST('create')) { + $action = 'create'; +} +if (GETPOST('editmedia')) { + $action = 'editmedia'; +} +if (GETPOST('editcss')) { + $action = 'editcss'; +} +if (GETPOST('editmenu')) { + $action = 'editmenu'; +} +if (GETPOST('setashome')) { + $action = 'setashome'; +} +if (GETPOST('editmeta')) { + $action = 'editmeta'; +} +if (GETPOST('editcontent')) { + $action = 'editcontent'; +} -if (empty($action)) $action = 'preview'; +if (empty($action)) { + $action = 'preview'; +} @@ -60,13 +82,16 @@ if (empty($action)) $action = 'preview'; * Actions */ -if (GETPOST('refreshsite')) $pageid = 0; // If we change the site, we reset the pageid. -if (GETPOST('refreshpage')) $action = 'preview'; +if (GETPOST('refreshsite')) { + $pageid = 0; // If we change the site, we reset the pageid. +} +if (GETPOST('refreshpage')) { + $action = 'preview'; +} // Add a collab page -if ($action == 'add') -{ +if ($action == 'add') { $db->begin(); $objectpage->title = GETPOST('WEBSITE_TITLE'); @@ -74,23 +99,19 @@ if ($action == 'add') $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORD'); - if (empty($objectpage->title)) - { + if (empty($objectpage->title)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $res = $objectpage->create($user); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); $action = ''; @@ -103,25 +124,21 @@ if ($action == 'add') } // Update page -if ($action == 'delete') -{ +if ($action == 'delete') { $db->begin(); $res = $object->fetch(0, $website); $res = $objectpage->fetch($pageid, $object->fk_website); - if ($res > 0) - { + if ($res > 0) { $res = $objectpage->delete($user); - if (!($res > 0)) - { + if (!($res > 0)) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); @@ -149,15 +166,16 @@ llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', ' print "\n".'
'; print ''; -if ($action == 'create') -{ +if ($action == 'create') { print ''; } // Add a margin under toolbar ? $style = ''; -if ($action != 'preview' && $action != 'editcontent') $style = ' margin-bottom: 5px;'; +if ($action != 'preview' && $action != 'editcontent') { + $style = ' margin-bottom: 5px;'; +} //var_dump($objectpage);exit; print '
'; From 464e4442b1a7856880f50ebce440c3eeea0fad09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 18:23:14 +0100 Subject: [PATCH 060/173] fix fourn card --- htdocs/fourn/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9794ea3cc11..418773daec5 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2014 Jean Heimburger * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2021 Frédéric France * * 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 @@ -657,7 +658,7 @@ if ($object->id > 0) $num = $object_count->total; } - $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; + $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql .= " WHERE p.fk_soc =".$object->id; $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")"; From 5931051c88a6329086861e66201b708eddeebafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 18:59:19 +0100 Subject: [PATCH 061/173] code syntax comm directory --- htdocs/comm/action/card.php | 689 +++++----- htdocs/comm/action/class/actioncomm.class.php | 806 +++++++----- .../action/class/actioncommreminder.class.php | 29 +- .../action/class/api_agendaevents.class.php | 81 +- .../comm/action/class/cactioncomm.class.php | 99 +- htdocs/comm/action/class/ical.class.php | 96 +- htdocs/comm/action/document.php | 98 +- htdocs/comm/action/index.php | 887 +++++++------ htdocs/comm/action/info.php | 10 +- htdocs/comm/action/list.php | 566 +++++--- htdocs/comm/action/pertype.php | 590 +++++---- htdocs/comm/action/peruser.php | 719 ++++++---- htdocs/comm/action/rapport/index.php | 56 +- htdocs/comm/admin/propal_extrafields.php | 17 +- htdocs/comm/admin/propaldet_extrafields.php | 20 +- htdocs/comm/card.php | 1 - htdocs/comm/contact.php | 67 +- htdocs/comm/index.php | 3 +- htdocs/comm/mailing/advtargetemailing.php | 24 +- htdocs/comm/mailing/card.php | 2 +- htdocs/comm/mailing/cibles.php | 254 ++-- .../mailing/class/advtargetemailing.class.php | 2 +- .../html.formadvtargetemailing.class.php | 33 +- htdocs/comm/mailing/class/mailing.class.php | 2 +- htdocs/comm/mailing/index.php | 37 +- htdocs/comm/mailing/info.php | 1 - htdocs/comm/mailing/list.php | 125 +- htdocs/comm/multiprix.php | 35 +- htdocs/comm/propal/card.php | 690 +++++----- .../comm/propal/class/api_proposals.class.php | 141 +- htdocs/comm/propal/class/propal.class.php | 1164 +++++++++-------- .../comm/propal/class/propalestats.class.php | 47 +- htdocs/comm/propal/contact.php | 60 +- htdocs/comm/propal/document.php | 46 +- htdocs/comm/propal/index.php | 2 +- htdocs/comm/propal/info.php | 19 +- htdocs/comm/propal/list.php | 1076 +++++++++------ htdocs/comm/propal/note.php | 23 +- htdocs/comm/propal/stats/index.php | 90 +- .../comm/propal/tpl/linkedobjectblock.tpl.php | 13 +- htdocs/comm/prospect/index.php | 1 - htdocs/comm/prospect/recap-prospect.php | 20 +- htdocs/comm/recap-client.php | 19 +- htdocs/comm/remise.php | 54 +- htdocs/comm/remx.php | 277 ++-- 45 files changed, 5038 insertions(+), 4053 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fba2cf10cbc..3b539895348 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -77,9 +77,13 @@ $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2mi // Security check $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -if ($user->socid && $socid) $result = restrictedArea($user, 'societe', $socid); +if ($user->socid && $socid) { + $result = restrictedArea($user, 'societe', $socid); +} $error = GETPOST("error"); $donotclearsession = GETPOST('donotclearsession') ?GETPOST('donotclearsession') : 0; @@ -114,11 +118,17 @@ $hookmanager->initHooks(array('actioncard', 'globalcard')); $parameters = array('socid' => $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $TRemindTypes = array(); -if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes['browser'] = array('label'=>$langs->trans('BrowserPush'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0)); -if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes['email'] = array('label'=>$langs->trans('EMail'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0)); +if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) { + $TRemindTypes['browser'] = array('label'=>$langs->trans('BrowserPush'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0)); +} +if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) { + $TRemindTypes['email'] = array('label'=>$langs->trans('EMail'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0)); +} $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); @@ -129,60 +139,65 @@ $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month') $listUserAssignedUpdated = false; // Remove user to assigned list -if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) -{ +if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) { $idtoremove = GETPOST('removedassigned'); - if (!empty($_SESSION['assignedtouser'])) $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1); - else $tmpassigneduserids = array(); + if (!empty($_SESSION['assignedtouser'])) { + $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1); + } else { + $tmpassigneduserids = array(); + } - foreach ($tmpassigneduserids as $key => $val) - { - if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); + foreach ($tmpassigneduserids as $key => $val) { + if ($val['id'] == $idtoremove || $val['id'] == -1) { + unset($tmpassigneduserids[$key]); + } } $_SESSION['assignedtouser'] = json_encode($tmpassigneduserids); $donotclearsession = 1; - if ($action == 'add') $action = 'create'; - if ($action == 'update') $action = 'edit'; + if ($action == 'add') { + $action = 'create'; + } + if ($action == 'update') { + $action = 'edit'; + } $listUserAssignedUpdated = true; } // Add user to assigned list -if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) -{ +if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) { // Add a new user - if (GETPOST('assignedtouser') > 0) - { + if (GETPOST('assignedtouser') > 0) { $assignedtouser = array(); - if (!empty($_SESSION['assignedtouser'])) - { + if (!empty($_SESSION['assignedtouser'])) { $assignedtouser = json_decode($_SESSION['assignedtouser'], true); } $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); $_SESSION['assignedtouser'] = json_encode($assignedtouser); } $donotclearsession = 1; - if ($action == 'add') $action = 'create'; - if ($action == 'update') $action = 'edit'; + if ($action == 'add') { + $action = 'create'; + } + if ($action == 'update') { + $action = 'edit'; + } $listUserAssignedUpdated = true; } // Link to a project if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) -{ + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { //$object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } // Action clone object -if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') -{ - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { +if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { if ($id > 0) { @@ -204,23 +219,22 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') } // Add event -if (empty($reshook) && $action == 'add') -{ +if (empty($reshook) && $action == 'add') { $error = 0; - if (empty($backtopage)) - { - if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + if (empty($backtopage)) { + if ($socid > 0) { + $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; + } else { + $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + } } - if (!empty($socpeopleassigned[0])) - { + if (!empty($socpeopleassigned[0])) { $result = $contact->fetch($socpeopleassigned[0]); } - if ($cancel) - { + if ($cancel) { header("Location: ".$backtopage); exit; } @@ -232,23 +246,20 @@ if (empty($reshook) && $action == 'add') $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); // Check parameters - if (!$datef && $percentage == 100) - { + if (!$datef && $percentage == 100) { $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !GETPOST('label')) - { + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !GETPOST('label')) { $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); } // Initialisation objet cactioncomm - if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) // actioncode is '0' - { + if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); @@ -256,8 +267,7 @@ if (empty($reshook) && $action == 'add') $object->type_code = GETPOST('actioncode', 'aZ09'); } - if (!$error) - { + if (!$error) { // Initialisation objet actioncomm $object->priority = GETPOSTISSET("priority") ? GETPOST("priority", "int") : 0; $object->fulldayevent = (!empty($fulldayevent) ? 1 : 0); @@ -265,14 +275,11 @@ if (empty($reshook) && $action == 'add') $object->label = GETPOST('label', 'alphanohtml'); $object->fk_element = GETPOST("fk_element", 'int'); $object->elementtype = GETPOST("elementtype", 'alpha'); - if (!GETPOST('label')) - { - if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) - { + if (!GETPOST('label')) { + if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) { $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs)); } else { - if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) - { + if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) { $object->label = $langs->transnoentitiesnoconv("Action".$object->type_code)."\n"; } else { $cactioncomm->fetch($object->type_code); @@ -301,13 +308,15 @@ if (empty($reshook) && $action == 'add') $transparency = (GETPOST("transparency") == 'on' ? 1 : 0); $listofuserid = array(); - if (!empty($_SESSION['assignedtouser'])) $listofuserid = json_decode($_SESSION['assignedtouser'], true); + if (!empty($_SESSION['assignedtouser'])) { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } $i = 0; - foreach ($listofuserid as $key => $value) - { - if ($i == 0) // First entry - { - if ($value['id'] > 0) $object->userownerid = $value['id']; + foreach ($listofuserid as $key => $value) { + if ($i == 0) { // First entry + if ($value['id'] > 0) { + $object->userownerid = $value['id']; + } $object->transparency = $transparency; } @@ -317,17 +326,19 @@ if (empty($reshook) && $action == 'add') } } - if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) - { - if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby", "int"); + if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) { + if (GETPOST("doneby") > 0) { + $object->userdoneid = GETPOST("doneby", "int"); + } } $object->note_private = trim(GETPOST("note", "restricthtml")); - if (GETPOSTISSET("contactid")) $object->contact = $contact; + if (GETPOSTISSET("contactid")) { + $object->contact = $contact; + } - if (GETPOST('socid', 'int') > 0) - { + if (GETPOST('socid', 'int') > 0) { $object->socid = GETPOST('socid', 'int'); $object->fetch_thirdparty(); @@ -335,51 +346,45 @@ if (empty($reshook) && $action == 'add') } // Check parameters - if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) - { + if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) { $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ActionsOwnedBy")), null, 'errors'); } - if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) - { + if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) { $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } - if (!GETPOST('apyear') && !GETPOST('adyear')) - { + if (!GETPOST('apyear') && !GETPOST('adyear')) { $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - foreach ($socpeopleassigned as $cid) - { + foreach ($socpeopleassigned as $cid) { $object->socpeopleassigned[$cid] = array('id' => $cid); } - if (!empty($object->socpeopleassigned)) - { + if (!empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); $object->contact_id = key($object->socpeopleassigned); } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { $db->begin(); // Creation of action/event $idaction = $object->create($user); - if ($idaction > 0) - { - if (!$object->error) - { + if ($idaction > 0) { + if (!$object->error) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); @@ -387,7 +392,9 @@ if (empty($reshook) && $action == 'add') unset($_SESSION['assignedtouser']); $moreparam = ''; - if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + if ($user->id != $object->userownerid) { + $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + } // Create reminders if ($addreminder == 'on') { @@ -401,11 +408,12 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } // the notification must be created for every user assigned to the event - foreach ($object->userassigned as $userassigned) - { + foreach ($object->userassigned as $userassigned) { $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); @@ -427,12 +435,10 @@ if (empty($reshook) && $action == 'add') $db->commit(); } - if (!empty($backtopage)) - { + if (!empty($backtopage)) { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - } elseif ($idaction) - { + } elseif ($idaction) { header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); } else { header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); @@ -457,10 +463,8 @@ if (empty($reshook) && $action == 'add') /* * Action update event */ -if (empty($reshook) && $action == 'update') -{ - if (empty($cancel)) - { +if (empty($reshook) && $action == 'update') { + if (empty($cancel)) { $fulldayevent = GETPOST('fullday'); $aphour = GETPOST('aphour', 'int'); $apmin = GETPOST('apmin', 'int'); @@ -469,10 +473,18 @@ if (empty($reshook) && $action == 'update') $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters - if ($aphour == -1) $aphour = '0'; - if ($apmin == -1) $apmin = '0'; - if ($p2hour == -1) $p2hour = '0'; - if ($p2min == -1) $p2min = '0'; + if ($aphour == -1) { + $aphour = '0'; + } + if ($apmin == -1) { + $apmin = '0'; + } + if ($p2hour == -1) { + $p2hour = '0'; + } + if ($p2min == -1) { + $p2min = '0'; + } $object->fetch($id); $object->fetch_optionals(); @@ -493,7 +505,9 @@ if (empty($reshook) && $action == 'update') $object->socid = GETPOST("socid", "int"); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); $object->socpeopleassigned = array(); - foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); + foreach ($socpeopleassigned as $cid) { + $object->socpeopleassigned[$cid] = array('id' => $cid); + } $object->contact_id = GETPOST("contactid", 'int'); if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); @@ -503,8 +517,7 @@ if (empty($reshook) && $action == 'update') $object->note_private = trim(GETPOST("note", "restricthtml")); $object->fk_element = GETPOST("fk_element", "int"); $object->elementtype = GETPOST("elementtype", "alphanohtml"); - if (!$datef && $percentage == 100) - { + if (!$datef && $percentage == 100) { $error++; $donotclearsession = 1; setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), $object->errors, 'errors'); $action = 'edit'; @@ -514,23 +527,26 @@ if (empty($reshook) && $action == 'update') // Users $listofuserid = array(); - if (!empty($_SESSION['assignedtouser'])) // Now concat assigned users - { + if (!empty($_SESSION['assignedtouser'])) { // Now concat assigned users // Restore array with key with same value than param 'id' $tmplist1 = json_decode($_SESSION['assignedtouser'], true); - foreach ($tmplist1 as $key => $val) - { - if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']] = $val; + foreach ($tmplist1 as $key => $val) { + if ($val['id'] > 0 && $val['id'] != $assignedtouser) { + $listofuserid[$val['id']] = $val; + } } } else { $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0); - if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first + if ($assignedtouser) { + $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first + } } $object->userassigned = array(); $object->userownerid = 0; // Clear old content $i = 0; - foreach ($listofuserid as $key => $val) - { - if ($i == 0) $object->userownerid = $val['id']; + foreach ($listofuserid as $key => $val) { + if ($i == 0) { + $object->userownerid = $val['id']; + } $object->userassigned[$val['id']] = array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>($user->id == $val['id'] ? $transparency : '')); $i++; } @@ -538,22 +554,21 @@ if (empty($reshook) && $action == 'update') $object->transparency = $transparency; // We set transparency on event (even if we can also store it on each user, standard says this property is for event) // TODO store also transparency on owner user - if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) - { - if (GETPOST("doneby")) $object->userdoneid = GETPOST("doneby", "int"); + if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) { + if (GETPOST("doneby")) { + $object->userdoneid = GETPOST("doneby", "int"); + } } // Check parameters - if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) // actioncode is '0' - { + if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' $error++; $donotclearsession = 1; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } else { $result = $cactioncomm->fetch(GETPOST('actioncode', 'aZ09')); } - if (empty($object->userownerid)) - { + if (empty($object->userownerid)) { $error++; $donotclearsession = 1; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ActionsOwnedBy")), null, 'errors'); @@ -561,7 +576,9 @@ if (empty($reshook) && $action == 'update') // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { // check if an event resource is already in use @@ -622,23 +639,19 @@ if (empty($reshook) && $action == 'update') } } - if (!$error) - { + if (!$error) { $db->begin(); $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $object->loadReminders(); - if (!empty($object->reminders) && $object->datep > dol_now()) - { - foreach ($object->reminders as $reminder) - { + if (!empty($object->reminders) && $object->datep > dol_now()) { + foreach ($object->reminders as $reminder) { $reminder->delete($user); } $object->reminders = array(); @@ -656,11 +669,12 @@ if (empty($reshook) && $action == 'update') $actionCommReminder->offsetvalue = $offsetvalue; $actionCommReminder->status = $actionCommReminder::STATUS_TODO; $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } // the notification must be created for every user assigned to the event - foreach ($object->userassigned as $userassigned) - { + foreach ($object->userassigned as $userassigned) { $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); @@ -677,8 +691,11 @@ if (empty($reshook) && $action == 'update') unset($_SESSION['assignedtouser']); - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); @@ -686,10 +703,8 @@ if (empty($reshook) && $action == 'update') } } - if (!$error) - { - if (!empty($backtopage)) - { + if (!$error) { + if (!empty($backtopage)) { unset($_SESSION['assignedtouser']); header("Location: ".$backtopage); exit; @@ -700,20 +715,17 @@ if (empty($reshook) && $action == 'update') /* * delete event */ -if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') -{ +if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); $object->fetch_optionals(); $object->fetch_userassigned(); $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete - || $user->rights->agenda->allactions->delete) - { + || $user->rights->agenda->allactions->delete) { $result = $object->delete(); - if ($result >= 0) - { + if ($result >= 0) { header("Location: index.php"); exit; } else { @@ -726,16 +738,14 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes * Action move update, used when user move an event in calendar by drag'n drop * TODO Move this into page comm/action/index that trigger this call by the drag and drop of event. */ -if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') -{ +if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { $error = 0; $shour = dol_print_date($object->datep, "%H", 'tzuserrel'); // We take the date visible by user $newdate is also date visible by user. $smin = dol_print_date($object->datep, "%M", 'tzuserrel'); $newdate = GETPOST('newdate', 'alpha'); - if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) - { + if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) { header("Location: ".$backtopage); exit; } @@ -743,10 +753,8 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4), 'tzuserrel'); //print dol_print_date($datep, 'dayhour');exit; - if ($datep != $object->datep) - { - if (!empty($object->datef)) - { + if ($datep != $object->datep) { + if (!empty($object->datef)) { $object->datef += $datep - $object->datep; } $object->datep = $datep; @@ -822,8 +830,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') } } } - if (!empty($backtopage)) - { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -857,21 +864,20 @@ $arrayrecurrulefreq = array( $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); -if ($action == 'create') -{ +if ($action == 'create') { $contact = new Contact($db); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); - if (!empty($socpeopleassigned[0])) - { + if (!empty($socpeopleassigned[0])) { $result = $contact->fetch($socpeopleassigned[0]); - if ($result < 0) dol_print_error($db, $contact->error); + if ($result < 0) { + dol_print_error($db, $contact->error); + } } dol_set_focus("#label"); - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; - foreach ($showextcals as $val) - { + foreach ($showextcals as $val) { $htmlname = md5($val['name']); $s .= '
 
'; } @@ -538,11 +574,9 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on // Calendars from hooks $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { + if (empty($reshook)) { $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) - { + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } @@ -551,12 +585,17 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on { $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); - if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + if (!preg_match('/showbirthday=/i', $newparam)) { + $newparam .= '&showbirthday=1'; + } $link = '
'; - if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); - else $link .= $langs->trans("AgendaHideBirthdayEvents"); + if (empty($showbirthday)) { + $link .= $langs->trans("AgendaShowBirthdayEvents"); + } else { + $link .= $langs->trans("AgendaHideBirthdayEvents"); + } $link .= ''; } @@ -567,7 +606,9 @@ $eventarray = array(); // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR $sql = 'SELECT '; -if ($usergroup > 0) $sql .= " DISTINCT"; +if ($usergroup > 0) { + $sql .= " DISTINCT"; +} $sql .= ' a.id, a.label,'; $sql .= ' a.datep,'; $sql .= ' a.datep2,'; @@ -578,31 +619,44 @@ $sql .= ' a.fk_soc, a.fk_contact, a.fk_project,'; $sql .= ' a.fk_element, a.elementtype,'; $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +} // We must filter on resource table -if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +if ($filtert > 0 || $usergroup > 0) { + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +} +if ($usergroup > 0) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +} $sql .= ' WHERE a.fk_action = ca.id'; $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (!empty($actioncode)) -{ - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; +if (!empty($actioncode)) { + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND ca.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND ca.type = 'systemauto'"; + } else { + if ($actioncode == 'AC_OTH') { + $sql .= " AND ca.type != 'systemauto'"; + } + if ($actioncode == 'AC_OTH_AUTO') { + $sql .= " AND ca.type = 'systemauto'"; + } } } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND ca.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND ca.type = 'systemauto'"; + } else { + if (is_array($actioncode)) { $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; } else { $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; @@ -610,15 +664,24 @@ if (!empty($actioncode)) } } } -if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; -if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; +if ($resourceid > 0) { + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +} +if ($pid) { + $sql .= " AND a.fk_project=".$db->escape($pid); +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +} +if ($socid > 0) { + $sql .= ' AND a.fk_soc = '.$socid; +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($filtert > 0 || $usergroup > 0) { + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +} //var_dump($day.' '.$month.' '.$year); -if ($action == 'show_day') -{ +if ($action == 'show_day') { $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; @@ -642,18 +705,33 @@ if ($action == 'show_day') $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; $sql .= ')'; } -if ($type) $sql .= " AND ca.id = ".$type; -if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($type) { + $sql .= " AND ca.id = ".$type; +} +if ($status == '0') { + $sql .= " AND a.percent = 0"; +} +if ($status == '-1') { + $sql .= " AND a.percent = -1"; +} // Not applicable +if ($status == '50') { + $sql .= " AND (a.percent > 0 AND a.percent < 100)"; +} // Running already started +if ($status == 'done' || $status == '100') { + $sql .= " AND (a.percent = 100)"; +} +if ($status == 'todo') { + $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) -{ +if ($filtert > 0 || $usergroup > 0) { $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + if ($filtert > 0) { + $sql .= "ar.fk_element = ".$filtert; + } + if ($usergroup > 0) { + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + } $sql .= ")"; } // Sort on date @@ -663,19 +741,16 @@ $sql .= ' ORDER BY datep'; dol_syslog("comm/action/index.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) $i = 0; - while ($i < $num && $i < $MAXONSAMEPAGE) - { + while ($i < $num && $i < $MAXONSAMEPAGE) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') - { + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } @@ -720,11 +795,13 @@ if ($resql) // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; - else $event->date_end_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) { + $event->date_end_in_calendar = $event->datef; + } else { + $event->date_end_in_calendar = $event->datep; + } // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { + if ($event->date_start_in_calendar == $event->date_end_in_calendar) { $event->ponctuel = 1; } @@ -732,8 +809,12 @@ if ($resql) if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_start_in_calendar < $firstdaytoshow) { + $event->date_start_in_calendar = $firstdaytoshow; + } + if ($event->date_end_in_calendar >= $lastdaytoshow) { + $event->date_end_in_calendar = ($lastdaytoshow - 1); + } // Add an entry in actionarray for each day $daycursor = $event->date_start_in_calendar; @@ -753,7 +834,9 @@ if ($resql) $j++; $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; + if ($daykey > $event->date_end_in_calendar) { + $loop = false; + } } while ($loop); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); @@ -767,15 +850,13 @@ if ($resql) // BIRTHDATES CALENDAR // Complete $eventarray with birthdates -if ($showbirthday) -{ +if ($showbirthday) { // Add events in array $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; - if ($action == 'show_day') - { + if ($action == 'show_day') { $sql .= ' AND MONTH(birthday) = '.$month; $sql .= ' AND DAY(birthday) = '.$day; } else { @@ -785,12 +866,10 @@ if ($showbirthday) dol_syslog("comm/action/index.php", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $event = new ActionComm($db); @@ -859,13 +938,11 @@ if ($action == 'show_day') { } $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $event = new ActionComm($db); @@ -885,21 +962,17 @@ if ($resql) $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; - if ($obj->status == 3) - { + if ($obj->status == 3) { // Show no symbol for leave with state "leave approved" $event->percentage = -1; - } elseif ($obj->status == 2) - { + } elseif ($obj->status == 2) { // Show TO-DO symbol for leave with state "leave wait for approval" $event->percentage = 0; } - if ($obj->halfday == 1) - { + if ($obj->halfday == 1) { $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } elseif ($obj->halfday == -1) - { + } elseif ($obj->halfday == -1) { $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; } else { $event->label = $obj->lastname; @@ -923,11 +996,9 @@ if ($resql) // EXTERNAL CALENDAR // Complete $eventarray with external import Ical -if (count($listofextcals)) -{ +if (count($listofextcals)) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; - foreach ($listofextcals as $extcal) - { + foreach ($listofextcals as $extcal) { $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics $namecal = $extcal['name']; $offsettz = $extcal['offsettz']; @@ -940,29 +1011,27 @@ if (count($listofextcals)) // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; $icalevents = array(); - if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] - if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + if (is_array($ical->get_event_list())) { + $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + } + if (is_array($ical->get_freebusy_list())) { + $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + } - if (count($icalevents) > 0) - { + if (count($icalevents) > 0) { // Duplicate all repeatable events into new entries $moreicalevents = array(); - foreach ($icalevents as $icalevent) - { - if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event - { + foreach ($icalevents as $icalevent) { + if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) { //repeatable event //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); - if ($icalevent['DTSTART;VALUE=DATE']) //fullday event - { + if ($icalevent['DTSTART;VALUE=DATE']) { //fullday event $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) - { + } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { $datecurstart = $icalevent['DTSTART']['unixtime']; $datecurend = $icalevent['DTEND']['unixtime']; - if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) - { + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) { //var_dump($ical->cal); $tmpcurstart = $datecurstart; $tmpcurend = $datecurend; @@ -970,10 +1039,16 @@ if (count($listofextcals)) $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); // Edit datecurstart and datecurend - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { + $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + } else { + $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { + $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + } else { + $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } } // datecurstart and datecurend are now GMT date //var_dump($datecurstart); var_dump($datecurend); exit; @@ -987,18 +1062,19 @@ if (count($listofextcals)) $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; - if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show - if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) { + continue; // We discard repeatable event that end before start date to show + } + if ($datecurstart >= $lastdaytoshow) { + continue; // We discard repeatable event that start after end date to show + } $numofevent = 0; - while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) - { - if ($datecurend >= $firstdaytoshow) // We add event - { + while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { + if ($datecurend >= $firstdaytoshow) { // We add event $newevent = $icalevent; unset($newevent['RRULE']); - if ($icalevent['DTSTART;VALUE=DATE']) - { + if ($icalevent['DTSTART;VALUE=DATE']) { $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); } else { @@ -1010,27 +1086,22 @@ if (count($listofextcals)) // Jump on next occurence $numofevent++; $savdatecurstart = $datecurstart; - if ($icalevent['RRULE']['FREQ'] == 'DAILY') - { + if ($icalevent['RRULE']['FREQ'] == 'DAILY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); } - if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') - { + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); - } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') - { + } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); - } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') - { + } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); } // Test to avoid infinite loop ($datecurstart must increase) - if ($savdatecurstart >= $datecurstart) - { + if ($savdatecurstart >= $datecurstart) { dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); $datecurstart += 3600 * 24 * 7; $datecurend += 3600 * 24 * 7; @@ -1041,18 +1112,18 @@ if (count($listofextcals)) $icalevents = array_merge($icalevents, $moreicalevents); // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray - foreach ($icalevents as $icalevent) - { + foreach ($icalevents as $icalevent) { //var_dump($icalevent); //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; - if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + if (!empty($icalevent['RRULE'])) { + continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + } // Create a new object action $event = new ActionComm($db); $addevent = false; - if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event - { + if (isset($icalevent['DTSTART;VALUE=DATE'])) { // fullday event // For full day events, date are also GMT but they wont but converted using tz during output $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day @@ -1060,8 +1131,7 @@ if (count($listofextcals)) //print dol_print_date($dateend,'dayhour','gmt'); $event->fulldayevent = 1; $addevent = true; - } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) - { + } elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) $datestart = $icalevent['DTSTART']; $dateend = $icalevent['DTEND']; @@ -1071,8 +1141,7 @@ if (count($listofextcals)) $addevent = true; //var_dump($offsettz); //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); - } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) - { + } elseif (isset($icalevent['DTSTART']['unixtime'])) { // File contains a local timezone + a TZ (for example when using bluemind) $datestart = $icalevent['DTSTART']['unixtime']; $dateend = $icalevent['DTEND']['unixtime']; @@ -1080,13 +1149,11 @@ if (count($listofextcals)) $dateend += +($offsettz * 3600); // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' - if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 - { + if ($buggedfile === 'uselocalandtznodaylight') { // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 // TODO } // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) - if ($buggedfile === 'uselocalandtzdaylight') // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer - { + if ($buggedfile === 'uselocalandtzdaylight') { // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); @@ -1100,13 +1167,11 @@ if (count($listofextcals)) $addevent = true; } - if ($addevent) - { + if ($addevent) { $event->id = $icalevent['UID']; $event->ref = $event->id; $userId = $userstatic->findUserIdByEmail($namecal); - if (!empty($userId) && $userId > 0) - { + if (!empty($userId) && $userId > 0) { $event->userassigned[$userId] = $userId; $event->percentage = -1; } @@ -1123,21 +1188,30 @@ if (count($listofextcals)) $event->datep = $datestart + $usertime; $event->datef = $dateend + $usertime; - if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; - elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); - else $event->label = $langs->trans("ExtSiteNoLabel"); + if ($icalevent['SUMMARY']) { + $event->label = $icalevent['SUMMARY']; + } elseif ($icalevent['DESCRIPTION']) { + $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); + } else { + $event->label = $langs->trans("ExtSiteNoLabel"); + } // Priority (see https://www.kanzaki.com/docs/ical/priority.html) // LOW = 0 to 4 // MEDIUM = 5 // HIGH = 6 to 9 - if ($icalevent['PRIORITY']) $event->priority = $icalevent['PRIORITY']; + if ($icalevent['PRIORITY']) { + $event->priority = $icalevent['PRIORITY']; + } // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) - if ($icalevent['TRANSP']) - { - if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free - if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy + if ($icalevent['TRANSP']) { + if ($icalevent['TRANSP'] == "TRANSPARENT") { + $event->transparency = 0; // 0 = available / free + } + if ($icalevent['TRANSP'] == "OPAQUE") { + $event->transparency = 1; // 1 = busy + } // TODO: MS outlook states // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free @@ -1147,30 +1221,37 @@ if (count($listofextcals)) // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site } - if ($icalevent['LOCATION']) $event->location = $icalevent['LOCATION']; + if ($icalevent['LOCATION']) { + $event->location = $icalevent['LOCATION']; + } $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; - else $event->date_end_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) { + $event->date_end_in_calendar = $event->datef; + } else { + $event->date_end_in_calendar = $event->datep; + } // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { + if ($event->date_start_in_calendar == $event->date_end_in_calendar) { $event->ponctuel = 1; //print 'x'.$datestart.'-'.$dateend;exit; } // Add event into $eventarray if date range are ok. - if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) - { + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { //print 'x'.$datestart.'-'.$dateend;exit; //print 'x'.$datestart.'-'.$dateend;exit; //print 'x'.$datestart.'-'.$dateend;exit; // This record is out of visible range } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_start_in_calendar < $firstdaytoshow) { + $event->date_start_in_calendar = $firstdaytoshow; + } + if ($event->date_end_in_calendar >= $lastdaytoshow) { + $event->date_end_in_calendar = ($lastdaytoshow - 1); + } // Add an entry in actionarray for each day $daycursor = $event->date_start_in_calendar; @@ -1187,7 +1268,9 @@ if (count($listofextcals)) //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; $eventarray[$daykey][] = $event; $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) { + $loop = false; + } } while ($loop); } } @@ -1211,8 +1294,7 @@ if (!empty($hookmanager->resArray['eventarray'])) { } // Sort events -foreach ($eventarray as $keyDate => &$dateeventarray) -{ +foreach ($eventarray as $keyDate => &$dateeventarray) { usort($dateeventarray, 'sort_events_by_date'); } @@ -1224,11 +1306,12 @@ $cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; -if (is_readable($color_file)) -{ +if (is_readable($color_file)) { include_once $color_file; } -if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); +if (!is_array($theme_datacolor)) { + $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); +} $massactionbutton =''; @@ -1238,8 +1321,7 @@ print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, print $s; -if (empty($action) || $action == 'show_month') // View by month -{ +if (empty($action) || $action == 'show_month') { // View by month $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done $newparam = preg_replace('/action=show_month&?/i', '', $newparam); @@ -1261,15 +1343,15 @@ if (empty($action) || $action == 'show_month') // View by month // Column title of weeks numbers echo '
#'; $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); - if (!empty($conf->dol_optimize_smallscreen)) - { + if (!empty($conf->dol_optimize_smallscreen)) { $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); print $langs->trans($labelshort[$numdayinweek]); - } else print $langs->trans("Day".$numdayinweek); + } else { + print $langs->trans("Day".$numdayinweek); + } print '
'; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); @@ -1324,7 +1412,9 @@ if (empty($action) || $action == 'show_month') // View by month } else { /* Show days after the current month (next month) */ $style = 'cal_other_month'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; + if ($iter_day == 6) { + $style .= ' cal_other_month_right'; + } echo ' '; show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo "'; show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); @@ -1406,7 +1502,9 @@ if (empty($action) || $action == 'show_month') // View by month $style = 'cal_current_month cal_current_month_oneday'; $today = 0; $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) { + $today = 1; + } //if ($today) $style='cal_today'; $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); @@ -1424,12 +1522,12 @@ if (empty($action) || $action == 'show_month') // View by month echo "
'; @@ -1437,8 +1535,7 @@ if (empty($action) || $action == 'show_month') // View by month /* WIP View per hour */ $useviewhour = 0; - if ($useviewhour) - { + if ($useviewhour) { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file @@ -1451,14 +1548,19 @@ if (empty($action) || $action == 'show_month') // View by month $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); $minhour = round($tmp[0], 0); $maxhour = round($tmp[1], 0); - if ($minhour > 23) $minhour = 23; - if ($maxhour < 1) $maxhour = 1; - if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } + if ($minhour > 23) { + $minhour = 23; + } + if ($maxhour < 1) { + $maxhour = 1; + } + if ($maxhour <= $minhour) { + $maxhour = $minhour + 1; + } $i = 0; $j = 0; - while ($i < 24) - { + while ($i < 24) { echo '
'."\n"; echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; echo '
'."\n"; @@ -1524,8 +1626,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $curtime = dol_mktime(0, 0, 0, $month, $day, $year); $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; $urltocreate = ''; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) - { + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; $hourminsec = '100000'; $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); @@ -1534,16 +1635,17 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Line with title of day print '
'."\n"; - if ($nonew <= 0) - { + if ($nonew <= 0) { print '
'; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) - { + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { print ''; // Explicit link, usefull for nojs interfaces print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; @@ -1551,8 +1653,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'."\n"; } - if ($nonew < 0) - { + if ($nonew < 0) { print '
'; return; } @@ -1572,29 +1673,23 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $tmpholiday = new Holiday($db); - foreach ($eventarray as $daykey => $notused) - { + foreach ($eventarray as $daykey => $notused) { $annee = dol_print_date($daykey, '%Y'); $mois = dol_print_date($daykey, '%m'); $jour = dol_print_date($daykey, '%d'); - if ($day == $jour && $month == $mois && $year == $annee) - { - foreach ($eventarray[$daykey] as $index => $event) - { - if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) - { + if ($day == $jour && $month == $mois && $year == $annee) { + foreach ($eventarray[$daykey] as $index => $event) { + if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) { $keysofuserassigned = array_keys($event->userassigned); $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); // Define $color (Hex string like '0088FF') and $cssclass of event $color = -1; $cssclass = ''; $colorindex = -1; - if (in_array($user->id, $keysofuserassigned)) - { + if (in_array($user->id, $keysofuserassigned)) { $cssclass = 'family_mytasks'; - if (empty($cacheusers[$event->userownerid])) - { + if (empty($cacheusers[$event->userownerid])) { $newuser = new User($db); $newuser->fetch($event->userownerid); $cacheusers[$event->userownerid] = $newuser; @@ -1602,9 +1697,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file - { + if (!empty($cacheusers[$event->userownerid]->color)) { + $color = $cacheusers[$event->userownerid]->color; + } + } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file $numical++; if (!empty($event->icalname)) { if (!isset($numicals[dol_string_nospecial($event->icalname)])) { @@ -1615,37 +1711,37 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $color = ($event->icalcolor ? $event->icalcolor : -1); $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - } elseif ($event->type_code == 'BIRTHDAY') - { + } elseif ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday '; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; $color = ($event->icalcolor ? $event->icalcolor : -1); $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - if (empty($cacheusers[$event->userownerid])) - { + if (empty($cacheusers[$event->userownerid])) { $newuser = new User($db); $newuser->fetch($event->userownerid); $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (!empty($cacheusers[$event->userownerid]->color)) { + $color = $cacheusers[$event->userownerid]->color; + } } - if ($color < 0) // Color was not set on user card. Set color according to color index. - { + if ($color < 0) { // Color was not set on user card. Set color according to color index. // Define color index if not yet defined $idusertouse = ($event->userownerid ? $event->userownerid : 0); - if (isset($colorindexused[$idusertouse])) - { + if (isset($colorindexused[$idusertouse])) { $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { - $colorindex = $nextindextouse; - $colorindexused[$idusertouse] = $colorindex; - if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) { + $nextindextouse++; // Prepare to use next color + } } //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
'; // Define color @@ -1666,14 +1762,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); - if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) - { + if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) { $cssclass .= " unmovable"; } } else { if ($user->rights->agenda->allactions->create || - (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) - { + (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { $cssclass .= " movable cursormove"; } else { $cssclass .= " unmovable"; @@ -1681,8 +1775,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } $h = ''; $nowrapontd = 1; - if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } - if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } + if ($action == 'show_day') { + $h = 'height: 100%; '; $nowrapontd = 0; + } + if ($action == 'show_week') { + $h = 'height: 100%; '; $nowrapontd = 0; + } // Show event box print "\n"; @@ -1720,8 +1818,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '" style="'.$h; $colortouse = $color; // If colortouse is similar than background, we force to change it. - if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) - { + if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { print 'background: #f0f0f0;'; print 'border-left: 5px solid #'.$colortouse.';'; } else { @@ -1729,8 +1826,8 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print 'border-left: 5px solid #'.dol_color_minus($colortouse, -3).';'; //print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($colortouse, -3).'), to(#'.dol_color_minus($colortouse, -1).'));'; } - //print 'background: #'.$colortouse.';'; - //print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($color, -3).'), to(#'.dol_color_minus($color, -1).'));'; + //print 'background: #'.$colortouse.';'; + //print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($color, -3).'), to(#'.dol_color_minus($color, -1).'));'; //if (! empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));'; //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;'; //print ' -moz-border-radius:4px;"'; @@ -1759,14 +1856,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print $listofusertoshow; } else { // Other calendar // Picto - if (empty($event->fulldayevent)) - { + if (empty($event->fulldayevent)) { //print $event->getNomUrl(2).' '; } // Date - if (empty($event->fulldayevent)) - { + if (empty($event->fulldayevent)) { // Show hours (start ... end) $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel'); $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel'); @@ -1776,29 +1871,26 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel'); // Hour start - if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) - { + if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel'); - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) - $daterange .= '-'; + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { + $daterange .= '-'; + } //else //print '...'; } } - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) - { + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { $daterange .= '...'; } } // Hour end - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { + $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); + } } } else { if ($showinfo) { @@ -1824,9 +1916,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Loop on each assigned user $listofusertoshow = ''; $posuserassigned = 0; - foreach ($event->userassigned as $tmpid => $tmpdata) - { - if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
'; + foreach ($event->userassigned as $tmpid => $tmpdata) { + if (!$posuserassigned && $titletoshow) { + $listofusertoshow .= '
'; + } $posuserassigned++; if (empty($cacheusers[$tmpid])) { $newuser = new User($db); @@ -1840,48 +1933,57 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print $titletoshow; print $listofusertoshow; - if ($event->type_code == 'ICALEVENT') print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; + if ($event->type_code == 'ICALEVENT') { + print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; + } $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); // If action related to company / contact $linerelatedto = ''; - if ($thirdparty_id > 0) - { - if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) - { + if ($thirdparty_id > 0) { + if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) { $thirdparty = new Societe($db); $thirdparty->fetch($thirdparty_id); $cachethirdparties[$thirdparty_id] = $thirdparty; - } else $thirdparty = $cachethirdparties[$thirdparty_id]; - if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); + } else { + $thirdparty = $cachethirdparties[$thirdparty_id]; + } + if (!empty($thirdparty->id)) { + $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); + } } - if (!empty($contact_id) && $contact_id > 0) - { - if (!is_object($cachecontacts[$contact_id])) - { + if (!empty($contact_id) && $contact_id > 0) { + if (!is_object($cachecontacts[$contact_id])) { $contact = new Contact($db); $contact->fetch($contact_id); $cachecontacts[$contact_id] = $contact; - } else $contact = $cachecontacts[$contact_id]; - if ($linerelatedto) $linerelatedto .= ' '; - if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); + } else { + $contact = $cachecontacts[$contact_id]; + } + if ($linerelatedto) { + $linerelatedto .= ' '; + } + if (!empty($contact->id)) { + $linerelatedto .= $contact->getNomUrl(1, '', 0); + } } - if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) - { + if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ($linerelatedto) $linerelatedto .= '
'; + if ($linerelatedto) { + $linerelatedto .= '
'; + } $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); } - if ($linerelatedto) print '
'.$linerelatedto; + if ($linerelatedto) { + print '
'.$linerelatedto; + } } // Show location - if ($showinfo) - { - if ($event->location) - { + if ($showinfo) { + if ($event->location) { print '
'; print $langs->trans("Location").': '.$event->location; } @@ -1890,14 +1992,18 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'; - if ($withstatus) print $event->getLibStatut(3, 1); - else print ' '; + if ($withstatus) { + print $event->getLibStatut(3, 1); + } else { + print ' '; + } print '
'; print ''."\n"; @@ -1923,8 +2029,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print ' '; } - if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $itoshow > $ireallyshown && $maxprint) - { + if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $itoshow > $ireallyshown && $maxprint) { print '
'.img_picto("All", "angle-double-down", 'class="warning"').' +'.($itoshow - $ireallyshown).'
'; //print ' +'.(count($eventarray[$daykey])-$maxprint); @@ -1963,8 +2068,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa function dol_color_minus($color, $minus, $minusunit = 16) { $newcolor = $color; - if ($minusunit == 16) - { + if ($minusunit == 16) { $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); @@ -1984,12 +2088,10 @@ function dol_color_minus($color, $minus, $minusunit = 16) function sort_events_by_date($a, $b) { // Sort holidays at first - if ($a->type_code === 'HOLIDAY') - { + if ($a->type_code === 'HOLIDAY') { return -1; } - if ($b->type_code === 'HOLIDAY') - { + if ($b->type_code === 'HOLIDAY') { return 1; } @@ -1997,20 +2099,17 @@ function sort_events_by_date($a, $b) // datef => Event end time // Events have different start time - if ($a->datep !== $b->datep) - { + if ($a->datep !== $b->datep) { return $a->datep - $b->datep; } // Events have same start time and no end time - if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) - { + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) { return sort_events_by_percentage($a, $b); } // Events have the same start time and same end time - if ($b->datef === $a->datef) - { + if ($b->datef === $a->datef) { return sort_events_by_percentage($a, $b); } @@ -2030,13 +2129,11 @@ function sort_events_by_percentage($a, $b) // Sort events with no percentage before each other // (usefull to sort holidays, sick days or similar on the top) - if ($a->percentage < 0) - { + if ($a->percentage < 0) { return -1; } - if ($b->percentage < 0) - { + if ($b->percentage < 0) { return 1; } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 40787abb8c3..2360f2925d9 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -39,8 +39,7 @@ $langs->load("commercial"); $id = GETPOST('id', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -84,8 +83,7 @@ $morehtmlref = '
'; // Thirdparty //$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').': '; @@ -95,7 +93,9 @@ if (!empty($conf->projet->enabled)) $morehtmlref .= '
'; $morehtmlref .= $proj->ref; $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 68925c57bfa..64ed79d87ca 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -27,7 +27,9 @@ * \brief Page to list actions */ -if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); +if (!defined("NOREDIRECTBYMAINTOLOGIN")) { + define('NOREDIRECTBYMAINTOLOGIN', 1); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -55,14 +57,17 @@ $toselect = GETPOST('toselect', 'array'); $confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('search_actioncode', 'array')) -{ +if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + if (!count($actioncode)) { + $actioncode = '0'; + } } else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } -if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +if ($actioncode == '' && empty($actioncodearray)) { + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +} $search_id = GETPOST('search_id', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_note = GETPOST('search_note', 'alpha'); @@ -70,8 +75,12 @@ $search_note = GETPOST('search_note', 'alpha'); $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel'); $datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'), 'tzuserrel'); $dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'), 'tzuserrel'); -if ($search_status == '' && !GETPOSTISSET('search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($search_status == '' && !GETPOSTISSET('search_status')) { + $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +} +if (empty($action) && !GETPOSTISSET('action')) { + $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +} $filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); @@ -89,8 +98,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // If not choice done on calendar owner, we filter on user. -if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) -{ +if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } @@ -98,30 +106,41 @@ $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 ($page == -1 || $page == null) { $page = 0; } -$offset = $limit * $page; -if (!$sortorder) -{ - $sortorder = "DESC,DESC"; - if ($search_status == 'todo') $sortorder = "DESC,DESC"; +if ($page == -1 || $page == null) { + $page = 0; } -if (!$sortfield) -{ +$offset = $limit * $page; +if (!$sortorder) { + $sortorder = "DESC,DESC"; + if ($search_status == 'todo') { + $sortorder = "DESC,DESC"; + } +} +if (!$sortfield) { $sortfield = "a.datep,a.id"; - if ($search_status == 'todo') $sortfield = "a.datep,a.id"; + if ($search_status == 'todo') { + $sortfield = "a.datep,a.id"; + } } // Security check $socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($socid < 0) $socid = ''; +if ($socid < 0) { + $socid = ''; +} $canedit = 1; -if (!$user->rights->agenda->myactions->read) accessforbidden(); -if (!$user->rights->agenda->allactions->read) $canedit = 0; -if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me -{ +if (!$user->rights->agenda->myactions->read) { + accessforbidden(); +} +if (!$user->rights->agenda->allactions->read) { + $canedit = 0; +} +if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } @@ -152,18 +171,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) -{ +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) -{ +if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { + if (is_array($_POST)) { + foreach ($_POST as $key => $val) { $param .= '&'.$key.'='.urlencode($val); } } @@ -174,13 +189,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 //$actioncode=''; $search_id = ''; $search_title = ''; @@ -192,12 +208,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options = array(); } -if (empty($reshook) && !empty($massaction)) -{ +if (empty($reshook) && !empty($massaction)) { unset($percent); - switch ($massaction) - { + switch ($massaction) { case 'set_all_events_to_todo': $percent = ActionComm::EVENT_TODO; break; @@ -211,13 +225,10 @@ if (empty($reshook) && !empty($massaction)) break; } - if (isset($percent)) - { - foreach ($toselect as $toselectid) - { + if (isset($percent)) { + foreach ($toselect as $toselectid) { $result = $object->updatePercent($toselectid, $percent); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); break; } @@ -226,8 +237,7 @@ if (empty($reshook) && !empty($massaction)) } // As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion). -if (empty($reshook)) -{ +if (empty($reshook)) { $objectclass = 'ActionComm'; $objectlabel = 'Events'; $uploaddir = true; @@ -258,32 +268,78 @@ llxHeader('', $langs->trans("Agenda"), $help_url); $listofextcals = array(); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} if ($actioncode != '') { if (is_array($actioncode)) { - foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); - } else $param .= "&search_actioncode=".urlencode($actioncode); + foreach ($actioncode as $str_action) { + $param .= "&search_actioncode[]=".urlencode($str_action); + } + } else { + $param .= "&search_actioncode=".urlencode($actioncode); + } +} +if ($resourceid > 0) { + $param .= "&search_resourceid=".urlencode($resourceid); +} +if ($search_status != '' && $search_status > -1) { + $param .= "&search_status=".urlencode($search_status); +} +if ($filter) { + $param .= "&search_filter=".urlencode($filter); +} +if ($filtert) { + $param .= "&search_filtert=".urlencode($filtert); +} +if ($usergroup > 0) { + $param .= "&search_usergroup=".urlencode($usergroup); +} +if ($socid > 0) { + $param .= "&search_socid=".urlencode($socid); +} +if ($showbirthday) { + $param .= "&search_showbirthday=1"; +} +if ($pid) { + $param .= "&search_projectid=".urlencode($pid); +} +if ($type) { + $param .= "&search_type=".urlencode($type); +} +if ($search_id != '') { + $param .= '&search_title='.urlencode($search_id); +} +if ($search_title != '') { + $param .= '&search_title='.urlencode($search_title); +} +if ($search_note != '') { + $param .= '&search_note='.$search_note; +} +if (GETPOST('datestartday', 'int')) { + $param .= '&datestartday='.GETPOST('datestartday', 'int'); +} +if (GETPOST('datestartmonth', 'int')) { + $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); +} +if (GETPOST('datestartyear', 'int')) { + $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); +} +if (GETPOST('dateendday', 'int')) { + $param .= '&dateendday='.GETPOST('dateendday', 'int'); +} +if (GETPOST('dateendmonth', 'int')) { + $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); +} +if (GETPOST('dateendyear', 'int')) { + $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); } -if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); -if ($filter) $param .= "&search_filter=".urlencode($filter); -if ($filtert) $param .= "&search_filtert=".urlencode($filtert); -if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup); -if ($socid > 0) $param .= "&search_socid=".urlencode($socid); -if ($showbirthday) $param .= "&search_showbirthday=1"; -if ($pid) $param .= "&search_projectid=".urlencode($pid); -if ($type) $param .= "&search_type=".urlencode($type); -if ($search_id != '') $param .= '&search_title='.urlencode($search_id); -if ($search_title != '') $param .= '&search_title='.urlencode($search_title); -if ($search_note != '') $param .= '&search_note='.$search_note; -if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int'); -if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); -if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); -if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int'); -if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); -if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -295,16 +351,21 @@ $arrayofmassactions = array( 'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"), 'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), ); -if ($user->rights->agenda->allactions->delete) -{ +if ($user->rights->agenda->allactions->delete) { $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); } -if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); +if ($user->rights->agenda->myactions->create) { + $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $sql = "SELECT"; -if ($usergroup > 0) $sql .= " DISTINCT"; +if ($usergroup > 0) { + $sql .= " DISTINCT"; +} $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; $sql .= ' a.fk_user_author,a.fk_user_action,'; @@ -315,7 +376,9 @@ $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as // 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 : ''); + 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 @@ -325,34 +388,47 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; // We must filter on resource table -if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +if ($filtert > 0 || $usergroup > 0) { + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +} +if ($usergroup > 0) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +} $sql .= " WHERE c.id = a.fk_action"; $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (!empty($actioncode)) -{ - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; +if (!empty($actioncode)) { + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } else { + if ($actioncode == 'AC_OTH') { + $sql .= " AND c.type != 'systemauto'"; + } + if ($actioncode == 'AC_OTH_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } } } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } else { + if (is_array($actioncode)) { $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; } else { $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; @@ -360,35 +436,74 @@ if (!empty($actioncode)) } } } -if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; -if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +if ($resourceid > 0) { + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +} +if ($pid) { + $sql .= " AND a.fk_project=".$db->escape($pid); +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +} +if ($socid > 0) { + $sql .= " AND s.rowid = ".$socid; +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -if ($type) $sql .= " AND c.id = ".(int) $type; -if ($search_status == '0') { $sql .= " AND a.percent = 0"; } -if ($search_status == 'na') { $sql .= " AND a.percent = -1"; } // Not applicable -if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($search_status == '100') { $sql .= " AND a.percent = 100"; } -if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; } -if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } -if ($search_id) $sql .= natural_search("a.id", $search_id, 1); -if ($search_title) $sql .= natural_search("a.label", $search_title); -if ($search_note) $sql .= natural_search('a.note', $search_note); +if ($filtert > 0 || $usergroup > 0) { + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +} +if ($type) { + $sql .= " AND c.id = ".(int) $type; +} +if ($search_status == '0') { + $sql .= " AND a.percent = 0"; +} +if ($search_status == 'na') { + $sql .= " AND a.percent = -1"; +} // Not applicable +if ($search_status == '50') { + $sql .= " AND (a.percent > 0 AND a.percent < 100)"; +} // Running already started +if ($search_status == '100') { + $sql .= " AND a.percent = 100"; +} +if ($search_status == 'done') { + $sql .= " AND (a.percent = 100)"; +} +if ($search_status == 'todo') { + $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; +} +if ($search_id) { + $sql .= natural_search("a.id", $search_id, 1); +} +if ($search_title) { + $sql .= natural_search("a.label", $search_title); +} +if ($search_note) { + $sql .= natural_search('a.note', $search_note); +} // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) -{ +if ($filtert > 0 || $usergroup > 0) { $sql .= " AND ("; - if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + if ($filtert > 0) { + $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + } + if ($usergroup > 0) { + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + } $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) -if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; -if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; -if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; +if ($dateselect > 0) { + $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; +} +if ($datestart > 0) { + $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; +} +if ($dateend > 0) { + $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -401,12 +516,10 @@ $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -417,8 +530,7 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("comm/action/list.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $actionstatic = new ActionComm($db); $societestatic = new Societe($db); @@ -438,7 +550,9 @@ if ($resql) print ''."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -446,8 +560,12 @@ if ($resql) print ''; $nav = ''; - if ($filter) $nav .= ''; - if ($showbirthday) $nav .= ''; + if ($filter) { + $nav .= ''; + } + if ($showbirthday) { + $nav .= ''; + } print $nav; //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); @@ -457,19 +575,19 @@ if ($resql) // Add link to show birthdays $link = ''; /* - if (empty($conf->use_javascript_ajax)) - { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam); - if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1'; - $link=''; - if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); - else $link.=$langs->trans("AgendaHideBirthdayEvents"); - $link.=''; - } - */ + if (empty($conf->use_javascript_ajax)) + { + $newparam=$param; // newparam is for birthday links + $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam); + if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1'; + $link=''; + if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); + else $link.=$langs->trans("AgendaHideBirthdayEvents"); + $link.=''; + } + */ $s = $newtitle; @@ -550,7 +668,9 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } $i = 0; print '
'; @@ -561,11 +681,21 @@ if ($resql) print ''."\n"; print ''; - if (!empty($arrayfields['a.id']['checked'])) print ''; - if (!empty($arrayfields['owner']['checked'])) print ''; - if (!empty($arrayfields['c.libelle']['checked'])) print ''; - if (!empty($arrayfields['a.label']['checked'])) print ''; - if (!empty($arrayfields['a.note']['checked'])) print ''; + if (!empty($arrayfields['a.id']['checked'])) { + print ''; + } + if (!empty($arrayfields['owner']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.libelle']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.label']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.note']['checked'])) { + print ''; + } if (!empty($arrayfields['a.datep']['checked'])) { print ''; } - if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; - if (!empty($arrayfields['a.fk_element']['checked'])) print ''; + if (!empty($arrayfields['a.fk_contact']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.fk_element']['checked'])) { + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -590,8 +724,12 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['a.datec']['checked'])) print ''; - if (!empty($arrayfields['a.tms']['checked'])) print ''; + if (!empty($arrayfields['a.datec']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.tms']['checked'])) { + print ''; + } if (!empty($arrayfields['a.percent']['checked'])) { print '\n"; print ''; - if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.id']['checked'])) { + print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['owner']['checked'])) { + print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['c.libelle']['checked'])) { + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['a.label']['checked'])) { + print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['a.note']['checked'])) { + print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + } //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.datep']['checked'])) { + print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['a.datep2']['checked'])) { + print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['a.fk_contact']['checked'])) { + print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + } + if (!empty($arrayfields['a.fk_element']['checked'])) { + print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -626,10 +784,16 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datec']['checked'])) { + print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['a.tms']['checked'])) { + print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + } - if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.percent']['checked'])) { + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -642,13 +806,11 @@ if ($resql) $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $contactListCache = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') - { + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } @@ -676,29 +838,34 @@ if ($resql) } // User owner - if (!empty($arrayfields['owner']['checked'])) - { + if (!empty($arrayfields['owner']['checked'])) { print ''; } // Type - if (!empty($arrayfields['c.libelle']['checked'])) - { + if (!empty($arrayfields['c.libelle']['checked'])) { print ''; @@ -726,11 +893,21 @@ if ($resql) print ''; } @@ -744,15 +921,16 @@ if ($resql) // Third party if (!empty($arrayfields['s.nom']['checked'])) { print ''; } @@ -760,17 +938,13 @@ if ($resql) if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 613ffee7be7..dc70fb30743 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; +} $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); @@ -49,31 +51,43 @@ $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", $showbirthday = 0; // If not choice done on calendar owner, we filter on user. -if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) -{ +if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "a.datec"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "a.datec"; +} // Security check $socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($socid < 0) $socid = ''; +if ($socid < 0) { + $socid = ''; +} $canedit = 1; -if (!$user->rights->agenda->myactions->read) accessforbidden(); -if (!$user->rights->agenda->allactions->read) $canedit = 0; -if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me -{ +if (!$user->rights->agenda->myactions->read) { + accessforbidden(); +} +if (!$user->rights->agenda->allactions->read) { + $canedit = 0; +} +if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } @@ -90,18 +104,20 @@ $type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPO $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('search_actioncode', 'array')) -{ +if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + if (!count($actioncode)) { + $actioncode = '0'; + } } else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } -if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +if ($actioncode == '' && empty($actioncodearray)) { + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +} $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); -if ($dateselect > 0) -{ +if ($dateselect > 0) { $day = GETPOST('dateselectday', 'int'); $month = GETPOST('dateselectmonth', 'int'); $year = GETPOST('dateselectyear', 'int'); @@ -112,9 +128,15 @@ $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); $end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); -if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; -if ($end_h < 1 || $end_h > 24) $end_h = 18; -if ($end_h <= $begin_h) $end_h = $begin_h + 1; +if ($begin_h < 0 || $begin_h > 23) { + $begin_h = 9; +} +if ($end_h < 1 || $end_h > 24) { + $end_h = 18; +} +if ($end_h <= $begin_h) { + $end_h = $begin_h + 1; +} $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; $tmp = str_replace(' ', '', $tmp); // FIX 7533 @@ -122,8 +144,12 @@ $tmparray = explode('-', $tmp); $begin_d = 1; $end_d = 53; -if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !GETPOSTISSET('status')) { + $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +} +if (empty($action) && !GETPOSTISSET('action')) { + $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +} if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; @@ -149,8 +175,7 @@ $hookmanager->initHooks(array('agenda')); * Actions */ -if ($action == 'delete_action') -{ +if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); $event->fetch_optionals(); @@ -185,7 +210,9 @@ $parameters = array( 'usergroup' => $usergroup, ); $reshook = $hookmanager->executeHooks('beforeAgendaPerType', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $form = new Form($db); $companystatic = new Societe($db); @@ -223,29 +250,65 @@ $tmpday = $first_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; $title = $langs->trans("DoneAndToDoActions"); -if ($status == 'done') $title = $langs->trans("DoneActions"); -if ($status == 'todo') $title = $langs->trans("ToDoActions"); +if ($status == 'done') { + $title = $langs->trans("DoneActions"); +} +if ($status == 'todo') { + $title = $langs->trans("ToDoActions"); +} $param = ''; if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { - foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); - } else $param .= "&search_actioncode=".urlencode($actioncode); + foreach ($actioncode as $str_action) { + $param .= "&search_actioncode[]=".urlencode($str_action); + } + } else { + $param .= "&search_actioncode=".urlencode($actioncode); + } +} +if ($resourceid > 0) { + $param .= "&search_resourceid=".urlencode($resourceid); +} +if ($status || GETPOSTISSET('status')) { + $param .= "&search_status=".urlencode($status); +} +if ($filter) { + $param .= "&search_filter=".urlencode($filter); +} +if ($filtert) { + $param .= "&search_filtert=".urlencode($filtert); +} +if ($usergroup > 0) { + $param .= "&search_usergroup=".urlencode($usergroup); +} +if ($socid > 0) { + $param .= "&search_socid=".urlencode($socid); +} +if ($showbirthday) { + $param .= "&search_showbirthday=1"; +} +if ($pid) { + $param .= "&search_projectid=".urlencode($pid); +} +if ($type) { + $param .= "&search_type=".urlencode($type); +} +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') { + $param .= '&action='.urlencode($action); +} +if ($begin_h != '') { + $param .= '&begin_h='.urlencode($begin_h); +} +if ($end_h != '') { + $param .= '&end_h='.urlencode($end_h); +} +if ($begin_d != '') { + $param .= '&begin_d='.urlencode($begin_d); +} +if ($end_d != '') { + $param .= '&end_d='.urlencode($end_d); } -if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); -if ($filter) $param .= "&search_filter=".urlencode($filter); -if ($filtert) $param .= "&search_filtert=".urlencode($filtert); -if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup); -if ($socid > 0) $param .= "&search_socid=".urlencode($socid); -if ($showbirthday) $param .= "&search_showbirthday=1"; -if ($pid) $param .= "&search_projectid=".urlencode($pid); -if ($type) $param .= "&search_type=".urlencode($type); -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); -if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); -if ($end_h != '') $param .= '&end_h='.urlencode($end_h); -if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); -if ($end_d != '') $param .= '&end_d='.urlencode($end_d); $param .= "&maxprint=".urlencode($maxprint); $paramnoactionodate = $param; @@ -301,28 +364,23 @@ print 'use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { $s = ''; $s .= ''."\n"; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { $s .= '
'.$langs->trans("LocalAgenda").'  
'; - if (is_array($showextcals) && count($showextcals) > 0) - { - foreach ($showextcals as $val) - { + if (is_array($showextcals) && count($showextcals) > 0) { + foreach ($showextcals as $val) { $htmlname = md5($val['name']); $s .= ''."\n"; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { $s .= '
'.$langs->trans("LocalAgenda").'  
'; - if (is_array($showextcals) && count($showextcals) > 0) - { - foreach ($showextcals as $val) - { + if (is_array($showextcals) && count($showextcals) > 0) { + foreach ($showextcals as $val) { $htmlname = md5($val['name']); $s .= ''."\n"; - else print ''."\n"; + if (defined('JS_JQUERY') && constant('JS_JQUERY')) { + print ''."\n"; + } else { + print ''."\n"; + } /*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) { if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; else print ''."\n"; }*/ - if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; - else print ''."\n"; - if (!defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; + if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) { + print ''."\n"; + } else { + print ''."\n"; + } + if (!defined('DISABLE_JQUERY_TABLEDND')) { + print ''."\n"; + } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { print ''."\n"; @@ -1502,16 +1583,14 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; print ''."\n"; // We include full because we need the support of containerCssClass } - if (!defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool - { + if (!defined('DISABLE_MULTISELECT')) { // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool print ''."\n"; } } if (!$disablejs && !empty($conf->use_javascript_ajax)) { // CKEditor - if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) - { + if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) { print ''."\n"; $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; $jsckeditor = 'ckeditor.js'; @@ -1520,7 +1599,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr $pathckeditor = constant('JS_CKEDITOR'); } print ''."\n"; } @@ -1554,27 +1635,21 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; // JS forced by modules (relative url starting with /) - if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) - { + if (!empty($conf->modules_parts['js'])) { // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) $arrayjs = (array) $conf->modules_parts['js']; - foreach ($arrayjs as $modjs => $filesjs) - { + foreach ($arrayjs as $modjs => $filesjs) { $filesjs = (array) $filesjs; // To be sure filejs is an array - foreach ($filesjs as $jsfile) - { + foreach ($filesjs as $jsfile) { // jsfile is a relative path print ''."\n".''."\n"; } } } // JS forced by page in top_htmlhead (relative url starting with /) - if (is_array($arrayofjs)) - { + if (is_array($arrayofjs)) { print ''."\n"; - foreach ($arrayofjs as $jsfile) - { - if (preg_match('/^(http|\/\/)/i', $jsfile)) - { + foreach ($arrayofjs as $jsfile) { + if (preg_match('/^(http|\/\/)/i', $jsfile)) { print ''."\n"; } else { print ''."\n"; @@ -1583,8 +1658,12 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } - if (!empty($head)) print $head."\n"; - if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; + if (!empty($head)) { + print $head."\n"; + } + if (!empty($conf->global->MAIN_HTML_HEADER)) { + print $conf->global->MAIN_HTML_HEADER."\n"; + } $parameters = array(); $result = $hookmanager->executeHooks('addHtmlHeader', $parameters); // Note that $action and $object may have been modified by some hooks @@ -1628,18 +1707,16 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $toprightmenu = ''; // For backward compatibility with old modules - if (empty($conf->headerdone)) - { + if (empty($conf->headerdone)) { $disablenofollow = 0; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow); print ''; } /* - * Top menu - */ - if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) - { + * Top menu + */ + if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { if (!isset($form) || !is_object($form)) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); @@ -1657,24 +1734,28 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Define link to login card $appli = constant('DOL_APPLICATION_TITLE'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) - { + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $appli = $conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core - } else $appli .= " ".DOL_VERSION; - } else $appli .= " ".DOL_VERSION; + if (preg_match('/\d\.\d/', $appli)) { + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { + $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + } else { + $appli .= " ".DOL_VERSION; + } + } else { + $appli .= " ".DOL_VERSION; + } - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $appli .= "
".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + $appli .= "
".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; + } $logouttext = ''; $logouthtmltext = ''; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$logouthtmltext=$appli.'
'; - if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') - { + if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') { $logouthtmltext .= $langs->trans("Logout").'
'; $logouttext .= ''; @@ -1693,11 +1774,10 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Execute hook printTopRightMenu (hooks should output string like '') $parameters = array(); $result = $hookmanager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks - if (is_numeric($result)) - { - if ($result == 0) + if (is_numeric($result)) { + if ($result == 0) { $toprightmenu .= $hookmanager->resPrint; // add - else { + } else { $toprightmenu = $hookmanager->resPrint; // replace } } else { @@ -1705,8 +1785,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } // Link to module builder - if (!empty($conf->modulebuilder->enabled)) - { + if (!empty($conf->modulebuilder->enabled)) { $text = ''; //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; @@ -1715,14 +1794,14 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } // Link to print main content area - if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $conf->browser->layout != 'phone') - { + if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $conf->browser->layout != 'phone') { $qs = dol_escape_htmltag($_SERVER["QUERY_STRING"]); - if (is_array($_POST)) - { - foreach ($_POST as $key=>$value) { - if ($key !== 'action' && $key !== 'password' && !is_array($value)) $qs .= '&'.$key.'='.urlencode($value); + if (is_array($_POST)) { + foreach ($_POST as $key => $value) { + if ($key !== 'action' && $key !== 'password' && !is_array($value)) { + $qs .= '&'.$key.'='.urlencode($value); + } } } $qs .= (($qs && $morequerystring) ? '&' : '').$morequerystring; @@ -1734,8 +1813,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } // Link to Dolibarr wiki pages - if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("help"); $helpbaseurl = ''; @@ -1756,21 +1834,28 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $mode = $arrayres['mode']; // Link to help pages - if ($helpbaseurl && $helppage) - { + if ($helpbaseurl && $helppage) { $text = ''; $title = $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage').'...'; if ($mode == 'wiki') { $title .= '
'.$langs->trans("PageWiki").' '.dol_escape_htmltag('"'.strtr($helppage, '_', ' ').'"'); - if ($helppresent) $title .= ' ('.$langs->trans("DedicatedPageAvailable").')'; - else $title .= ' ('.$langs->trans("HomePage").')'; + if ($helppresent) { + $title .= ' ('.$langs->trans("DedicatedPageAvailable").')'; + } else { + $title .= ' ('.$langs->trans("HomePage").')'; + } } $text .= '
'; $text .= ''; - if ($helppresent) $text .= ''; + if ($helppresent) { + $text .= ''; + } $text .= ''; $toprightmenu .= $form->textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); } @@ -1831,7 +1916,9 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead print "\n\n"; } - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) { + print '
'; + } } @@ -1849,14 +1936,17 @@ function top_menu_user($hideloginname = 0, $urllogout = '') global $menumanager; $userImage = $userDropDownImage = ''; - if (!empty($user->photo)) - { + if (!empty($user->photo)) { $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); } else { $nophoto = '/public/theme/common/user_anonymous.png'; - if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; - if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; + if ($user->gender == 'man') { + $nophoto = '/public/theme/common/user_man.png'; + } + if ($user->gender == 'woman') { + $nophoto = '/public/theme/common/user_woman.png'; + } $userImage = 'No photo'; $userDropDownImage = 'No photo'; @@ -1870,8 +1960,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') if (!empty($user->admin)) { $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); } - if (!empty($user->socid)) // Add thirdparty for external users - { + if (!empty($user->socid)) { // Add thirdparty for external users $thirdpartystatic = new Societe($db); $thirdpartystatic->fetch($user->socid); $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company @@ -1884,7 +1973,9 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'.$langs->trans("Session").''; $dropdownBody .= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); - if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { + $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + } $dropdownBody .= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); @@ -1903,15 +1994,18 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; $dropdownBody .= '
'.$langs->trans("Layout").': '.$conf->browser->layout; $dropdownBody .= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; - if ($conf->browser->layout == 'phone') $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); - if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); + if ($conf->browser->layout == 'phone') { + $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); + } + if (!empty($_SESSION["disablemodules"])) { + $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); + } $dropdownBody .= '
'; // Execute hook $parameters = array('user'=>$user, 'langs' => $langs); $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks - if (is_numeric($result)) - { + if (is_numeric($result)) { if ($result == 0) { $dropdownBody .= $hookmanager->resPrint; // add } else { @@ -1934,14 +2028,18 @@ function top_menu_user($hideloginname = 0, $urllogout = '') // Define version to show $appli = constant('DOL_APPLICATION_TITLE'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) - { + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $appli = $conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core - } else $appli .= " ".DOL_VERSION; - } else $appli .= " ".DOL_VERSION; + if (preg_match('/\d\.\d/', $appli)) { + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { + $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + } else { + $appli .= " ".DOL_VERSION; + } + } else { + $appli .= " ".DOL_VERSION; + } if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $btnUser = ' @@ -1990,8 +2088,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
'; } - if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors - { + if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) { // This may be set by some pages that use different jquery version to avoid errors $btnUser .= ' '."\n"; } // Wrapper to add log when clicking on download or preview - if (!empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) - { - if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' - { + if (!empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) { + if (in_array($object->element, array('facture'))) { // Restrict for the moment to element 'facture' print "\n\n"; ?> - + \n"; @@ -2916,20 +3063,17 @@ if (!function_exists("llxFooter")) // Add code for the asynchronous anonymous first ping (for telemetry) // You can use &forceping=1 in parameters to force the ping if the ping was already sent. $forceping = GETPOST('forceping', 'alpha'); - if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping) - { + if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping) { //print ''; $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) - || $forceping) - { + || $forceping) { // No ping done if we are into an alpha version 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 + } 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) { print "\n\n"; @@ -2941,51 +3085,55 @@ if (!function_exists("llxFooter")) $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); // Try to guess the distrib used $distrib = 'standard'; - if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; - if (!empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; + if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') { + $distrib = 'doliwamp'; + } + if (!empty($dolibarr_distrib)) { + $distrib = $dolibarr_distrib; + } ?> - + Date: Tue, 23 Feb 2021 20:46:19 +0100 Subject: [PATCH 068/173] code syntax commande directory --- htdocs/commande/card.php | 812 +++++------ htdocs/commande/class/api_orders.class.php | 127 +- htdocs/commande/class/commande.class.php | 1274 +++++++++-------- htdocs/commande/class/commandestats.class.php | 53 +- htdocs/commande/contact.php | 49 +- htdocs/commande/customer.php | 65 +- htdocs/commande/document.php | 41 +- htdocs/commande/index.php | 173 ++- htdocs/commande/info.php | 17 +- htdocs/commande/list.php | 1095 ++++++++------ htdocs/commande/note.php | 16 +- htdocs/commande/stats/index.php | 159 +- htdocs/commande/tpl/linkedobjectblock.tpl.php | 7 +- 13 files changed, 2140 insertions(+), 1748 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f0c05ec7986..889eb036ab4 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -60,9 +60,15 @@ if (!empty($conf->variants->enabled)) { // Load translation files required by the page $langs->loadLangs(array('orders', 'sendings', 'companies', 'bills', 'propal', 'deliveries', 'products', 'other')); -if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (!empty($conf->margin->enabled)) $langs->load('margins'); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->incoterm->enabled)) { + $langs->load('incoterm'); +} +if (!empty($conf->margin->enabled)) { + $langs->load('margins'); +} +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int')); $ref = GETPOST('ref', 'alpha'); @@ -82,8 +88,9 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if (!empty($user->socid)) +if (!empty($user->socid)) { $socid = $user->socid; +} $result = restrictedArea($user, 'commande', $id); $object = new Commande($db); @@ -125,14 +132,13 @@ $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int' $parameters = array('socid' => $socid); // Note that $action and $object may be modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -146,20 +152,16 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) - { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - if ($object->id > 0) - { + if ($object->id > 0) { // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; $result = $object->createFromClone($user, $socid); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { @@ -169,49 +171,38 @@ if (empty($reshook)) } } } - } - - // Reopen a closed order - elseif ($action == 'reopen' && $usercancreate) - { - if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) - { + } elseif ($action == 'reopen' && $usercancreate) { + // Reopen a closed order + if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) { $result = $object->set_reopen($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('OrderReopened', $object->ref), null); } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Remove order - elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) - { + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { + // Remove order $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { header('Location: list.php?restore_lastsearch_values=1'); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Remove a product line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) - { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + // Remove a product line $result = $object->deleteline($user, $lineid); - if ($result > 0) - { + if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -226,17 +217,11 @@ if (empty($reshook)) } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Link to a project - elseif ($action == 'classin' && $usercancreate) - { + } elseif ($action == 'classin' && $usercancreate) { + // Link to a project $object->setProject(GETPOST('projectid', 'int')); - } - - // Add order - elseif ($action == 'add' && $usercancreate) - { + } elseif ($action == 'add' && $usercancreate) { + // Add order $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $selectedLines = GETPOST('toselect', 'array'); @@ -282,15 +267,15 @@ if (empty($reshook)) $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Fill array 'array_options' with data from add form - if (!$error) - { + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { @@ -320,12 +305,10 @@ if (empty($reshook)) $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } - if (!$error) - { + if (!$error) { $object_id = $object->create($user); - if ($object_id > 0) - { + if ($object_id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); @@ -333,11 +316,9 @@ if (empty($reshook)) dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { + if ($result > 0) { $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } @@ -345,9 +326,10 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) { + continue; // Skip unselected lines + } $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : ''); @@ -356,15 +338,19 @@ if (empty($reshook)) // Dates // TODO mutualiser $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) + if ($lines[$i]->date_debut_reel) { $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) + } + if ($lines[$i]->date_start) { $date_start = $lines[$i]->date_start; + } $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) + if ($lines[$i]->date_fin_reel) { $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) + } + if ($lines[$i]->date_end) { $date_end = $lines[$i]->date_end; + } // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -372,20 +358,42 @@ if (empty($reshook)) } // Extrafields - if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if trigger used - { + if (method_exists($lines[$i], 'fetch_optionals')) { // For avoid conflicts if trigger used $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } $tva_tx = $lines[$i]->tva_tx; - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { + $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + } $result = $object->addline( - $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, - $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, - $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, - $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $date_start, + $date_end, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $label, + $array_options, + $lines[$i]->fk_unit, + $object->origin, + $lines[$i]->rowid ); if ($result < 0) { @@ -407,26 +415,26 @@ if (empty($reshook)) /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { - $originforcontact = $object->origin; - $originidforcontact = $object->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - $originforcontact=$srcobject->origin; - $originidforcontact=$srcobject->origin_id; - } - $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; + $originforcontact = $object->origin; + $originidforcontact = $object->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + $originforcontact=$srcobject->origin; + $originidforcontact=$srcobject->origin_id; + } + $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; - $resqlcontact = $db->query($sqlcontact); - if ($resqlcontact) - { - while($objcontact = $db->fetch_object($resqlcontact)) - { - //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n"; - $object->add_contact($objcontact->fk_socpeople, $objcontact->code); - } - } - else dol_print_error($resqlcontact); + $resqlcontact = $db->query($sqlcontact); + if ($resqlcontact) + { + while($objcontact = $db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n"; + $object->add_contact($objcontact->fk_socpeople, $objcontact->code); + } + } + else dol_print_error($resqlcontact); }*/ // Hooks @@ -445,15 +453,13 @@ if (empty($reshook)) $action = 'create'; } } else { - if (!$error) - { + if (!$error) { $object_id = $object->create($user); } } // Insert default contacts if defined - if ($object_id > 0) - { + if ($object_id > 0) { if (GETPOST('contactid', 'int')) { $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external'); if ($result < 0) { @@ -467,8 +473,7 @@ if (empty($reshook)) } // End of object creation, we show it - if ($object_id > 0 && !$error) - { + if ($object_id > 0 && !$error) { $db->commit(); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id); exit(); @@ -478,32 +483,26 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'classifybilled' && $usercancreate) - { + } elseif ($action == 'classifybilled' && $usercancreate) { $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'classifyunbilled' && $usercancreate) - { + } elseif ($action == 'classifyunbilled' && $usercancreate) { $ret = $object->classifyUnBilled(); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Positionne ref commande client - elseif ($action == 'setref_client' && $usercancreate) { + } elseif ($action == 'setref_client' && $usercancreate) { + // Positionne ref commande client $result = $object->set_ref_client($user, GETPOST('ref_client')); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremise' && $usercancreate) { $result = $object->setDiscount($user, GETPOST('remise')); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setabsolutediscount' && $usercancreate) { @@ -533,26 +532,25 @@ if (empty($reshook)) } } elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - - // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + } + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { + // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } elseif ($action == 'setavailability' && $usercancreate) { $result = $object->availability(GETPOST('availability_id')); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->demand_reason(GETPOST('demand_reason_id')); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { @@ -562,8 +560,9 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -573,35 +572,26 @@ if (empty($reshook)) $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - } - - // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) - { + } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { + // Set incoterm $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // bank account - elseif ($action == 'setbankaccount' && $usercancreate) { + } elseif ($action == 'setbankaccount' && $usercancreate) { + // bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // shipping method - elseif ($action == 'setshippingmethod' && $usercancreate) { + } elseif ($action == 'setshippingmethod' && $usercancreate) { + // shipping method $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // warehouse - elseif ($action == 'setwarehouse' && $usercancreate) { + } elseif ($action == 'setwarehouse' && $usercancreate) { + // warehouse $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -619,8 +609,7 @@ if (empty($reshook)) foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif ($action == 'addline' && $usercancreate) // Add a new line - { + } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; @@ -630,8 +619,7 @@ if (empty($reshook)) $price_ht = price2num(GETPOST('price_ht'), 'MU'); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); $prod_entry_mode = GETPOST('prod_entry_mode'); - if ($prod_entry_mode == 'free') - { + if ($prod_entry_mode == 'free') { $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { @@ -665,8 +653,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for order. - { + if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } @@ -712,7 +699,9 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -720,21 +709,21 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // If price per segment - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) { + $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + } + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) { + $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } } - } - // If price per customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + // If price per customer require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -742,38 +731,37 @@ if (empty($reshook)) $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) - { - if (count($prodcustprice->lines) > 0) - { + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { $pu_ht = price($prodcustprice->lines[0]->price); $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_min = price($prodcustprice->lines[0]->price_min); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { + $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + } $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } } } else { setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - } - // If price per quantity - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) - { - if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + // If price per quantity + if ($prod->prices_by_qty[0]) { // yes, this product has some prices per quantity // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) - { - if ($priceforthequantityarray['rowid'] != $pqp) continue; + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { + if ($priceforthequantityarray['rowid'] != $pqp) { + continue; + } // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') - { + if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; } else { $pu_ttc = $priceforthequantityarray['unitprice']; @@ -782,21 +770,18 @@ if (empty($reshook)) break; } } - } - // If price per quantity and customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { - if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + // If price per quantity and customer + if ($prod->prices_by_qty[$object->thirdparty->price_level]) { // yes, this product has some prices per quantity // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) - { - if ($priceforthequantityarray['rowid'] != $pqp) continue; + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { + if ($priceforthequantityarray['rowid'] != $pqp) { + continue; + } // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') - { + if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; } else { $pu_ttc = $priceforthequantityarray['unitprice']; @@ -814,10 +799,9 @@ if (empty($reshook)) if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tmpvat != $tmpprodvat) { + } elseif ($tmpvat != $tmpprodvat) { + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { @@ -831,16 +815,18 @@ if (empty($reshook)) if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) + } + if (empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; } else { $desc = $prod->description; } @@ -850,8 +836,11 @@ if (empty($reshook)) $product_desc=''; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; - else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { + $desc = $product_desc; + } else { + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + } // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { @@ -860,28 +849,36 @@ if (empty($reshook)) if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'alpha')) + if (empty($newlang) && GETPOST('lang_id', 'alpha')) { $newlang = GETPOST('lang_id', 'alpha'); - if (empty($newlang)) + } + if (empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (!empty($prod->customcode)) + if (!empty($prod->customcode)) { $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; - if (!empty($prod->customcode) && !empty($prod->country_code)) + } + if (!empty($prod->customcode) && !empty($prod->country_code)) { $tmptxt .= ' - '; - if (!empty($prod->country_code)) + } + if (!empty($prod->country_code)) { $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); + } } else { - if (!empty($prod->customcode)) + if (!empty($prod->customcode)) { $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; - if (!empty($prod->customcode) && !empty($prod->country_code)) + } + if (!empty($prod->customcode) && !empty($prod->country_code)) { $tmptxt .= ' - '; - if (!empty($prod->country_code)) + } + if (!empty($prod->country_code)) { $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); + } } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -912,8 +909,9 @@ if (empty($reshook)) $desc = dol_htmlcleanlastbr($desc); $info_bits = 0; - if ($tva_npr) + if ($tva_npr) { $info_bits |= 0x01; + } if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); @@ -930,8 +928,9 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -977,13 +976,8 @@ if (empty($reshook)) } } } - } - - /* - * Update a line - */ - elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) - { + } elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { + // Update a line // Clean parameters $date_start = ''; $date_end = ''; @@ -996,8 +990,9 @@ if (empty($reshook)) // Define info_bits $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) + if (preg_match('/\*/', $vat_rate)) { $info_bits |= 0x01; + } // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); @@ -1020,7 +1015,9 @@ if (empty($reshook)) // Define special_code for special lines $special_code = GETPOST('special_code'); - if (!GETPOST('qty')) $special_code = 3; + if (!GETPOST('qty')) { + $special_code = 3; + } // Check minimum price $productid = GETPOST('productid', 'int'); @@ -1031,8 +1028,9 @@ if (empty($reshook)) $type = $product->type; $price_min = $product->price_min; - if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) { $price_min = $product->multiprices_min[$object->thirdparty->price_level]; + } $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); @@ -1052,12 +1050,9 @@ if (empty($reshook)) } if (!$error) { - if (empty($user->rights->margins->creer)) - { - foreach ($object->lines as &$line) - { - if ($line->id == GETPOST('lineid')) - { + if (empty($user->rights->margins->creer)) { + foreach ($object->lines as &$line) { + if ($line->id == GETPOST('lineid')) { $fournprice = $line->fk_fournprice; $buyingprice = $line->pa_ht; break; @@ -1071,10 +1066,12 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1117,23 +1114,19 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); - } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) - { + } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change = $object->hasProductsOrServices(2); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (!$idwarehouse || $idwarehouse == -1) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -1142,15 +1135,17 @@ if (empty($reshook)) if (!$error) { $result = $object->valid($user, $idwarehouse); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1164,25 +1159,20 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Go back to draft status - elseif ($action == 'confirm_modif' && $usercancreate) { + } elseif ($action == 'confirm_modif' && $usercancreate) { + // Go back to draft status $idwarehouse = GETPOST('idwarehouse'); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change = $object->hasProductsOrServices(2); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (!$idwarehouse || $idwarehouse == -1) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -1191,15 +1181,17 @@ if (empty($reshook)) if (!$error) { $result = $object->setDraft($user, $idwarehouse); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1216,23 +1208,19 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) - { + } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change = $object->hasProductsOrServices(2); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (!$idwarehouse || $idwarehouse == -1) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -1248,58 +1236,53 @@ if (empty($reshook)) } } - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('ORDER_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } // add lines from objectlinked if ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Commande::STATUS_DRAFT - ) - { + ) { $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { + } elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; } $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach ($importLines as $lineId) - { + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals(); $desc = $originLine->desc; $pu_ht = $originLine->subprice; @@ -1343,8 +1326,7 @@ if (empty($reshook)) } } - if ($error) - { + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } } @@ -1366,10 +1348,8 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) - { - if ($action == 'addcontact') - { + if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { + if ($action == 'addcontact') { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -1387,21 +1367,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // bascule du statut d'un contact - elseif ($action == 'swapstatut') - { + } elseif ($action == 'swapstatut') { + // bascule du statut d'un contact if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } - - // Efface un contact - elseif ($action == 'deletecontact') - { + } elseif ($action == 'deletecontact') { + // Efface un contact $result = $object->delete_contact($lineid); if ($result >= 0) { @@ -1425,16 +1399,18 @@ $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formmargin = new FormMargin($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} // Mode creation -if ($action == 'create' && $usercancreate) -{ +if ($action == 'create' && $usercancreate) { print load_fiche_titre($langs->trans('CreateOrder'), '', 'order'); $soc = new Societe($db); - if ($socid > 0) + if ($socid > 0) { $res = $soc->fetch($socid); + } $remise_absolue = 0; @@ -1481,8 +1457,9 @@ if ($action == 'create' && $usercancreate) $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch($originid); - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); + } $objectsrc->fetch_thirdparty(); // Replicate extrafields @@ -1505,12 +1482,17 @@ if ($action == 'create' && $usercancreate) $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); - if (empty($date_delivery)) $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + if (empty($date_delivery)) { + $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + } - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($conf->multicurrency->enabled)) { + if (!empty($objectsrc->multicurrency_code)) { + $currency_code = $objectsrc->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) { + $currency_tx = $objectsrc->multicurrency_tx; + } } $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); @@ -1531,18 +1513,25 @@ if ($action == 'create' && $usercancreate) $remise_absolue = 0; $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; - if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) { + $currency_code = $soc->multicurrency_code; + } $note_private = $object->getDefaultCreateValueFor('note_private'); $note_public = $object->getDefaultCreateValueFor('note_public'); } //Warehouse default if null - if ($soc->fk_warehouse > 0) $warehouse_id = $soc->fk_warehouse; - if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) - { - if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; - if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $warehouse_id = $user->fk_warehouse; + if ($soc->fk_warehouse > 0) { + $warehouse_id = $soc->fk_warehouse; + } + if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { + $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + } + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { + $warehouse_id = $user->fk_warehouse; + } } print ''; @@ -1552,7 +1541,9 @@ if ($action == 'create' && $usercancreate) print ''; print ''; print ''; - if (!empty($currency_tx)) print ''; + if (!empty($currency_tx)) { + print ''; + } print dol_get_fiche_head(''); @@ -1563,9 +1554,11 @@ if ($action == 'create' && $usercancreate) // Reference client print ''; - else print ''; + } else { + print ''; + } print ''; // Thirdparty @@ -1580,8 +1573,7 @@ if ($action == 'create' && $usercancreate) print ''; print ''."\n"; } @@ -2958,15 +3072,21 @@ if ($action == 'create') $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later - if (empty($projectid)) $projectid = $invoice_predefined->fk_project; + if (empty($projectid)) { + $projectid = $invoice_predefined->fk_project; + } $cond_reglement_id = $invoice_predefined->cond_reglement_id; $mode_reglement_id = $invoice_predefined->mode_reglement_id; $fk_account = $invoice_predefined->fk_account; $note_public = $invoice_predefined->note_public; $note_private = $invoice_predefined->note_private; - if (!empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; - if (!empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; + if (!empty($invoice_predefined->multicurrency_code)) { + $currency_code = $invoice_predefined->multicurrency_code; + } + if (!empty($invoice_predefined->multicurrency_tx)) { + $currency_tx = $invoice_predefined->multicurrency_tx; + } $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; @@ -2985,8 +3105,7 @@ if ($action == 'create') while ($i < $num) { $objp = $db->fetch_object($resql); print '
'; print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); @@ -579,8 +709,12 @@ if ($resql) if (!empty($arrayfields['s.nom']['checked'])) { print ''; $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); @@ -606,17 +744,37 @@ if ($resql) print "
'; // With edge and chrome the td overflow is not supported correctly when content is not full text. - if ($obj->fk_user_action > 0) - { + if ($obj->fk_user_action > 0) { $userstatic->fetch($obj->fk_user_action); print $userstatic->getNomUrl(-1); - } else print ' '; + } else { + print ' '; + } print ''; print $actionstatic->getTypePicto(); $labeltype = $obj->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { + $labeltype = 'AC_OTH'; + } if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') { $labeltype = $langs->trans("Message"); } else { - if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; - if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code + if (!empty($arraylist[$labeltype])) { + $labeltype = $arraylist[$labeltype]; + } + if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) { + $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code + } } print dol_trunc($labeltype, 28); print ''; print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); $late = 0; - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; - if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; - if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; - if ($late) print img_warning($langs->trans("Late")).' '; + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { + $late = 1; + } + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) { + $late = 1; + } + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) { + $late = 1; + } + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { + $late = 1; + } + if ($late) { + print img_warning($langs->trans("Late")).' '; + } print ''; - if ($obj->socid > 0) - { + if ($obj->socid > 0) { $societestatic->id = $obj->socid; $societestatic->client = $obj->client; $societestatic->name = $obj->societe; $societestatic->email = $obj->socemail; print $societestatic->getNomUrl(1, '', 28); - } else print ' '; + } else { + print ' '; + } print ''; - if (!empty($actionstatic->socpeopleassigned)) - { + if (!empty($actionstatic->socpeopleassigned)) { $contactList = array(); - foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) - { - if (!isset($contactListCache[$socpeopleassigned['id']])) - { + foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) { + if (!isset($contactListCache[$socpeopleassigned['id']])) { // if no cache found we fetch it $contact = new Contact($db); - if ($contact->fetch($socpeopleassigned['id']) > 0) - { + if ($contact->fetch($socpeopleassigned['id']) > 0) { $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); $contactList[] = $contact->getNomUrl(1, '', 0); } @@ -782,8 +956,7 @@ if ($resql) if (!empty($contactList)) { print implode(', ', $contactList); } - } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event - { + } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event $contactstatic->id = $obj->fk_contact; $contactstatic->email = $obj->email; $contactstatic->lastname = $obj->lastname; @@ -835,10 +1008,11 @@ if ($resql) } // Action column print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->id, $arrayofselected)) $selected = 1; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans('RefCustomer').''; - if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) + if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) { print '
'; print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations - if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) - { + if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print ''; } - if (!GETPOST('fac_rec', 'int')) print ' '; + if (!GETPOST('fac_rec', 'int')) { + print ' '; + } print '
'; print '
'; - } + } } if ($socid > 0) { @@ -3124,8 +3243,9 @@ if ($action == 'create') $tmp .= '> '; $text = ' '; $text .= ''; @@ -3146,8 +3266,9 @@ if ($action == 'create') if (is_array($facids)) { foreach ($facids as $facparam) { $options .= ''; @@ -3234,8 +3355,9 @@ if ($action == 'create') $newinvoice_static->paye = $valarray ['paye']; $optionsav .= '
'; print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print ''; + } print '
'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -4299,8 +4426,9 @@ if ($action == 'create') print ''; + } print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $usercancreate) + if (($action != 'editbankaccount') && $usercancreate) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print '
'; if ($action == 'editbankaccount') { @@ -4318,8 +4446,11 @@ if ($action == 'create') print '
'; print $langs->trans('IncotermLabel'); print ''; - if ($usercancreate) print ''.img_edit().''; - else print ' '; + if ($usercancreate) { + print ''.img_edit().''; + } else { + print ' '; + } print '
'; print '
'; @@ -4351,8 +4482,7 @@ if ($action == 'create') print '
'; print '
'; - if ($action == 'editretainedwarranty') - { + if ($action == 'editretainedwarranty') { print ''; print ''; print ''; @@ -4575,7 +4705,9 @@ if ($action == 'create') print ''.$langs->trans('ListOfSituationInvoices').''.$langs->trans('Situation').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').' '.$prev_invoice->getNomUrl(1).''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).''.$object->getNomUrl(1).''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).''.price($total_global_ht).''.price($total_global_ttc).' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$next_invoice->getNomUrl(1).''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaye).'
'.price($total_global_ht).''.price($total_global_ttc).' 
'; print ''; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { print $langs->trans("CreditNote").' '; - if ($invoice->type == Facture::TYPE_DEPOSIT) + } + if ($invoice->type == Facture::TYPE_DEPOSIT) { print $langs->trans("Deposit").' '; + } print $invoice->getNomUrl(0); print ''; print '
'; $text = $langs->trans("HelpAbandonOther"); - if ($object->close_note) + if ($object->close_note) { $text .= '

'.$langs->trans("Reason").':'.$object->close_note; + } print ''; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print ''; @@ -4932,8 +5083,9 @@ if ($action == 'create') // Remainder to pay back print '
'; print $langs->trans('RemainderToPayBack'); - if ($resteapayeraffiche > 0) + if ($resteapayeraffiche > 0) { print ' ('.$langs->trans('ExcessPaid').')'; + } print ' :'.price($sign * $resteapayeraffiche).' 
'.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; $result .= ''; return $result; @@ -269,8 +271,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $total = 0; $i = 0; - while ($i < $nbofloop) - { + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->rowid; @@ -291,14 +292,11 @@ function getDraftTable($maxCount = 500, $socid = 0) $total += $obj->total_ttc; } - if ($num > $nbofloop) - { + if ($num > $nbofloop) { $result .= '
'.$langs->trans("XMoreLines", ($num - $nbofloop)).'
'.$langs->trans("Total").''.price($total).''.$langs->trans("LastCustomersBills", $maxCount).'
'; $result .= ''; return $result; @@ -360,8 +362,7 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $companystatic = new Societe($db); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->rowid; @@ -421,18 +422,23 @@ function getOpenTable($maxCount = 500, $socid = 0) $sql .= ", f.datef as df, f.date_lim_reglement as datelimite"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture').")"; $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; - 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; + 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 f.rowid DESC"; $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); } @@ -450,8 +456,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $result .= '
'; $result .= ''; return $result; @@ -465,8 +470,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $total = 0; $i = 0; - while ($i < $nbofloop) - { + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->id; @@ -490,8 +494,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $result .= '
'; - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) - { + if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { $result .= img_warning($langs->trans("Late")); } @@ -513,14 +516,11 @@ function getOpenTable($maxCount = 500, $socid = 0) $total += $obj->total_ttc; } - if ($num > $nbofloop) - { + if ($num > $nbofloop) { $result .= '
'.$langs->trans("XMoreLines", ($num - $nbofloop)).'
'.$langs->trans("Total").''.price($total).'
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print "'; $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); print ''; print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); print ''; print ''; print ''; print ''; print ''; print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($search_year_date_when ? $search_year_date_when : -1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; print ''; print ''; $liststatus = array( 0=>$langs->trans("Draft"), @@ -478,35 +558,67 @@ if ($resql) print "
'; print $invoicerectmp->getNomUrl(1); print ""; print "'.$companystatic->getNomUrl(1, 'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''; $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); print ''; $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); print ''.yn($objp->frequency ? 1 : 0).''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); print ''; print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); print ''; print '
'; print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); - if (!$invoicerectmp->isMaxNbGenReached()) - { - if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + if (!$invoicerectmp->isMaxNbGenReached()) { + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { + print img_warning($langs->trans("Late")); + } } else { print img_info($langs->trans("MaxNumberOfGenerationReached")); } print '
'; print '
'; print dol_print_date($db->jdate($objp->datec), 'dayhour'); print ''; print dol_print_date($db->jdate($objp->tms), 'dayhour'); print ''; print $invoicerectmp->getLibStatut(3, 0); print ''; - if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) - { - if ($invoicerectmp->isMaxNbGenReached()) - { + if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) { + if ($invoicerectmp->isMaxNbGenReached()) { print $langs->trans("MaxNumberOfGenerationReached"); - } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) - { + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { print ''; print $langs->trans("CreateBill").''; } else { @@ -663,7 +796,9 @@ if ($resql) } else { print " "; } - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -781,22 +989,19 @@ if ($resql) print ''; } // Ref - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print ''; } // Ref customer - if (!empty($arrayfields['f.ref_client']['checked'])) - { + if (!empty($arrayfields['f.ref_client']['checked'])) { print ''; } // Type - if (!empty($arrayfields['f.type']['checked'])) - { + if (!empty($arrayfields['f.type']['checked'])) { print ''; } // Date invoice - if (!empty($arrayfields['f.date']['checked'])) - { + if (!empty($arrayfields['f.date']['checked'])) { print ''; } // Date valid - if (!empty($arrayfields['f.date_valid']['checked'])) - { + if (!empty($arrayfields['f.date_valid']['checked'])) { print ''; } // Date due - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) - { + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; } // Project ref - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Project label - if (!empty($arrayfields['p.title']['checked'])) - { + if (!empty($arrayfields['p.title']['checked'])) { print ''; } // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) - { + if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; } // Town - if (!empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + } // Zip - if (!empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; } // Payment terms - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; } // Module source - if (!empty($arrayfields['f.module_source']['checked'])) - { + if (!empty($arrayfields['f.module_source']['checked'])) { print ''; } // POS Terminal - if (!empty($arrayfields['f.pos_source']['checked'])) - { + if (!empty($arrayfields['f.pos_source']['checked'])) { print ''; } - if (!empty($arrayfields['f.total_ht']['checked'])) - { + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['f.total_vat']['checked'])) - { + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['f.total_localtax1']['checked'])) - { + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Localtax1 print ''; } - if (!empty($arrayfields['f.total_localtax2']['checked'])) - { + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Localtax2 print ''; } - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { // Author print ''; } - if (!empty($arrayfields['f.retained_warranty']['checked'])) - { + if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; } - if (!empty($arrayfields['dynamount_payed']['checked'])) - { + if (!empty($arrayfields['dynamount_payed']['checked'])) { print ''; } - if (!empty($arrayfields['rtp']['checked'])) - { + if (!empty($arrayfields['rtp']['checked'])) { print ''; } - if (!empty($arrayfields['f.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { // Currency print ''; } - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { // Currency rate print ''; } - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { // Amount print ''; } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) - { + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { print ''; } - if (!empty($arrayfields['multicurrency_rtp']['checked'])) - { + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { print ''; } - if (!empty($arrayfields['f.date_closing']['checked'])) - { + if (!empty($arrayfields['f.date_closing']['checked'])) { print ''; } - if (!empty($arrayfields['total_pa']['checked'])) - { + if (!empty($arrayfields['total_pa']['checked'])) { print ''; } - if (!empty($arrayfields['total_margin']['checked'])) - { + if (!empty($arrayfields['total_margin']['checked'])) { print ''; } - if (!empty($arrayfields['total_margin_rate']['checked'])) - { + if (!empty($arrayfields['total_margin_rate']['checked'])) { print ''; } - if (!empty($arrayfields['total_mark_rate']['checked'])) - { + if (!empty($arrayfields['total_mark_rate']['checked'])) { print ''; } @@ -1061,32 +1234,27 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } - if (!empty($arrayfields['f.note_public']['checked'])) - { + if (!empty($arrayfields['f.note_public']['checked'])) { // Note public print ''; } - if (!empty($arrayfields['f.note_private']['checked'])) - { + if (!empty($arrayfields['f.note_private']['checked'])) { // Note private print ''; } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '\n"; print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_valid']['checked'])) print_liste_field_titre($arrayfields['f.date_valid']['label'], $_SERVER['PHP_SELF'], 'f.date_valid', '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); - if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['multicurrency_rtp']['checked'])) print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['total_pa']['checked'])) print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['total_margin']['checked'])) print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['total_margin_rate']['checked'])) print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['total_mark_rate']['checked'])) print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.ref']['checked'])) { + print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.type']['checked'])) { + print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date']['checked'])) { + print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date_valid']['checked'])) { + print_liste_field_titre($arrayfields['f.date_valid']['label'], $_SERVER['PHP_SELF'], 'f.date_valid', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.title']['checked'])) { + print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.module_source']['checked'])) { + print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.pos_source']['checked'])) { + print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.retained_warranty']['checked'])) { + print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['rtp']['checked'])) { + print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { + print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { + print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_pa']['checked'])) { + print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin']['checked'])) { + print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (!empty($arrayfields['f.note_public']['checked'])) print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.note_private']['checked'])) print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.date_closing']['checked'])) { + print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.note_public']['checked'])) { + print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.note_private']['checked'])) { + print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -1159,12 +1419,10 @@ if ($resql) $discount = new DiscountAbsolute($db); $userstatic = new User($db); - if ($num > 0) - { + if ($num > 0) { $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $datelimit = $db->jdate($obj->datelimite); @@ -1193,8 +1451,7 @@ if ($resql) $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; - if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_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; $facturestatic->situation_final = $obj->retained_warranty_date_limit; @@ -1250,8 +1507,7 @@ if ($resql) } print ''; @@ -1262,15 +1518,13 @@ if ($resql) } // Ref - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Customer ref - if (!empty($arrayfields['f.ref_client']['checked'])) - { + if (!empty($arrayfields['f.ref_client']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type - if (!empty($arrayfields['f.type']['checked'])) - { + if (!empty($arrayfields['f.type']['checked'])) { print '"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date - if (!empty($arrayfields['f.date']['checked'])) - { + if (!empty($arrayfields['f.date']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date - if (!empty($arrayfields['f.date_valid']['checked'])) - { + if (!empty($arrayfields['f.date_valid']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) - { + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project ref - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project title - if (!empty($arrayfields['p.title']['checked'])) - { + if (!empty($arrayfields['p.title']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Third party - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) - { + if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Town - if (!empty($arrayfields['s.town']['checked'])) - { + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip - if (!empty($arrayfields['s.zip']['checked'])) - { + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type ent - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Staff - if (!empty($arrayfields['staff.code']['checked'])) - { + if (!empty($arrayfields['staff.code']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Payment terms - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Module Source - if (!empty($arrayfields['f.module_source']['checked'])) - { + if (!empty($arrayfields['f.module_source']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // POS Terminal - if (!empty($arrayfields['f.pos_source']['checked'])) - { + if (!empty($arrayfields['f.pos_source']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) - { + if (!empty($arrayfields['f.total_ht']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } $totalarray['val']['f.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['f.total_vat']['checked'])) - { + if (!empty($arrayfields['f.total_vat']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + } $totalarray['val']['f.total_vat'] += $obj->total_vat; } // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) - { + if (!empty($arrayfields['f.total_localtax1']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; } // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) - { + if (!empty($arrayfields['f.total_localtax2']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; } // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } // Author - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { $userstatic->id = $obj->fk_user_author; $userstatic->login = $obj->login; print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.retained_warranty']['checked'])) - { + if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; } - if (!empty($arrayfields['dynamount_payed']['checked'])) - { + if (!empty($arrayfields['dynamount_payed']['checked'])) { print ''; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } $totalarray['val']['totalam'] += $totalpay; } // Pending amount - if (!empty($arrayfields['rtp']['checked'])) - { + if (!empty($arrayfields['rtp']['checked'])) { print ''; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } $totalarray['val']['rtp'] += $remaintopay; } // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Currency rate - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount VAT - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount TTC - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) - { + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { print ''; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Pending amount - if (!empty($arrayfields['multicurrency_rtp']['checked'])) - { + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { print ''; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) - { + if (!empty($arrayfields['total_pa']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Total margin - if (!empty($arrayfields['total_margin']['checked'])) - { + if (!empty($arrayfields['total_margin']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } $totalarray['val']['total_margin'] += $marginInfo['total_margin']; } // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) - { + if (!empty($arrayfields['total_margin_rate']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) - { + if (!empty($arrayfields['total_mark_rate']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -1627,64 +1939,73 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date closing - if (!empty($arrayfields['f.date_closing']['checked'])) - { + if (!empty($arrayfields['f.date_closing']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Note public - if (!empty($arrayfields['f.note_public']['checked'])) - { + if (!empty($arrayfields['f.note_public']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Note private - if (!empty($arrayfields['f.note_private']['checked'])) - { + if (!empty($arrayfields['f.note_private']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column (Show the massaction button only when this page is not opend from the Extended POS) print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; @@ -1709,7 +2030,9 @@ if ($resql) // Show the file area only when this page is not opend from the Extended POS if ($contextpage != 'poslist') { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index aa3bd40c591..23d4afb0417 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -43,7 +43,9 @@ $action = GETPOST('action', 'aZ09'); // Security check $socid = 0; -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'facture', $id, ''); $object = new Facture($db); @@ -70,8 +72,7 @@ llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new Facture($db); $object->fetch($id, $ref); @@ -94,15 +95,14 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') + if ($user->rights->facture->creer) { + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $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 .= ''; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 26bab3c1984..b6cf7ec5c06 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -48,7 +48,9 @@ $action = GETPOST('action', 'aZ09'); $type = GETPOST('type', 'aZ09'); $fieldid = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} if ($type == 'bank-transfer') { $object = new FactureFournisseur($db); @@ -57,12 +59,10 @@ if ($type == 'bank-transfer') { } // Load object -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); - if ($ret > 0) - { + if ($ret > 0) { $object->fetch_thirdparty(); } } @@ -71,10 +71,14 @@ $hookmanager->initHooks(array('directdebitcard', 'globalcard')); if ($type == 'bank-transfer') { $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', $fieldid, $isdraft); - if (!$user->rights->fournisseur->facture->lire) accessforbidden(); + if (!$user->rights->fournisseur->facture->lire) { + accessforbidden(); + } } else { $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); - if (!$user->rights->facture->lire) accessforbidden(); + if (!$user->rights->facture->lire) { + accessforbidden(); + } } @@ -84,14 +88,13 @@ if ($type == 'bank-transfer') { $parameters = array('socid' => $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($action == "new") - { - if ($object->id > 0) - { +if (empty($reshook)) { + if ($action == "new") { + if ($object->id > 0) { $db->begin(); $newtype = $type; @@ -102,8 +105,7 @@ if (empty($reshook)) } $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype); - if ($result > 0) - { + if ($result > 0) { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -115,13 +117,10 @@ if (empty($reshook)) $action = ''; } - if ($action == "delete") - { - if ($object->id > 0) - { + if ($action == "delete") { + if ($object->id > 0) { $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); - if ($result == 0) - { + if ($result == 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type); exit; } @@ -155,8 +154,7 @@ llxHeader('', $title, $helpurl); /* */ /* *************************************************************************** */ -if ($object->id > 0) -{ +if ($object->id > 0) { $selleruserevenustamp = $mysoc->useRevenueStamp(); $totalpaye = $object->getSommePaiement(); @@ -170,7 +168,9 @@ if ($object->id > 0) //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if ($object->paye) $resteapayer = 0; + if ($object->paye) { + $resteapayer = 0; + } $resteapayeraffiche = $resteapayer; if ($type == 'bank-transfer') { @@ -202,8 +202,7 @@ if ($object->id > 0) } $author = new User($db); - if ($object->user_author) - { + if ($object->user_author) { $author->fetch($object->user_author); } @@ -234,17 +233,19 @@ if ($object->id > 0) // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); if ($type == 'bank-transfer') { - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; + } } else { - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; + } } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { + if ($user->rights->facture->creer) { if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; @@ -293,8 +294,7 @@ if ($object->id > 0) if ($object->module_source) { print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; } - if ($object->type == $object::TYPE_REPLACEMENT) - { + if ($object->type == $object::TYPE_REPLACEMENT) { if ($type == 'bank-transfer') { $facreplaced = new FactureFournisseur($db); } else { @@ -303,8 +303,7 @@ if ($object->id > 0) $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } - if ($object->type == $object::TYPE_CREDIT_NOTE) - { + if ($object->type == $object::TYPE_CREDIT_NOTE) { if ($type == 'bank-transfer') { $facusing = new FactureFournisseur($db); } else { @@ -315,14 +314,15 @@ if ($object->id > 0) } $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { + if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $id) - { - if ($i == 0) print ' '; - else print ','; + foreach ($facidavoir as $id) { + if ($i == 0) { + print ' '; + } else { + print ','; + } if ($type == 'bank-transfer') { $facavoir = new FactureFournisseur($db); } else { @@ -374,14 +374,14 @@ if ($object->id > 0) print '
'; print ''; print ''; print ''; print ''; $listtype = array( Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), @@ -804,8 +1009,7 @@ if ($resql) Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. @@ -813,8 +1017,7 @@ if ($resql) print ''; print '
'; print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -825,8 +1028,7 @@ if ($resql) print '
'; print '
'; print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -837,8 +1039,7 @@ if ($resql) print '
'; print '
'; /* @@ -853,202 +1054,174 @@ if ($resql) print '
'; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100', 1); print ''; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print ''; $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); @@ -1100,58 +1268,150 @@ if ($resql) print "
'; print ''; print '
'; - if ($contextpage == 'poslist') - { + if ($contextpage == 'poslist') { print $obj->ref; } else { print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); @@ -1285,339 +1539,397 @@ if ($resql) print '
'; print "
'; print $obj->ref_client; print ''; print $facturestatic->getLibType(); print "'; print dol_print_date($db->jdate($obj->df), 'day'); print ''; print dol_print_date($db->jdate($obj->date_valid), 'day'); print ''.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) - { + if ($facturestatic->hasDelay()) { print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); } print ''; - if ($obj->project_id > 0) - { + if ($obj->project_id > 0) { print $projectstatic->getNomUrl(1); } print ''; - if ($obj->project_id > 0) - { + if ($obj->project_id > 0) { print $projectstatic->title; } print ''; - if ($contextpage == 'poslist') - { + if ($contextpage == 'poslist') { print $thirdpartystatic->name; } else { print $thirdpartystatic->getNomUrl(1, 'customer'); } print ''; print $obj->name_alias; print ''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + if (!is_array($typenArray) || count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } print $typenArray[$obj->typent_code]; print ''; - if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1); + if (!is_array($staffArray) || count($staffArray) == 0) { + $staffArray = $formcompany->effectif_array(1); + } print $staffArray[$obj->staff_code]; print ''; $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); print ''; $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); print ''; print $obj->module_source; print ''; print $obj->pos_source; print ''.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - if ($userstatic->id) print $userstatic->getLoginUrl(1); - else print ' '; + if ($userstatic->id) { + print $userstatic->getLoginUrl(1); + } else { + print ' '; + } print "'.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''; print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); print ''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); print ''; print dol_escape_htmltag($obj->note_public); print ''; print dol_escape_htmltag($obj->note_private); print ''; print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); print "'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->id, $arrayofselected)) $selected = 1; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) { + print ''; + } print '
'; print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print '
'; - if ($object->type != $object::TYPE_CREDIT_NOTE) - { - if ($action == 'editinvoicedate') - { + if ($object->type != $object::TYPE_CREDIT_NOTE) { + if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate'); } else { print dol_print_date($object->date, 'day'); @@ -397,13 +397,13 @@ if ($object->id > 0) print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) { + print ''; + } print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print '
'; - if ($object->type != $object::TYPE_CREDIT_NOTE) - { - if ($action == 'editconditions') - { + if ($object->type != $object::TYPE_CREDIT_NOTE) { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); @@ -418,18 +418,18 @@ if ($object->id > 0) print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) { + print ''; + } print '
'; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print '
'; - if ($object->type != $object::TYPE_CREDIT_NOTE) - { + if ($object->type != $object::TYPE_CREDIT_NOTE) { $duedate = $object->date_lim_reglement; if ($type == 'bank-transfer') { $duedate = $object->date_echeance; } - if ($action == 'editpaymentterm') - { + if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm'); } else { print dol_print_date($duedate, 'day'); @@ -447,11 +447,12 @@ if ($object->id > 0) print ''; - if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) { + print ''; + } print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print '
'; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id'); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); @@ -463,12 +464,12 @@ if ($object->id > 0) print ''; + } print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) + if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print '
'; - if ($action == 'editbankaccount') - { + if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); @@ -487,7 +488,9 @@ if ($object->id > 0) print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; if (!empty($bac->iban)) { - if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + if ($bac->verif() <= 0) { + print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + } } else { print img_warning($langs->trans("NoDefaultIBANFound")); } @@ -503,8 +506,7 @@ if ($object->id > 0) print ''; - if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) - { + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''; print ''; @@ -530,31 +532,27 @@ if ($object->id > 0) print ''; // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 - { + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1 print ''; print ''; } - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 - { + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 print ''; print ''; } // Revenue stamp - if ($selleruserevenustamp) // Test company use revenue stamp - { + if ($selleruserevenustamp) { // Test company use revenue stamp print ''; } @@ -597,8 +595,7 @@ if ($object->id > 0) $sql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($sql); - if ($result_sql) - { + if ($result_sql) { $num = $db->num_rows($result_sql); $numopen = $num; } else { @@ -618,10 +615,11 @@ if ($object->id > 0) $sql .= " AND pfd.ext_payment_id IS NULL"; $result_sql = $db->query($sql); - if ($result_sql) - { + if ($result_sql) { $obj = $db->fetch_object($result_sql); - if ($obj) $pending = $obj->amount; + if ($obj) { + $pending = $obj->amount; + } } else { dol_print_error($db); } @@ -641,12 +639,9 @@ if ($object->id > 0) } // Add a transfer request - if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) - { - if ($resteapayer > 0) - { - if ($user_perms) - { + if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) { + if ($resteapayer > 0) { + if ($user_perms) { $remaintopaylesspendingdebit = $resteapayer - $pending; print ''; @@ -665,10 +660,12 @@ if ($object->id > 0) print ''.$buttonlabel.''; } } else { - if ($num == 0) - { - if ($object->statut > $object::STATUS_DRAFT) print ''.$buttonlabel.''; - else print ''.$buttonlabel.''; + if ($num == 0) { + if ($object->statut > $object::STATUS_DRAFT) { + print ''.$buttonlabel.''; + } else { + print ''.$buttonlabel.''; + } } else { print ''.$buttonlabel.''; } @@ -722,15 +719,13 @@ if ($object->id > 0) $result_sql = $db->query($sql); $num = 0; - if ($result_sql) - { + if ($result_sql) { $i = 0; $tmpuser = new User($db); $num = $db->num_rows($result); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result_sql); $tmpuser->id = $obj->user_id; @@ -788,16 +783,14 @@ if ($object->id > 0) $sql .= " ORDER BY pfd.date_demande DESC"; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $numclosed = $num; $i = 0; $tmpuser = new User($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); $tmpuser->id = $obj->user_id; @@ -819,8 +812,7 @@ if ($object->id > 0) print ''; print ''; + } $db->free($result); } else { diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 2a722f8723d..536beff168d 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; -if (!empty($conf->category->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->category->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); @@ -41,8 +43,12 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $langs->loadLangs(array('bills', 'companies', 'other')); $mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; -if ($mode == 'customer' && !$user->rights->facture->lire) accessforbidden(); -if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) accessforbidden(); +if ($mode == 'customer' && !$user->rights->facture->lire) { + accessforbidden(); +} +if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} $object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); @@ -52,23 +58,27 @@ $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); $custcats = GETPOST('custcats', 'array'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; -if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear = $year - 2; -else $startyear = $year - 1; +if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) { + $startyear = $year - 2; +} else { + $startyear = $year - 1; +} $endyear = $year; /* * View */ -if (!empty($conf->category->enabled)) $langs->load('categories'); +if (!empty($conf->category->enabled)) { + $langs->load('categories'); +} $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); @@ -79,8 +89,7 @@ $picto = 'bill'; $title = $langs->trans("BillsStatistics"); $dir = $conf->facture->dir_temp; -if ($mode == 'supplier') -{ +if ($mode == 'supplier') { $picto = 'supplier_invoice'; $title = $langs->trans("BillsStatisticsSuppliers"); $dir = $conf->fournisseur->facture->dir_temp; @@ -92,17 +101,19 @@ print load_fiche_titre($title, '', $picto); dol_mkdir($dir); $stats = new FactureStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); -if ($mode == 'customer') -{ - if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($mode == 'customer') { + if ($object_status != '' && $object_status >= 0) { + $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; + } if (is_array($custcats) && !empty($custcats)) { $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.implode(',', $custcats).')'; } } -if ($mode == 'supplier') -{ - if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($mode == 'supplier') { + if ($object_status != '' && $object_status >= 0) { + $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; + } } // Build graphic number of object @@ -111,17 +122,19 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); //var_dump($data); $filenamenb = $dir."/invoicesnbinyear-".$year.".png"; -if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; -if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnbinyear-'.$year.'.png'; +if ($mode == 'customer') { + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; +} +if ($mode == 'supplier') { + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnbinyear-'.$year.'.png'; +} $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -144,17 +157,19 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) $filenameamount = $dir."/invoicesamountinyear-".$year.".png"; -if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; -if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamountinyear-'.$year.'.png'; +if ($mode == 'customer') { + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; +} +if ($mode == 'supplier') { + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamountinyear-'.$year.'.png'; +} $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px2->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -175,25 +190,30 @@ if (!$mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + } + if ($mode == 'supplier') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + } } else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + if ($mode == 'customer') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + } + if ($mode == 'supplier') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + } } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px3->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -218,7 +238,9 @@ $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; @@ -228,8 +250,12 @@ $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -if ($mode == 'customer') $type = 'invoice_stats'; -if ($mode == 'supplier') $type = 'supplier_invoice_stats'; +if ($mode == 'customer') { + $type = 'invoice_stats'; +} +if ($mode == 'supplier') { + $type = 'supplier_invoice_stats'; +} complete_head_from_modules($conf, $langs, null, $head, $h, $type); @@ -256,8 +282,12 @@ print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'; print ''; - if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) - { + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) { print ''; } print '
'; print $langs->trans('RevenueStamp'); print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
'; print '
'; - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); print '
'.price($obj->amount).''; - if ($obj->fk_prelevement_bons > 0) - { + if ($obj->fk_prelevement_bons > 0) { $withdrawreceipt = new BonPrelevement($db); $withdrawreceipt->id = $obj->fk_prelevement_bons; $withdrawreceipt->ref = $obj->ref; @@ -838,8 +830,9 @@ if ($object->id > 0) $i++; } - if (!$numopen && !$numclosed) + if (!$numopen && !$numclosed) { print '
'.$langs->trans("None").'
'; print ''; // Company print ''; @@ -265,18 +295,18 @@ print ''; print ''; // Category if (!empty($conf->category->enabled)) { - if ($mode == 'customer') - { + if ($mode == 'customer') { $cat_type = Categorie::TYPE_CUSTOMER; $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } - if ($mode == 'supplier') - { + if ($mode == 'supplier') { $cat_type = Categorie::TYPE_SUPPLIER; $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } @@ -293,21 +323,23 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0 print ''; // Status print ''; // Year print ''; @@ -329,11 +361,9 @@ print ''; print ''; $oldyear = 0; -foreach ($data as $val) -{ +foreach ($data as $val) { $year = $val['year']; - while ($year && $oldyear > $year + 1) - { // If we have empty year + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -367,7 +397,9 @@ print '
'; // Show graphs print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; -if ($mode == 'customer') $filter = 's.client in (1,2,3)'; -if ($mode == 'supplier') $filter = 's.fournisseur = 1'; +if ($mode == 'customer') { + $filter = 's.client in (1,2,3)'; +} +if ($mode == 'supplier') { + $filter = 's.fournisseur = 1'; +} print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); print '
'.$langs->trans("ThirdPartyType").''; $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1); -if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); +if ($user->admin) { + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); +} print '
'.$langs->trans("Status").''; -if ($mode == 'customer') -{ +if ($mode == 'customer') { $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '1,2'=>$langs->trans("BillStatusNotPaid").' / '.$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); print $form->selectarray('object_status', $liststatus, $object_status, 1); } -if ($mode == 'supplier') -{ +if ($mode == 'supplier') { $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); print $form->selectarray('object_status', $liststatus, $object_status, 1); } 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 '
%
'; print ''; print "\n"; } -if (count($linkedObjectBlock) > 1) -{ +if (count($linkedObjectBlock) > 1) { print ''; print ''; print ''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 1c8473637f3..935f6b03948 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -18,8 +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; } @@ -38,16 +37,17 @@ $langs->load("bills"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - - + + 1) -{ +if (count($linkedObjectBlock) > 1) { ?> - - - - - - - - - - "> + + + + + + + + + \n"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 8a50619f17c..7cc15d7f9a7 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -47,16 +47,16 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); -if (!empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $langs->load("orders"); +} $action = GETPOST('action', 'aZ09'); $bid = GETPOST('bid', 'int'); // Security check $socid = ''; -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -89,37 +89,35 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); 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 // Search customer invoices - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); } // Search supplier invoices - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) { $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); } - if (!empty($conf->don->enabled) && $user->rights->don->lire) - { + if (!empty($conf->don->enabled) && $user->rights->don->lire) { $langs->load("donations"); $listofsearchfields['search_donation'] = array('text'=>'Donation'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print ''; print ''; print '
'; print '
'; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { print $px1->show(); print "
\n"; print $px2->show(); diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 92745a276e1..f9bb5902cce 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -18,8 +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; } @@ -38,12 +37,13 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1) $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } print '
'; switch ($objectlink->type) { @@ -73,7 +73,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) print ''; if ($user->rights->facture->lire) { $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + $sign = -1; + } if ($objectlink->statut != 3) { // If not abandonned $total = $total + $sign * $objectlink->total_ht; @@ -87,8 +89,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'
'.$langs->trans("Total").'
trans("RepeatableInvoice"); ?>getNomUrl(1); ?>trans("RepeatableInvoice"); ?>getNomUrl(1); ?> date_when, 'day'); ?> $objectlink)
trans("Total"); ?>
trans("Total"); ?>
'; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -134,8 +132,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles /** * Draft customers invoices */ -if (!empty($conf->facture->enabled) && $user->rights->facture->lire) -{ +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $tmpinvoice = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; @@ -144,15 +141,20 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= ", s.rowid as socid, s.email"; $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } - if ($socid) - { + if ($socid) { $sql .= " AND f.fk_soc = $socid"; } // Add where from hooks @@ -163,7 +165,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " cc.rowid, cc.code"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql.= ", sc.fk_soc, sc.fk_user"; + } // Add Group from hooks $parameters = array(); @@ -172,8 +176,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '
'; @@ -188,15 +191,13 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; print ''; - if ($num) - { + if ($num) { $companystatic = new Societe($db); $i = 0; $othernb = 0; $tot_ttc = 0; - while ($i < $num && $i < $conf->liste_limit) - { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -264,8 +265,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) /** * Draft suppliers invoices */ -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) -{ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $facturesupplierstatic = new FactureFournisseur($db); $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye"; @@ -274,19 +274,24 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); $sql .= $hookmanager->resPrint; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '
'; @@ -301,15 +306,13 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; - if ($num) - { + if ($num) { $companystatic = new Societe($db); $i = 0; $othernb = 0; $tot_ttc = 0; - while ($i < $num && $i < $conf->liste_limit) - { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -378,8 +381,7 @@ print '
'; // Latest modified customer invoices -if (!empty($conf->facture->enabled) && $user->rights->facture->lire) -{ +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $langs->load("boxes"); $tmpinvoice = new Facture($db); @@ -392,11 +394,17 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); @@ -409,8 +417,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $othernb = 0; @@ -418,16 +425,16 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
'; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print ''; - if ($num) - { + if ($num) { $total_ttc = $totalam = $total = 0; - while ($i < $num && $i < $conf->liste_limit) - { + while ($i < $num && $i < $conf->liste_limit) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -483,7 +490,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -505,7 +514,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) } } else { $colspan = 5; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; } print '
'.$langs->trans("BoxTitleLastCustomerBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' 
'; print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$tmpinvoice->getLibStatut(3, $obj->am).'
'.$langs->trans("NoInvoice").'

'; @@ -518,8 +529,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) // Last modified supplier invoices -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) -{ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $langs->load("boxes"); $facstatic = new FactureFournisseur($db); @@ -530,11 +540,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", SUM(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = ff.fk_soc"; $sql .= " AND ff.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND ff.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND ff.fk_soc = ".$socid; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierLastModified', $parameters); @@ -546,26 +562,25 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '
'; print ''; print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; print "\n"; - if ($num) - { + if ($num) { $i = 0; $total = $total_ttc = $totalam = 0; $othernb = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -602,7 +617,9 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } print ''; print ''; print ''; @@ -622,7 +639,9 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU } } else { $colspan = 5; - if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } print ''; } print '
'.$langs->trans("BoxTitleLastSupplierBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' 
'; print $thirdpartystatic->getNomUrl(1, 'supplier'); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->getLibStatut(3).'
'.$langs->trans("NoInvoice").'

'; @@ -634,8 +653,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU // Latest donations -if (!empty($conf->don->enabled) && $user->rights->don->lire) -{ +if (!empty($conf->don->enabled) && $user->rights->don->lire) { include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("boxes"); @@ -653,8 +671,7 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; @@ -669,12 +686,10 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) print '
'.$langs->trans("DateModificationShort").' 
'.$donationstatic->getNomUrl(1).'
'.$langs->trans("None").'

'; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } /** * Social contributions to pay */ -if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) -{ - if (!$socid) - { +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { + if (!$socid) { $chargestatic = new ChargeSociales($db); $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; @@ -746,8 +763,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '
'; @@ -759,14 +775,12 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '
'.$langs->trans("Paid").' 
'.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("ToBill").' '; print $societestatic->getNomUrl(1, 'customer'); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc - $obj->tot_fttc).''.$commandestatic->getLibStatut(3).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') '.price($tot_ht).''.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).' '.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").' 
'.dol_print_date($db->jdate($obj->datelimite), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$tmpinvoice->getLibStatut(3, $obj->am).'
'; print ''.$langs->trans("More").'... ('.$othernb.')'; @@ -1104,14 +1134,18 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
'.$langs->trans("NoInvoice").'

'; @@ -1124,8 +1158,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) /* * Unpaid supplier invoices */ -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) -{ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; @@ -1137,13 +1170,19 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = ff.fk_soc"; $sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.paye = 0"; $sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND ff.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND ff.fk_soc = ".$socid; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); @@ -1154,8 +1193,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= " ORDER BY ff.date_lim_reglement ASC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $othernb = 0; @@ -1173,18 +1211,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print '
'.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").' 
'.$societestatic->getNomUrl(1, 'supplier').''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->getLibStatut(3, $obj->am).'
'; print ''.$langs->trans("More").'... ('.$othernb.')'; @@ -1242,14 +1284,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print '
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
'.$langs->trans("NoInvoice").'

'; @@ -1262,15 +1308,13 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU // TODO Mettre ici recup des actions en rapport avec la compta $resql = 0; -if ($resql) -{ +if ($resql) { print '
'; print ''; print ''.$langs->trans("TasksToDo").''; print "\n"; $i = 0; - while ($i < $db->num_rows($resql)) - { + while ($i < $db->num_rows($resql)) { $obj = $db->fetch_object($resql); print ''; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 45ffae7c1ff..fda83a75668 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -45,9 +45,15 @@ $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); // Security check -if ($user->socid > 0) $socid = $user->socid; -if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); -if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +if ($user->socid > 0) { + $socid = $user->socid; +} +if (!empty($conf->comptabilite->enabled)) { + $result = restrictedArea($user, 'compta', '', '', 'resultat'); +} +if (!empty($conf->accounting->enabled)) { + $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +} /* @@ -70,8 +76,7 @@ $form = new Form($db); $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; -if ($pastmonth == 0) -{ +if ($pastmonth == 0) { $pastmonth = 12; $pastmonthyear--; } @@ -79,8 +84,7 @@ if ($pastmonth == 0) $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } @@ -90,8 +94,11 @@ $periodlink = ''; $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescPurchasesJournal").'
'; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); -else $description .= $langs->trans("DepositsAreIncluded"); +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= $langs->trans("DepositsAreNotIncluded"); +} else { + $description .= $langs->trans("DepositsAreIncluded"); +} $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink); @@ -111,16 +118,22 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 AND f.entity IN (".getEntity('invoice').")"; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2)"; -else $sql .= " AND f.type IN (0,1,2,3)"; -if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (0,1,2)"; +} else { + $sql .= " AND f.type IN (0,1,2,3)"; +} +if ($date_start && $date_end) { + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; +} // TODO Find a better trick to avoid problem with some mysql installations -if (in_array($db->type, array('mysql', 'mysqli'))) $db->query('SET SQL_BIG_SELECTS=1'); +if (in_array($db->type, array('mysql', 'mysqli'))) { + $db->query('SET SQL_BIG_SELECTS=1'); +} $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); // les variables $cptfour = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); @@ -135,16 +148,17 @@ if ($result) $tabcompany = array(); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); // contrôles $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $cptfour); $compta_prod = $obj->accountancy_code_buy; - if (empty($compta_prod)) - { - if ($obj->product_type == 0) $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - else $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + if (empty($compta_prod)) { + if ($obj->product_type == 0) { + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + } else { + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + } } $compta_tva = (!empty($obj->account_tva) ? $obj->account_tva : $cpttva); $compta_localtax1 = (!empty($obj->account_localtax1) ? $obj->account_localtax1 : $langs->trans("CodeNotDef")); @@ -161,9 +175,11 @@ if ($result) $tabfac[$obj->rowid]["lib"] = $obj->label; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; - if ($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + if ($obj->recuperableonly != 1) { + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + } $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; - $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; + $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; $tabcompany[$obj->rowid] = array('id'=>$obj->socid, 'name'=>$obj->name); $i++; @@ -188,8 +204,7 @@ print "\n"; $invoicestatic = new FactureFournisseur($db); $companystatic = new Fournisseur($db); -foreach ($tabfac as $key => $val) -{ +foreach ($tabfac as $key => $val) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; @@ -222,19 +237,15 @@ foreach ($tabfac as $key => $val) ) ); - foreach ($lines as $line) - { - foreach ($line['var'] as $k => $mt) - { - if (isset($line['nomtcheck']) || $mt) - { + foreach ($lines as $line) { + foreach ($line['var'] as $k => $mt) { + if (isset($line['nomtcheck']) || $mt) { print ''; print ""; print ""; print ""; - if (isset($line['inv'])) - { + if (isset($line['inv'])) { print '"; print '"; } else { diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index ea6222dc63f..39faf295c45 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -47,9 +47,15 @@ $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); // Security check -if ($user->socid > 0) $socid = $user->socid; -if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); -if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +if ($user->socid > 0) { + $socid = $user->socid; +} +if (!empty($conf->comptabilite->enabled)) { + $result = restrictedArea($user, 'compta', '', '', 'resultat'); +} +if (!empty($conf->accounting->enabled)) { + $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +} /* * Actions @@ -73,8 +79,7 @@ llxHeader('', $langs->trans("SellsJournal"), '', '', 0, 0, '', '', $morequery); $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; -if ($pastmonth == 0) -{ +if ($pastmonth == 0) { $pastmonth = 12; $pastmonthyear--; } @@ -82,8 +87,7 @@ if ($pastmonth == 0) $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } @@ -92,8 +96,11 @@ $periodlink = ''; $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescSellsJournal").'
'; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); -else $description .= $langs->trans("DepositsAreIncluded"); +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= $langs->trans("DepositsAreNotIncluded"); +} else { + $description .= $langs->trans("DepositsAreIncluded"); +} $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink); @@ -119,15 +126,18 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } $sql .= " AND fd.product_type IN (0,1)"; -if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; +if ($date_start && $date_end) { + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; +} $sql .= " ORDER BY f.rowid"; // TODO Find a better trick to avoid problem with some mysql installations -if (in_array($db->type, array('mysql', 'mysqli'))) $db->query('SET SQL_BIG_SELECTS=1'); +if (in_array($db->type, array('mysql', 'mysqli'))) { + $db->query('SET SQL_BIG_SELECTS=1'); +} $result = $db->query($sql); -if ($result) -{ +if ($result) { $tabfac = array(); $tabht = array(); $tabtva = array(); @@ -139,19 +149,20 @@ if ($result) $account_localtax2 = 0; $num = $db->num_rows($result); - $i = 0; - $resligne = array(); - while ($i < $num) - { - $obj = $db->fetch_object($result); - // les variables - $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); - $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $cptcli); + $i = 0; + $resligne = array(); + while ($i < $num) { + $obj = $db->fetch_object($result); + // les variables + $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); + $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $cptcli); $compta_prod = $obj->accountancy_code_sell; - if (empty($compta_prod)) - { - if ($obj->product_type == 0) $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - else $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + if (empty($compta_prod)) { + if ($obj->product_type == 0) { + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } else { + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } } $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_tva = (!empty($obj->account_tva) ? $obj->account_tva : $cpttva); @@ -178,22 +189,34 @@ if ($result) } //la ligne facture - $tabfac[$obj->rowid]["date"] = $obj->datef; - $tabfac[$obj->rowid]["ref"] = $obj->ref; - $tabfac[$obj->rowid]["type"] = $obj->type; - if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; - if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; - if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; - if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + $tabfac[$obj->rowid]["date"] = $obj->datef; + $tabfac[$obj->rowid]["ref"] = $obj->ref; + $tabfac[$obj->rowid]["type"] = $obj->type; + if (!isset($tabttc[$obj->rowid][$compta_soc])) { + $tabttc[$obj->rowid][$compta_soc] = 0; + } + if (!isset($tabht[$obj->rowid][$compta_prod])) { + $tabht[$obj->rowid][$compta_prod] = 0; + } + if (!isset($tabtva[$obj->rowid][$compta_tva])) { + $tabtva[$obj->rowid][$compta_tva] = 0; + } + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) { + $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; + } + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) { + $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + } $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; - if ($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; - $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; - $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; - $tabcompany[$obj->rowid] = array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client); - $i++; - } + if ($obj->recuperableonly != 1) { + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; + } + $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; + $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; + $tabcompany[$obj->rowid] = array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client); + $i++; + } } else { dol_print_error($db); } @@ -216,8 +239,7 @@ print "\n"; $invoicestatic = new Facture($db); $companystatic = new Client($db); -foreach ($tabfac as $key => $val) -{ +foreach ($tabfac as $key => $val) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; @@ -251,19 +273,15 @@ foreach ($tabfac as $key => $val) ) ); - foreach ($lines as $line) - { - foreach ($line['var'] as $k => $mt) - { - if (isset($line['nomtcheck']) || $mt) - { + foreach ($lines as $line) { + foreach ($line['var'] as $k => $mt) { + if (isset($line['nomtcheck']) || $mt) { print ''; print ""; print ""; print ""; - if (isset($line['inv'])) - { + if (isset($line['inv'])) { print '"; print '"; } else { diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index ec365ac68e7..ee7dbb5e3f4 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -34,13 +34,17 @@ $langs->loadLangs(array('compta', 'banks', 'bills')); $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); $refund = GETPOST("refund", "int"); -if (empty($refund)) $refund = 0; +if (empty($refund)) { + $refund = 0; +} $lttype = GETPOST('localTaxType', 'int'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); $object = new Localtax($db); @@ -53,14 +57,12 @@ $hookmanager->initHooks(array('localtaxvatcard', 'globalcard')); * Actions */ -if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) -{ +if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) { header("Location: list.php?localTaxType=".$lttype); exit; } -if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) -{ +if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->begin(); $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); @@ -75,8 +77,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->ltt = $lttype; $ret = $object->addPayment($user); - if ($ret > 0) - { + if ($ret > 0) { $db->commit(); header("Location: list.php?localTaxType=".$lttype); exit; @@ -88,26 +89,23 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) } //delete payment of localtax -if ($action == 'delete') -{ +if ($action == 'delete') { $result = $object->fetch($id); - if ($object->rappro == 0) - { + if ($object->rappro == 0) { $db->begin(); $ret = $object->delete($user); - if ($ret > 0) - { - if ($object->fk_bank) - { + if ($ret > 0) { + if ($object->fk_bank) { $accountline = new AccountLine($db); $result = $accountline->fetch($object->fk_bank); - if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + if ($result > 0) { + $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + } } - if ($result >= 0) - { + if ($result >= 0) { $db->commit(); header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt); exit; @@ -131,11 +129,9 @@ if ($action == 'delete') * View */ -if ($id) -{ +if ($id) { $result = $object->fetch($id); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db); exit; } @@ -147,8 +143,7 @@ $title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); $help_url = ''; llxHeader("", $title, $helpurl); -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); print ''."\n"; @@ -175,8 +170,7 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; @@ -211,8 +205,7 @@ if ($action == 'create') // View mode -if ($id) -{ +if ($id) { $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$object->id; $head[$h][1] = $langs->trans('Card'); @@ -246,11 +239,9 @@ if ($id) print ''; - if (!empty($conf->banque->enabled)) - { - if ($object->fk_account > 0) - { - $bankline = new AccountLine($db); + if (!empty($conf->banque->enabled)) { + if ($object->fk_account > 0) { + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -278,8 +269,7 @@ if ($id) * Action buttons */ print "
\n"; - if ($object->rappro == 0) - { + if ($object->rappro == 0) { print ''.$langs->trans("Delete").''; } else { print ''.$langs->trans("Delete").''; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 18367a04a46..cdea12902bc 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -122,19 +122,19 @@ class Localtax extends CommonObject $sql .= " ".((int) $this->fk_user_modif); $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // Call trigger $result = $this->call_trigger('LOCALTAX_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -184,22 +184,21 @@ class Localtax extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LOCALTAX_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -239,10 +238,8 @@ class Localtax extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -265,7 +262,7 @@ class Localtax extends CommonObject return 1; } else { - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -281,16 +278,17 @@ class Localtax extends CommonObject { // Call trigger $result = $this->call_trigger('LOCALTAX_DELETE', $user); - if ($result < 0) return -1; + if ($result < 0) { + return -1; + } // End call triggers $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -355,16 +353,13 @@ class Localtax extends CommonObject // phpcs:enable $sql = "SELECT sum(f.localtax) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { + if ($year) { $sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; } $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $ret = $obj->amount; $this->db->free($result); @@ -392,16 +387,13 @@ class Localtax extends CommonObject $sql = "SELECT sum(f.total_localtax) as total_localtax"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { + if ($year) { $sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; } $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $ret = $obj->total_localtax; $this->db->free($result); @@ -430,16 +422,13 @@ class Localtax extends CommonObject $sql = "SELECT sum(f.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f"; - if ($year) - { + if ($year) { $sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' "; } $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $ret = $obj->amount; $this->db->free($result); @@ -469,62 +458,64 @@ class Localtax extends CommonObject // Check parameters $this->amount = price2num($this->amount); - if (!$this->label) - { + if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount <= 0) - { + if ($this->amount <= 0) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -4; } - 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")); return -5; } - if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) - { + if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -5; } // Insertion dans table des paiement localtax $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (localtaxtype, datep, datev, amount"; - if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; + if ($this->note) { + $sql .= ", note"; + } + if ($this->label) { + $sql .= ", label"; + } $sql .= ", fk_user_creat, fk_bank"; $sql .= ") "; $sql .= " VALUES (".$this->ltt.", '".$this->db->idate($this->datep)."',"; $sql .= "'".$this->db->idate($this->datev)."',".$this->amount; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; + if ($this->note) { + $sql .= ", '".$this->db->escape($this->note)."'"; + } + if ($this->label) { + $sql .= ", '".$this->db->escape($this->label)."'"; + } $sql .= ", ".((int) $user->id).", NULL"; $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // TODO devrait s'appeler paiementlocaltax - if ($this->id > 0) - { + if ($this->id > 0) { $ok = 1; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // Insertion dans llx_bank require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $result = $acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + if ($result <= 0) { + dol_print_error($this->db); + } $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); // Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g�n�r� l'�criture bancaire - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); } else { $this->error = $acc->error; @@ -533,15 +524,13 @@ class Localtax extends CommonObject // Mise a jour liens $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/localtax/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { + if ($result < 0) { $this->error = $acc->error; $ok = 0; } } - if ($ok) - { + if ($ok) { $this->db->commit(); return $this->id; } else { @@ -601,9 +590,15 @@ class Localtax extends CommonObject $picto = 'payment'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.$this->ref.$linkend; + if ($withpicto) { + $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + } + if ($withpicto && $withpicto != 2) { + $result .= ' '; + } + if ($withpicto != 2) { + $result .= $link.$this->ref.$linkend; + } return $result; } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index fe605c2224d..603e8564927 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -37,8 +37,7 @@ $local = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y", dol_now()); $year_start = $year_current; } else { @@ -48,41 +47,60 @@ if (empty($year)) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q"); - if (empty($q)) - { - if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { + if (empty($q)) { + if (GETPOST("month")) { + $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); + } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } } } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } $min = price2num(GETPOST("min", "alpha")); -if (empty($min)) $min = 0; +if (empty($min)) { + $min = 0; +} // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); -if (empty($local)) -{ +if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); exit; } @@ -98,9 +116,10 @@ $company_static = new Societe($db); $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); -foreach ($listofparams as $param) -{ - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); +foreach ($listofparams as $param) { + if (GETPOST($param) != '') { + $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + } } llxHeader('', '', '', '', 0, 0, '', '', $morequerystring); @@ -117,12 +136,13 @@ $fsearch .= ''; $calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport -if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services -{ +if ($calc == 0 || $calc == 1) { // Calculate on invoice for goods and services $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) { + $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + } $description .= $fsearch; $description .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; $builddate = dol_now(); @@ -134,12 +154,13 @@ if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); } -if ($calc == 2) // Invoice for goods, payment for services -{ +if ($calc == 2) { // Invoice for goods, payment for services $calcmode = $langs->trans("CalcModeLT2Debt"); $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) { + $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + } $description .= $fsearch; $description .= '('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; $builddate = dol_now(); @@ -161,8 +182,7 @@ print '
'; print '
'.dol_print_date($db->jdate($obj->da), "day").'
".dol_print_date($db->jdate($val["date"]))."".$invoicestatic->getNomUrl(1)."".$k."".$line['label']."'.($mt < 0 ?price(-$mt) : '')."'.($mt >= 0 ?price($mt) : '')."
".dol_print_date($db->jdate($val["date"]))."".$invoicestatic->getNomUrl(1)."".$k."".$line['label']."'.($mt >= 0 ?price($mt) : '')."'.($mt < 0 ?price(-$mt) : '')."
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 2); // Affiche liste des comptes courant print '
'.$langs->trans("Amount").''.price($object->amount).'
'; // IRPF that the customer has retained me -if ($calc == 0 || $calc == 2) -{ +if ($calc == 0 || $calc == 2) { print ''; print ''; print ''; @@ -185,19 +205,14 @@ if ($calc == 0 || $calc == 2) $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (is_array($coll_list)) - { + if (is_array($coll_list)) { $total = 0; $totalamount = 0; $i = 1; - foreach ($coll_list as $coll) - { - if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) - { + foreach ($coll_list as $coll) { + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) - { - if ($coll->assuj == '1') - { + if (empty($intra)) { + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } else { $intra = ''; @@ -227,11 +242,13 @@ if ($calc == 0 || $calc == 2) print ''; } else { $langs->load("errors"); - if ($coll_list == -1) + if ($coll_list == -1) { print ''; - elseif ($coll_list == -2) + } elseif ($coll_list == -2) { print ''; - else print ''; + } else { + print ''; + } } } @@ -252,19 +269,14 @@ if ($calc == 0 || $calc == 1) { $parameters["type"] = 'localtax'.$local; $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (is_array($coll_list)) - { + if (is_array($coll_list)) { $total = 0; $totalamount = 0; $i = 1; - foreach ($coll_list as $coll) - { - if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) - { + foreach ($coll_list as $coll) { + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) - { - if ($coll->assuj == '1') - { + if (empty($intra)) { + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } else { $intra = ''; @@ -294,11 +306,13 @@ if ($calc == 0 || $calc == 1) { print ''; } else { $langs->load("errors"); - if ($coll_list == -1) + if ($coll_list == -1) { print ''; - elseif ($coll_list == -2) + } elseif ($coll_list == -2) { print ''; - else print ''; + } else { + print ''; + } } } diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index bedb7259184..051a98a4b3b 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -37,8 +37,7 @@ $localTaxType = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y", dol_now()); $year_start = $year_current; } else { @@ -47,32 +46,46 @@ if (empty($year)) } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { + if (empty($q)) { + if (GETPOST("month", "int")) { + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + } else { $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; } } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -114,8 +127,7 @@ function pt($db, $sql, $date) $mode = $obj->mode; //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { + if ($obj->mode == 'claimed' && !empty($previousmode)) { print ''; print '\n"; print '\n"; @@ -126,19 +138,16 @@ function pt($db, $sql, $date) $amountpaid = 0; } - if ($obj->mode == 'claimed') - { + if ($obj->mode == 'claimed') { $amountclaimed = $obj->mm; $totalclaimed = $totalclaimed + $amountclaimed; } - if ($obj->mode == 'paid') - { + if ($obj->mode == 'paid') { $amountpaid = $obj->mm; $totalpaid = $totalpaid + $amountpaid; } - if ($obj->mode == 'paid') - { + if ($obj->mode == 'paid') { print ''; print '\n"; print '\n"; @@ -156,8 +165,7 @@ function pt($db, $sql, $date) $i++; } - if ($mode == 'claimed' && !empty($previousmode)) - { + if ($mode == 'claimed' && !empty($previousmode)) { print ''; print '\n"; print '\n"; @@ -181,8 +189,7 @@ function pt($db, $sql, $date) } } -if (empty($localTaxType)) -{ +if (empty($localTaxType)) { accessforbidden('Parameter localTaxType is missing'); exit; } @@ -281,11 +288,14 @@ $mend = $tmp['mon']; $total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; $i = 0; $mcursor = 0; -while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop -{ +while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); - if ($m == 13) $y++; - if ($m > 12) $m -= 12; + if ($m == 13) { + $y++; + } + if ($m > 12) { + $m -= 12; + } $mcursor++; // Get array with details of each line @@ -294,8 +304,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $x_both = array(); //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_rate) - { + foreach (array_keys($x_coll) as $my_coll_rate) { $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; $x_both[$my_coll_rate]['coll']['localtax1'] = $x_coll[$my_coll_rate]['localtax1']; @@ -306,7 +315,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $x_both[$my_coll_rate]['paye']['localtax2'] = 0; $x_both[$my_coll_rate]['coll']['links'] = ''; $x_both[$my_coll_rate]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) { //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; @@ -352,11 +361,9 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $x_both[$my_paye_rate]['paye']['links'] = ''; $x_both[$my_paye_rate]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) - { + foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) { // ExpenseReport - if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') - { + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') { //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; @@ -425,14 +432,12 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { + if (!is_array($x_coll) && $coll_listbuy == -1) { $langs->load("errors"); print ''; break; } - if (!is_array($x_paye) && $coll_listbuy == -2) - { + if (!is_array($x_paye) && $coll_listbuy == -2) { print ''; break; } @@ -442,17 +447,14 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc print ''; $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { + foreach (array_keys($x_coll) as $rate) { $subtot_coll_total_ht = 0; $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { // Define type // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); @@ -466,8 +468,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -486,17 +487,14 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc print ''; $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { + foreach (array_keys($x_paye) as $rate) { $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { // Define type // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); @@ -510,8 +508,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -541,8 +538,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc print "\n"; $i++; $m++; - if ($i > 2) - { + if ($i > 2) { print ''; print ''; print ''; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 4d7e2bf0e54..8742589a6a9 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -29,7 +29,9 @@ $langs->load("compta"); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt = GETPOST("localTaxType", 'int'); @@ -43,7 +45,9 @@ llxHeader(); $localtax_static = new Localtax($db); $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy'); @@ -54,8 +58,7 @@ $sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".$db->escape($l $sql .= " ORDER BY datev DESC"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; @@ -69,8 +72,7 @@ if ($result) print ""; print "\n"; $var = 1; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print ''; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 2b0415800ac..aec90544e09 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -47,8 +47,7 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ $local = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y", dol_now()); $year_start = $year_current; } else { @@ -58,43 +57,62 @@ if (empty($year)) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { + if (empty($q)) { + if (GETPOST("month", "int")) { + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } } } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } $min = price2num(GETPOST("min", "alpha")); -if (empty($min)) $min = 0; +if (empty($min)) { + $min = 0; +} // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products //$modetax = $conf->global->TAX_MODE; $calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; $modetax = $conf->global->$calc; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); -if (empty($local)) -{ +if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); exit; } @@ -117,9 +135,10 @@ $paymentexpensereport_static = new PaymentExpenseReport($db); $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); -foreach ($listofparams as $param) -{ - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); +foreach ($listofparams as $param) { + if (GETPOST($param) != '') { + $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + } } llxHeader('', $langs->trans("LocalTaxReport"), '', '', 0, 0, '', '', $morequerystring); @@ -131,9 +150,15 @@ $fsearch .= ''; $name = $langs->transcountry($local == 1 ? "LT1ReportByQuarters" : "LT2ReportByQuarters", $mysoc->country_code); $calcmode = ''; -if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +if ($modetax == 0) { + $calcmode = $langs->trans('OptionVATDefault'); +} +if ($modetax == 1) { + $calcmode = $langs->trans('OptionVATDebitOption'); +} +if ($modetax == 2) { + $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +} $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -164,7 +189,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description.='
'.$langs->trans("DepositsAreNotIncluded"); } */ -if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= $langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { + $description .= $langs->trans("ThisIsAnEstimatedValue"); +} // Customers invoices $elementcust = $langs->trans("CustomersInvoices"); @@ -212,28 +239,27 @@ $columns = 4; $x_coll = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); $x_paye = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); -if (!is_array($x_coll) || !is_array($x_paye)) -{ +if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); - if ($x_coll == -1) + if ($x_coll == -1) { print ''; - elseif ($x_coll == -2) + } elseif ($x_coll == -2) { print ''; - else print ''; + } else { + print ''; + } } else { $x_both = array(); //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_rate) - { + foreach (array_keys($x_coll) as $my_coll_rate) { $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; $x_both[$my_coll_rate]['coll']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local]; $x_both[$my_coll_rate]['paye']['totalht'] = 0; $x_both[$my_coll_rate]['paye']['localtax'.$local] = 0; $x_both[$my_coll_rate]['coll']['links'] = ''; $x_both[$my_coll_rate]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) - { + foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) { $invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id]; $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id]; @@ -273,8 +299,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_both[$my_paye_rate]['paye']['links'] = ''; $x_both[$my_paye_rate]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) - { + foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) { $invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id]; $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id]; @@ -312,15 +337,23 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_paye_ht = 0; $span = $columns - 1; - if ($modetax != 2) $span += 1; - if ($modetax != 1) $span += 1; + if ($modetax != 2) { + $span += 1; + } + if ($modetax != 1) { + $span += 1; + } // Customers invoices print ''; print ''; print ''; - if ($modetax != 2) print ''; - if ($modetax != 1) print ''; + if ($modetax != 2) { + print ''; + } + if ($modetax != 1) { + print ''; + } print ''; print ''; print ''; @@ -328,29 +361,29 @@ if (!is_array($x_coll) || !is_array($x_paye)) $LT = 0; $sameLT = false; - foreach (array_keys($x_coll) as $rate) - { + foreach (array_keys($x_coll) as $rate) { $subtot_coll_total_ht = 0; $subtot_coll_vat = 0; - if (is_array($x_both[$rate]['coll']['detail'])) - { + if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate if ($rate != 0) { print ""; print ''; print ''."\n"; } - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) - { + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { + if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) { // Define type $type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']); // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. - if (!empty($fields['ddate_start'])) $type = 1; - if (!empty($fields['ddate_end'])) $type = 1; + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } print ''; @@ -360,21 +393,28 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Description print ''; // Total HT - if ($modetax != 2) - { + if ($modetax != 2) { print ''; @@ -397,21 +435,22 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + if ($modetax != 1) { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } print ''; } @@ -419,7 +458,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Total collected print ''; @@ -442,8 +483,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''; print ''; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; print ''; } @@ -452,13 +492,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { + if (count($x_coll) == 0) { // Show a total ine if nothing shown print ''; print ''; print ''; - if ($modetax == 0) - { + if ($modetax == 0) { print ''; print ''; } @@ -477,8 +515,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''; print ''; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; print ''; } @@ -486,28 +523,28 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''."\n"; - foreach (array_keys($x_paye) as $rate) - { + foreach (array_keys($x_paye) as $rate) { $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - if (is_array($x_both[$rate]['paye']['detail'])) - { + if (is_array($x_both[$rate]['paye']['detail'])) { if ($rate != 0) { print ""; print ''; print ''."\n"; } - foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) - { - if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) - { + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { + if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) { // Define type $type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']); // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. - if (!empty($fields['ddate_start'])) $type = 1; - if (!empty($fields['ddate_end'])) $type = 1; + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } print ''; @@ -517,16 +554,20 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Description print ''; // Total HT - if ($modetax != 2) - { + if ($modetax != 2) { print ''; print ''; print ''; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; print ''; } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 8ea227482b1..0fcbf6a914a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -59,16 +59,14 @@ $multicurrency_amounts = array(); $multicurrency_amountsresttopay = array(); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } $object = new Facture($db); // Load object -if ($facid > 0) -{ +if ($facid > 0) { $ret = $object->fetch($facid); } @@ -84,12 +82,12 @@ $formquestion = array(); $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) - { +if (empty($reshook)) { + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -102,28 +100,27 @@ if (empty($reshook)) // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new Facture($db); - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') - { + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') { $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(GETPOST($key)); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + if (!empty($amounts[$cursorfacid])) { + $atleastonepaymentnotnull++; + } $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); + if ($result <= 0) { + dol_print_error($db); + } $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) - { + if ($amounts[$cursorfacid]) { // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { + if ($datepaye && ($datepaye < $tmpinvoice->date)) { $langs->load("errors"); //$error++; setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); @@ -131,26 +128,26 @@ if (empty($reshook)) } $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); - } elseif (substr($key, 0, 21) == 'multicurrency_amount_') - { + } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + if (!empty($multicurrency_amounts[$cursorfacid])) { + $atleastonepaymentnotnull++; + } $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); + if ($result <= 0) { + dol_print_error($db); + } $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); - if ($multicurrency_amounts[$cursorfacid]) - { + if ($multicurrency_amounts[$cursorfacid]) { // Check amount - if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) - { + if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { + if ($datepaye && ($datepaye < $tmpinvoice->date)) { $langs->load("errors"); //$error++; setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); @@ -162,37 +159,31 @@ if (empty($reshook)) } // Check parameters - if (!GETPOST('paiementcode')) - { + if (!GETPOST('paiementcode')) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { + if (GETPOST('accountid') <= 0) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); $error++; } } - if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) - { + if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); $error++; } - if (empty($datepaye)) - { + if (empty($datepaye)) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); $error++; } // Check if payments in both currency - if ($totalpayment > 0 && $multicurrency_totalpayment > 0) - { + if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); $error++; } @@ -201,10 +192,8 @@ if (empty($reshook)) /* * Action add_paiement */ - if ($action == 'add_paiement') - { - if ($error) - { + if ($action == 'add_paiement') { + if ($error) { $action = 'create'; } // The next of this action is displayed at the page's bottom. @@ -213,8 +202,7 @@ if (empty($reshook)) /* * Action confirm_paiement */ - if ($action == 'confirm_paiement' && $confirm == 'yes') - { + if ($action == 'confirm_paiement' && $confirm == 'yes') { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -222,36 +210,32 @@ if (empty($reshook)) $db->begin(); $thirdparty = new Societe($db); - if ($socid > 0) $thirdparty->fetch($socid); + if ($socid > 0) { + $thirdparty->fetch($socid); + } // Clean parameters amount if payment is for a credit note - foreach ($amounts as $key => $value) // How payment is dispatched - { + foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new Facture($db); $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) - { + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } } - foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched - { + foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new Facture($db); $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) - { + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } } - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // If the bank module is active, an account is required to input a payment - if (GETPOST('accountid', 'int') <= 0) - { + if (GETPOST('accountid', 'int') <= 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); $error++; } @@ -266,47 +250,48 @@ if (empty($reshook)) $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); - if (!$error) - { + if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents - if ($paiement_id < 0) - { + if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $label = '(CustomerInvoicePayment)'; - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); - if ($result < 0) - { + if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card $invoiceid = 0; - foreach ($paiement->amounts as $key => $amount) - { + foreach ($paiement->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment - else $invoiceid = $facid; + if (is_numeric($amount) && $amount <> 0) { + if ($invoiceid != 0) { + $invoiceid = -1; // There is more than one invoice payed by this payment + } else { + $invoiceid = $facid; + } } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + if ($invoiceid > 0) { + $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; + } else { + $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + } header('Location: '.$loc); exit; } else { @@ -327,23 +312,24 @@ llxHeader('', $langs->trans("Payment")); -if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') -{ +if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); $result = $facture->fetch($facid); - if ($result >= 0) - { + if ($result >= 0) { $facture->fetch_thirdparty(); $title = ''; - if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentDueToCustomer"); + if ($facture->type != Facture::TYPE_CREDIT_NOTE) { + $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + } + if ($facture->type == Facture::TYPE_CREDIT_NOTE) { + $title .= $langs->trans("EnterPaymentDueToCustomer"); + } print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) - if ($action == 'add_paiement') - { + if ($action == 'add_paiement') { $i = 0; $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); @@ -353,15 +339,15 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Invoice with Paypal transaction // TODO add hook here - if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) - { - if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; + if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) { + if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) { + $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; + } $paymentnum = $facture->ref_ext; } // Add realtime total information - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print '
'; - print '
'; - print $langs->trans("Type").':   '; - print '
'; - print ''; - print '   '; - print ''; - print '
'; - print "
\n"; + print '
'; + print '
'; + print $langs->trans("Type").':   '; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print "
\n"; - dol_fiche_head(); + dol_fiche_head(); - print '
'.$langs->trans("Num").''.$langs->trans("Customer").'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'.$langs->trans("Error").'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'.$langs->trans("Error").'
'.$previousmonth."'.price($amountclaimed)."
'.$obj->dm."'.price($amountclaimed)."
'.$previousmonth."'.price($amountclaimed)."
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''.price(price2num($x_coll_sum, 'MT')).'
'.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll, 'MT')).'".$langs->trans("PayedByThisPayment")."
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'.$langs->trans("Error").'
'.$elementcust.''.$productcust.''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatcust.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'; - if ($fields['pid']) - { + if ($fields['pid']) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['ptype']; print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + } } else { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) - { - if ($reg[1] == 'DEPOSIT') $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1] == 'CREDIT_NOTE') $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } } print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); @@ -384,12 +424,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { + if (price2num($fields['ftotal_ttc'])) { $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); } print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id = $fields['payment_id']; print $payment_static->getNomUrl(2); } - if ($type == 0) - { + if ($type == 0) { print $langs->trans("NotUsedForGoods"); } else { print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } } print ''; $temp_ht = $fields['totalht']; - if ($type == 1) $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + if ($type == 1) { + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + } print price(price2num($temp_ht, 'MT')); print '
'.$langs->trans("Total").':  
 '.$langs->trans("Total").':  
'.$elementsup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$vatsup.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'; - if ($fields['pid']) - { + if ($fields['pid']) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['ptype']; print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + } } else { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); // Show range @@ -535,12 +576,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { + if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; @@ -550,17 +589,16 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; print $paymentfourn_static->getNomUrl(2); } - if ($type == 0) - { + if ($type == 0) { print $langs->trans("NA"); } else { print price(price2num($fields['payment_amount'], 'MT')); @@ -596,8 +634,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) print '
 '.$langs->trans("Total").':  
'; + print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; // Label if ($refund == 1) { @@ -457,14 +429,13 @@ if ($action == 'create') // Amount print ''; - // Type payment + // Type payment print '\n"; print ""; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; @@ -485,19 +456,19 @@ if ($action == 'create') print ''; print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; // Bouton Save payment print ''; - print '
'.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
'.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); - print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); + print '
'.$langs->trans("Amount").'
'.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); print "
'.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1); // List of bank account available print '
'; print $langs->trans("ClosePaidVATAutomatically"); print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); print '
'; print ''; @@ -505,19 +476,17 @@ if ($action == 'create') print ''; print '
'; - print ''; + print ''; } // View mode -if ($id) -{ +if ($id) { $head = vat_prepare_head($object); $totalpaye = $object->getSommePaiement(); // Clone confirmation - if ($action === 'clone') - { + if ($action === 'clone') { $formquestion = array( array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label), ); @@ -528,20 +497,17 @@ if ($id) print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } - if ($action == 'paid') - { + if ($action == 'paid') { $text = $langs->trans('ConfirmPayVAT'); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayVAT'), $text, "confirm_paid", '', '', 2); } - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteVAT'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVAT'), $text, 'confirm_delete', '', '', 2); } - if ($action == 'edit') - { + if ($action == 'edit') { print "
id&action=update\" method=\"post\">"; print ''; } @@ -593,8 +559,9 @@ if ($id) print ''; - if ($action != 'editmode') + if ($action != 'editmode') { print ''; + } print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; if ($action == 'editmode') { @@ -605,14 +572,14 @@ if ($id) print ''; // Bank account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; print ''; + } print '
'; print $langs->trans('BankAccount'); print ''; - if ($action != 'editbankaccount' && $user->rights->tax->charges->creer) + if ($action != 'editbankaccount' && $user->rights->tax->charges->creer) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print ''; if ($action == 'editbankaccount') { @@ -659,8 +626,7 @@ if ($id) //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $totalpaye = 0; $num = $db->num_rows($resql); @@ -678,11 +644,9 @@ if ($id) print ''.$langs->trans("Amount").''; print ''; - if ($num > 0) - { + if ($num > 0) { $bankaccountstatic = new Account($db); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -690,8 +654,7 @@ if ($id) print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; $bankaccountstatic->label = $objp->baref; @@ -707,8 +670,9 @@ if ($id) } print ''; - if ($bankaccountstatic->id) + if ($bankaccountstatic->id) { print $bankaccountstatic->getNomUrl(1, 'transactions'); + } print ''; } print ''.price($objp->amount)."\n"; @@ -716,8 +680,7 @@ if ($id) $totalpaye += $objp->amount; $i++; } - } - else { + } else { print ''.$langs->trans("None").''; print ''; print ''; @@ -736,8 +699,7 @@ if ($id) print '
'; $db->free($resql); - } - else { + } else { dol_print_error($db); } @@ -749,8 +711,7 @@ if ($id) dol_fiche_end(); - if ($action == 'edit') - { + if ($action == 'edit') { print '
'; print ''; print '   '; @@ -763,23 +724,19 @@ if ($id) * Action buttons */ print "
\n"; - if ($action != 'edit') - { + if ($action != 'edit') { // Reopen - if ($object->paye && $user->rights->tax->charges->creer) - { + if ($object->paye && $user->rights->tax->charges->creer) { print ""; } // Edit - if ($object->paye == 0 && $user->rights->tax->charges->creer) - { + if ($object->paye == 0 && $user->rights->tax->charges->creer) { print ""; } // Emit payment - if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) - { + if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) { print ""; } @@ -789,22 +746,18 @@ if ($id) (round($resteapayer) <= 0 && $object->amount > 0) || (round($resteapayer) >= 0 && $object->amount < 0) ) - && $user->rights->tax->charges->creer) - { + && $user->rights->tax->charges->creer) { print ""; } // Clone - if ($user->rights->tax->charges->creer) - { + if ($user->rights->tax->charges->creer) { print ""; } - if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye)) - { + if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye)) { print ''; - } - else { + } else { print ''; } } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 13369e596bc..ff1c8b46040 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -48,8 +48,8 @@ class PaymentVAT extends CommonObject public $picto = 'payment'; /** - * @var int ID - */ + * @var int ID + */ public $fk_tva; public $datec = ''; @@ -62,12 +62,12 @@ class PaymentVAT extends CommonObject */ public $total; - public $amount; // Total amount of payment - public $amounts = array(); // Array of amounts + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_typepaiement; /** @@ -82,18 +82,18 @@ class PaymentVAT extends CommonObject public $num_payment; /** - * @var int ID - */ + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; /** @@ -108,8 +108,8 @@ class PaymentVAT extends CommonObject /** * Create payment of social contribution into database. - * Use this->amounts to have list of lines for the payment - * + * Use this->amounts to have list of lines for the payment + * * @param User $user User making payment * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more * @return int <0 if KO, id of payment if OK @@ -120,45 +120,62 @@ class PaymentVAT extends CommonObject $error = 0; - $now = dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::create", LOG_DEBUG); // Validate parametres - if (!$this->datepaye) - { + if (!$this->datepaye) { $this->error = 'ErrorBadValueForParameterCreatePaymentVAT'; return -1; } // Clean parameters - if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva; - if (isset($this->amount)) $this->amount = trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated - if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); - if (isset($this->note)) $this->note = trim($this->note); - 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; + if (isset($this->fk_tva)) { + $this->fk_tva = (int) $this->fk_tva; + } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } + if (isset($this->fk_typepaiement)) { + $this->fk_typepaiement = (int) $this->fk_typepaiement; + } + if (isset($this->num_paiement)) { + $this->num_paiement = trim($this->num_paiement); // deprecated + } + if (isset($this->num_payment)) { + $this->num_payment = trim($this->num_payment); + } + if (isset($this->note)) { + $this->note = trim($this->note); + } + 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; + } - $totalamount = 0; - foreach ($this->amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value, 'MT'); - $this->amounts[$key] = $newvalue; - $totalamount += $newvalue; - } - $totalamount = price2num($totalamount); + $totalamount = 0; + foreach ($this->amounts as $key => $value) { // How payment is dispatch + $newvalue = price2num($value, 'MT'); + $this->amounts[$key] = $newvalue; + $totalamount += $newvalue; + } + $totalamount = price2num($totalamount); - // Check parameters - if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + // Check parameters + if ($totalamount == 0) { + return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + } $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_vat (fk_tva, datec, datep, amount,"; $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; @@ -168,21 +185,17 @@ class PaymentVAT extends CommonObject $sql .= " 0)"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_vat"); // Insere tableau des montants / factures - foreach ($this->amounts as $key => $amount) - { + foreach ($this->amounts as $key => $amount) { $contribid = $key; - if (is_numeric($amount) && $amount <> 0) - { + if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); // If we want to closed payed invoices - if ($closepaidcontrib) - { + if ($closepaidcontrib) { $contrib = new Tva($this->db); $contrib->fetch($contribid); $paiement = $contrib->getSommePaiement(); @@ -192,31 +205,30 @@ class PaymentVAT extends CommonObject $deposits = 0; $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); - if ($remaintopay == 0) - { + if ($remaintopay == 0) { $result = $contrib->setPaid($user); + } else { + dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } - else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } } } - } - else { + } else { $error++; } } $result = $this->call_trigger('PAYMENTVAT_CREATE', $user); - if ($result < 0) $error++; - - if ($totalamount != 0 && !$error) - { - $this->amount = $totalamount; - $this->total = $totalamount; // deprecated - $this->db->commit(); - return $this->id; + if ($result < 0) { + $error++; } - else { + + if ($totalamount != 0 && !$error) { + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated + $this->db->commit(); + return $this->id; + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -254,10 +266,8 @@ class PaymentVAT extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -285,8 +295,7 @@ class PaymentVAT extends CommonObject $this->db->free($resql); return 1; - } - else { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -307,15 +316,33 @@ class PaymentVAT extends CommonObject // Clean parameters - if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva; - if (isset($this->amount)) $this->amount = trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated - if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); - if (isset($this->note)) $this->note = trim($this->note); - 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; + if (isset($this->fk_tva)) { + $this->fk_tva = (int) $this->fk_tva; + } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } + if (isset($this->fk_typepaiement)) { + $this->fk_typepaiement = (int) $this->fk_typepaiement; + } + if (isset($this->num_paiement)) { + $this->num_paiement = trim($this->num_paiement); // deprecated + } + if (isset($this->num_payment)) { + $this->num_payment = trim($this->num_payment); + } + if (isset($this->note)) { + $this->note = trim($this->note); + } + 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; + } @@ -344,20 +371,19 @@ class PaymentVAT extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; - } - else { + } else { $this->db->commit(); return 1; } @@ -380,39 +406,36 @@ class PaymentVAT extends CommonObject $this->db->begin(); - if ($this->bank_line > 0) - { - $accline = new AccountLine($this->db); + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); $accline->fetch($this->bank_line); $result = $accline->delete(); if ($result < 0) { $this->errors[] = $accline->error; $error++; } - } + } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_vat"; $sql .= " WHERE rowid=".$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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; - } - else { + } else { $this->db->commit(); return 1; } @@ -448,8 +471,7 @@ class PaymentVAT extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $error++; } @@ -457,12 +479,10 @@ class PaymentVAT extends CommonObject unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; - } - else { + } else { $this->db->rollback(); return -1; } @@ -470,11 +490,11 @@ class PaymentVAT extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { @@ -495,101 +515,97 @@ class PaymentVAT extends CommonObject } - /** - * Add record into bank for payment with links between this bank record and invoices of payment. - * All payment properties must have been set first like after a call to create(). - * - * @param User $user Object of user making payment - * @param string $mode 'payment_sc' - * @param string $label Label to use in bank record - * @param int $accountid Id of bank account to do link with - * @param string $emetteur_nom Name of transmitter - * @param string $emetteur_banque Name of bank - * @return int <0 if KO, >0 if OK - */ - public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) - { - global $conf; + /** + * Add record into bank for payment with links between this bank record and invoices of payment. + * All payment properties must have been set first like after a call to create(). + * + * @param User $user Object of user making payment + * @param string $mode 'payment_sc' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @return int <0 if KO, >0 if OK + */ + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + { + global $conf; // Clean data - $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); + $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); - $error = 0; + $error = 0; - if (!empty($conf->banque->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if (!empty($conf->banque->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); - $acc->fetch($accountid); + $acc = new Account($this->db); + $acc->fetch($accountid); - $total = $this->total; - if ($mode == 'payment_vat') $total = -$total; + $total = $this->total; + if ($mode == 'payment_vat') { + $total = -$total; + } - // Insert payment into llx_bank - $bank_line_id = $acc->addline( - $this->datepaye, - $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") - $label, - $total, - $this->num_payment, - '', - $user, - $emetteur_nom, - $emetteur_banque - ); + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaye, + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $total, + $this->num_payment, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); - // Mise a jour fk_bank dans llx_paiement. - // On connait ainsi le paiement qui a genere l'ecriture bancaire - if ($bank_line_id > 0) - { - $result = $this->update_fk_bank($bank_line_id); - if ($result <= 0) - { - $error++; - dol_print_error($this->db); - } + // Mise a jour fk_bank dans llx_paiement. + // On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) { + $result = $this->update_fk_bank($bank_line_id); + if ($result <= 0) { + $error++; + dol_print_error($this->db); + } - // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction - $url = ''; - if ($mode == 'payment_vat') $url = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='; - if ($url) - { - $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); - if ($result <= 0) - { - $error++; - dol_print_error($this->db); - } - } + // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction + $url = ''; + if ($mode == 'payment_vat') { + $url = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='; + } + if ($url) { + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + if ($result <= 0) { + $error++; + dol_print_error($this->db); + } + } - // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - $linkaddedforthirdparty = array(); - foreach ($this->amounts as $key => $value) - { - if ($mode == 'payment_vat') - { - $tva = new Tva($this->db); - $tva->fetch($key); - $result = $acc->add_url_line($bank_line_id, $tva->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', '('.$tva->label.')', 'vat'); - if ($result <= 0) dol_print_error($this->db); - } - } - } - else { - $this->error = $acc->error; - $error++; - } - } + // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + $linkaddedforthirdparty = array(); + foreach ($this->amounts as $key => $value) { + if ($mode == 'payment_vat') { + $tva = new Tva($this->db); + $tva->fetch($key); + $result = $acc->add_url_line($bank_line_id, $tva->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', '('.$tva->label.')', 'vat'); + if ($result <= 0) { + dol_print_error($this->db); + } + } + } + } else { + $this->error = $acc->error; + $error++; + } + } - if (!$error) - { - return 1; - } - else { - return -1; - } - } + if (!$error) { + return 1; + } else { + return -1; + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -606,11 +622,9 @@ class PaymentVAT extends CommonObject dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; - } - else { + } else { $this->error = $this->db->error(); return 0; } @@ -693,30 +707,41 @@ class PaymentVAT extends CommonObject $result = ''; - if (empty($this->ref)) $this->ref = $this->lib; + if (empty($this->ref)) { + $this->ref = $this->lib; + } $label = img_picto('', $this->picto).' '.$langs->trans("VATPayment").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->label)) { $labeltoshow = $this->label; $reg = array(); - if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) - { + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + if ($reg[1] == 'paiement') { + $reg[1] = 'Payment'; + } $labeltoshow = $langs->trans($reg[1]); } $label .= '
'.$langs->trans('Label').': '.$labeltoshow; } - if ($this->datep) $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->datep, 'day'); + if ($this->datep) { + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->datep, 'day'); + } if (!empty($this->id)) { $link = ''; $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/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index a39a00d8b01..f45112aedda 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -57,13 +57,13 @@ class Tva extends CommonObject public $num_payment; /** - * @var string label - */ - public $label; + * @var string label + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_bank; /** @@ -72,39 +72,39 @@ class Tva extends CommonObject public $accountid; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; const STATUS_UNPAID = 0; const STATUS_PAID = 1; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; $error = 0; $now = dol_now(); @@ -135,7 +135,7 @@ class Tva extends CommonObject $sql .= "fk_typepayment,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -148,44 +148,42 @@ class Tva extends CommonObject $sql .= " '".$this->db->escape($this->fk_user_modif)."'"; $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); - // Call trigger - $result = $this->call_trigger('TVA_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('TVA_CREATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers - if (!$error) - { - $this->db->commit(); - return $this->id; - } - else { + if (!$error) { + $this->db->commit(); + return $this->id; + } else { $this->db->rollback(); return -1; - } - } - else { + } + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; @@ -202,7 +200,7 @@ class Tva extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " tms='".$this->db->idate($this->tms)."',"; $sql .= " datep='".$this->db->idate($this->datep)."',"; $sql .= " datev='".$this->db->idate($this->datev)."',"; @@ -211,34 +209,32 @@ class Tva extends CommonObject $sql .= " note='".$this->db->escape($this->note)."',"; $sql .= " fk_user_creat=".$this->fk_user_creat.","; $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; - $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) - { - $this->error = "Error ".$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('TVA_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('TVA_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } - else { - $this->db->rollback(); - return -1; - } - } + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } /** * Tag TVA as payed completely @@ -253,8 +249,11 @@ class Tva extends CommonObject $sql .= " paye = 1"; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) return 1; - else return -1; + if ($resql) { + return 1; + } else { + return -1; + } } /** @@ -270,22 +269,25 @@ class Tva extends CommonObject $sql .= " paye = 0"; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) return 1; - else return -1; + if ($resql) { + return 1; + } else { + return -1; + } } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.tms,"; @@ -301,20 +303,18 @@ class Tva extends CommonObject $sql .= " t.fk_user_modif,"; $sql .= " t.fk_account"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); @@ -329,22 +329,21 @@ class Tva extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } - else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** + /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @return int <0 if KO, >0 if OK */ public function delete($user) @@ -355,16 +354,17 @@ class Tva extends CommonObject // Call trigger $result = $this->call_trigger('TVA_DELETE', $user); - if ($result < 0) return -1; + if ($result < 0) { + return -1; + } // End call triggers $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva"; $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -375,11 +375,11 @@ class Tva extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { @@ -397,244 +397,233 @@ class Tva extends CommonObject } - /** - * Balance of VAT - * - * @param int $year Year - * @return double Amount - */ - public function solde($year = 0) - { + /** + * Balance of VAT + * + * @param int $year Year + * @return double Amount + */ + public function solde($year = 0) + { - $reglee = $this->tva_sum_reglee($year); + $reglee = $this->tva_sum_reglee($year); - $payee = $this->tva_sum_payee($year); - $collectee = $this->tva_sum_collectee($year); + $payee = $this->tva_sum_payee($year); + $collectee = $this->tva_sum_collectee($year); - $solde = $reglee - ($collectee - $payee); + $solde = $reglee - ($collectee - $payee); - return $solde; - } + return $solde; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT from invoices emitted by the thirdparty. - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_collectee($year = 0) - { + /** + * Total of the VAT from invoices emitted by the thirdparty. + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_collectee($year = 0) + { // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { + $sql = "SELECT sum(f.tva) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; + if ($year) { $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); $ret = $obj->amount; - $this->db->free($result); - return $ret; - } - else { - $this->db->free($result); + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } - else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_payee($year = 0) - { + /** + * VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_payee($year = 0) + { // phpcs:enable - $sql = "SELECT sum(f.total_tva) as total_tva"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { - $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.total_tva) as total_tva"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + if ($year) { + $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->total_tva; - $this->db->free($result); - return $ret; - } - else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $ret = $obj->total_tva; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } - else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_reglee($year = 0) - { + /** + * Total of the VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_reglee($year = 0) + { // phpcs:enable - $sql = "SELECT sum(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql = "SELECT sum(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; - if ($year) - { + if ($year) { $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; - } + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } - else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } - else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - /** - * Create in database - * + /** + * Create in database + * * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK - */ - public function addPayment($user) - { - global $conf, $langs; + */ + public function addPayment($user) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); $this->note = trim($this->note); $this->num_payment = trim($this->num_payment); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_creat = (int) $this->fk_user_creat; $this->fk_user_modif = (int) $this->fk_user_modif; - if (empty($this->datec)) $this->datec = dol_now(); + if (empty($this->datec)) { + $this->datec = dol_now(); + } - // Check parameters - if (!$this->label) - { + // Check parameters + if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -4; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -5; - } + if ($this->amount == '') { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -4; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -5; + } - // Insert into llx_tva - $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; - $sql .= "datec"; - $sql .= ", datep"; - $sql .= ", datev"; + // Insert into llx_tva + $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; + $sql .= "datec"; + $sql .= ", datep"; + $sql .= ", datev"; $sql .= ", amount"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; - if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; - $sql .= ", fk_user_creat"; + if ($this->note) { + $sql .= ", note"; + } + if ($this->label) { + $sql .= ", label"; + } + $sql .= ", fk_user_creat"; $sql .= ", fk_bank"; $sql .= ", entity"; $sql .= ") "; - $sql .= " VALUES ("; - $sql .= " '".$this->db->idate($this->datec)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= " VALUES ("; + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", ".$this->amount; - $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; + if ($this->note) { + $sql .= ", '".$this->db->escape($this->note)."'"; + } + if ($this->label) { + $sql .= ", '".$this->db->escape($this->label)."'"; + } + $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", NULL"; $sql .= ", ".$conf->entity; - $sql .= ")"; + $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' + $result = $this->db->query($sql); + if ($result) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' - // Call trigger - //XXX: Should be done just befor commit no ? - $result = $this->call_trigger('TVA_ADDPAYMENT', $user); - if ($result < 0) - { - $this->id = 0; - $ok = 0; - } - // End call triggers + // Call trigger + //XXX: Should be done just befor commit no ? + $result = $this->call_trigger('TVA_ADDPAYMENT', $user); + if ($result < 0) { + $this->id = 0; + $ok = 0; + } + // End call triggers - if ($this->id > 0) - { - $ok = 1; - if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($this->id > 0) { + $ok = 1; + 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); + $acc = new Account($this->db); $result = $acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + if ($result <= 0) { + dol_print_error($this->db); + } if ($this->amount > 0) { $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user); @@ -642,65 +631,56 @@ class Tva extends CommonObject $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user); } - // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } - else { + // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction + if ($bank_line_id > 0) { + $this->update_fk_bank($bank_line_id); + } else { $this->error = $acc->error; $ok = 0; } - // Update links - $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { - $this->error = $acc->error; - $ok = 0; - } - } + // Update links + $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) { + $this->error = $acc->error; + $ok = 0; + } + } - if ($ok) - { + if ($ok) { $this->db->commit(); return $this->id; - } - else { + } else { $this->db->rollback(); return -3; } - } - else { - $this->db->rollback(); - return -2; - } - } - else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + /** * Update link between payment tva and line generate into llx_bank - * - * @param int $id_bank Id bank account + * + * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK - */ + */ public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; $sql .= ' WHERE rowid = '.(int) $this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; - } - else { + } else { dol_print_error($this->db); return -1; } @@ -711,8 +691,8 @@ class Tva extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss More CSS + * @param int $notooltip 1=Disable tooltip + * @param string $morecss More CSS * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine with URL */ @@ -720,83 +700,92 @@ class Tva extends CommonObject { global $langs, $conf; - 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("ShowVatPayment").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->label)) + if (!empty($this->label)) { $label .= '
'.$langs->trans('Label').': '.$this->label; + } - $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/tva/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'; - } + 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'; + } + } - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; $picto = 'payment'; $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; return $result; } /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'payment_vat'; - $field = 'fk_tva'; + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'payment_vat'; + $field = 'fk_tva'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) { + $amount = $obj->amount ? $obj->amount : 0; + } - $this->db->free($resql); - return $amount; - } - else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } /** * Informations of vat payment object @@ -812,10 +801,8 @@ class Tva extends CommonObject dol_syslog(get_class($this)."::info", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -838,8 +825,7 @@ class Tva extends CommonObject } $this->db->free($result); - } - else { + } else { dol_print_error($this->db); } } @@ -877,21 +863,28 @@ class Tva extends CommonObject $this->labelStatus = array(); $this->labelStatusShort = array(); - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } } $statusType = 'status1'; - if ($status == 0 && $alreadypaid <> 0) $statusType = 'status3'; - if ($status == 1) $statusType = 'status6'; + if ($status == 0 && $alreadypaid <> 0) { + $statusType = 'status3'; + } + if ($status == 1) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index d4acecf063d..e0801ba1db2 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -46,12 +46,13 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ $now = dol_now(); $current_date = dol_getdate($now); -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +} // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = $current_date['year']; $year_start = $year_current; } else { @@ -61,12 +62,12 @@ if (empty($year)) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Set default period if not defined -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { + if (empty($q)) { + if (GETPOST("month", 'int')) { + $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); + } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; @@ -88,25 +89,41 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } } } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } $min = price2num(GETPOST("min", "alpha")); -if (empty($min)) $min = 0; +if (empty($min)) { + $min = 0; +} // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -128,9 +145,10 @@ $user_static = new User($db); $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); -foreach ($listofparams as $param) -{ - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); +foreach ($listofparams as $param) { + if (GETPOST($param) != '') { + $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + } } $special_report = false; @@ -149,9 +167,15 @@ $fsearch .= ''; // Show report header $name = $langs->trans("VATReportByThirdParties"); $calcmode = ''; -if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +if ($modetax == 0) { + $calcmode = $langs->trans('OptionVATDefault'); +} +if ($modetax == 1) { + $calcmode = $langs->trans('OptionVATDebitOption'); +} +if ($modetax == 2) { + $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +} $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -173,19 +197,28 @@ if ($nextquarter < 4) { } $builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { + $description .= $langs->trans("RulesVATDueProducts"); +} +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { + $description .= $langs->trans("RulesVATInProducts"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { + $description .= '
'.$langs->trans("RulesVATDueServices"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + $description .= '
'.$langs->trans("RulesVATInServices"); +} if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } -if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { + $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +} //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description .= ($description ? '
' : '').$fsearch; -if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) -{ +if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) { $description .= '
'; $description .= ' '; $description .= $langs->trans('SimpleReport'); @@ -229,8 +262,7 @@ $columns = 5; $x_coll = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'sell'); $x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'buy'); -if (!is_array($x_coll) || !is_array($x_paye)) -{ +if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); if ($x_coll == -1) { print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; @@ -242,15 +274,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) } else { $x_both = array(); //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_thirdpartyid) - { + foreach (array_keys($x_coll) as $my_coll_thirdpartyid) { $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id => $dummy) { $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; @@ -289,11 +320,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) - { + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id => $dummy) { // ExpenseReport - if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') - { + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') { $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; @@ -356,7 +385,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_paye_ht = 0; $span = $columns; - if ($modetax != 1) $span += 2; + if ($modetax != 1) { + $span += 2; + } //print ''..')'; @@ -364,12 +395,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''.$elementcust.''; print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.$langs->trans("DatePayment").''; + } else { + print ''; + } print ''.$namerate.''; print ''.$productcust.''; - if ($modetax != 1) - { + if ($modetax != 1) { print ''.$amountcust.''; print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; } @@ -392,10 +425,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) $subtot_coll_total_ht = 0; $subtot_coll_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) - { - if (is_array($x_both[$thirdparty_id]['coll']['detail'])) - { + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) { + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) { // VAT Rate print ""; print ''; @@ -542,8 +573,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) } } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { + if (count($x_coll) == 0) { // Show a total ine if nothing shown print ''; print ''; print ''.$langs->trans("Total").':'; @@ -563,8 +593,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''.$elementsup.''; print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.$langs->trans("DatePayment").''; + } else { + print ''; + } print ''.$namesup.''; print ''.$productsup.''; if ($modetax != 1) { @@ -575,8 +608,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''.$vatsup.''; print ''."\n"; - foreach (array_keys($x_paye) as $thirdparty_id) - { + foreach (array_keys($x_paye) as $thirdparty_id) { $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; @@ -673,18 +705,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; print $paymentfourn_static->getNomUrl(2); } if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index addaf50d990..38d88fb3d12 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -34,8 +34,7 @@ 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/vat.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.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'; } @@ -48,7 +47,9 @@ $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, 'tax', '', 'vat', 'charges'); @@ -63,12 +64,18 @@ if (empty($page) || $page == -1) { $offset = $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 Tva($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref); $modulepart = 'tax-vat'; @@ -80,12 +87,12 @@ $modulepart = 'tax-vat'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; -if ($action == 'setlib' && $user->rights->tax->charges->creer) -{ +if ($action == 'setlib' && $user->rights->tax->charges->creer) { $object->fetch($id); $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } @@ -94,14 +101,15 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) */ $form = new Form($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $title = $langs->trans("VATPayment").' - '.$langs->trans("Documents"); $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; llxHeader("", $title, $help_url); -if ($object->id) -{ +if ($object->id) { $alreadypayed = $object->getSommePaiement(); $head = vat_prepare_head($object); @@ -126,8 +134,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 081023cd2e8..76eed6b1bf8 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -39,12 +39,13 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ $form = new Form($db); $now = dol_now(); $current_date = dol_getdate($now); -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +} // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = $current_date['year']; $year_start = $year_current; } else { @@ -54,18 +55,16 @@ if (empty($year)) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Set default period if not defined -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else { + if (empty($q)) { + if (GETPOST("month", "int")) { + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year $year_start--; @@ -77,30 +76,42 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } - } - else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + } else { + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -114,102 +125,95 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs, $form; + global $conf, $bc, $langs, $form; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $totalclaimed = 0; - $totalpaid = 0; - $amountclaimed = 0; - $amountpaid = 0; - $previousmonth = ''; - $previousmode = ''; - $mode = ''; + $totalclaimed = 0; + $totalpaid = 0; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; + $mode = ''; - while ($i < $num) { - $obj = $db->fetch_object($result); - $mode = $obj->mode; + while ($i < $num) { + $obj = $db->fetch_object($result); + $mode = $obj->mode; - //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && !empty($previousmode)) { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - if ($obj->mode == 'claimed') - { - $amountclaimed = $obj->mm; - $totalclaimed = $totalclaimed + $amountclaimed; - } - if ($obj->mode == 'paid') - { - $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaid; - } + if ($obj->mode == 'claimed') { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } - if ($obj->mode == 'paid') - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - $previousmode = ''; - $previousmonth = ''; - } - else { - $previousmode = $obj->mode; - $previousmonth = $obj->dm; - } + if ($obj->mode == 'paid') { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } else { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } - $i++; - } + $i++; + } - if ($mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + if ($mode == 'claimed' && !empty($previousmode)) { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - print ''; - print ''; - print ''; - print ''; - print ""; + print ''; + print ''; + print ''; + print ''; + print ""; - print "
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).'
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).'
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; + print ""; - $db->free($result); - } - else { - dol_print_error($db); - } + $db->free($result); + } else { + dol_print_error($db); + } } @@ -229,20 +233,36 @@ $description = $fsearch; // Show report header $name = $langs->trans("VATReportByMonth"); $calcmode = ''; -if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +if ($modetax == 0) { + $calcmode = $langs->trans('OptionVATDefault'); +} +if ($modetax == 1) { + $calcmode = $langs->trans('OptionVATDebitOption'); +} +if ($modetax == 2) { + $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +} $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; $description .= $langs->trans("VATSummary").'
'; -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { + $description .= $langs->trans("RulesVATDueProducts"); +} +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { + $description .= $langs->trans("RulesVATInProducts"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { + $description .= '
'.$langs->trans("RulesVATDueServices"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + $description .= '
'.$langs->trans("RulesVATInServices"); +} if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } -if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { + $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +} $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -284,11 +304,14 @@ $mend = $tmp['mon']; $total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; $i = 0; $mcursor = 0; -while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop -{ +while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); - if ($m == 13) $y++; - if ($m > 12) $m -= 12; + if ($m == 13) { + $y++; + } + if ($m > 12) { + $m -= 12; + } $mcursor++; $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); @@ -296,15 +319,14 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $x_both = array(); //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_rate) - { + foreach (array_keys($x_coll) as $my_coll_rate) { $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; $x_both[$my_coll_rate]['paye']['totalht'] = 0; $x_both[$my_coll_rate]['paye']['vat'] = 0; $x_both[$my_coll_rate]['coll']['links'] = ''; $x_both[$my_coll_rate]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) { //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; @@ -343,11 +365,9 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc $x_both[$my_paye_rate]['paye']['links'] = ''; $x_both[$my_paye_rate]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) - { + foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) { // ExpenseReport - if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') - { + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') { //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; @@ -369,8 +389,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], //'link' =>$expensereport->getNomUrl(1) ); - } - else { + } else { //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; @@ -400,144 +419,133 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } //now we have an array (x_both) indexed by rates for coll and paye - $action = "tva"; - $object = array(&$x_coll, &$x_paye, &$x_both); - $parameters["mode"] = $modetax; - $parameters["year"] = $y; - $parameters["month"] = $m; - $parameters["type"] = 'vat'; + $action = "tva"; + $object = array(&$x_coll, &$x_paye, &$x_both); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + $parameters["type"] = 'vat'; - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { - $langs->load("errors"); - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) - { - print ''.$langs->trans("FeatureNotYetAvailable").''; - break; - } + if (!is_array($x_coll) && $coll_listbuy == -1) { + $langs->load("errors"); + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + break; + } + if (!is_array($x_paye) && $coll_listbuy == -2) { + print ''.$langs->trans("FeatureNotYetAvailable").''; + break; + } - print ''; - print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; + print ''; + print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; - $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - print ''.price(price2num($x_coll_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ''.price(price2num($x_coll_sum, 'MT')).''; - $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - print ''.price(price2num($x_paye_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ''.price(price2num($x_paye_sum, 'MT')).''; - $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = price2num($subtotal + $diff, 'MT'); + $diff = $x_coll_sum - $x_paye_sum; + $total = $total + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print ''.price(price2num($diff, 'MT')).''."\n"; - print " \n"; - print "\n"; + print ''.price(price2num($diff, 'MT')).''."\n"; + print " \n"; + print "\n"; - $i++; $m++; - if ($i > 2) - { - print ''; - print ''.$langs->trans("SubTotal").':'; - print ''.price(price2num($subtotalcoll, 'MT')).''; - print ''.price(price2num($subtotalpaye, 'MT')).''; - print ''.price(price2num($subtotal, 'MT')).''; - print ' '; - $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; - } + $i++; $m++; + if ($i > 2) { + print ''; + print ''.$langs->trans("SubTotal").':'; + print ''.price(price2num($subtotalcoll, 'MT')).''; + print ''.price(price2num($subtotalpaye, 'MT')).''; + print ''.price(price2num($subtotal, 'MT')).''; + print ' '; + $i = 0; + $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + } } print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; print " \n"; @@ -579,45 +587,44 @@ $sql .= " ORDER BY dm ASC, mode ASC"; pt($db, $sql, $langs->trans("Month")); -if (!empty($conf->global->MAIN_FEATURES_LEVEL)) -{ +if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { print '
'; /* - * Recap - */ + * Recap + */ - print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - $sql1 = "SELECT SUM(amount) as mm"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; - $sql1 .= " WHERE f.entity = ".$conf->entity; - $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; - $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; + $sql1 = "SELECT SUM(amount) as mm"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql1 .= " WHERE f.entity = ".$conf->entity; + $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; + $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; - $result = $db->query($sql1); - if ($result) { - $obj = $db->fetch_object($result); - print ''; + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print '
'; - print ""; - print ''; - print ''; - print "\n"; + print ""; + print ''; + print ''; + print "\n"; - print ""; - print ''; - print '\n"; - print "\n"; + print ""; + print ''; + print '\n"; + print "\n"; - $restopay = $total - $obj->mm; - print ""; - print ''; - print ''; - print "\n"; + $restopay = $total - $obj->mm; + print ""; + print ''; + print ''; + print "\n"; - print '
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'; - } + print ''; + } } print '
'; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 45799c8e1f5..fb3d0c62d86 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -34,7 +34,9 @@ $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, 'tax', '', '', 'charges'); $object = new Tva($db); @@ -45,12 +47,12 @@ $object = new Tva($db); * Actions */ -if ($action == 'setlib' && $user->rights->tax->charges->creer) -{ +if ($action == 'setlib' && $user->rights->tax->charges->creer) { $object->fetch($id); $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index dd5118bc656..c7146023aab 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -30,7 +30,9 @@ require '../../main.inc.php'; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; @@ -65,13 +67,19 @@ $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 't.datev'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 't.datev'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} $arrayfields = array( 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",), @@ -94,14 +102,15 @@ $object = new Tva($db); $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - 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 - { + 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 $search_ref = ''; $search_label = ''; $search_dateend_start = ''; @@ -137,16 +146,36 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON t.fk_typepayment = ps $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON ptva.fk_tva = t.rowid"; $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')'; -if (!empty($search_ref)) $sql .= natural_search('t.rowid', $search_ref); -if (!empty($search_label)) $sql .= natural_search('t.label', $search_label); -if (!empty($search_dateend_start)) $sql .= ' AND t.datev >= "'.$db->idate($search_dateend_start).'"'; -if (!empty($search_dateend_end)) $sql .= ' AND t.datev <= "'.$db->idate($search_dateend_end).'"'; -if (!empty($search_datepayment_start)) $sql .= ' AND t.datep >= "'.$db->idate($search_datepayment_start).'"'; -if (!empty($search_datepayment_end)) $sql .= ' AND t.datep <= "'.$db->idate($search_datepayment_end).'"'; -if (!empty($search_type) && $search_type > 0) $sql .= ' AND t.fk_typepayment='.$search_type; -if (!empty($search_account) && $search_account > 0) $sql .= ' AND b.fk_account='.$search_account; -if (!empty($search_amount)) $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1); -if ($search_status != '' && $search_status >= 0) $sql .= " AND t.paye = ".$db->escape($search_status); +if (!empty($search_ref)) { + $sql .= natural_search('t.rowid', $search_ref); +} +if (!empty($search_label)) { + $sql .= natural_search('t.label', $search_label); +} +if (!empty($search_dateend_start)) { + $sql .= ' AND t.datev >= "'.$db->idate($search_dateend_start).'"'; +} +if (!empty($search_dateend_end)) { + $sql .= ' AND t.datev <= "'.$db->idate($search_dateend_end).'"'; +} +if (!empty($search_datepayment_start)) { + $sql .= ' AND t.datep >= "'.$db->idate($search_datepayment_start).'"'; +} +if (!empty($search_datepayment_end)) { + $sql .= ' AND t.datep <= "'.$db->idate($search_datepayment_end).'"'; +} +if (!empty($search_type) && $search_type > 0) { + $sql .= ' AND t.fk_typepayment='.$search_type; +} +if (!empty($search_account) && $search_account > 0) { + $sql .= ' AND b.fk_account='.$search_account; +} +if (!empty($search_amount)) { + $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1); +} +if ($search_status != '' && $search_status >= 0) { + $sql .= " AND t.paye = ".$db->escape($search_status); +} $sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.num_payment, pst.code"; $sql .= $db->order($sortfield, $sortorder); @@ -166,8 +195,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if (!$result) -{ +if (!$result) { dol_print_error($db); llxFooter(); $db->close(); @@ -177,32 +205,78 @@ if (!$result) $num = $db->num_rows($result); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { + $param .= '&contextpage='.$contextpage; +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} -if (!empty($search_ref)) $param .= '&search_ref="'.$search_ref.'"'; -if (!empty($search_label)) $param .= '&search_label="'.$search_label.'"'; -if (!empty($search_dateend_start)) $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int'); -if (!empty($search_dateend_start)) $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int'); -if (!empty($search_dateend_start)) $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int'); -if (!empty($search_dateend_end)) $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int'); -if (!empty($search_dateend_end)) $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int'); -if (!empty($search_dateend_end)) $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int'); -if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int'); -if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int'); -if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int'); -if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int'); -if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int'); -if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int'); -if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.$search_type; -if (!empty($search_cheque)) $param .= '&search_cheque="'.$search_cheque.'"'; -if (!empty($search_account) && $search_account > 0) $param .= '&search_account='.$search_account; -if (!empty($search_amount)) $param .= '&search_amount="'.$search_amount.'"'; -if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); +if (!empty($search_ref)) { + $param .= '&search_ref="'.$search_ref.'"'; +} +if (!empty($search_label)) { + $param .= '&search_label="'.$search_label.'"'; +} +if (!empty($search_dateend_start)) { + $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int'); +} +if (!empty($search_dateend_start)) { + $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int'); +} +if (!empty($search_dateend_start)) { + $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int'); +} +if (!empty($search_dateend_end)) { + $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int'); +} +if (!empty($search_dateend_end)) { + $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int'); +} +if (!empty($search_dateend_end)) { + $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int'); +} +if (!empty($search_datepayment_start)) { + $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int'); +} +if (!empty($search_datepayment_start)) { + $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int'); +} +if (!empty($search_datepayment_start)) { + $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int'); +} +if (!empty($search_datepayment_end)) { + $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int'); +} +if (!empty($search_datepayment_end)) { + $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int'); +} +if (!empty($search_datepayment_end)) { + $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int'); +} +if (!empty($search_type) && $search_type > 0) { + $param .= '&search_type='.$search_type; +} +if (!empty($search_cheque)) { + $param .= '&search_cheque="'.$search_cheque.'"'; +} +if (!empty($search_account) && $search_account > 0) { + $param .= '&search_account='.$search_account; +} +if (!empty($search_amount)) { + $param .= '&search_amount="'.$search_amount.'"'; +} +if ($search_status != '' && $search_status != '-1') { + $param .= '&search_status='.urlencode($search_status); +} print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -211,13 +285,17 @@ print ''; print ''; $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} print '
'; print ''; @@ -303,13 +381,27 @@ print ''; print ''; print ''; -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['t.rowid']['checked'])) print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder); -if (!empty($arrayfields['t.datev']['checked'])) print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder); -if (!empty($arrayfields['t.fk_typepayment']['checked'])) print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left '); -if (!empty($arrayfields['t.amount']['checked'])) print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['t.status']['checked'])) print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder); +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['t.rowid']['checked'])) { + print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['t.label']['checked'])) { + print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder); +} +if (!empty($arrayfields['t.datev']['checked'])) { + print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder); +} +if (!empty($arrayfields['t.fk_typepayment']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left '); +} +if (!empty($arrayfields['t.amount']['checked'])) { + print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['t.status']['checked'])) { + print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder); +} // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -333,25 +425,33 @@ while ($i < min($num, $limit)) { // No if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref if (!empty($arrayfields['t.rowid']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Label if (!empty($arrayfields['t.label']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date end period if (!empty($arrayfields['t.datev']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date payment @@ -361,10 +461,11 @@ while ($i < min($num, $limit)) { }*/ // Type - if (!empty($arrayfields['t.fk_typepayment']['checked'])) - { + if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Account @@ -390,15 +491,21 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['t.amount']['checked'])) { $total = $total + $obj->amount; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } $totalarray['pos'][$totalarray['nbfield']] = 'amount'; $totalarray['val']['amount'] += $obj->amount; } if (!empty($arrayfields['t.status']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($arrayfields['t.amount']['checked'])) $totalarray['pos'][$totalarray['nbfield']] = ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.amount']['checked'])) { + $totalarray['pos'][$totalarray['nbfield']] = ''; + } } // Buttons diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 0cdf7e7086b..73e2dae0e05 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -39,24 +39,34 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); $mode = GETPOST("mode", 'alpha'); $year = GETPOST("year", 'int'); $filtre = GETPOST("filtre", 'alpha'); -if (!$year && $mode != 'tvaonly') { $year = date("Y", time()); } +if (!$year && $mode != 'tvaonly') { + $year = date("Y", time()); +} $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "ptva.datep"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "ptva.datep"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} /* @@ -73,14 +83,24 @@ llxHeader('', $langs->trans("VATExpensesArea")); $title = $langs->trans("VATPayments"); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($sortfield) $param .= '&sortfield='.$sortfield; -if ($sortorder) $param .= '&sortorder='.$sortorder; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} +if ($sortfield) { + $param .= '&sortfield='.$sortfield; +} +if ($sortorder) { + $param .= '&sortorder='.$sortorder; +} print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -90,10 +110,11 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); -if ($year) $param .= '&year='.$year; +if ($year) { + $param .= '&year='.$year; +} -if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) -{ +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.(($offset * $limit) + $i).''.$tva_static->getNomUrl(1).''.dol_trunc($obj->label, 40).''.dol_print_date($db->jdate($obj->datev), 'day').''.$langs->trans("PaymentTypeShort".$obj->payment_code).'' . price($obj->amount) . '' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '
'; print ''; @@ -120,8 +141,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id"; $sql .= " WHERE ptva.fk_tva = tva.rowid"; $sql .= " AND tva.entity = ".$conf->entity; - if ($year > 0) - { + if ($year > 0) { $sql .= " AND ("; // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire @@ -133,22 +153,22 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || preg_match('/^tva\./', $sortfield) || preg_match('/^ptva\./', $sortfield) || preg_match('/^pct\./', $sortfield) - || preg_match('/^bank\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + || preg_match('/^bank\./', $sortfield)) { + $sql .= $db->order($sortfield, $sortorder); + } //$sql.= $db->plimit($limit+1,$offset); //print $sql; dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; $totalnb = 0; $totalpaye = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $payment_vat_static->id = $obj->pid; @@ -159,11 +179,13 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '\n"; // Date payment print ''; - // Type payment - print ''; - // Account + // Type payment + print ''; + // Account print ''; // Paid print ''; print ''; @@ -194,16 +218,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $totalpaye = $totalpaye + $obj->totalpaye; $i++; } - print ''; - print ''; // A total here has no sense - //print ''; - print ''; + print ''; + print ''; // A total here has no sense + //print ''; print ''; print ''; - print '"; + print ''; + print '"; print ""; - } - else { + } else { dol_print_error($db); } print '
'.$payment_vat_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + } + print $obj->num_payment.''; $account = new Account($db); $account->fetch($obj->fk_account); @@ -185,7 +207,9 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''.price($obj->total).''; - if ($obj->totalpaye) print price($obj->totalpaye); + if ($obj->totalpaye) { + print price($obj->totalpaye); + } print '
'.$langs->trans("Total").'  
'.$langs->trans("Total").'   '.price($totalpaye)." '.price($totalpaye)."
'; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index ba12b08b3b0..04f90ba02f9 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -46,12 +46,13 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ $now = dol_now(); $current_date = dol_getdate($now); -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +} // Date range $year = GETPOST("year", "int"); -if (empty($year)) -{ +if (empty($year)) { $year_current = $current_date['year']; $year_start = $year_current; } else { @@ -61,12 +62,12 @@ if (empty($year)) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Set default period if not defined -if (empty($date_start) || empty($date_end)) // We define date_start and date_end -{ +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { + if (empty($q)) { + if (GETPOST("month", "int")) { + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; @@ -88,25 +89,41 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } } } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + } } } $min = price2num(GETPOST("min", "alpha")); -if (empty($min)) $min = 0; +if (empty($min)) { + $min = 0; +} // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax = 0; +if (GETPOSTISSET("modetax")) { + $modetax = GETPOST("modetax", 'int'); +} +if (empty($modetax)) { + $modetax = 0; +} // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -127,9 +144,10 @@ $paymentexpensereport_static = new PaymentExpenseReport($db); $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); -foreach ($listofparams as $param) -{ - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); +foreach ($listofparams as $param) { + if (GETPOST($param) != '') { + $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + } } $title = $langs->trans("VATReport")." ".dol_print_date($date_start)." -> ".dol_print_date($date_end); @@ -149,9 +167,15 @@ $fsearch .= ''; // Show report header $name = $langs->trans("VATReportByRates"); $calcmode = ''; -if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +if ($modetax == 0) { + $calcmode = $langs->trans('OptionVATDefault'); +} +if ($modetax == 1) { + $calcmode = $langs->trans('OptionVATDebitOption'); +} +if ($modetax == 2) { + $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +} $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -173,14 +197,24 @@ if ($nextquarter < 4) { $description .= $fsearch; $builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { + $description .= $langs->trans("RulesVATDueProducts"); +} +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { + $description .= $langs->trans("RulesVATInProducts"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { + $description .= '
'.$langs->trans("RulesVATDueServices"); +} +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + $description .= '
'.$langs->trans("RulesVATInServices"); +} if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } -if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { + $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); +} // Customers invoices $elementcust = $langs->trans("CustomersInvoices"); @@ -225,8 +259,7 @@ $columns = 5; $x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); $x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); -if (!is_array($x_coll) || !is_array($x_paye)) -{ +if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); if ($x_coll == -1) { print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; @@ -238,15 +271,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) } else { $x_both = array(); //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_rate) - { + foreach (array_keys($x_coll) as $my_coll_rate) { $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; $x_both[$my_coll_rate]['paye']['totalht'] = 0; $x_both[$my_coll_rate]['paye']['vat'] = 0; $x_both[$my_coll_rate]['coll']['links'] = ''; $x_both[$my_coll_rate]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) { $invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id]; $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id]; @@ -284,11 +316,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_both[$my_paye_rate]['paye']['links'] = ''; $x_both[$my_paye_rate]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) - { + foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) { // ExpenseReport - if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') - { + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') { $expensereport->id = $x_paye[$my_paye_rate]['facid'][$id]; $expensereport->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $expensereport->type = $x_paye[$my_paye_rate]['type'][$id]; @@ -349,7 +379,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) $x_paye_ht = 0; $span = $columns; - if ($modetax != 1) $span += 2; + if ($modetax != 1) { + $span += 2; + } //print ''..')'; @@ -357,12 +389,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''.$elementcust.''; print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.$langs->trans("DatePayment").''; + } else { + print ''; + } print ''.$namecust.''; print ''.$productcust.''; - if ($modetax != 1) - { + if ($modetax != 1) { print ''.$amountcust.''; print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; } @@ -385,8 +419,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) $subtot_coll_total_ht = 0; $subtot_coll_vat = 0; - if (is_array($x_both[$rate]['coll']['detail'])) - { + if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate print ""; print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; @@ -415,16 +448,18 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''.dol_print_date($fields['datef'], 'day').''; // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.dol_print_date($fields['datep'], 'day').''; - else print ''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } // Company name print ''.$fields['company_link'].''; // Description print ''; - if ($fields['pid']) - { + if ($fields['pid']) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered @@ -455,12 +490,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; // Total HT - if ($modetax != 1) - { + if ($modetax != 1) { print ''; print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { + if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; @@ -470,18 +503,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id = $fields['payment_id']; print $payment_static->getNomUrl(2); } if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -527,8 +557,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; } - if (count($x_coll) == 0) // Show a total line if nothing shown - { + if (count($x_coll) == 0) { // Show a total line if nothing shown print ''; print ''; print ''.$langs->trans("Total").':'; @@ -548,8 +577,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; print ''.$elementsup.''; print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.$langs->trans("DatePayment").''; + } else { + print ''; + } print ''.$namesup.''; print ''.$productsup.''; if ($modetax != 1) { @@ -560,18 +592,16 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''.$vatsup.''; print ''."\n"; - foreach (array_keys($x_paye) as $rate) - { + foreach (array_keys($x_paye) as $rate) { $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - if (is_array($x_both[$rate]['paye']['detail'])) - { + if (is_array($x_both[$rate]['paye']['detail'])) { print ""; print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; print ''."\n"; - foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) { + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { // Define type // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); @@ -594,16 +624,18 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''.dol_print_date($fields['datef'], 'day').''; // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.dol_print_date($fields['datep'], 'day').''; - else print ''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } // Company name print ''.$fields['company_link'].''; // Description print ''; - if ($fields['pid']) - { + if ($fields['pid']) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered @@ -634,12 +666,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''; // Total HT - if ($modetax != 1) - { + if ($modetax != 1) { print ''; print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { + if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; @@ -649,18 +679,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) // Payment $ratiopaymentinvoice = 1; - if ($modetax != 1) - { + if ($modetax != 1) { print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; print $paymentfourn_static->getNomUrl(2); } if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { From 3b6d01ffaeaed9d0111772af98f3aa84ba43eeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 21:16:15 +0100 Subject: [PATCH 070/173] code syntax contact directory --- htdocs/contact/agenda.php | 128 +-- .../actions_contactcard_common.class.php | 116 +-- .../default/tpl/contactcard_create.tpl.php | 3 +- .../default/tpl/contactcard_edit.tpl.php | 3 +- .../default/tpl/contactcard_view.tpl.php | 11 +- htdocs/contact/card.php | 454 +++++------ htdocs/contact/class/contact.class.php | 486 ++++++----- htdocs/contact/consumption.php | 269 ++++--- htdocs/contact/document.php | 81 +- htdocs/contact/info.php | 7 +- htdocs/contact/ldap.php | 32 +- htdocs/contact/list.php | 761 +++++++++++------- htdocs/contact/note.php | 29 +- htdocs/contact/perso.php | 128 +-- htdocs/contact/vcard.php | 49 +- 15 files changed, 1432 insertions(+), 1125 deletions(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 2aeb2e4e2a1..ca496540a47 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -65,36 +65,44 @@ $extrafields->fetch_name_optionals_label($object->table_element); $object->getCanvas($id); $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('contact', 'contactcard', $canvas); } -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } $search_agenda_label = GETPOST('search_agenda_label'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep, a.id'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'a.datep, a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactagenda', 'globalcard')); @@ -106,20 +114,19 @@ $hookmanager->initHooks(array('contactagenda', 'globalcard')); $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -133,29 +140,30 @@ if (empty($reshook)) $form = new Form($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { + $title = $object->lastname; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($socid > 0) -{ +if ($socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($socid); } -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) - { - $object = new Contact($db); - $result = $object->fetch($id); - if ($result <= 0) dol_print_error('', $object->error); - } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + if (empty($object->error) && $id) { + $object = new Contact($db); + $result = $object->fetch($id); + if ($result <= 0) { + dol_print_error('', $object->error); + } + } + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- @@ -163,26 +171,27 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { + if ($user->rights->societe->contact->supprimer) { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } /* - * Onglets - */ + * Onglets + */ $head = array(); - if ($id > 0) - { + if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); $res = $object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + if ($res < 0) { + dol_print_error($db, $object->error); exit; + } $res = $object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + if ($res < 0) { + dol_print_error($db, $object->error); exit; + } // Show tabs $head = contact_prepare_head($object); @@ -190,13 +199,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } - if (!empty($id) && $action != 'edit' && $action != 'create') - { + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); /* - * Fiche en mode visualisation - */ + * Fiche en mode visualisation + */ dol_htmloutput_errors($error, $errors); @@ -205,14 +213,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; @@ -238,29 +248,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $out = ''; $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { - if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { + $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); + } $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); } $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) - { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { + if (!empty($conf->agenda->enabled)) { + 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); } } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + print '
'; $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + 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("ActionsOnContact"), $newcardbutton, ''); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index f6f6fa0b45e..a32263cd65e 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -64,14 +64,16 @@ abstract class ActionsContactCardCommon { /*$ret = $this->getInstanceDao(); - if (is_object($this->object) && method_exists($this->object,'fetch')) - { - if (! empty($id)) $this->object->fetch($id); - } - else - {*/ + if (is_object($this->object) && method_exists($this->object,'fetch')) + { + if (! empty($id)) $this->object->fetch($id); + } + else + {*/ $object = new Contact($this->db); - if (!empty($id)) $object->fetch($id); + if (!empty($id)) { + $object->fetch($id); + } $this->object = $object; //} } @@ -90,20 +92,19 @@ abstract class ActionsContactCardCommon global $conf, $langs, $user, $canvas; global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') { + $this->assign_post(); + } - foreach ($this->object as $key => $value) - { + foreach ($this->object as $key => $value) { $this->tpl[$key] = $value; } $this->tpl['error'] = $this->error; $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') - { - if ($conf->use_javascript_ajax) - { + if ($action == 'create' || $action == 'edit') { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { + if (is_object($objsoc) && $objsoc->id > 0) { $this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company_id'] = $objsoc->id; } else { @@ -127,14 +127,25 @@ abstract class ActionsContactCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) - { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; - if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) { + if (dol_strlen(trim($this->object->address)) == 0) { + $this->tpl['address'] = $objsoc->address; + } + if (dol_strlen(trim($this->object->zip)) == 0) { + $this->object->zip = $objsoc->zip; + } + if (dol_strlen(trim($this->object->town)) == 0) { + $this->object->town = $objsoc->town; + } + if (dol_strlen(trim($this->object->phone_pro)) == 0) { + $this->object->phone_pro = $objsoc->phone; + } + if (dol_strlen(trim($this->object->fax)) == 0) { + $this->object->fax = $objsoc->fax; + } + if (dol_strlen(trim($this->object->email)) == 0) { + $this->object->email = $objsoc->email; + } } // Zip @@ -143,28 +154,33 @@ abstract class ActionsContactCardCommon // Town $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) { + $this->object->country_id = $objsoc->country_id; + } // Country $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + if ($this->object->country_id) { + $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + } else { + $this->tpl['select_state'] = $countrynotdefined; + } // Public or private $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { // Emailing - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } @@ -175,46 +191,41 @@ abstract class ActionsContactCardCommon $this->object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); $i++; } - if (!empty($conf->propal->enabled)) - { + if (!empty($conf->propal->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); $i++; } - if (!empty($conf->contrat->enabled)) - { + if (!empty($conf->contrat->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); $i++; } - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); $i++; } // Dolibarr user - if ($this->object->user_id) - { + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); - } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); + } else { + $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); + } } - if ($action == 'view' || $action == 'delete') - { + if ($action == 'view' || $action == 'delete') { $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { + if ($this->object->socid > 0) { $objsoc = new Societe($this->db); $objsoc->fetch($this->object->socid); @@ -243,14 +254,13 @@ abstract class ActionsContactCardCommon $this->tpl['note'] = nl2br($this->object->note); } - if ($action == 'create_user') - { + if ($action == 'create_user') { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); + $generated_password = getRandomPassword(false); $password = $generated_password; // Create a form array @@ -297,12 +307,10 @@ abstract class ActionsContactCardCommon $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { + if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); } else { dol_print_error($this->db); diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php index 98a66e499b9..bd5cf24e195 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php @@ -16,8 +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; } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index 2c82a868ed4..41fbdb5def9 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -16,8 +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; } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index 43fd48e3ef0..c624eca4026 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -16,8 +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; } @@ -30,8 +29,12 @@ echo $this->control->tpl['showhead']; dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']); -if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; -if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> +if (!empty($this->control->tpl['action_create_user'])) { + echo $this->control->tpl['action_create_user']; +} +if (!empty($this->control->tpl['action_delete'])) { + echo $this->control->tpl['action_delete']; +} ?> diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 3866405bee8..0def459d444 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -71,24 +71,26 @@ $socialnetworks = getArrayOfSocialNetworks(); $object->getCanvas($id); $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactcard', 'globalcard')); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} -if (!($object->id > 0) && $action == 'view') -{ +if (!($object->id > 0) && $action == 'view') { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); exit; @@ -100,36 +102,32 @@ if (!($object->id > 0) && $action == 'view') $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // Creation utilisateur depuis contact - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) - { + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { // Recuperation contact actuel $result = $object->fetch($id); - if ($result > 0) - { + if ($result > 0) { $db->begin(); // Creation user $nuser = new User($db); $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) - if ($result > 0) - { + if ($result > 0) { $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) - if ($result2) - { + if ($result2) { $db->commit(); } else { $error = $nuser->error; $errors = $nuser->errors; @@ -146,11 +144,9 @@ if (empty($reshook)) // Confirmation desactivation - if ($action == 'disable') - { + if ($action == 'disable') { $object->fetch($id); - if ($object->setstatus(0) < 0) - { + if ($object->setstatus(0) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); @@ -159,11 +155,9 @@ if (empty($reshook)) } // Confirmation activation - if ($action == 'enable') - { + if ($action == 'enable') { $object->fetch($id); - if ($object->setstatus(1) < 0) - { + if ($object->setstatus(1) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); @@ -172,11 +166,12 @@ if (empty($reshook)) } // Add contact - if ($action == 'add' && $user->rights->societe->contact->creer) - { + if ($action == 'add' && $user->rights->societe->contact->creer) { $db->begin(); - if ($canvas) $object->canvas = $canvas; + if ($canvas) { + $object->canvas = $canvas; + } $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); $object->socid = GETPOST("socid", 'int'); @@ -221,8 +216,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) - { + if ($ret < 0) { $error++; $action = 'create'; } @@ -233,8 +227,7 @@ if (empty($reshook)) $action = 'create'; } - if (!empty($object->email) && !isValidEMail($object->email)) - { + if (!empty($object->email) && !isValidEMail($object->email)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha')); @@ -279,11 +272,13 @@ if (empty($reshook)) } } - if (empty($error) && $id > 0) - { + if (empty($error) && $id > 0) { $db->commit(); - if (!empty($backtopage)) $url = $backtopage; - else $url = 'card.php?id='.$id; + if (!empty($backtopage)) { + $url = $backtopage; + } else { + $url = 'card.php?id='.$id; + } header("Location: ".$url); exit; } else { @@ -291,8 +286,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) - { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) { $result = $object->fetch($id); $object->oldcopy = clone $object; @@ -313,10 +307,8 @@ if (empty($reshook)) } } - if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer) - { - if (!GETPOST("lastname", 'alpha')) - { + if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer) { + if (!GETPOST("lastname", 'alpha')) { $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } @@ -327,16 +319,14 @@ if (empty($reshook)) $action = 'edit'; } - if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) - { + if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha')); $action = 'edit'; } - if (!$error) - { + if (!$error) { $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); $object->fetchRoles($contactid); @@ -344,27 +334,22 @@ if (empty($reshook)) // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if (GETPOST('deletephoto') && $object->photo) - { + if (GETPOST('deletephoto') && $object->photo) { $fileimg = $dir.'/'.$object->photo; $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); $object->photo = ''; } - if ($file_OK) - { - if (image_format_supported($_FILES['photo']['name']) > 0) - { + if ($file_OK) { + if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); - if (@is_dir($dir)) - { + if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (!$result > 0) - { + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } else { $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); @@ -377,8 +362,7 @@ if (empty($reshook)) $errors[] = "ErrorBadImageFormat"; } } else { - switch ($_FILES['photo']['error']) - { + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; @@ -433,10 +417,11 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { $result = $object->update($contactid, $user); if ($result > 0) { @@ -445,8 +430,7 @@ if (empty($reshook)) $object->setCategories($categories); // Update mass emailing flag into table mailing_unsubscribe - if (GETPOSTISSET('no_email') && $object->email) - { + if (GETPOSTISSET('no_email') && $object->email) { $no_email = GETPOST('no_email', 'int'); $result=$object->setNoEmail($no_email); if ($result<0) { @@ -465,31 +449,31 @@ if (empty($reshook)) } } - if (!$error && empty($errors)) - { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + if (!$error && empty($errors)) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } } } - if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) - { + if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // set communication status - if ($action == 'setstcomm') - { + if ($action == 'setstcomm') { $object->fetch($id); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Actions to send emails @@ -506,7 +490,9 @@ if (empty($reshook)) $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { + $title = $object->lastname; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -515,24 +501,23 @@ $formcompany = new FormCompany($db); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if ($socid > 0) -{ +if ($socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($socid); } -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) - { - $object = new Contact($db); - $result = $object->fetch($id); - if ($result <= 0) dol_print_error('', $object->error); - } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + if (empty($object->error) && $id) { + $object = new Contact($db); + $result = $object->fetch($id); + if ($result <= 0) { + dol_print_error('', $object->error); + } + } + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- @@ -540,20 +525,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { + if ($user->rights->societe->contact->supprimer) { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } /* - * Onglets - */ + * Onglets + */ $head = array(); - if ($id > 0) - { + if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); $res = $object->fetch($id, $user); @@ -569,21 +551,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } - if ($user->rights->societe->contact->creer) - { - if ($action == 'create') - { + if ($user->rights->societe->contact->creer) { + if ($action == 'create') { /* - * Fiche en mode creation - */ + * Fiche en mode creation + */ $object->canvas = $canvas; $object->state_id = GETPOST("state_id"); // We set country_id, country_code and label for the selected country $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); - if ($object->country_id) - { + if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -596,8 +575,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print "\n".''."\n"; } - if (!GETPOSTISSET("no_email") && !empty($object->email)) - { + if (!GETPOSTISSET("no_email") && !empty($object->email)) { $result=$object->getNoEmail(); if ($result<0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -829,8 +820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -846,8 +836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Date To Birth print ''; print ''; } - if (!empty($conf->propal->enabled)) - { + if (!empty($conf->propal->enabled)) { print ''; } - if (!empty($conf->contrat->enabled)) - { + if (!empty($conf->contrat->enabled)) { print ''; } - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { print ''; @@ -1182,12 +1160,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Login Dolibarr print ''; // Photo @@ -1199,7 +1178,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print "
\n"; } print '
'; $form = new Form($db); - if ($object->birthday) - { + if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); } else { print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); @@ -855,8 +844,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ': '; - if ($object->birthday_alert) - { + if ($object->birthday_alert) { print ''; } else { print ''; @@ -870,8 +858,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; print ''; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { print '     '; print ''; } else { @@ -883,12 +870,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; } elseif ($action == 'edit' && !empty($id)) { /* - * Fiche en mode edition - */ + * Fiche en mode edition + */ // We set country_id, and country_code label of the chosen country - if (GETPOSTISSET("country_id") || $object->country_id) - { + if (GETPOSTISSET("country_id") || $object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -900,8 +886,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print "\n".''."\n"; } - if (!GETPOSTISSET("no_email") && !empty($object->email)) - { + if (!GETPOSTISSET("no_email") && !empty($object->email)) { $result=$object->getNoEmail(); if ($result<0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1145,36 +1128,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } $object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { print '
'.$langs->trans("ContactForOrders").''; print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); print '
'.$langs->trans("ContactForProposals").''; print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
'.$langs->trans("ContactForContracts").''; print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
'.$langs->trans("ContactForInvoices").''; print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { + if ($object->user_id) { $dolibarr_user = new User($db); $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); + } else { + print $langs->trans("NoDolibarrAccess"); + } print '
'; - if ($object->photo) print ''; + if ($object->photo) { + print ''; + } //print ''; print ''; print '
'.$langs->trans("Delete").'

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

'.$langs->trans("PhotoFile").'
'; @@ -1226,8 +1207,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $action = 'presend'; } - if (!empty($id) && $action != 'edit' && $action != 'create') - { + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); // View mode @@ -1237,15 +1217,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print dol_get_fiche_head($head, 'card', $title, -1, 'contact'); - if ($action == 'create_user') - { + if ($action == 'create_user') { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $login = dol_buildlogin($object->lastname, $object->firstname); $generated_password = ''; - if (!$ldap_sid) // TODO ldap_sid ? - { + if (!$ldap_sid) { // TODO ldap_sid ? require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password = getRandomPassword(false); } @@ -1258,10 +1236,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) ); $text = $langs->trans("ConfirmCreateContact").'
'; - if (!empty($conf->societe->enabled)) - { - if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); - else $text .= $langs->trans("UserWillBeInternalUser"); + if (!empty($conf->societe->enabled)) { + if ($object->socid > 0) { + $text .= $langs->trans("UserWillBeExternalUser"); + } else { + $text .= $langs->trans("UserWillBeInternalUser"); + } } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } @@ -1269,13 +1249,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($object->socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; @@ -1297,16 +1279,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''.$langs->trans("PostOrFunction").''.$object->poste.''; // Email - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''.$langs->trans("NbOfEMailingsSend").''; print ''.$object->getNbOfEMailings().''; } // Unsubscribe opt-out - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $result=$object->getNoEmail(); if ($result<0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1324,8 +1304,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object->fetch_thirdparty(); if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { - if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) - { + if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) { print '
'; print '
'; @@ -1336,7 +1315,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; + if ($action != 'editlevel' && $user->rights->societe->contact->creer) { + print ''; + } print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->contact->creer) print 'id.'">'.img_edit($langs->trans('Modify'), 1).'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; print ''; if ($action == 'editlevel') { @@ -1354,8 +1335,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; foreach ($object->cacheprospectstatus as $key => $val) { $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($object->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } } print '
'; @@ -1391,45 +1376,48 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object->load_ref_elements(); - if (!empty($conf->propal->enabled)) - { + if (!empty($conf->propal->enabled)) { print ''.$langs->trans("ContactForProposals").''; print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print ''; } - if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) - { + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) { print ''; - if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); + if (!empty($conf->expedition->enabled)) { + print $langs->trans("ContactForOrdersOrShipments"); + } else { + print $langs->trans("ContactForOrders"); + } print ''; $none = $langs->trans("NoContactForAnyOrder"); - if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + if (!empty($conf->expedition->enabled)) { + $none = $langs->trans("NoContactForAnyOrderOrShipments"); + } print $object->ref_commande ? $object->ref_commande : $none; print ''; } - if (!empty($conf->contrat->enabled)) - { + if (!empty($conf->contrat->enabled)) { print ''.$langs->trans("ContactForContracts").''; print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print ''; } - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { print ''.$langs->trans("ContactForInvoices").''; print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print ''; } print ''.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { + if ($object->user_id) { $dolibarr_user = new User($db); $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); + } else { + print $langs->trans("NoDolibarrAccess"); + } print ''; print ''; @@ -1452,11 +1440,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && $action != 'presend') - { + if (empty($reshook) && $action != 'presend') { if (empty($user->socid)) { - if (!empty($object->email)) - { + if (!empty($object->email)) { $langs->load("mails"); print ''; } else { @@ -1465,30 +1451,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - if ($user->rights->societe->contact->creer) - { + if ($user->rights->societe->contact->creer) { print ''.$langs->trans('Modify').''; } - if (!$object->user_id && $user->rights->user->user->creer) - { + if (!$object->user_id && $user->rights->user->user->creer) { print ''.$langs->trans("CreateDolibarrLogin").''; } // Activer - if ($object->statut == 0 && $user->rights->societe->contact->creer) - { + if ($object->statut == 0 && $user->rights->societe->contact->creer) { print ''.$langs->trans("Reactivate").''; } // Desactiver - if ($object->statut == 1 && $user->rights->societe->contact->creer) - { + if ($object->statut == 1 && $user->rights->societe->contact->creer) { print ''.$langs->trans("DisableUser").''; } // Delete - if ($user->rights->societe->contact->supprimer) - { + if ($user->rights->societe->contact->supprimer) { print ''.$langs->trans('Delete').''; } } @@ -1500,8 +1481,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '
'; print '
'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 1d2cb3355a5..62d0d444c3e 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -473,40 +473,35 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople"); - if (!$error) - { + if (!$error) { $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CONTACT_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -558,13 +553,20 @@ class Contact extends CommonObject $this->town = (empty($this->town) ? '' : trim($this->town)); $this->setUpperOrLowerCase(); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); - if (empty($this->statut)) $this->statut = 0; - if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility + if (empty($this->statut)) { + $this->statut = 0; + } + if (empty($this->civility_code) && !is_numeric($this->civility_id)) { + $this->civility_code = $this->civility_id; // For backward compatibility + } $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; - if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; - elseif ($this->socid == -1) $sql .= " fk_soc=null,"; + if ($this->socid > 0) { + $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; + } elseif ($this->socid == -1) { + $sql .= " fk_soc=null,"; + } $sql .= " civility='".$this->db->escape($this->civility_code)."'"; $sql .= ", lastname='".$this->db->escape($this->lastname)."'"; $sql .= ", firstname='".$this->db->escape($this->firstname)."'"; @@ -586,8 +588,7 @@ class Contact extends CommonObject $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; $sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'"; - if (isset($this->stcomm_id)) - { + if (isset($this->stcomm_id)) { $sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0"); } $sql .= ", statut = ".$this->db->escape($this->statut); @@ -598,8 +599,7 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { unset($this->country_code); unset($this->country); unset($this->state_code); @@ -608,25 +608,21 @@ class Contact extends CommonObject $action = 'update'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } if (!$error) { $result = $this->updateRoles(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && $this->user_id > 0) - { + if (!$error && $this->user_id > 0) { // If contact is linked to a user $tmpobj = new User($this->db); $tmpobj->fetch($this->user_id); @@ -685,14 +681,18 @@ class Contact extends CommonObject // } if ($usermustbemodified) { $result = $tmpobj->update($user, 0, 1, 1, 1); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } } } if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -759,34 +759,69 @@ class Contact extends CommonObject $this->fullname = $this->getFullName($langs); // Fields - if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; - if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; - if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; + if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) { + $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; + } + if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) { + $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; + } + if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) { + $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; + } - if ($this->poste) $info["title"] = $this->poste; + if ($this->poste) { + $info["title"] = $this->poste; + } if ($this->socid > 0) { $soc = new Societe($this->db); $soc->fetch($this->socid); $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name; - if ($soc->client == 1) $info["businessCategory"] = "Customers"; - if ($soc->client == 2) $info["businessCategory"] = "Prospects"; - if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers"; + if ($soc->client == 1) { + $info["businessCategory"] = "Customers"; + } + if ($soc->client == 2) { + $info["businessCategory"] = "Prospects"; + } + if ($soc->fournisseur == 1) { + $info["businessCategory"] = "Suppliers"; + } + } + if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) { + $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; + } + if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) { + $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; + } + if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) { + $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; + } + if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) { + $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; + } + if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) { + $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; + } + if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) { + $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; + } + if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) { + $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; + } + if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) { + $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; + } + if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) { + $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; + } + if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) { + $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + } + if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) { + $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; } - if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address; - if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip; - if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town; - if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code; - if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro; - if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; - if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; - if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; - if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); - if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; - if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') - { + if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') { $info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware $info['uidnumber'] = $this->id; @@ -805,8 +840,12 @@ class Contact extends CommonObject $info["phpgwContactOwner"] = $this->egroupware_id; - if ($this->email) $info["rfc822Mailbox"] = $this->email; - if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; + if ($this->email) { + $info["rfc822Mailbox"] = $this->email; + } + if ($this->phone_mobile) { + $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; + } } return $info; @@ -834,13 +873,14 @@ class Contact extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; $sql .= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); - if ($user) $sql .= ", fk_user_modif=".$user->id; + if ($user) { + $sql .= ", fk_user_modif=".$user->id; + } $sql .= " WHERE rowid=".$this->db->escape($id); dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } @@ -875,7 +915,9 @@ class Contact extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -906,8 +948,7 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG); - if (empty($id) && empty($ref_ext) && empty($email)) - { + if (empty($id) && empty($ref_ext) && empty($email)) { $this->error = 'BadParameter'; return -1; } @@ -936,8 +977,9 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; - if ($id) $sql .= " WHERE c.rowid = ".((int) $id); - else { + if ($id) { + $sql .= " WHERE c.rowid = ".((int) $id); + } else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; if ($ref_ext) { $sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'"; @@ -948,17 +990,14 @@ class Contact extends CommonObject } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 1) - { + if ($num > 1) { $this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.'; dol_syslog($this->error, LOG_ERR); return 2; - } elseif ($num) // $num = 1 - { + } elseif ($num) { // $num = 1 $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -1030,10 +1069,8 @@ class Contact extends CommonObject $sql .= " WHERE u.fk_socpeople = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $uobj = $this->db->fetch_object($resql); $this->user_id = $uobj->rowid; @@ -1049,17 +1086,14 @@ class Contact extends CommonObject $this->fetch_optionals(); // Load also alerts of this user - if ($user) - { + if ($user) { $sql = "SELECT fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."user_alert"; $sql .= " WHERE fk_user = ".$user->id." AND fk_contact = ".$this->db->escape($id); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->birthday_alert = 1; @@ -1102,11 +1136,9 @@ class Contact extends CommonObject { unset($this->gender); - if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) - { + if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) { $this->gender = 'man'; - } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) - { + } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) { $this->gender = 'woman'; } } @@ -1135,16 +1167,18 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::load_ref_elements", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { - if ($obj->nb) - { - if ($obj->element == 'facture') $this->ref_facturation = $obj->nb; - elseif ($obj->element == 'contrat') $this->ref_contrat = $obj->nb; - elseif ($obj->element == 'commande') $this->ref_commande = $obj->nb; - elseif ($obj->element == 'propal') $this->ref_propal = $obj->nb; + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if ($obj->nb) { + if ($obj->element == 'facture') { + $this->ref_facturation = $obj->nb; + } elseif ($obj->element == 'contrat') { + $this->ref_contrat = $obj->nb; + } elseif ($obj->element == 'commande') { + $this->ref_commande = $obj->nb; + } elseif ($obj->element == 'propal') { + $this->ref_propal = $obj->nb; + } } } $this->db->free($resql); @@ -1169,8 +1203,7 @@ class Contact extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { // Get all rowid of element_contact linked to a type that is link to llx_socpeople $sql = "SELECT ec.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec,"; @@ -1180,21 +1213,18 @@ class Contact extends CommonObject $sql .= " AND tc.source='external'"; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num && !$error) - { + while ($i < $num && !$error) { $obj = $this->db->fetch_object($resql); $sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sqldel .= " WHERE rowid = ".$obj->rowid; dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sqldel); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->error().' sql='.$sqldel; } @@ -1207,56 +1237,48 @@ class Contact extends CommonObject } } - if (!$error) - { + if (!$error) { // Remove Roles $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -1; } } - if (!$error) - { + if (!$error) { // Remove Roles $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -1; } } - if (!$error) - { + if (!$error) { // Remove category $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -1; } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; $sql .= " WHERE rowid=".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->error().' sql='.$sql; } @@ -1266,19 +1288,21 @@ class Contact extends CommonObject if (!$error) { // For avoid conflicts if trigger used $result = $this->deleteExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1303,10 +1327,8 @@ class Contact extends CommonObject $sql .= " WHERE c.rowid = ".$this->db->escape($id); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -1346,8 +1368,7 @@ class Contact extends CommonObject $sql .= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $nb = $obj->nb; @@ -1377,8 +1398,7 @@ class Contact extends CommonObject $result = ''; $label = ''; - if (!empty($this->photo) && class_exists('Form')) - { + if (!empty($this->photo) && class_exists('Form')) { $label .= '
'; $label .= Form::showphoto('contact', $this, 0, 40, 0, '', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. $label .= '
'; @@ -1388,67 +1408,83 @@ class Contact extends CommonObject $label .= ' '.$this->getLibStatut(4); $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; + if (!empty($this->poste)) { + $label .= '
'.$langs->trans("Poste").': '.$this->poste; + } $label .= '
'.$langs->trans("EMail").': '.$this->email; $phonelist = array(); $country_code = empty($this->country_code) ? '': $this->country_code; - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_pro) { + $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); + } + if ($this->phone_mobile) { + $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); + } + if ($this->phone_perso) { + $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); + } $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - if ($option !== 'nolink') - { + 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'; + 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'; + } } $url .= $moreparam; $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContact"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; - /* - $hookmanager->initHooks(array('contactdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ + /* + $hookmanager->initHooks(array('contactdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ } $linkstart = ''; $linkend = ''; - if ($option == 'xxx') - { + if ($option == 'xxx') { $linkstart = ''; $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 .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); + 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 .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); + } $result .= $linkend; global $action; $hookmanager->initHooks(array('contactdao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -1463,7 +1499,9 @@ class Contact extends CommonObject global $langs; $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite : ''))); - if (empty($code)) return ''; + if (empty($code)) { + return ''; + } $langs->load("dict"); return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); @@ -1507,7 +1545,9 @@ class Contact extends CommonObject ); $statusType = 'status4'; - if ($status == 0 || $status == 5) $statusType = 'status5'; + if ($status == 0 || $status == 5) { + $statusType = 'status5'; + } $label = $langs->trans($labelStatus[$status]); $labelshort = $langs->trans($labelStatusShort[$status]); @@ -1527,8 +1567,11 @@ class Contact extends CommonObject { // phpcs:enable global $langs; - if ($status == '1') return $langs->trans('ContactPrivate'); - else return $langs->trans('ContactPublic'); + if ($status == '1') { + return $langs->trans('ContactPrivate'); + } else { + return $langs->trans('ContactPublic'); + } } @@ -1547,7 +1590,9 @@ class Contact extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) $socid = $obj->rowid; + if ($obj) { + $socid = $obj->rowid; + } } // Initialise parameters @@ -1592,8 +1637,11 @@ class Contact extends CommonObject $error = 0; // Check parameters - if ($this->statut == $status) return 0; - else $this->statut = $status; + if ($this->statut == $status) { + return 0; + } else { + $this->statut = $status; + } $this->db->begin(); @@ -1604,16 +1652,16 @@ class Contact extends CommonObject $result = $this->db->query($sql); dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); - if ($result) - { + if ($result) { // Call trigger $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if ($error) - { + if ($error) { $this->db->rollback(); return -$error; } else { @@ -1725,12 +1773,10 @@ class Contact extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab[] = array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact); @@ -1758,7 +1804,9 @@ class Contact extends CommonObject $error = 0; - if (!isset($this->roles)) return; // Avoid to loose roles when property not set + if (!isset($this->roles)) { + return; // Avoid to loose roles when property not set + } $this->db->begin(); @@ -1800,8 +1848,7 @@ class Contact extends CommonObject $sql .= ")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->errors[] = $this->db->lasterror().' sql='.$sql; $error++; } @@ -1830,12 +1877,13 @@ class Contact extends CommonObject global $langs; $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; - if ($active >= 0) $sql .= " WHERE active = ".$active; + if ($active >= 0) { + $sql .= " WHERE active = ".$active; + } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + 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)), 'picto' => $obj->picto); $i++; @@ -1865,8 +1913,7 @@ class Contact extends CommonObject $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse - if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) - { + if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } return $lib; @@ -1915,36 +1962,48 @@ class Contact extends CommonObject global $langs; $langs->load('customers'); - if ($mode == 2) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); - else { + if ($mode == 2) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } - if ($mode == 3) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto); - else { + if ($mode == 3) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto); } } - if ($mode == 4) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); - else { + if ($mode == 4) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } @@ -1964,24 +2023,19 @@ class Contact extends CommonObject $error = 0; // Update mass emailing flag into table mailing_unsubscribe - if ($this->email) - { + if ($this->email) { $this->db->begin(); - if ($no_email) - { + if ($no_email) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$this->db->escape($this->email)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $noemail = $obj->nb; - if (empty($noemail)) - { + if (empty($noemail)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->db->escape($this->email)."', ".$this->db->escape(getEntity('mailing', 0)).", '".$this->db->idate(dol_now())."')"; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -1995,8 +2049,7 @@ class Contact extends CommonObject } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$this->db->escape($this->email)."' AND entity = ".$this->db->escape(getEntity('mailing', 0)); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2024,8 +2077,7 @@ class Contact extends CommonObject */ public function getNoEmail() { - if ($this->email) - { + if ($this->email) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($this->email)."'"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index da00374cc2a..1e0f5b06094 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -37,8 +37,12 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -if ($id > 0) $object->fetch($id); -if (empty($object->thirdparty)) $object->fetch_thirdparty(); +if ($id > 0) { + $object->fetch($id); +} +if (empty($object->thirdparty)) { + $object->fetch_thirdparty(); +} $socid = $object->thirdparty->id; // Sort & Order fields @@ -46,12 +50,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = 'dateprint'; +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'dateprint'; +} // Search fields $sref = GETPOST("sref"); @@ -60,8 +70,7 @@ $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 -{ +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 = ''; @@ -84,7 +93,9 @@ $hookmanager->initHooks(array('consumptioncontact')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} /* @@ -99,8 +110,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if (empty($id)) -{ +if (empty($id)) { dol_print_error($db); exit; } @@ -111,13 +121,15 @@ print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses" $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; -if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) -{ +if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; @@ -133,22 +145,34 @@ print ''.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); print ''; -if ($object->thirdparty->client) -{ +if ($object->thirdparty->client) { $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->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->thirdparty->fournisseur) -{ +if ($object->thirdparty->fournisseur) { $thirdTypeArray['supplier'] = $langs->trans("supplier"); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { + $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); + } // There no contact type for supplier proposals // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); @@ -166,8 +190,7 @@ print '
'; print ''; $sql_select = ''; -if ($type_element == 'fichinter') -{ // Customer : show products from invoices +if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $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, tc.libelle as type_contact_label, '; @@ -178,8 +201,7 @@ if ($type_element == 'fichinter') $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number = 'f.ref'; -} elseif ($type_element == 'invoice') -{ // Customer : show products from invoices +} elseif ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $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, tc.libelle as type_contact_label, '; @@ -192,8 +214,7 @@ if ($type_element == 'fichinter') $dateprint = 'f.datef'; $doc_number = 'f.ref'; $thirdTypeSelect = 'customer'; -} elseif ($type_element == 'propal') -{ +} elseif ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $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, tc.libelle as type_contact_label, '; @@ -206,8 +227,7 @@ if ($type_element == 'fichinter') $datePrint = 'c.datep'; $doc_number = 'c.ref'; $thirdTypeSelect = 'customer'; -} elseif ($type_element == 'order') -{ +} elseif ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $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, tc.libelle as type_contact_label, '; @@ -220,8 +240,7 @@ if ($type_element == 'fichinter') $dateprint = 'c.date_commande'; $doc_number = 'c.ref'; $thirdTypeSelect = 'customer'; -} elseif ($type_element == 'supplier_invoice') -{ // Supplier : Show products from invoices. +} elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $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, tc.libelle as type_contact_label, '; @@ -234,22 +253,19 @@ if ($type_element == 'fichinter') $dateprint = 'f.datef'; $doc_number = 'f.ref'; $thirdTypeSelect = 'supplier'; -} -//elseif ($type_element == 'supplier_proposal') -//{ -// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -// $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; -// $dateprint = 'c.date_valid'; -// $doc_number='c.ref'; -// $thirdTypeSelect='supplier'; -//} -elseif ($type_element == 'supplier_order') -{ // Supplier : Show products from orders. + //} elseif ($type_element == 'supplier_proposal') { + // require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; + // $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; + // $dateprint = 'c.date_valid'; + // $doc_number='c.ref'; + // $thirdTypeSelect='supplier'; + //} +} elseif ($type_element == 'supplier_order') { // Supplier : Show products from orders. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $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, tc.libelle as type_contact_label, '; @@ -262,8 +278,7 @@ elseif ($type_element == 'supplier_order') $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; $thirdTypeSelect = 'supplier'; -} elseif ($type_element == 'contract') -{ // Order +} elseif ($type_element == 'contract') { // Order require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $documentstatic = new Contrat($db); $documentstaticline = new ContratLigne($db); @@ -282,26 +297,40 @@ elseif ($type_element == 'supplier_order') $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -if (!empty($sql_select)) -{ +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'; + 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 .= " "; - if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; + 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) - { + 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)."%'"; + 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); @@ -332,21 +361,36 @@ $param .= "&type_element=".urlencode($type_element); $total_qty = 0; -if ($sql_select) -{ +if ($sql_select) { $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } $num = $db->num_rows($resql); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); - if ($sref) $param .= "&sref=".urlencode($sref); - if ($month) $param .= "&month=".urlencode($month); - if ($year) $param .= "&year=".urlencode($year); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sprod_fulldescr) { + $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); + } + if ($sref) { + $param .= "&sref=".urlencode($sref); + } + if ($month) { + $param .= "&month=".urlencode($month); + } + if ($year) { + $param .= "&year=".urlencode($year); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); @@ -393,8 +437,7 @@ if ($sql_select) $i = 0; - while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) - { + 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; @@ -405,7 +448,9 @@ if ($sql_select) $documentstatic->paye = $objp->paid; $documentstatic->paid = $objp->paid; - if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status; + if (is_object($documentstaticline)) { + $documentstaticline->statut = $objp->status; + } print ''; print ''; @@ -415,8 +460,7 @@ if ($sql_select) // Status print ''; - if ($type_element == 'contract') - { + if ($type_element == 'contract') { print $documentstaticline->getLibStatut(2); } else { print $documentstatic->getLibStatut(2); @@ -429,8 +473,7 @@ if ($sql_select) $text = ''; $description = ''; $type = 0; // Code to show product duplicated from commonobject->printObjectLine - if ($objp->fk_product > 0) - { + if ($objp->fk_product > 0) { $product_static = new Product($db); $product_static->type = $objp->fk_product_type; @@ -441,20 +484,21 @@ if ($sql_select) } // Product - if ($objp->fk_product > 0) - { + 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)) - { + 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); } @@ -468,42 +512,42 @@ if ($sql_select) $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); } - if (($objp->info_bits & 2) == 2) - { + if (($objp->info_bits & 2) == 2) { print ''; $txt = ''; print img_object($langs->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; print ''; - if ($objp->description) - { - if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) - { + if ($objp->description) { + if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); } - if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) - { + if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) - { + } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); - } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) - { + } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); 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); } @@ -516,15 +560,16 @@ 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) : ''; } } else { - if (!empty($objp->label) || !empty($objp->description)) - { - if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); + if (!empty($objp->label) || !empty($objp->description)) { + 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.''; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 2065ab772e6..6118553914d 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -43,15 +43,16 @@ $object = new Contact($db); $object->getCanvas($id); $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission // Get parameters @@ -59,18 +60,30 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!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 = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref); $modulepart = 'contact'; @@ -90,12 +103,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { + $title = $object->lastname; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $helpurl); -if ($object->id) -{ +if ($object->id) { $head = contact_prepare_head($object); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); @@ -105,22 +119,23 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; @@ -133,23 +148,23 @@ if ($object->id) // Company /* - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; - } + print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; + } - else - { - print ''.$langs->trans("ThirdParty").''; - print $langs->trans("ContactNotLinkedToCompany"); - print ''; - } - }*/ + else + { + print ''.$langs->trans("ThirdParty").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + }*/ // Civility print ''.$langs->trans("UserTitle").''; diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index c39c20d3d25..4cea1cae85b 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -34,7 +34,9 @@ $langs->load("companies"); // Security check $id = GETPOST("id", 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); @@ -51,8 +53,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -if ($id > 0) -{ +if ($id > 0) { $result = $object->fetch($id, $user); $object->info($id); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 78934c5857e..7f84393c858 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -36,12 +36,13 @@ $action = GETPOST('action', 'aZ09'); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -if ($id > 0) -{ +if ($id > 0) { $object->fetch($id, $user); } @@ -50,8 +51,7 @@ if ($id > 0) * Actions */ -if ($action == 'dolibarr2ldap') -{ +if ($action == 'dolibarr2ldap') { $db->begin(); $ldap = new Ldap(); @@ -63,8 +63,7 @@ if ($action == 'dolibarr2ldap') $result = $ldap->update($dn, $info, $user, $olddn); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("ContactSynchronized"), null, 'mesgs'); $db->commit(); } else { @@ -98,8 +97,7 @@ print '
'; print ''; // Company -if ($object->socid > 0) -{ +if ($object->socid > 0) { $thirdparty = new Societe($db); $thirdparty->fetch($object->socid); @@ -139,14 +137,15 @@ print dol_get_fiche_end(); print '
'; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') -{ +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { print ''.$langs->trans("ForceSynchronize").''; } print "
\n"; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n"; +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { + print "
\n"; +} @@ -163,8 +162,7 @@ print ''; // Lecture LDAP $ldap = new Ldap(); $result = $ldap->connect_bind(); -if ($result > 0) -{ +if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; @@ -174,10 +172,8 @@ if ($result > 0) //var_dump($records); // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) - { - if (!is_array($records)) - { + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { print ''; } else { $result = show_ldap_content($records, 0, $records['count'], true); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c33867fed7f..53ebbdfddd9 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -55,7 +55,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'con $id = GETPOST('id', 'int'); $contactid = GETPOST('id', 'int'); $ref = ''; // There is no ref for contacts -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $contactid, ''); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -95,7 +97,9 @@ $search_roles = GETPOST("search_roles", 'array'); $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); -if ($search_status == '') $search_status = 1; // always display active customer first +if ($search_status == '') { + $search_status = 1; // always display active customer first +} $optioncss = GETPOST('optioncss', 'alpha'); @@ -109,31 +113,41 @@ $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $userid = GETPOST('userid', 'int'); $begin = GETPOST('begin'); -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "p.lastname"; -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "p.lastname"; +} +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} $offset = $limit * $page; $titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); -if ($type == "p") -{ - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactprospectlist'; +if ($type == "p") { + if (empty($contextpage) || $contextpage == 'contactlist') { + $contextpage = 'contactprospectlist'; + } $titre .= ' ('.$langs->trans("ThirdPartyProspects").')'; $urlfiche = "card.php"; } -if ($type == "c") -{ - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactcustomerlist'; +if ($type == "c") { + if (empty($contextpage) || $contextpage == 'contactlist') { + $contextpage = 'contactcustomerlist'; + } $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche = "card.php"; -} elseif ($type == "f") -{ - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactsupplierlist'; +} elseif ($type == "f") { + if (empty($contextpage) || $contextpage == 'contactlist') { + $contextpage = 'contactsupplierlist'; + } $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche = "card.php"; -} elseif ($type == "o") -{ - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactotherlist'; +} elseif ($type == "o") { + if (empty($contextpage) || $contextpage == 'contactlist') { + $contextpage = 'contactotherlist'; + } $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; $urlfiche = ""; } @@ -150,8 +164,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // don't allow search in private notes for external users when doing "search in all" if (!empty($user->socid) && $key == "note_private") { continue; @@ -209,10 +222,11 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if (($id > 0 || !empty($ref)) && $action != 'add') -{ +if (($id > 0 || !empty($ref)) && $action != 'add') { $result = $object->fetch($id, $ref); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } } @@ -220,21 +234,25 @@ if (($id > 0 || !empty($ref)) && $action != 'add') * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Did we click on 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 $sall = ""; $search_id = ''; $search_firstlast_only = ""; @@ -281,19 +299,22 @@ if (empty($reshook)) $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($action == 'setstcomm') - { + if ($action == 'setstcomm') { $object = new Contact($db); $result = $object->fetch(GETPOST('stcommcontactid')); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } $action = ''; } } -if ($search_priv < 0) $search_priv = ''; +if ($search_priv < 0) { + $search_priv = ''; +} /* @@ -318,17 +339,18 @@ $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $db->query($sql); -if ($resql) -{ - while ($obj = $db->fetch_object($resql)) - { +if ($resql) { + while ($obj = $db->fetch_object($resql)) { // Compute level text $level = $langs->trans($obj->code); - if ($level == $obj->code) $level = $langs->trans($obj->label); + if ($level == $obj->code) { + $level = $langs->trans($obj->label); + } $tab_level[$obj->code] = $level; } +} else { + dol_print_error($db); } -else dol_print_error($db); $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; @@ -338,64 +360,121 @@ $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as $sql .= " co.label as country, co.code as country_code"; // 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 : ''); + 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."socpeople as p"; -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 (p.rowid = ef.fk_object)"; +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 (p.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; -if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ -if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ -if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +if (!empty($search_categ)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ +} +if (!empty($search_categ_thirdparty)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ +} +if (!empty($search_categ_supplier)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +} $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; -if (!$user->rights->societe->client->voir && !$socid) //restriction -{ +if (!$user->rights->societe->client->voir && !$socid) { //restriction $sql .= " AND (sc.fk_user = ".$user->id." OR p.fk_soc IS NULL)"; } -if (!empty($userid)) // propre au commercial -{ +if (!empty($userid)) { // propre au commercial $sql .= " AND p.fk_user_creat=".$db->escape($userid); } -if ($search_level) $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3); -if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2); - -// Filter to exclude not owned private contacts -if ($search_priv != '0' && $search_priv != '1') -{ - $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))"; -} else { - if ($search_priv == '0') $sql .= " AND p.priv='0'"; - if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")"; +if ($search_level) { + $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3); +} +if ($search_stcomm != '' && $search_stcomm != -2) { + $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2); } -if ($search_categ > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql .= " AND cc.fk_categorie IS NULL"; -if ($search_categ_thirdparty > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty); -if ($search_categ_thirdparty == -2) $sql .= " AND cs.fk_categorie IS NULL"; -if ($search_categ_supplier > 0) $sql .= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); -if ($search_categ_supplier == -2) $sql .= " AND cs2.fk_categorie IS NULL"; +// Filter to exclude not owned private contacts +if ($search_priv != '0' && $search_priv != '1') { + $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))"; +} else { + if ($search_priv == '0') { + $sql .= " AND p.priv='0'"; + } + if ($search_priv == '1') { + $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")"; + } +} -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if (strlen($search_phone)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); -if (strlen($search_cti)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti); -if (strlen($search_firstlast_only)) $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only); +if ($search_categ > 0) { + $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ); +} +if ($search_categ == -2) { + $sql .= " AND cc.fk_categorie IS NULL"; +} +if ($search_categ_thirdparty > 0) { + $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty); +} +if ($search_categ_thirdparty == -2) { + $sql .= " AND cs.fk_categorie IS NULL"; +} +if ($search_categ_supplier > 0) { + $sql .= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); +} +if ($search_categ_supplier == -2) { + $sql .= " AND cs2.fk_categorie IS NULL"; +} -if ($search_id > 0) $sql .= natural_search('p.rowid', $search_id, 1); -if ($search_lastname) $sql .= natural_search('p.lastname', $search_lastname); -if ($search_firstname) $sql .= natural_search('p.firstname', $search_firstname); -if ($search_societe) $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); -if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')'; -if (strlen($search_poste)) $sql .= natural_search('p.poste', $search_poste); -if (strlen($search_phone_perso)) $sql .= natural_search('p.phone_perso', $search_phone_perso); -if (strlen($search_phone_pro)) $sql .= natural_search('p.phone', $search_phone_pro); -if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $search_phone_mobile); -if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax); +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if (strlen($search_phone)) { + $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); +} +if (strlen($search_cti)) { + $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti); +} +if (strlen($search_firstlast_only)) { + $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only); +} + +if ($search_id > 0) { + $sql .= natural_search('p.rowid', $search_id, 1); +} +if ($search_lastname) { + $sql .= natural_search('p.lastname', $search_lastname); +} +if ($search_firstname) { + $sql .= natural_search('p.firstname', $search_firstname); +} +if ($search_societe) { + $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); +} +if ($search_country) { + $sql .= " AND p.fk_pays IN (".$search_country.')'; +} +if (strlen($search_poste)) { + $sql .= natural_search('p.poste', $search_poste); +} +if (strlen($search_phone_perso)) { + $sql .= natural_search('p.phone_perso', $search_phone_perso); +} +if (strlen($search_phone_pro)) { + $sql .= natural_search('p.phone', $search_phone_pro); +} +if (strlen($search_phone_mobile)) { + $sql .= natural_search('p.phone_mobile', $search_phone_mobile); +} +if (strlen($search_fax)) { + $sql .= natural_search('p.fax', $search_fax); +} if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_[$key])) { @@ -403,31 +482,38 @@ if (!empty($conf->socialnetworks->enabled)) { } } } -if (strlen($search_email)) $sql .= natural_search('p.email', $search_email); -if (strlen($search_zip)) $sql .= natural_search("p.zip", $search_zip); -if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); +if (strlen($search_email)) { + $sql .= natural_search('p.email', $search_email); +} +if (strlen($search_zip)) { + $sql .= natural_search("p.zip", $search_zip); +} +if (strlen($search_town)) { + $sql .= natural_search("p.town", $search_town); +} if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } -if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email); -if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); -if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); -if ($type == "o") // filtre sur type -{ +if ($search_no_email != '' && $search_no_email >= 0) { + $sql .= " AND p.no_email = ".$db->escape($search_no_email); +} +if ($search_status != '' && $search_status >= 0) { + $sql .= " AND p.statut = ".$db->escape($search_status); +} +if ($search_import_key) { + $sql .= natural_search("p.import_key", $search_import_key); +} +if ($type == "o") { // filtre sur type $sql .= " AND p.fk_soc IS NULL"; -} elseif ($type == "f") // filtre sur type -{ +} elseif ($type == "f") { // filtre sur type $sql .= " AND s.fournisseur = 1"; -} elseif ($type == "c") // filtre sur type -{ +} elseif ($type == "c") { // filtre sur type $sql .= " AND s.client IN (1, 3)"; -} elseif ($type == "p") // filtre sur type -{ +} elseif ($type == "p") { // filtre sur type $sql .= " AND s.client IN (2, 3)"; } -if (!empty($socid)) -{ +if (!empty($socid)) { $sql .= " AND s.rowid = ".$socid; } // Add where from extra fields @@ -437,8 +523,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Add order -if ($view == "recent") -{ +if ($view == "recent") { $sql .= $db->order("p.datec", "DESC"); } else { $sql .= $db->order($sortfield, $sortorder); @@ -446,12 +531,10 @@ if ($view == "recent") // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -460,8 +543,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } @@ -470,8 +552,7 @@ $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id); @@ -482,39 +563,91 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; llxHeader('', $title, $help_url); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} $param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); $param .= '&type='.urlencode($type).'&view='.urlencode($view); -if (!empty($search_categ)) $param .= '&search_categ='.urlencode($search_categ); -if (!empty($search_categ_thirdparty)) $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty); -if (!empty($search_categ_supplier)) $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); -if ($sall != '') $param .= '&sall='.urlencode($sall); -if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); -if ($search_lastname != '') $param .= '&search_lastname='.urlencode($search_lastname); -if ($search_firstname != '') $param .= '&search_firstname='.urlencode($search_firstname); -if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); -if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); -if ($search_town != '') $param .= '&search_town='.urlencode($search_town); -if ($search_country != '') $param .= "&search_country=".urlencode($search_country); -if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); -if ($search_phone_pro != '') $param .= '&search_phone_pro='.urlencode($search_phone_pro); -if ($search_phone_perso != '') $param .= '&search_phone_perso='.urlencode($search_phone_perso); -if ($search_phone_mobile != '') $param .= '&search_phone_mobile='.urlencode($search_phone_mobile); -if ($search_fax != '') $param .= '&search_fax='.urlencode($search_fax); -if ($search_email != '') $param .= '&search_email='.urlencode($search_email); -if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email); -if ($search_status != '') $param .= '&search_status='.urlencode($search_status); -if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv); -if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm); +if (!empty($search_categ)) { + $param .= '&search_categ='.urlencode($search_categ); +} +if (!empty($search_categ_thirdparty)) { + $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty); +} +if (!empty($search_categ_supplier)) { + $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); +} +if ($sall != '') { + $param .= '&sall='.urlencode($sall); +} +if ($search_id > 0) { + $param .= "&search_id=".urlencode($search_id); +} +if ($search_lastname != '') { + $param .= '&search_lastname='.urlencode($search_lastname); +} +if ($search_firstname != '') { + $param .= '&search_firstname='.urlencode($search_firstname); +} +if ($search_societe != '') { + $param .= '&search_societe='.urlencode($search_societe); +} +if ($search_zip != '') { + $param .= '&search_zip='.urlencode($search_zip); +} +if ($search_town != '') { + $param .= '&search_town='.urlencode($search_town); +} +if ($search_country != '') { + $param .= "&search_country=".urlencode($search_country); +} +if ($search_poste != '') { + $param .= '&search_poste='.urlencode($search_poste); +} +if ($search_phone_pro != '') { + $param .= '&search_phone_pro='.urlencode($search_phone_pro); +} +if ($search_phone_perso != '') { + $param .= '&search_phone_perso='.urlencode($search_phone_perso); +} +if ($search_phone_mobile != '') { + $param .= '&search_phone_mobile='.urlencode($search_phone_mobile); +} +if ($search_fax != '') { + $param .= '&search_fax='.urlencode($search_fax); +} +if ($search_email != '') { + $param .= '&search_email='.urlencode($search_email); +} +if ($search_no_email != '') { + $param .= '&search_no_email='.urlencode($search_no_email); +} +if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); +} +if ($search_priv == '0' || $search_priv == '1') { + $param .= "&search_priv=".urlencode($search_priv); +} +if ($search_stcomm != '') { + $param .= '&search_stcomm='.urlencode($search_stcomm); +} if (is_array($search_level) && count($search_level)) { foreach ($search_level as $slevel) { $param .= '&search_level[]='.urlencode($slevel); } } -if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); +if ($search_import_key != '') { + $param .= '&search_import_key='.urlencode($search_import_key); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if (count($search_roles) > 0) { + $param .= implode('&search_roles[]=', $search_roles); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -525,15 +658,23 @@ $arrayofmassactions = array( // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); +if ($user->rights->societe->supprimer) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if ($user->rights->societe->creer) { + $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); +} +if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -550,35 +691,36 @@ $objecttmp = new Contact($db); $trackid = 'ctc'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } -if ($search_firstlast_only) -{ +if ($search_firstlast_only) { print '
'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'
'; } $moreforfilter = ''; -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); $moreforfilter .= '
'; - if (empty($type) || $type == 'c' || $type == 'p') - { + if (empty($type) || $type == 'c' || $type == 'p') { $moreforfilter .= '
'; - if ($type == 'c') $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; - elseif ($type == 'p') $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; - else $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + if ($type == 'c') { + $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; + } elseif ($type == 'p') { + $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; + } else { + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + } $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); $moreforfilter .= '
'; } - if (empty($type) || $type == 'f') - { + if (empty($type) || $type == 'f') { $moreforfilter .= '
'; $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); @@ -600,45 +742,41 @@ print '
'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} print '
'; print '
'.$langs->trans("ErrorFailedToReadLDAP").'
'."\n"; // Lines for filter fields print ''; -if (!empty($arrayfields['p.rowid']['checked'])) -{ +if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } -if (!empty($arrayfields['p.lastname']['checked'])) -{ +if (!empty($arrayfields['p.lastname']['checked'])) { print ''; } -if (!empty($arrayfields['p.firstname']['checked'])) -{ +if (!empty($arrayfields['p.firstname']['checked'])) { print ''; } -if (!empty($arrayfields['p.poste']['checked'])) -{ +if (!empty($arrayfields['p.poste']['checked'])) { print ''; } -if (!empty($arrayfields['p.zip']['checked'])) -{ +if (!empty($arrayfields['p.zip']['checked'])) { print ''; } -if (!empty($arrayfields['p.town']['checked'])) -{ +if (!empty($arrayfields['p.town']['checked'])) { print ''; @@ -658,44 +796,37 @@ if (!empty($arrayfields['p.town']['checked'])) print ''; }*/ // Country -if (!empty($arrayfields['country.code_iso']['checked'])) -{ +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } -if (!empty($arrayfields['p.phone']['checked'])) -{ +if (!empty($arrayfields['p.phone']['checked'])) { print ''; } -if (!empty($arrayfields['p.phone_perso']['checked'])) -{ +if (!empty($arrayfields['p.phone_perso']['checked'])) { print ''; } -if (!empty($arrayfields['p.phone_mobile']['checked'])) -{ +if (!empty($arrayfields['p.phone_mobile']['checked'])) { print ''; } -if (!empty($arrayfields['p.fax']['checked'])) -{ +if (!empty($arrayfields['p.fax']['checked'])) { print ''; } -if (!empty($arrayfields['p.email']['checked'])) -{ +if (!empty($arrayfields['p.email']['checked'])) { print ''; } -if (!empty($arrayfields['p.no_email']['checked'])) -{ +if (!empty($arrayfields['p.no_email']['checked'])) { print ''; @@ -703,8 +834,7 @@ if (!empty($arrayfields['p.no_email']['checked'])) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - if (!empty($arrayfields['p.'.$key]['checked'])) - { + if (!empty($arrayfields['p.'.$key]['checked'])) { print ''; @@ -712,33 +842,28 @@ if (!empty($conf->socialnetworks->enabled)) { } } } -if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) -{ +if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { print ''; } -if (!empty($arrayfields['p.priv']['checked'])) -{ +if (!empty($arrayfields['p.priv']['checked'])) { print ''; } // Prospect level -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) -{ +if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { print ''; } // Prospect status -if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) -{ +if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print ''; } // Date modification -if (!empty($arrayfields['p.tms']['checked'])) -{ +if (!empty($arrayfields['p.tms']['checked'])) { print ''; } // Status -if (!empty($arrayfields['p.statut']['checked'])) -{ +if (!empty($arrayfields['p.statut']['checked'])) { print ''; } -if (!empty($arrayfields['p.import_key']['checked'])) -{ +if (!empty($arrayfields['p.import_key']['checked'])) { print ''; @@ -786,23 +907,47 @@ print ''; // Ligne des titres print ''; -if (!empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.rowid']['checked'])) { + print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.lastname']['checked'])) { + print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.firstname']['checked'])) { + print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.poste']['checked'])) { + print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.zip']['checked'])) { + print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.town']['checked'])) { + print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder); +} //if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); //if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); } -if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.phone']['checked'])) { + print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.phone_perso']['checked'])) { + print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.phone_mobile']['checked'])) { + print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.fax']['checked'])) { + print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.email']['checked'])) { + print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.no_email']['checked'])) { + print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); +} if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -810,11 +955,21 @@ if (!empty($conf->socialnetworks->enabled)) { } } } -if (!empty($arrayfields['p.fk_soc']['checked'])) print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER["PHP_SELF"], "p.fk_soc", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.fk_soc']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER["PHP_SELF"], "p.fk_soc", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.priv']['checked'])) { + print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -844,8 +999,7 @@ print "\n"; $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -870,44 +1024,50 @@ while ($i < min($num, $limit)) print ''; // ID - if (!empty($arrayfields['p.rowid']['checked'])) - { + if (!empty($arrayfields['p.rowid']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Name - if (!empty($arrayfields['p.lastname']['checked'])) - { + if (!empty($arrayfields['p.lastname']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Firstname - if (!empty($arrayfields['p.firstname']['checked'])) - { + if (!empty($arrayfields['p.firstname']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Job position - if (!empty($arrayfields['p.poste']['checked'])) - { + if (!empty($arrayfields['p.poste']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip - if (!empty($arrayfields['p.zip']['checked'])) - { + if (!empty($arrayfields['p.zip']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Town - if (!empty($arrayfields['p.town']['checked'])) - { + if (!empty($arrayfields['p.town']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State /*if (! empty($arrayfields['state.nom']['checked'])) @@ -922,101 +1082,119 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; }*/ // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Phone - if (!empty($arrayfields['p.phone']['checked'])) - { + if (!empty($arrayfields['p.phone']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Phone perso - if (!empty($arrayfields['p.phone_perso']['checked'])) - { + if (!empty($arrayfields['p.phone_perso']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Phone mobile - if (!empty($arrayfields['p.phone_mobile']['checked'])) - { + if (!empty($arrayfields['p.phone_mobile']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Fax - if (!empty($arrayfields['p.fax']['checked'])) - { + if (!empty($arrayfields['p.fax']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // EMail - if (!empty($arrayfields['p.email']['checked'])) - { + if (!empty($arrayfields['p.email']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // No EMail - if (!empty($arrayfields['p.no_email']['checked'])) - { + if (!empty($arrayfields['p.no_email']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } } } // Company - if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Private/Public - if (!empty($arrayfields['p.priv']['checked'])) - { + if (!empty($arrayfields['p.priv']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) - { + if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { // Prospect level print '"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) - { + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { // Prospect status print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -1026,45 +1204,52 @@ while ($i < min($num, $limit)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['p.datec']['checked'])) - { + if (!empty($arrayfields['p.datec']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['p.tms']['checked'])) - { + if (!empty($arrayfields['p.tms']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['p.statut']['checked'])) - { + if (!empty($arrayfields['p.statut']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.import_key']['checked'])) - { + if (!empty($arrayfields['p.import_key']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; $i++; diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index ae32ef5c95e..9a90cafdd9a 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -36,11 +36,15 @@ $langs->load("companies"); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $id = $user->socid; +if ($user->socid) { + $id = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php @@ -65,12 +69,13 @@ $form = new Form($db); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($id > 0) -{ +if ($id > 0) { /* - * Affichage onglets - */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + * Affichage onglets + */ + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = contact_prepare_head($object); @@ -79,14 +84,16 @@ if ($id > 0) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 0555eb84719..d313712a6a6 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -35,7 +35,9 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); @@ -43,47 +45,43 @@ $object = new Contact($db); * Action */ -if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) -{ +if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { $ret = $object->fetch($id); // Note: Correct date should be completed with location to have exact GM time of birth. $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]); $object->birthday_alert = $_POST["birthday_alert"]; - if (GETPOST('deletephoto')) $object->photo = ''; - elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (GETPOST('deletephoto')) { + $object->photo = ''; + } elseif (!empty($_FILES['photo']['name'])) { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + } $result = $object->update_perso($id, $user); - if ($result > 0) - { + if ($result > 0) { $object->old_name = ''; $object->old_firstname = ''; // Logo/Photo save $dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) - { + if ($file_OK) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - if (GETPOST('deletephoto')) - { + if (GETPOST('deletephoto')) { $fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo; $dirthumbs = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } - if (image_format_supported($_FILES['photo']['name']) > 0) - { + if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); - if (@is_dir($dir)) - { + if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) - { + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { // Create thumbs @@ -94,8 +92,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- setEventMessages("ErrorBadImageFormat", null, 'errors'); } } else { - switch ($_FILES['photo']['error']) - { + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; @@ -118,7 +115,9 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- $now = dol_now(); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { + $title = $object->lastname; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $helpurl); @@ -128,8 +127,7 @@ $object->fetch($id, $user); $head = contact_prepare_head($object); -if ($action == 'edit') -{ +if ($action == 'edit') { /* * Fiche en mode edition */ @@ -151,11 +149,15 @@ if ($action == 'edit') // Photo print ''; // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { + if ($object->socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); @@ -194,8 +194,7 @@ if ($action == 'edit') print ''; print ''; } else { print ''; @@ -221,14 +220,16 @@ if ($action == 'edit') $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1); + } else { + $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } } $morehtmlref .= '
'; @@ -243,23 +244,23 @@ if ($action == 'edit') // Company /* - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''; - } + print ''; + } - else - { - print ''; - } - }*/ + else + { + print ''; + } + }*/ // Civility print ''; - if (!empty($object->birthday)) - { + if (!empty($object->birthday)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; print ''; } else { print ''; @@ -300,15 +307,12 @@ if ($action == 'edit') } -if ($action != 'edit') -{ +if ($action != 'edit') { // Barre d'actions - if ($user->socid == 0) - { + if ($user->socid == 0) { print '
'; - if ($user->rights->societe->contact->creer) - { + if ($user->rights->societe->contact->creer) { print ''.$langs->trans('Modify').''; } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index 05426db19a6..1fba506e910 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -39,8 +39,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $result = $contact->fetch($id); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($contact->error); exit; } @@ -48,8 +47,7 @@ if ($result <= 0) $physicalperson = 1; $company = new Societe($db); -if ($contact->socid) -{ +if ($contact->socid) { $result = $company->fetch($contact->socid); } @@ -76,33 +74,32 @@ $v->setNote($contact->note); $v->setTitle($contact->poste); // Data from linked company -if ($company->id) -{ +if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (!$contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (!$contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (!$contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$contact->phone_pro) { + $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + } + if (!$contact->fax) { + $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + } + if (!$contact->zip) { + $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + } // when company e-mail is empty, use only contact e-mail - if (empty(trim($company->email))) - { + if (empty(trim($company->email))) { // was set before, don't set twice - } - // when contact e-mail is empty, use only company e-mail - elseif (empty(trim($contact->email))) - { + } elseif (empty(trim($contact->email))) { + // when contact e-mail is empty, use only company e-mail $v->setEmail($company->email); - } - // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) - elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) - { + } elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) { + // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) $v->setEmail($contact->email); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); - } - // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) - else { + } else { + // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) @@ -110,12 +107,16 @@ if ($company->id) } // Si contact lie a un tiers non de type "particulier" - if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); + if ($contact->typent_code != 'TE_PRIVATE') { + $v->setOrg($company->name); + } } // Personal informations $v->setPhoneNumber($contact->phone_perso, "TYPE=HOME;VOICE"); -if ($contact->birthday) $v->setBirthday($contact->birthday); +if ($contact->birthday) { + $v->setBirthday($contact->birthday); +} $db->close(); From 2da97c2bacffdeb4ff652525aafb3154448883be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 21:24:38 +0100 Subject: [PATCH 071/173] code syntax contrat directory --- htdocs/contrat/admin/contract_extrafields.php | 17 +- .../contrat/admin/contractdet_extrafields.php | 17 +- htdocs/contrat/agenda.php | 84 +- htdocs/contrat/card.php | 902 +++++++++-------- htdocs/contrat/class/api_contracts.class.php | 61 +- htdocs/contrat/class/contrat.class.php | 914 +++++++++--------- htdocs/contrat/contact.php | 44 +- htdocs/contrat/document.php | 37 +- htdocs/contrat/index.php | 233 +++-- htdocs/contrat/list.php | 478 +++++---- htdocs/contrat/note.php | 36 +- htdocs/contrat/services_list.php | 558 +++++++---- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 21 +- 13 files changed, 1882 insertions(+), 1520 deletions(-) diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 8571856362a..dc361a1f0b6 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -40,13 +40,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'contrat'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +82,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +107,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/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 4b3f03ffedf..6e83f0a4c1b 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -40,13 +40,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'contratdet'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +82,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +107,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/contrat/agenda.php b/htdocs/contrat/agenda.php index f88b470215c..94232aa6afd 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -35,10 +35,11 @@ if (!empty($conf->projet->enabled)) { // Load translation files required by the page $langs->loadLangs(array("companies", "contracts")); -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -50,19 +51,27 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id, ''); $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendacontract', 'globalcard')); @@ -74,20 +83,19 @@ $hookmanager->initHooks(array('agendacontract', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // 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 $actioncode = ''; $search_agenda_label = ''; } @@ -102,19 +110,18 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} -if ($id > 0) -{ +if ($id > 0) { // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); - if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') - { + if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } $result = dol_include_once('/core/modules/contract/'.$module.'.php'); - if ($result > 0) - { + if ($result > 0) { $modCodeContract = new $module(); } @@ -126,10 +133,14 @@ if ($id > 0) $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); - if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) $title = $object->ref." - ".$title; + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) { + $title = $object->ref." - ".$title; + } llxHeader('', $title); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = contract_prepare_head($object); print dol_get_fiche_head($head, 'agenda', $langs->trans("Contract"), -1, 'contract'); @@ -156,14 +167,14 @@ if ($id > 0) $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $permtoedit, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { + if ($user->rights->contrat->creer) { if ($action != 'classify') { //$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).''; $morehtmlref .= ' : '; @@ -231,21 +242,22 @@ if ($id > 0) $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) - { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { + if (!empty($conf->agenda->enabled)) { + 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); } } - 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 = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + 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("ActionsOnContract"), $newcardbutton, ''); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d625298b14c..8a8f91f2a93 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -40,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.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'; @@ -62,7 +64,9 @@ $datecontrat = ''; $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -74,10 +78,12 @@ $extrafields = new ExtraFields($db); // Load object if ($id > 0 || !empty($ref) && $action != 'add') { $ret = $object->fetch($id, $ref); - if ($ret > 0) + if ($ret > 0) { $ret = $object->fetch_thirdparty(); - if ($ret < 0) + } + if ($ret < 0) { dol_print_error('', $object->error); + } } // fetch optionals attributes and labels @@ -98,36 +104,31 @@ $error = 0; $parameters = array('socid' => $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)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) - { + if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { $result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) - { - if (!GETPOST('dateend')) - { + } elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { + if (!GETPOST('dateend')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->close_line($user, GETPOST('ligne'), GETPOST('dateend'), urldecode(GETPOST('comment'))); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -137,16 +138,13 @@ if (empty($reshook)) } // Si ajout champ produit predefini - if (GETPOST('mode') == 'predefined') - { + if (GETPOST('mode') == 'predefined') { $date_start = ''; $date_end = ''; - if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear')) - { + if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear')) { $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); } - if (GETPOST('date_endmonth') && GETPOST('date_endday') && GETPOST('date_endyear')) - { + if (GETPOST('date_endmonth') && GETPOST('date_endday') && GETPOST('date_endyear')) { $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); } } @@ -156,40 +154,32 @@ if (empty($reshook)) $date_end_update = ''; $date_start_real_update = ''; $date_end_real_update = ''; - if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear')) - { + if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear')) { $date_start_update = dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear')); } - if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear')) - { + if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear')) { $date_end_update = dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear')); } - if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear')) - { + if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear')) { $date_start_real_update = dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear')); } - if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear')) - { + if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear')) { $date_end_real_update = dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear')); } - if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear')) - { + if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear')) { $datecontrat = dol_mktime(GETPOST('rehour'), GETPOST('remin'), 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); } // Add contract - if ($action == 'add' && $user->rights->contrat->creer) - { + if ($action == 'add' && $user->rights->contrat->creer) { // Check - if (empty($datecontrat)) - { + if (empty($datecontrat)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; } - if ($socid < 1) - { + if ($socid < 1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); $action = 'create'; $error++; @@ -202,8 +192,7 @@ if (empty($reshook)) $action = 'create'; } - if (!$error) - { + if (!$error) { $object->socid = $socid; $object->date_contrat = $datecontrat; @@ -219,27 +208,28 @@ if (empty($reshook)) $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; - if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) - { + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { $element = $regs[1]; $subelement = $regs[2]; } // For compatibility - if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } $object->origin = $origin; $object->origin_id = $originid; // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) - { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } @@ -248,8 +238,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - if ($id > 0) - { + if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); @@ -257,12 +246,10 @@ if (empty($reshook)) dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { + if ($result > 0) { $srcobject->fetch_thirdparty(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } @@ -270,29 +257,29 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); if ($product_type == 1 || (!empty($conf->global->CONTRACT_SUPPORT_PRODUCTS) && in_array($product_type, array(0, 1)))) { // TODO Exclude also deee // service prédéfini - if ($lines[$i]->fk_product > 0) - { + if ($lines[$i]->fk_product > 0) { $product_static = new Product($db); // 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->id = $lines[$i]->fk_product; $prod->getMultiLangs(); $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; - if (!empty($newlang)) - { + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $srcobject->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -340,8 +327,7 @@ if (empty($reshook)) $lines[$i]->fk_unit ); - if ($result < 0) - { + if ($result < 0) { $error++; break; } @@ -356,16 +342,16 @@ if (empty($reshook)) $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if ($reshook < 0) + if ($reshook < 0) { $error++; + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } else { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -376,18 +362,14 @@ if (empty($reshook)) } } elseif ($action == 'classin' && $user->rights->contrat->creer) { $object->setProject(GETPOST('projectid')); - } - - // Add a new line - elseif ($action == 'addline' && $user->rights->contrat->creer) - { + } elseif ($action == 'addline' && $user->rights->contrat->creer) { + // Add a new line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU')); - if (GETPOST('prod_entry_mode', 'alpha') == 'free') - { + if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { @@ -398,21 +380,18 @@ if (empty($reshook)) $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0); - if ($qty == '') - { + if ($qty == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode', 'alpha') == 'free' && empty($idprod) && empty($product_desc)) - { + if (GETPOST('prod_entry_mode', 'alpha') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; } $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) { setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); $error++; } @@ -428,8 +407,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { // Clean parameters $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -439,15 +417,16 @@ if (empty($reshook)) // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit - if ($idprod > 0) - { + if ($idprod > 0) { $prod = new Product($db); $prod->fetch($idprod); // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -455,14 +434,12 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // On defini prix unitaire - if ($conf->global->PRODUIT_MULTIPRICES && $object->thirdparty->price_level) - { + if ($conf->global->PRODUIT_MULTIPRICES && $object->thirdparty->price_level) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -476,9 +453,13 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines [0]->price_ttc); $price_base_type = $prodcustprice->lines [0]->price_base_type; $tva_tx = $prodcustprice->lines [0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { + $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + } $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } } } } @@ -488,25 +469,26 @@ if (empty($reshook)) // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tmpvat != $tmpprodvat) - { - if ($price_base_type != 'HT') - { + if ($tmpvat != $tmpprodvat) { + if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } - $desc = $prod->description; + $desc = $prod->description; //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; - else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { + $desc = $product_desc; + } else { + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + } $fk_unit = $prod->fk_unit; } else { @@ -523,16 +505,19 @@ if (empty($reshook)) // ajout prix achat $fk_fournprice = $_POST['fournprice']; - if (!empty($_POST['buying_price'])) - $pa_ht = $_POST['buying_price']; - else $pa_ht = null; + if (!empty($_POST['buying_price'])) { + $pa_ht = $_POST['buying_price']; + } else { + $pa_ht = null; + } $info_bits = 0; - if ($tva_npr) $info_bits |= 0x01; + if ($tva_npr) { + $info_bits |= 0x01; + } if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) - || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) - { + || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); $result = -1; } else { @@ -551,22 +536,24 @@ if (empty($reshook)) $price_base_type, $pu_ttc, $info_bits, - $fk_fournprice, - $pa_ht, + $fk_fournprice, + $pa_ht, $array_options, $fk_unit ); } - if ($result > 0) - { + if ($result > 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) // No generation if default type not defined - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) { // No generation if default type not defined $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -615,19 +602,16 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { $error = 0; - if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) - { + if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) { setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); $action = 'editline'; $_GET['rowid'] = GETPOST('elrowid'); $error++; } - if (!$error) - { + if (!$error) { $objectline = new ContratLigne($db); - if ($objectline->fetch(GETPOST('elrowid', 'int')) < 0) - { + if ($objectline->fetch(GETPOST('elrowid', 'int')) < 0) { setEventMessages($objectline->error, $objectline->errors, 'errors'); $error++; } @@ -636,16 +620,20 @@ if (empty($reshook)) $db->begin(); - if (!$error) - { - if ($date_start_real_update == '') $date_start_real_update = $objectline->date_ouverture; - if ($date_end_real_update == '') $date_end_real_update = $objectline->date_cloture; + if (!$error) { + if ($date_start_real_update == '') { + $date_start_real_update = $objectline->date_ouverture; + } + if ($date_end_real_update == '') { + $date_end_real_update = $objectline->date_cloture; + } $vat_rate = GETPOST('eltva_tx'); // Define info_bits $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) + if (preg_match('/\*/', $vat_rate)) { $info_bits |= 0x01; + } // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); @@ -657,17 +645,18 @@ if (empty($reshook)) // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // ajout prix d'achat $fk_fournprice = $_POST['fournprice']; - if (!empty($_POST['buying_price'])) - $pa_ht = $_POST['buying_price']; - else $pa_ht = null; + if (!empty($_POST['buying_price'])) { + $pa_ht = $_POST['buying_price']; + } else { + $pa_ht = null; + } $fk_unit = GETPOST('unit', 'alpha'); @@ -709,43 +698,40 @@ if (empty($reshook)) // TODO verifier price_min si fk_product et multiprix $result = $objectline->update($user); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($objectline->error, $objectline->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); } - } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) - { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->deleteline(GETPOST('lineid'), $user); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) - { + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->validate($user); - if ($result > 0) - { + if ($result > 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -758,49 +744,38 @@ if (empty($reshook)) } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'reopen' && $user->rights->contrat->creer) - { + } elseif ($action == 'reopen' && $user->rights->contrat->creer) { $result = $object->reopen($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Close all lines - elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { + // Close all lines $result = $object->closeAll($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Close all lines - elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { + // Close all lines $result = $object->activateAll($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { $result = $object->delete($user); - if ($result >= 0) - { + if ($result >= 0) { header("Location: list.php?restore_lastsearch_values=1"); return; } else { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { - if (GETPOST('newcid') > 0) - { + if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); $result = $contractline->fetch(GETPOSTINT('lineid')); $contractline->fk_contrat = GETPOSTINT('newcid'); $result = $contractline->update($user, 1); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); return; } else { @@ -809,18 +784,18 @@ if (empty($reshook)) } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("RefNewContract")), null, 'errors'); } - } elseif ($action == 'update_extras') - { + } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $result = $object->insertExtraFields('CONTRACT_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -829,8 +804,7 @@ if (empty($reshook)) if ($error) { $action = 'edit_extras'; } - } elseif ($action == 'setref_supplier') - { + } elseif ($action == 'setref_supplier') { $cancelbutton = GETPOST('cancel', 'alpha'); if (!$cancelbutton) { $object->oldcopy = dol_clone($object); @@ -847,12 +821,10 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } elseif ($action == 'setref_customer') - { + } elseif ($action == 'setref_customer') { $cancelbutton = GETPOST('cancel', 'alpha'); - if (!$cancelbutton) - { + if (!$cancelbutton) { $object->oldcopy = dol_clone($object); $result = $object->setValueFrom('ref_customer', GETPOST('ref_customer', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); @@ -888,11 +860,11 @@ if (empty($reshook)) $new_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $files = dol_dir_list($old_filedir); - if (!empty($files)) - { - if (!is_dir($new_filedir)) dol_mkdir($new_filedir); - foreach ($files as $file) - { + if (!empty($files)) { + if (!is_dir($new_filedir)) { + dol_mkdir($new_filedir); + } + foreach ($files as $file) { dol_move($file['fullname'], $new_filedir.'/'.$file['name']); } } @@ -941,42 +913,31 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) - { - if ($action == 'addcontact') - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { + if ($action == 'addcontact') { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // bascule du statut d'un contact - elseif ($action == 'swapstatut') - { + } elseif ($action == 'swapstatut') { + // bascule du statut d'un contact $result = $object->swapContactStatus(GETPOST('ligne')); - } - - // Efface un contact - elseif ($action == 'deletecontact') - { + } elseif ($action == 'deletecontact') { + // Efface un contact $result = $object->delete_contact(GETPOST('lineid')); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -986,10 +947,8 @@ if (empty($reshook)) } // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes') - { - if (!GETPOST('socid', 3)) - { + if ($action == 'confirm_clone' && $confirm == 'yes') { + if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { if ($object->id > 0) { @@ -998,7 +957,9 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else { - if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); + if (count($object->errors) > 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } $action = ''; } } @@ -1015,53 +976,57 @@ llxHeader('', $langs->trans("Contract"), ""); $form = new Form($db); $formfile = new FormFile($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); -if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') -{ +if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } $result = dol_include_once('/core/modules/contract/'.$module.'.php'); -if ($result > 0) -{ +if ($result > 0) { $modCodeContract = new $module(); } // Create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans('AddContract'), '', 'contract'); $soc = new Societe($db); - if ($socid > 0) $soc->fetch($socid); + if ($socid > 0) { + $soc->fetch($socid); + } - if (GETPOST('origin') && GETPOST('originid')) - { + if (GETPOST('origin') && GETPOST('originid')) { // Parse element/subelement (ex: project_task) $regs = array(); $element = $subelement = GETPOST('origin'); - if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin'), $regs)) - { + if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin'), $regs)) { $element = $regs[1]; $subelement = $regs[2]; } - if ($element == 'project') - { + if ($element == 'project') { $projectid = GETPOST('originid'); } else { // For compatibility - if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'order' || $element == 'commande') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch($originid); - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) $objectsrc->fetch_lines(); + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { + $objectsrc->fetch_lines(); + } $objectsrc->fetch_thirdparty(); // Replicate extrafields @@ -1118,8 +1083,7 @@ if ($action == 'create') // Thirdparty print '
'; print ''; - if ($socid > 0) - { + if ($socid > 0) { print ''."\n"; - if ($socid > 0) - { + if ($socid > 0) { // Ligne info remises tiers print ''; } @@ -1161,8 +1130,7 @@ if ($action == 'create') print ""; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load('projects'); $formproject = new FormProjets($db); @@ -1178,8 +1146,7 @@ if ($action == 'create') print $doleditor->Create(1); print ''; - if (empty($user->socid)) - { + if (empty($user->socid)) { print ''; @@ -1405,22 +1374,19 @@ if ($action == 'create') print ''; - if (!empty($object->brouillon) && $user->rights->contrat->creer) - { + if (!empty($object->brouillon) && $user->rights->contrat->creer) { print ''; } echo '
'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; @@ -1430,19 +1396,20 @@ if ($action == 'create') $arrayothercontracts = $object->getListOfContracts('others'); /* - * Lines of contracts - */ + * Lines of contracts + */ $productstatic = new Product($db); $usemargins = 0; - if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) $usemargins = 1; + if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { + $usemargins = 1; + } // Title line for service $cursorline = 1; print '
'; - while ($cursorline <= $nbofservices) - { + while ($cursorline <= $nbofservices) { print '
'; print '
'; print ''; @@ -1466,8 +1433,7 @@ if ($action == 'create') $sql .= " WHERE cd.rowid = ".$object->lines[$cursorline - 1]->id; $result = $db->query($sql); - if ($result) - { + if ($result) { $total = 0; print '
'; @@ -1478,23 +1444,27 @@ if ($action == 'create') // print ''; //} print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + } print ''; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + print ''; + } print ''; print "\n"; $objp = $db->fetch_object($result); // Line in view mode - if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) - { + if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { $moreparam = ''; - if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { + $moreparam = 'style="display: none;"'; + } print ''; // Label - if ($objp->fk_product > 0) - { + if ($objp->fk_product > 0) { $productstatic->id = $objp->fk_product; $productstatic->type = $objp->ptype; $productstatic->ref = $objp->pref; @@ -1506,16 +1476,14 @@ if ($action == 'create') print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + } // Discount - if ($objp->remise_percent > 0) - { + if ($objp->remise_percent > 0) { print '\n"; } else { print ''; } // Margin - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + print ''; + } // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print '\n"; // Dates of service planed and real - if ($objp->subprice >= 0) - { + if ($objp->subprice >= 0) { $colspan = 6; if ($conf->margin->enabled && $conf->global->PRODUCT_USE_UNITS) { @@ -1592,8 +1559,7 @@ if ($action == 'create') // Date planned print $langs->trans("DateStartPlanned").': '; - if ($objp->date_debut) - { + if ($objp->date_debut) { print dol_print_date($db->jdate($objp->date_debut), 'day'); // Warning si date prevu passee et pas en service if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { @@ -1601,18 +1567,21 @@ if ($action == 'create') $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } - } else print $langs->trans("Unknown"); + } else { + print $langs->trans("Unknown"); + } print '  -  '; print $langs->trans("DateEndPlanned").': '; - if ($objp->date_fin) - { + if ($objp->date_fin) { print dol_print_date($db->jdate($objp->date_fin), 'day'); if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } - } else print $langs->trans("Unknown"); + } else { + print $langs->trans("Unknown"); + } print ''; print ''; @@ -1625,14 +1594,12 @@ if ($action == 'create') $line->fetch_optionals(); print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven', 'style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); } - } - // Line in mode update - else { + } else { + // Line in mode update // Ligne carac print ''; print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) - { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; @@ -1693,10 +1661,11 @@ if ($action == 'create') // Discount print ''; - if (!empty($usemargins)) - { + if (!empty($usemargins)) { print ''; } print ''; $colspan = 6; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++; - if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + $colspan++; + } + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $colspan++; + } // Ligne dates prevues print ''; @@ -1732,10 +1705,11 @@ if ($action == 'create') dol_print_error($db); } - if ($object->statut > 0) - { + if ($object->statut > 0) { $moreparam = ''; - if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { + $moreparam = 'style="display: none;"'; + } print ''; print ''; print "\n"; @@ -1748,22 +1722,21 @@ if ($action == 'create') /* - * Confirmation to delete service line of contract - */ - if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) - { + * Confirmation to delete service line of contract + */ + if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1); - if ($ret == 'html') print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); print ''; print ''; print ''; print ''; print ''; $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); print $form->selectarray('search_priv', $selectarray, $search_priv, 1); print ''; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; $arraystcomm = array(); - foreach ($contactstatic->cacheprospectstatus as $key => $val) - { + foreach ($contactstatic->cacheprospectstatus as $key => $val) { $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap '); @@ -752,26 +877,22 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (!empty($arrayfields['p.datec']['checked'])) -{ +if (!empty($arrayfields['p.datec']['checked'])) { print ''; print ''; print ''; print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status); print ''; print ''; print '
'; print $obj->rowid; print "'; print $contactstatic->getNomUrl(1); print ''.$obj->firstname.''.$obj->poste.''.$obj->zip.''.$obj->town.''; $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''.yn($obj->no_email).''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks).''; - if ($obj->socid) - { + if ($obj->socid) { $objsoc = new Societe($db); $objsoc->fetch($obj->socid); print $objsoc->getNomUrl(1); - } else print ' '; + } else { + print ' '; + } print ''.$contactstatic->LibPubPriv($obj->priv).''; print $contactstatic->getLibProspLevel(); print "
'; print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; foreach ($contactstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($obj->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } } print '
'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''.$contactstatic->getLibStatut(5).''; print $obj->import_key; print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'; print $form->showphoto('contact', $object)."\n"; - if ($object->photo) print "
\n"; + if ($object->photo) { + print "
\n"; + } print ''; - if ($object->photo) print ''; + if ($object->photo) { + print ''; + } print ''; print ''; print '
'.$langs->trans("Delete").'

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

'.$langs->trans("PhotoFile").'
'; @@ -167,10 +169,8 @@ if ($action == 'edit') print '
'.$langs->trans("Firstname").''.$object->firstname.''.$langs->trans("Alert").': '; - if (!empty($object->birthday_alert)) - { + if (!empty($object->birthday_alert)) { print '
'.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).'
'.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).'
'.$langs->trans("ThirdParty").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("ThirdParty").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; @@ -268,8 +269,7 @@ if ($action == 'edit') // Date To Birth print '
'.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); @@ -278,14 +278,21 @@ if ($action == 'edit') //var_dump($birthdatearray); $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + if ($ageyear >= 2) { + print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + } elseif ($agemonth >= 2) { + print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + } else { + print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + } print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); + if ($object->birthday_alert) { + print $langs->trans("BirthdayAlertOn"); + } else { + print $langs->trans("BirthdayAlertOff"); + } print ''.$langs->trans("DateOfBirth").'
'.$langs->trans('ThirdParty').''; print $soc->getNomUrl(1); print ''; @@ -1132,16 +1096,21 @@ if ($action == 'create') } print '
'.$langs->trans('Discounts').''; - if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); + if ($soc->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } print '. '; $absolute_discount = $soc->getAvailableDiscounts(); - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + if ($absolute_discount) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + } else { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } print '.'; print '
'.$langs->trans("NotePrivate").''; $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1206,13 +1173,11 @@ if ($action == 'create') print ''; print ''; - if (is_object($objectsrc)) - { + if (is_object($objectsrc)) { print ''; print ''; - if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) - { + if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) { print '
'.$langs->trans("Note").': '.$langs->trans("OnlyLinesWithTypeServiceAreUsed"); } } @@ -1226,8 +1191,7 @@ if ($action == 'create') { $now = dol_now(); - if ($object->id > 0) - { + if ($object->id > 0) { $object->fetch_thirdparty(); $soc = $object->thirdparty; // $soc is used later @@ -1299,10 +1263,9 @@ if ($action == 'create') print $formconfirm; /* - * Contrat - */ - if (!empty($object->brouillon) && $user->rights->contrat->creer) - { + * Contrat + */ + if (!empty($object->brouillon) && $user->rights->contrat->creer) { print ''; print ''; print ''; @@ -1331,14 +1294,14 @@ if ($action == 'create') $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { + if ($user->rights->contrat->creer) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } @@ -1379,12 +1342,18 @@ if ($action == 'create') // Line info of thirdparty discounts print '
'.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } $absolute_discount = $object->thirdparty->getAvailableDiscounts(); print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + if ($absolute_discount) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + } else { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } print '.'; print '
'.$langs->trans("PriceUHTCurrency").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$langs->trans("BuyingPrice").''.$langs->trans("BuyingPrice").' 
'; $text = $productstatic->getNomUrl(1, '', 32); - if ($objp->plabel) - { + if ($objp->plabel) { $text .= ' - '; $text .= $objp->plabel; } $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 } @@ -1539,35 +1507,35 @@ if ($action == 'create') // Quantity print '
'.$objp->qty.''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''.$objp->remise_percent."% '.price($objp->pa_ht).''.price($objp->pa_ht).''; - if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) - { + if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; print ''; print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow'); print ''; } - if ($user->rights->contrat->creer && ($object->statut >= 0)) - { + if ($user->rights->contrat->creer && ($object->statut >= 0)) { print ''; print img_edit(); print ''; } - if ($user->rights->contrat->creer && ($object->statut >= 0)) - { + if ($user->rights->contrat->creer && ($object->statut >= 0)) { print ''; print img_delete(); print ''; @@ -1577,8 +1545,7 @@ if ($action == 'create') print "
'; - if ($objp->fk_product > 0) - { + if ($objp->fk_product > 0) { $canchangeproduct = 1; if (empty($canchangeproduct)) { $productstatic->id = $objp->fk_product; @@ -1659,7 +1626,9 @@ if ($action == 'create') // editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $nbrows = ROWS_2; - if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { + $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; + } $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); $doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); $doleditor->Create(); @@ -1683,8 +1652,7 @@ if ($action == 'create') print ''; print $form->selectUnits($objp->fk_unit, "unit"); print '%'; - if ($objp->fk_product) print ''; + if ($objp->fk_product) { + print ''; + } print ''; @@ -1706,8 +1675,12 @@ if ($action == 'create') print '

'; + if ($ret == 'html') { + print '
'; + } } /* - * Confirmation to move service toward another contract - */ - if ($action == 'move' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) - { + * Confirmation to move service toward another contract + */ + if ($action == 'move' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { $arraycontractid = array(); - foreach ($arrayothercontracts as $contractcursor) - { + foreach ($arrayothercontracts as $contractcursor) { $arraycontractid[$contractcursor->id] = $contractcursor->ref; } //var_dump($arraycontractid); @@ -1777,10 +1750,9 @@ if ($action == 'create') } /* - * Confirmation de la validation activation - */ - if ($action == 'active' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) - { + * Confirmation de la validation activation + */ + if ($action == 'active' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); $comment = GETPOST('comment', 'alpha'); @@ -1789,16 +1761,14 @@ if ($action == 'create') } /* - * Confirmation de la validation fermeture - */ - if ($action == 'closeline' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) - { + * Confirmation de la validation fermeture + */ + if ($action == 'closeline' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); $comment = GETPOST('comment', 'alpha'); - if (empty($dateactend)) - { + if (empty($dateactend)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEndReal")), null, 'errors'); } else { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne', 'int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService", dol_print_date($dateactend, "%A %d %B %Y")), "confirm_closeline", '', 0, 1); @@ -1808,28 +1778,23 @@ if ($action == 'create') // Area with status and activation info of line - if ($object->statut > 0) - { + if ($object->statut > 0) { print ''; print ''; print ''; print ''; print ''; @@ -1871,8 +1841,7 @@ if ($action == 'create') } // Form to activate line - if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) - { + if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { print ''; print ''; @@ -1880,15 +1849,17 @@ if ($action == 'create') // Definie date debut et fin par defaut $dateactstart = $objp->date_debut; - if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - elseif (!$dateactstart) $dateactstart = time(); + if (GETPOST('remonth')) { + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } elseif (!$dateactstart) { + $dateactstart = time(); + } $dateactend = $objp->date_fin; - if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - elseif (!$dateactend) - { - if ($objp->fk_product > 0) - { + if (GETPOST('endmonth')) { + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } elseif (!$dateactend) { + if ($objp->fk_product > 0) { $product = new Product($db); $product->fetch($objp->fk_product); $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); @@ -1920,8 +1891,7 @@ if ($action == 'create') print ''; } - if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) - { + if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { /** * Disable a contract line */ @@ -1935,28 +1905,30 @@ if ($action == 'create') // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; - if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - elseif (!$dateactstart) $dateactstart = time(); + if (GETPOST('remonth')) { + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } elseif (!$dateactstart) { + $dateactstart = time(); + } $dateactend = $objp->date_fin_reelle; - if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - elseif (!$dateactend) - { - if ($objp->fk_product > 0) - { + if (GETPOST('endmonth')) { + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } elseif (!$dateactend) { + if ($objp->fk_product > 0) { $product = new Product($db); $product->fetch($objp->fk_product); $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); } } $now = dol_now(); - if ($dateactend > $now) $dateactend = $now; + if ($dateactend > $now) { + $dateactend = $now; + } print ''; } } - if (!empty($conf->projet->enabled) && !$this->ispublic) - { + if (!empty($conf->projet->enabled) && !$this->ispublic) { $formproject = new FormProjets($this->db); print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).''; - if ($user->socid == 0) - { - if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') - { + if ($user->socid == 0) { + if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { $tmpaction = 'activateline'; $tmpactionpicto = 'play'; $tmpactiontext = $langs->trans("Activate"); - if ($objp->statut == 4) - { + if ($objp->statut == 4) { $tmpaction = 'unactivateline'; $tmpactionpicto = 'playstop'; $tmpactiontext = $langs->trans("Disable"); } - if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) - { + if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) { print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; @@ -1845,8 +1810,11 @@ if ($action == 'create') // Si pas encore active if (!$objp->date_debut_reelle) { print $langs->trans("DateStartReal").': '; - if ($objp->date_debut_reelle) print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); - else print $langs->trans("ContractStatusNotRunning"); + if ($objp->date_debut_reelle) { + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + } else { + print $langs->trans("ContractStatusNotRunning"); + } } // Si active et en cours if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { @@ -1861,7 +1829,9 @@ if ($action == 'create') print $langs->trans("DateEndReal").': '; print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); } - if (!empty($objp->comment)) print "  -  ".$objp->comment; + if (!empty($objp->comment)) { + print "  -  ".$objp->comment; + } print ' 
'; - if ($objp->statut >= 4) - { - if ($objp->statut == 4) - { + if ($objp->statut >= 4) { + if ($objp->statut == 4) { print $langs->trans("DateEndReal").' '; print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_fin_reelle > 0 ? 0 : 1), "closeline", 1, 1); } @@ -1983,8 +1955,7 @@ if ($action == 'create') print ''; // Form to add new line - if ($user->rights->contrat->creer && ($object->statut == 0)) - { + if ($user->rights->contrat->creer && ($object->statut == 0)) { $dateSelector = 1; print "\n"; @@ -1999,10 +1970,11 @@ if ($action == 'create') print ''; // Array with (n*2)+1 lines // Form to add new line - if ($action != 'editline') - { + if ($action != 'editline') { $forcetoshowtitlelines = 1; - if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts + if (empty($object->multicurrency_code)) { + $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts + } // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); @@ -2020,65 +1992,69 @@ if ($action == 'create') /* - * Buttons - */ + * Buttons + */ - if ($user->socid == 0) - { + if ($user->socid == 0) { print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { // Send if (empty($user->socid)) { if ($object->statut == 1) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) { print ''; - } else print ''; + } else { + print ''; + } } } - if ($object->statut == 0 && $nbofservices) - { - if ($user->rights->contrat->creer) print ''; - else print ''; + if ($object->statut == 0 && $nbofservices) { + if ($user->rights->contrat->creer) { + print ''; + } else { + print ''; + } } - if ($object->statut == 1) - { - if ($user->rights->contrat->creer) print ''; - else print ''; + if ($object->statut == 1) { + if ($user->rights->contrat->creer) { + print ''; + } else { + print ''; + } } - if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) - { + if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { $langs->load("orders"); - if ($user->rights->commande->creer) print ''; - else print ''; + if ($user->rights->commande->creer) { + print ''; + } else { + print ''; + } } - if (!empty($conf->facture->enabled) && $object->statut > 0) - { + if (!empty($conf->facture->enabled) && $object->statut > 0) { $langs->load("bills"); - if ($user->rights->facture->creer) print ''; - else print ''; + if ($user->rights->facture->creer) { + print ''; + } else { + print ''; + } } - if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) - { - if ($user->rights->contrat->activer) - { + if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) { + if ($user->rights->contrat->activer) { print ''; } else { print ''; } } - if ($object->nbofservicesclosed < $nbofservices) - { - if ($user->rights->contrat->desactiver) - { + if ($object->nbofservicesclosed < $nbofservices) { + if ($user->rights->contrat->desactiver) { print ''; } else { print ''; @@ -2093,10 +2069,12 @@ if ($action == 'create') //} } - if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) - { - if ($action == 'showclosedlines') print ''; - else print ''; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) { + if ($action == 'showclosedlines') { + print ''; + } else { + print ''; + } } // Clone @@ -2107,8 +2085,7 @@ if ($action == 'create') // On peut supprimer entite si // - Droit de creer + mode brouillon (erreur creation) // - Droit de supprimer - if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) - { + if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) { print ''; } else { print ''; @@ -2123,13 +2100,12 @@ if ($action == 'create') $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '
'; /* - * Documents generes - */ + * Documents generes + */ $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; @@ -2145,8 +2121,7 @@ if ($action == 'create') $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show direct download link - if ($object->statut != Contrat::STATUS_DRAFT && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) - { + if ($object->statut != Contrat::STATUS_DRAFT && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) { print '
'."\n"; print showDirectDownloadLink($object).'
'; } @@ -2182,8 +2157,7 @@ $db->close(); ?> margin->enabled) && $action == 'editline') -{ +if (!empty($conf->margin->enabled) && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? ?> 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) + 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."contrat 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('contrat').')'; - 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 + 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) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -143,8 +152,7 @@ class Contracts extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -155,13 +163,11 @@ class Contracts extends DolibarrApi dol_syslog("API Rest request"); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $contrat_static = new Contrat($this->db); if ($contrat_static->fetch($obj->rowid)) { @@ -196,12 +202,12 @@ class Contracts extends DolibarrApi $this->contract->$field = $value; } /*if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->contract->lines = $lines; - }*/ + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->contract->lines = $lines; + }*/ if ($this->contract->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating contract", array_merge(array($this->contract->error), $this->contract->errors)); } @@ -491,7 +497,9 @@ class Contracts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->contract->$field = $value; } @@ -667,8 +675,9 @@ class Contracts extends DolibarrApi { $contrat = array(); foreach (Contracts::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $contrat[$field] = $data[$field]; } return $contrat; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 7c99a9483b9..94da51cca8a 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -269,8 +269,7 @@ class Contrat extends CommonObject global $db, $langs, $conf; $langs->load("contracts"); - if (!empty($conf->global->CONTRACT_ADDON)) - { + if (!empty($conf->global->CONTRACT_ADDON)) { $mybool = false; $file = $conf->global->CONTRACT_ADDON.".php"; @@ -286,8 +285,7 @@ class Contrat extends CommonObject $mybool |= @include_once $dir.$file; } - if (!$mybool) - { + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -295,8 +293,7 @@ class Contrat extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -325,8 +322,7 @@ class Contrat extends CommonObject { // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; } @@ -348,8 +344,7 @@ class Contrat extends CommonObject { // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; } @@ -369,7 +364,9 @@ class Contrat extends CommonObject */ public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') { - if (empty($date_start)) $date_start = dol_now(); + if (empty($date_start)) { + $date_start = dol_now(); + } $this->db->begin(); @@ -378,16 +375,13 @@ class Contrat extends CommonObject // Load lines $this->fetch_lines(); - foreach ($this->lines as $contratline) - { + foreach ($this->lines as $contratline) { // Open lines not already open - if ($contratline->statut != ContratLigne::STATUS_OPEN) - { + if ($contratline->statut != ContratLigne::STATUS_OPEN) { $contratline->context = $this->context; $result = $contratline->active_line($user, $date_start, -1, $comment); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $contratline->error; $this->errors = $contratline->errors; @@ -396,14 +390,14 @@ class Contrat extends CommonObject } } - if (!$error && $this->statut == 0) - { + if (!$error && $this->statut == 0) { $result = $this->validate($user, '', $notrigger); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -432,17 +426,14 @@ class Contrat extends CommonObject $error = 0; - foreach ($this->lines as $contratline) - { + foreach ($this->lines as $contratline) { // Close lines not already closed - if ($contratline->statut != ContratLigne::STATUS_CLOSED) - { + if ($contratline->statut != ContratLigne::STATUS_CLOSED) { $contratline->date_cloture = $now; $contratline->fk_user_cloture = $user->id; $contratline->statut = ContratLigne::STATUS_CLOSED; $result = $contratline->close_line($user, $now, $comment, $notrigger); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $contratline->error; $this->errors = $contratline->errors; @@ -451,14 +442,14 @@ class Contrat extends CommonObject } } - if (!$error && $this->statut == 0) - { + if (!$error && $this->statut == 0) { $result = $this->validate($user, '', $notrigger); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -491,76 +482,69 @@ class Contrat extends CommonObject $this->fetch_thirdparty(); // A contract is validated so we can move thirdparty to status customer - if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) - { + if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) { $result = $this->thirdparty->set_as_client(); } // Define new ref - if ($force_number) - { + if ($force_number) { $num = $force_number; - } elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + } elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef($this->thirdparty); } else { $num = $this->ref; } $this->newref = dol_sanitizeFileName($num); - if ($num) - { + if ($num) { $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$this->db->escape($num)."', statut = 1"; //$sql.= ", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; $sql .= " WHERE rowid = ".$this->id." AND statut = 0"; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $error++; $this->error = $this->db->lasterror(); } // Trigger calls - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTRACT_VALIDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'contract/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$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($num); $dirsource = $conf->contract->dir_output.'/'.$oldref; $dirdest = $conf->contract->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -573,8 +557,7 @@ class Contrat extends CommonObject } // Set new ref and define current statut - if (!$error) - { + if (!$error) { $this->ref = $num; $this->statut = 1; $this->brouillon = 0; @@ -584,8 +567,7 @@ class Contrat extends CommonObject $error++; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -621,16 +603,14 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $error++; $this->error = $this->db->lasterror(); } // Trigger calls - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTRACT_REOPEN', $user); if ($result < 0) { @@ -640,15 +620,13 @@ class Contrat extends CommonObject } // Set new ref and define current status - if (!$error) - { + if (!$error) { $this->statut = 0; $this->brouillon = 1; $this->date_validation = $now; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -678,36 +656,32 @@ class Contrat extends CommonObject $sql .= " fk_commercial_signature, fk_commercial_suivi,"; $sql .= " note_private, note_public, model_pdf, extraparams"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat"; - if (!$id) $sql .= " WHERE entity IN (".getEntity('contract').")"; - else $sql .= " WHERE rowid=".(int) $id; - if ($ref_customer) - { + if (!$id) { + $sql .= " WHERE entity IN (".getEntity('contract').")"; + } else { + $sql .= " WHERE rowid=".(int) $id; + } + if ($ref_customer) { $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; } - if ($ref_supplier) - { + if ($ref_supplier) { $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; } - if ($ref) - { + if ($ref) { $sql .= " AND ref='".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 1) - { + if ($num > 1) { $this->error = 'Fetch found several records.'; dol_syslog($this->error, LOG_ERR); $result = -2; - } elseif ($num) // $num = 1 - { + } elseif ($num) { // $num = 1 $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; $this->ref_customer = $obj->ref_customer; @@ -745,8 +719,7 @@ class Contrat extends CommonObject // Lines $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->db->lasterror(); return -3; } @@ -791,8 +764,7 @@ class Contrat extends CommonObject $now = dol_now(); - if (!is_object($extrafields)) - { + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); } @@ -825,13 +797,11 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new ContratLigne($this->db); @@ -908,10 +878,18 @@ class Contrat extends CommonObject //dol_syslog("1 ".$line->desc); //dol_syslog("2 ".$line->product_desc); - if ($line->statut == ContratLigne::STATUS_INITIAL) $this->nbofserviceswait++; - if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; - if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; - if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; + if ($line->statut == ContratLigne::STATUS_INITIAL) { + $this->nbofserviceswait++; + } + if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) { + $this->nbofservicesopened++; + } + if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) { + $this->nbofservicesexpired++; + } + if ($line->statut == ContratLigne::STATUS_CLOSED) { + $this->nbofservicesclosed++; + } $total_ttc += $objp->total_ttc; // TODO Not saved into database $total_vat += $objp->total_tva; @@ -946,20 +924,20 @@ class Contrat extends CommonObject // Check parameters $paramsok = 1; - if ($this->commercial_signature_id <= 0) - { + if ($this->commercial_signature_id <= 0) { $langs->load("commercial"); $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeSignature")); $paramsok = 0; } - if ($this->commercial_suivi_id <= 0) - { + if ($this->commercial_suivi_id <= 0) { $langs->load("commercial"); $this->error .= ($this->error ? "
" : ''); $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeFollowUp")); $paramsok = 0; } - if (!$paramsok) return -1; + if (!$paramsok) { + return -1; + } $this->db->begin(); @@ -985,76 +963,66 @@ class Contrat extends CommonObject $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $error = 0; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat"); // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); - if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') - { + if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } $result = dol_include_once('/core/modules/contract/'.$module.'.php'); - if ($result > 0) - { + if ($result > 0) { $modCodeContract = new $module(); if (!empty($modCodeContract->code_auto)) { // Force the ref to a draft value if numbering module is an automatic numbering $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { - if ($this->id) - { + if ($this->db->query($sql)) { + if ($this->id) { $this->ref = "(PROV".$this->id.")"; } } } } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } // Insert business contacts ('SALESREPSIGN','contrat') - if (!$error) - { + if (!$error) { $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Insert business contacts ('SALESREPFOLL','contrat') if (!$error) { $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -1063,8 +1031,7 @@ class Contrat extends CommonObject { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { $this->error = $this->db->lasterror(); $error++; } @@ -1072,20 +1039,16 @@ class Contrat extends CommonObject } } - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object - { + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) { // Get contact from origin object $originforcontact = $this->origin; $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { + if ($originforcontact == 'shipping') { // shipment and order share the same contacts. If creating from shipment we take data of order require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { + if (count($exp->linkedObjectsIds['commande']) > 0) { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; $originidforcontact = $value->id; break; // We take first one @@ -1097,28 +1060,30 @@ class Contrat extends CommonObject $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + if ($resqlcontact) { + while ($objcontact = $this->db->fetch_object($resqlcontact)) { + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) { + continue; // ignore this, already forced previously + } //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } - } else dol_print_error($resqlcontact); + } else { + dol_print_error($resqlcontact); + } } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CONTRACT_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -1158,29 +1123,29 @@ class Contrat extends CommonObject // Call trigger $result = $this->call_trigger('CONTRACT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); - if ($res < 0) - { + if ($res < 0) { dol_syslog(get_class($this)."::delete error", LOG_ERR); $error++; } } - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Delete contratdet_log /* $sql = "DELETE cdl"; @@ -1193,17 +1158,14 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->error(); $error++; } $numressql = $this->db->num_rows($resql); - if (!$error && $numressql) - { + if (!$error && $numressql) { $tab_resql = array(); - for ($i = 0; $i < $numressql; $i++) - { + for ($i = 0; $i < $numressql; $i++) { $objresql = $this->db->fetch_object($resql); $tab_resql[] = $objresql->cdlrowid; } @@ -1214,8 +1176,7 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->error(); $error++; } @@ -1231,23 +1192,20 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::delete contratdet_extrafields", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->error(); $error++; } } - if (!$error) - { + if (!$error) { // Delete contratdet $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; $sql .= " WHERE fk_contrat=".$this->id; dol_syslog(get_class($this)."::delete contratdet", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->error(); $error++; } @@ -1257,8 +1215,7 @@ class Contrat extends CommonObject if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; $error++; @@ -1266,15 +1223,13 @@ class Contrat extends CommonObject } // Delete contract - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete contrat", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->error(); $error++; } @@ -1283,25 +1238,20 @@ class Contrat extends CommonObject // Removed extrafields if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->contrat->dir_output) - { + if ($conf->contrat->dir_output) { $dir = $conf->contrat->multidir_output[$this->entity]."/".$ref; - if (file_exists($dir)) - { + if (file_exists($dir)) { $res = @dol_delete_dir_recursive($dir); - if (!$res) - { + if (!$res) { $this->error = 'ErrorFailToDeleteDir'; $error++; } @@ -1309,8 +1259,7 @@ class Contrat extends CommonObject } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1333,23 +1282,55 @@ class Contrat extends CommonObject $error = 0; // Clean parameters - if (empty($this->fk_commercial_signature) && $this->commercial_signature_id > 0) $this->fk_commercial_signature = $this->commercial_signature_id; - if (empty($this->fk_commercial_suivi) && $this->commercial_suivi_id > 0) $this->fk_commercial_suivi = $this->commercial_suivi_id; - if (empty($this->fk_soc) && $this->socid > 0) $this->fk_soc = (int) $this->socid; - if (empty($this->fk_project) && $this->projet > 0) $this->fk_project = (int) $this->projet; + if (empty($this->fk_commercial_signature) && $this->commercial_signature_id > 0) { + $this->fk_commercial_signature = $this->commercial_signature_id; + } + if (empty($this->fk_commercial_suivi) && $this->commercial_suivi_id > 0) { + $this->fk_commercial_suivi = $this->commercial_suivi_id; + } + if (empty($this->fk_soc) && $this->socid > 0) { + $this->fk_soc = (int) $this->socid; + } + if (empty($this->fk_project) && $this->projet > 0) { + $this->fk_project = (int) $this->projet; + } - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->ref_customer)) $this->ref_customer = trim($this->ref_customer); - if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); - if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); - if (isset($this->entity)) $this->entity = (int) $this->entity; - if (isset($this->statut)) $this->statut = (int) $this->statut; - if (isset($this->fk_soc)) $this->fk_soc = (int) $this->fk_soc; - if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature = trim($this->fk_commercial_signature); - if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi = trim($this->fk_commercial_suivi); - 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->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } + if (isset($this->ref_customer)) { + $this->ref_customer = trim($this->ref_customer); + } + if (isset($this->ref_supplier)) { + $this->ref_supplier = trim($this->ref_supplier); + } + if (isset($this->ref_ext)) { + $this->ref_ext = trim($this->ref_ext); + } + if (isset($this->entity)) { + $this->entity = (int) $this->entity; + } + if (isset($this->statut)) { + $this->statut = (int) $this->statut; + } + if (isset($this->fk_soc)) { + $this->fk_soc = (int) $this->fk_soc; + } + if (isset($this->fk_commercial_signature)) { + $this->fk_commercial_signature = trim($this->fk_commercial_signature); + } + if (isset($this->fk_commercial_suivi)) { + $this->fk_commercial_suivi = trim($this->fk_commercial_suivi); + } + 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->import_key)) { + $this->import_key = trim($this->import_key); + } //if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); // Check parameters @@ -1377,30 +1358,29 @@ class Contrat extends CommonObject $this->db->begin(); $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) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('CONTRACT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -1444,14 +1424,12 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang"); // Check parameters - if ($fk_product <= 0 && empty($desc)) - { + if ($fk_product <= 0 && empty($desc)) { $this->error = "ErrorDescRequiredForFreeProductLines"; return -1; } - if ($this->statut >= 0) - { + if ($this->statut >= 0) { // Clean parameters $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); @@ -1460,8 +1438,7 @@ class Contrat extends CommonObject // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -1471,23 +1448,38 @@ class Contrat extends CommonObject $remise_percent = price2num($remise_percent); $qty = price2num($qty); - if (empty($qty)) $qty = 1; - if (empty($info_bits)) $info_bits = 0; - if (empty($pu_ht) || !is_numeric($pu_ht)) $pu_ht = 0; - if (empty($pu_ttc)) $pu_ttc = 0; - if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; - if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; + if (empty($qty)) { + $qty = 1; + } + if (empty($info_bits)) { + $info_bits = 0; + } + if (empty($pu_ht) || !is_numeric($pu_ht)) { + $pu_ht = 0; + } + if (empty($pu_ttc)) { + $pu_ttc = 0; + } + if (empty($txtva) || !is_numeric($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) { + $txlocaltax2 = 0; + } - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; } // Check parameters - if (empty($remise_percent)) $remise_percent = 0; + if (empty($remise_percent)) { + $remise_percent = 0; + } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -1518,20 +1510,19 @@ class Contrat extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $remise = 0; $price = price2num(round($pu_ht, 2)); - if (dol_strlen($remise_percent) > 0) - { + if (dol_strlen($remise_percent) > 0) { $remise = round(($pu_ht * $remise_percent / 100), 2); $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) { + $pa_ht = 0; + } // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) - { + if ($this->pa_ht == 0) { + if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) { return $result; } else { $pa_ht = $result; @@ -1545,8 +1536,12 @@ class Contrat extends CommonObject $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; $sql .= " info_bits,"; $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($date_start > 0) { $sql .= ",date_ouverture_prevue"; } - if ($date_end > 0) { $sql .= ",date_fin_validite"; } + if ($date_start > 0) { + $sql .= ",date_ouverture_prevue"; + } + if ($date_end > 0) { + $sql .= ",date_fin_validite"; + } $sql .= ", fk_unit"; $sql .= ") VALUES ("; $sql .= $this->id.", '', '".$this->db->escape($desc)."',"; @@ -1563,28 +1558,35 @@ class Contrat extends CommonObject $sql .= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; $sql .= " '".$this->db->escape($info_bits)."',"; $sql .= " ".price2num($price).",".price2num($remise).","; - if (isset($fk_fournprice)) $sql .= ' '.$fk_fournprice.','; - else $sql .= ' null,'; - if (isset($pa_ht)) $sql .= ' '.price2num($pa_ht); - else $sql .= ' null'; - if ($date_start > 0) { $sql .= ",'".$this->db->idate($date_start)."'"; } - if ($date_end > 0) { $sql .= ",'".$this->db->idate($date_end)."'"; } + if (isset($fk_fournprice)) { + $sql .= ' '.$fk_fournprice.','; + } else { + $sql .= ' null,'; + } + if (isset($pa_ht)) { + $sql .= ' '.price2num($pa_ht); + } else { + $sql .= ' null'; + } + if ($date_start > 0) { + $sql .= ",'".$this->db->idate($date_start)."'"; + } + if ($date_end > 0) { + $sql .= ",'".$this->db->idate($date_end)."'"; + } $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - if (!$error) - { + if (!$error) { $contractline = new ContratLigne($this->db); $contractline->array_options = $array_options; $contractline->id = $contractlineid; $result = $contractline->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->error[] = $contractline->error; $error++; } @@ -1593,15 +1595,13 @@ class Contrat extends CommonObject if (empty($error)) { // Call trigger $result = $this->call_trigger('LINECONTRACT_INSERT', $user); - if ($result < 0) - { + if ($result < 0) { $error++; } // End call triggers } - if ($error) - { + if ($error) { $this->db->rollback(); return -1; } else { @@ -1657,12 +1657,13 @@ class Contrat extends CommonObject $localtax1tx = price2num($localtax1tx); $localtax2tx = price2num($localtax2tx); $pa_ht = price2num($pa_ht); - if (empty($fk_fournprice)) $fk_fournprice = 0; + if (empty($fk_fournprice)) { + $fk_fournprice = 0; + } $subprice = $price; $remise = 0; - if (dol_strlen($remise_percent) > 0) - { + if (dol_strlen($remise_percent) > 0) { $remise = round(($pu * $remise_percent / 100), 2); $price = $pu - $remise; } else { @@ -1701,19 +1702,18 @@ class Contrat extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $remise = 0; $price = price2num(round($pu, 2)); - if (dol_strlen($remise_percent) > 0) - { + if (dol_strlen($remise_percent) > 0) { $remise = round(($pu * $remise_percent / 100), 2); $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) { + $pa_ht = 0; + } // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0) - { + if ($this->pa_ht == 0) { + if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0) { return $result; } else { $pa_ht = $result; @@ -1738,22 +1738,35 @@ class Contrat extends CommonObject $sql .= ", total_ttc='".price2num($total_ttc)."'"; $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql .= ", buy_price_ht='".price2num($pa_ht)."'"; - if ($date_start > 0) { $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } else { $sql .= ",date_ouverture_prevue=null"; } - if ($date_end > 0) { $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; } else { $sql .= ",date_fin_validite=null"; } - if ($date_debut_reel > 0) { $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } else { $sql .= ",date_ouverture=null"; } - if ($date_fin_reel > 0) { $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } else { $sql .= ",date_cloture=null"; } + if ($date_start > 0) { + $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; + } else { + $sql .= ",date_ouverture_prevue=null"; + } + if ($date_end > 0) { + $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; + } else { + $sql .= ",date_fin_validite=null"; + } + if ($date_debut_reel > 0) { + $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; + } else { + $sql .= ",date_ouverture=null"; + } + if ($date_fin_reel > 0) { + $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; + } else { + $sql .= ",date_cloture=null"; + } $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $result = $this->update_statut($user); - if ($result >= 0) - { - if (is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used - { + if ($result >= 0) { + if (is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used $contractline = new ContratLigne($this->db); $contractline->fetch($rowid); $contractline->fetch_optionals(); @@ -1764,8 +1777,7 @@ class Contrat extends CommonObject } $result = $contractline->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->error[] = $contractline->error; $error++; } @@ -1774,8 +1786,7 @@ class Contrat extends CommonObject if (empty($error)) { // Call trigger $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -3; } @@ -1810,11 +1821,12 @@ class Contrat extends CommonObject $error = 0; - if ($this->statut >= 0) - { + if ($this->statut >= 0) { // Call trigger $result = $this->call_trigger('LINECONTRACT_DELETE', $user); - if ($result < 0) return -1; + if ($result < 0) { + return -1; + } // End call triggers $this->db->begin(); @@ -1824,8 +1836,7 @@ class Contrat extends CommonObject dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); $error++; } @@ -1835,8 +1846,7 @@ class Contrat extends CommonObject $contractline = new ContratLigne($this->db); $contractline->id = $idline; $result = $contractline->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = "Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; } @@ -1871,7 +1881,9 @@ class Contrat extends CommonObject dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) - if ($this->statut == 0) return 1; + if ($this->statut == 0) { + return 1; + } // Load $this->lines array // $this->fetch_lines(); @@ -1910,8 +1922,7 @@ class Contrat extends CommonObject // phpcs:enable global $langs; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("contracts"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('ContractStatusDraft'); @@ -1923,10 +1934,11 @@ class Contrat extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) $statusType = 'status6'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status6'; + } - if ($mode == 4 || $mode == 6 || $mode == 7) - { + if ($mode == 4 || $mode == 6 || $mode == 7) { $text = ''; if ($mode == 4) { $text = ''; @@ -1972,8 +1984,12 @@ class Contrat extends CommonObject //{ // 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'; + 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'; + } //} $label = ''; @@ -1999,10 +2015,8 @@ class Contrat extends CommonObject } $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip) && $user->rights->contrat->lire) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowOrder"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -2015,8 +2029,12 @@ class Contrat extends CommonObject $linkend = ''; $result .= $linkstart; - 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 .= ($this->ref ? $this->ref : $this->id); + 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 .= ($this->ref ? $this->ref : $this->id); + } $result .= $linkend; global $action; @@ -2047,10 +2065,8 @@ class Contrat extends CommonObject $sql .= " WHERE c.rowid = ".((int) $id); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -2087,16 +2103,16 @@ class Contrat extends CommonObject $sql = "SELECT cd.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql .= " WHERE fk_contrat =".$this->id; - if ($status >= 0) $sql .= " AND statut = ".$status; + if ($status >= 0) { + $sql .= " AND statut = ".$status; + } dol_syslog(get_class($this)."::array_detail()", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab[$i] = $obj->rowid; $i++; @@ -2121,16 +2137,16 @@ class Contrat extends CommonObject $sql = "SELECT c.rowid, c.ref"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE fk_soc =".$this->socid; - if ($option == 'others') $sql .= " AND c.rowid != ".$this->id; + if ($option == 'others') { + $sql .= " AND c.rowid != ".$this->id; + } dol_syslog(get_class($this)."::getOtherContracts()", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $contrat = new Contrat($this->db); $contrat->fetch($obj->rowid); @@ -2161,25 +2177,24 @@ class Contrat extends CommonObject $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; $this->from .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $this->from .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } - if ($mode == 'inactive') - { + if ($mode == 'inactive') { $sql = "SELECT cd.rowid, cd.date_ouverture_prevue as datefin"; $sql .= $this->from; $sql .= " WHERE c.statut = 1"; $sql .= " AND c.rowid = cd.fk_contrat"; $sql .= " AND cd.statut = 0"; - } elseif ($mode == 'expired') - { + } elseif ($mode == 'expired') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; $sql .= $this->from; $sql .= " WHERE c.statut = 1"; $sql .= " AND c.rowid = cd.fk_contrat"; $sql .= " AND cd.statut = 4"; $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; - } elseif ($mode == 'active') - { + } elseif ($mode == 'active') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; $sql .= $this->from; $sql .= " WHERE c.statut = 1"; @@ -2190,12 +2205,15 @@ class Contrat extends CommonObject } $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; - if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) { + $sql .= " AND c.fk_soc = ".$user->socid; + } + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $langs->load("contracts"); $now = dol_now(); @@ -2225,8 +2243,7 @@ class Contrat extends CommonObject $response->url = $url; $response->img = img_object('', "contract"); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; if ($obj->datefin && $this->db->jdate($obj->datefin) < ($now - $warning_delay)) { @@ -2259,8 +2276,7 @@ class Contrat extends CommonObject $sql = "SELECT count(c.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -2268,10 +2284,8 @@ class Contrat extends CommonObject $sql .= " ".$clause." c.entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["contracts"] = $obj->nb; } $this->db->free($resql); @@ -2328,12 +2342,10 @@ class Contrat extends CommonObject $sql .= $this->db->plimit(100); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_prods = $this->db->num_rows($resql); $i = 0; - while ($i < $num_prods) - { + while ($i < $num_prods) { $i++; $row = $this->db->fetch_row($resql); $prodids[$i] = $row[0]; @@ -2359,8 +2371,7 @@ class Contrat extends CommonObject // Lines $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new ContratLigne($this->db); $line->qty = 1; $line->subprice = 100; @@ -2374,8 +2385,7 @@ class Contrat extends CommonObject $line->date_start_real = dol_now() - 200000; $line->date_end = dol_now() + 500000; $line->date_end_real = dol_now() - 100000; - if ($num_prods > 0) - { + if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; } @@ -2478,15 +2488,12 @@ class Contrat extends CommonObject // Clean data $clonedObj->statut = 0; // Clean extrafields - if (is_array($clonedObj->array_options) && count($clonedObj->array_options) > 0) - { + if (is_array($clonedObj->array_options) && count($clonedObj->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($clonedObj->array_options as $key => $option) - { + foreach ($clonedObj->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); //var_dump($shortkey); var_dump($extrafields->attributes[$this->element]['unique'][$shortkey]); - if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($clonedObj->array_options[$key]); } @@ -2546,8 +2553,9 @@ class Contrat extends CommonObject ); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) + if ($reshook < 0) { $error++; + } } } @@ -2756,12 +2764,15 @@ class ContratLigne extends CommonObjectLine } $statusType = 'status'.$status; - if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + if ($status == self::STATUS_OPEN && $expired == 1) { + $statusType = 'status1'; + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; + } $params = array(); $reg = array(); - if (preg_match('/class="(.*)"/', $moreatt, $reg)) - { + if (preg_match('/class="(.*)"/', $moreatt, $reg)) { $params = array('badgeParams'=>array('css' => $reg[1])); } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); @@ -2780,17 +2791,27 @@ class ContratLigne extends CommonObjectLine $result = ''; $label = $langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label = $this->description; + if (empty($label)) { + $label = $this->description; + } $link = ''; $linkend = ''; $picto = 'service'; - if ($this->type == 0) $picto = 'product'; + if ($this->type == 0) { + $picto = 'product'; + } - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; + if ($withpicto) { + $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + } + if ($withpicto && $withpicto != 2) { + $result .= ' '; + } + if ($withpicto != 2) { + $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; + } return $result; } @@ -2804,7 +2825,9 @@ class ContratLigne extends CommonObjectLine public function fetch($id, $ref = '') { // Check parameters - if (empty($id) && empty($ref)) return -1; + if (empty($id) && empty($ref)) { + return -1; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -2849,15 +2872,17 @@ class ContratLigne extends CommonObjectLine $sql .= " t.commentaire,"; $sql .= " t.fk_unit"; $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - if ($ref) $sql .= " WHERE t.rowid = '".$this->db->escape($ref)."'"; + if ($id) { + $sql .= " WHERE t.rowid = ".$id; + } + if ($ref) { + $sql .= " WHERE t.rowid = '".$this->db->escape($ref)."'"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -2966,18 +2991,40 @@ class ContratLigne extends CommonObjectLine $this->fk_user_cloture = (int) $this->fk_user_cloture; $this->commentaire = trim($this->commentaire); //if (empty($this->subprice)) $this->subprice = 0; - if (empty($this->price_ht)) $this->price_ht = 0; - if (empty($this->total_ht)) $this->total_ht = 0; - if (empty($this->total_tva)) $this->total_tva = 0; - if (empty($this->total_ttc)) $this->total_ttc = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->price_ht)) { + $this->price_ht = 0; + } + if (empty($this->total_ht)) { + $this->total_ht = 0; + } + if (empty($this->total_tva)) { + $this->total_tva = 0; + } + if (empty($this->total_ttc)) { + $this->total_ttc = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } // For backward compatibility - if (empty($this->date_start)) $this->date_start = $this->date_ouverture_prevue; - if (empty($this->date_start_real)) $this->date_start = $this->date_ouverture; - if (empty($this->date_end)) $this->date_start = $this->date_fin_validite; - if (empty($this->date_end_real)) $this->date_start = $this->date_cloture; + if (empty($this->date_start)) { + $this->date_start = $this->date_ouverture_prevue; + } + if (empty($this->date_start_real)) { + $this->date_start = $this->date_ouverture; + } + if (empty($this->date_end)) { + $this->date_start = $this->date_fin_validite; + } + if (empty($this->date_end_real)) { + $this->date_start = $this->date_cloture; + } // Check parameters @@ -2996,13 +3043,13 @@ class ContratLigne extends CommonObjectLine $this->total_localtax1 = $tabprice[9]; $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->pa_ht)) { + $this->pa_ht = 0; + } // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { + if ($this->pa_ht == 0) { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; } else { $this->pa_ht = $result; @@ -3055,46 +3102,38 @@ class ContratLigne extends CommonObjectLine dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); $error++; } - if (!$error) // For avoid conflicts if trigger used - { + if (!$error) { // For avoid conflicts if trigger used $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } // If we change a planned date (start or end), sync dates for all services - if (!$error && !empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) - { - if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) - { + if (!$error && !empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) { + if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; $sql .= " date_ouverture_prevue = ".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null"); $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = "Error ".$this->db->lasterror(); } } - if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) - { + if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; $sql .= " date_fin_validite = ".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null"); $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = "Error ".$this->db->lasterror(); } @@ -3111,8 +3150,7 @@ class ContratLigne extends CommonObjectLine // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -3147,8 +3185,7 @@ class ContratLigne extends CommonObjectLine dol_syslog(get_class($this)."::update_total", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -3178,8 +3215,12 @@ class ContratLigne extends CommonObjectLine $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; $sql .= " info_bits,"; $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($this->date_ouverture_prevue > 0) { $sql .= ",date_ouverture_prevue"; } - if ($this->date_fin_validite > 0) { $sql .= ",date_fin_validite"; } + if ($this->date_ouverture_prevue > 0) { + $sql .= ",date_ouverture_prevue"; + } + if ($this->date_fin_validite > 0) { + $sql .= ",date_fin_validite"; + } $sql .= ") VALUES ($this->fk_contrat, '', '".$this->db->escape($this->description)."',"; $sql .= ($this->fk_product > 0 ? $this->fk_product : "null").","; $sql .= " '".$this->db->escape($this->qty)."',"; @@ -3193,34 +3234,40 @@ class ContratLigne extends CommonObjectLine $sql .= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; $sql .= " '".$this->db->escape($this->info_bits)."',"; $sql .= " ".price2num($this->price_ht).",".price2num($this->remise).","; - if ($this->fk_fournprice > 0) $sql .= ' '.$this->fk_fournprice.','; - else $sql .= ' null,'; - if ($this->pa_ht > 0) $sql .= ' '.price2num($this->pa_ht); - else $sql .= ' null'; - if ($this->date_ouverture > 0) { $sql .= ",'".$this->db->idate($this->date_ouverture)."'"; } - if ($this->date_cloture > 0) { $sql .= ",'".$this->db->idate($this->date_cloture)."'"; } + if ($this->fk_fournprice > 0) { + $sql .= ' '.$this->fk_fournprice.','; + } else { + $sql .= ' null,'; + } + if ($this->pa_ht > 0) { + $sql .= ' '.price2num($this->pa_ht); + } else { + $sql .= ' null'; + } + if ($this->date_ouverture > 0) { + $sql .= ",'".$this->db->idate($this->date_ouverture)."'"; + } + if ($this->date_cloture > 0) { + $sql .= ",'".$this->db->idate($this->date_cloture)."'"; + } $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet'); // Insert of extrafields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINECONTRACT_INSERT', $user); if ($result < 0) { @@ -3260,7 +3307,9 @@ class ContratLigne extends CommonObjectLine $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; $sql .= " date_ouverture = ".(dol_strlen($date) != 0 ? "'".$this->db->idate($date)."'" : "null").","; - if ($date_end >= 0) $sql .= " date_fin_validite = ".(dol_strlen($date_end) != 0 ? "'".$this->db->idate($date_end)."'" : "null").","; + if ($date_end >= 0) { + $sql .= " date_fin_validite = ".(dol_strlen($date_end) != 0 ? "'".$this->db->idate($date_end)."'" : "null").","; + } $sql .= " fk_user_ouverture = ".$user->id.","; $sql .= " date_cloture = null,"; $sql .= " commentaire = '".$this->db->escape($comment)."'"; @@ -3271,11 +3320,12 @@ class ContratLigne extends CommonObjectLine if ($resql) { // Call trigger $result = $this->call_trigger('LINECONTRACT_ACTIVATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->statut = ContratLigne::STATUS_OPEN; $this->date_ouverture = $date; $this->date_fin_validite = $date_end; @@ -3329,10 +3379,8 @@ class ContratLigne extends CommonObjectLine $sql .= " WHERE rowid = ".$this->id." AND statut = ".ContratLigne::STATUS_OPEN; $resql = $this->db->query($sql); - if ($resql) - { - if (!$notrigger) - { + if ($resql) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); if ($result < 0) { diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index c837769819a..35b7268109b 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -43,7 +43,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id); $object = new Contrat($db); @@ -56,19 +58,16 @@ $hookmanager->initHooks(array('contractcard', 'globalcard')); * Actions */ -if ($action == 'addcontact' && $user->rights->contrat->creer) -{ +if ($action == 'addcontact' && $user->rights->contrat->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -84,10 +83,8 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) } // bascule du statut d'un contact -if ($action == 'swapstatut' && $user->rights->contrat->creer) -{ - if ($object->fetch($id)) - { +if ($action == 'swapstatut' && $user->rights->contrat->creer) { + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db, $object->error); @@ -95,13 +92,11 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) } // Delete contact -if ($action == 'deletecontact' && $user->rights->contrat->creer) -{ +if ($action == 'deletecontact' && $user->rights->contrat->creer) { $object->fetch($id); $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -125,10 +120,8 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $head = contract_prepare_head($object); @@ -146,9 +139,9 @@ if ($id > 0 || !empty($ref)) //if (! empty($modCodeContract->code_auto)) { $morehtmlref .= $object->ref; /*} else { - $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); - $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); - }*/ + $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); + $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); + }*/ $morehtmlref .= '
'; // Ref customer @@ -213,8 +206,11 @@ if ($id > 0 || !empty($ref)) } $absolute_discount = $object->thirdparty->getAvailableDiscounts(); print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + if ($absolute_discount) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + } else { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } print '.'; print ''; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index dfdb0fe6d31..8e5b1281c47 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -46,8 +46,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { unset($_GET["action"]); $action = ''; $socid = $user->socid; @@ -59,18 +58,23 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Contrat($db); $object->fetch($id, $ref); -if ($object->id > 0) -{ +if ($object->id > 0) { $object->fetch_thirdparty(); } @@ -97,8 +101,7 @@ $form = new Form($db); llxHeader('', $langs->trans("Contract"), ""); -if ($object->id) -{ +if ($object->id) { $head = contract_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans("Contract"), -1, 'contract'); @@ -107,8 +110,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -136,17 +138,18 @@ if ($object->id) $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') + if ($user->rights->contrat->creer) { + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $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 .= '
'; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 5ea558c9689..6b1aecf1162 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -46,7 +46,9 @@ $statut = GETPOST('statut') ?GETPOST('statut') : 1; // Security check $socid = 0; $id = GETPOST('id', 'int'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id); $staticcompany = new Societe($db); @@ -78,11 +80,9 @@ print load_fiche_titre($langs->trans("ContractsArea"), '', 'contract'); 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 // Search contract - if (!empty($conf->contrat->enabled)) - { + if (!empty($conf->contrat->enabled)) { print ''; print ''; @@ -112,26 +112,28 @@ $vals = array(); $sql = "SELECT count(cd.rowid) as nb, cd.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql .= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))"; $sql .= " AND c.entity IN (".getEntity('contract', 0).")"; -if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND c.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY cd.statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $nb[$obj->status] = $obj->nb; - if ($obj->status != 5) - { + if ($obj->status != 5) { $vals[$obj->status] = $obj->nb; $totalinprocess += $obj->nb; } @@ -147,28 +149,30 @@ if ($resql) $sql = "SELECT count(cd.rowid) as nb, cd.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql .= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')"; $sql .= " AND c.entity IN (".getEntity('contract', 0).")"; -if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND c.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY cd.statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); // 0 inactive, 4 active, 5 closed $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $nb[$obj->status.true] = $obj->nb; - if ($obj->status != 5) - { + if ($obj->status != 5) { $vals[$obj->status.true] = $obj->nb; $totalinprocess += $obj->nb; } @@ -189,26 +193,34 @@ print '
'; print '
'; print ''."\n"; $listofstatus = array(0, 4, 4, 5); $bool = false; -foreach ($listofstatus as $status) -{ +foreach ($listofstatus as $status) { $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); - if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; - if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; - if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; - if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; + if ($status == ContratLigne::STATUS_INITIAL) { + $colorseries[$status.$bool] = '-'.$badgeStatus0; + } + if ($status == ContratLigne::STATUS_OPEN && !$bool) { + $colorseries[$status.$bool] = $badgeStatus4; + } + if ($status == ContratLigne::STATUS_OPEN && $bool) { + $colorseries[$status.$bool] = $badgeStatus1; + } + if ($status == ContratLigne::STATUS_CLOSED) { + $colorseries[$status.$bool] = $badgeStatus6; + } - if (empty($conf->use_javascript_ajax)) - { + if (empty($conf->use_javascript_ajax)) { print ''; print ''; print ''; print "\n"; } - if ($status == 4 && !$bool) $bool = true; - else $bool = false; + if ($status == 4 && !$bool) { + $bool = true; + } else { + $bool = false; + } } -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ''; } $listofstatus = array(0, 4, 4, 5); $bool = false; -foreach ($listofstatus as $status) -{ - if (empty($conf->use_javascript_ajax)) - { +foreach ($listofstatus as $status) { + if (empty($conf->use_javascript_ajax)) { print ''; print ''; print ''; - if ($status == 4 && !$bool) $bool = true; - else $bool = false; + if ($status == 4 && !$bool) { + $bool = true; + } else { + $bool = false; + } print "\n"; } } @@ -245,36 +258,38 @@ print "
'.$langs->trans("Statistics").' - '.$langs->trans("Services").'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -225,15 +237,16 @@ if (!empty($conf->use_javascript_ajax)) print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'

"; // Draft contracts -if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) -{ +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT c.rowid, c.ref,"; $sql .= " s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.rowid = c.fk_soc"; $sql .= " AND c.entity IN (".getEntity('contract', 0).")"; $sql .= " AND c.statut = 0"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $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; + } + if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '
'; print ''; print ''; print ''; - if ($num) - { + if ($num) { $companystatic = new Societe($db); $i = 0; //$tot_ttc = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $staticcontrat->ref = $obj->ref; @@ -319,22 +334,27 @@ $sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AN $sql .= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; $sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +} $sql .= " ".MAIN_DB_PREFIX."contrat as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('contract', 0).")"; $sql .= " AND c.statut > 0"; -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; +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 .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid"; $sql .= " ORDER BY c.tms DESC"; $sql .= " LIMIT ".$max; dol_syslog("contrat/index.php", LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; @@ -347,8 +367,7 @@ if ($result) print ''; print "\n"; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print ''; @@ -356,7 +375,9 @@ if ($result) $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); $staticcontrat->id = $obj->cid; print $staticcontrat->getNomUrl(1, 16); - if ($obj->nb_late) print img_warning($langs->trans("Late")); + if ($obj->nb_late) { + print img_warning($langs->trans("Late")); + } print ''; print ''; print "\n"; - while ($i < min($num, $max)) - { + while ($i < min($num, $max)) { $obj = $db->fetch_object($resql); print ''; @@ -422,8 +447,7 @@ if ($resql) //if (1 == 1) print img_warning($langs->trans("Late")); print ''; print ''; print ''; print "\n"; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; @@ -498,8 +529,7 @@ if ($resql) print $staticcontrat->getNomUrl(1, 16); print ''; print ''; print ''; print "\n"; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; @@ -574,8 +611,7 @@ if ($resql) print $staticcontrat->getNomUrl(1, 16); print ''; print ''; print ''; print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($resqllist); print ''; @@ -7308,23 +7707,27 @@ class Form dol_print_error($this->db); } print ''; - if ($num > 0) - { + if ($num > 0) { } //$linktoelem.=($linktoelem?'   ':''); - if ($num > 0) $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' ('.$num.')
  • '; + if ($num > 0) { + $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' ('.$num.')
  • '; + } //else $linktoelem.=$langs->trans($possiblelink['label']); - else $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' (0)
  • '; + else { + $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' (0)
  • '; + } } } - if ($linktoelemlist) - { + if ($linktoelemlist) { $linktoelem = ' '; print "\n"; - if (is_array($listofactions) && count($listofactions)) - { + if (is_array($listofactions) && count($listofactions)) { $cacheusers = array(); $cursorevent = 0; - foreach ($listofactions as $actioncomm) - { - if ($max && $cursorevent >= $max) break; + foreach ($listofactions as $actioncomm) { + if ($max && $cursorevent >= $max) { + break; + } $ref = $actioncomm->getNomUrl(1, -1); $label = $actioncomm->getNomUrl(0, 36); @@ -244,18 +260,15 @@ class FormActions // Onwer print ''; print ''; } - if ($max && $num > $max) - { + if ($max && $num > $max) { print ''; } @@ -329,7 +343,9 @@ class FormActions // phpcs:enable global $langs, $user, $form, $conf; - if (!is_object($form)) $form = new Form($this->db); + if (!is_object($form)) { + $form = new Form($this->db); + } require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -343,28 +359,37 @@ class FormActions } //asort($arraylist); - if ($selected == 'manual') $selected = 'AC_OTH'; - if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; + if ($selected == 'manual') { + $selected = 'AC_OTH'; + } + if ($selected == 'auto') { + $selected = 'AC_OTH_AUTO'; + } - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) { + unset($arraylist['AC_OTH_AUTO']); + } - $out = ''; + $out = ''; - if (!empty($multiselect)) - { - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); + if (!empty($multiselect)) { + if (!is_array($selected) && !empty($selected)) { + $selected = explode(',', $selected); + } $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth300'.($morecss ? ' '.$morecss : ''), 1); } - if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) - { + if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); } - if ($nooutput) return $out; - else print $out; + if ($nooutput) { + return $out; + } else { + print $out; + } return ''; } } diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 36af8bfa875..f58e567a37d 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -67,45 +67,59 @@ class FormAdmin // phpcs:enable global $conf, $langs; - if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; + if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) { + $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; + } $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly); $out = ''; $out .= ''; // Make select dynamic - if (!$forcecombo) - { + if (!$forcecombo) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } @@ -152,38 +165,45 @@ class FormAdmin // Check parameters - if (!is_array($dirmenuarray)) return -1; + if (!is_array($dirmenuarray)) { + return -1; + } $menuarray = array(); - foreach ($conf->file->dol_document_root as $dirroot) - { - foreach ($dirmenuarray as $dirtoscan) - { + foreach ($conf->file->dol_document_root as $dirroot) { + foreach ($dirmenuarray as $dirtoscan) { $dir = $dirroot.$dirtoscan; //print $dir.'
    '; - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') - { - if (preg_match('/lib\.php$/i', $file)) continue; // We exclude library files - if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files - if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files - if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') { + if (preg_match('/lib\.php$/i', $file)) { + continue; // We exclude library files + } + if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) { + continue; // We exclude all menu manager files + } + if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) { + continue; // We exclude all menu manager files + } + if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) { + continue; // We exclude all menu manager files + } $filelib = preg_replace('/\.php$/i', '', $file); $prefix = ''; // 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other - if (preg_match('/^eldy/i', $file)) $prefix = '0'; - elseif (preg_match('/^smartphone/i', $file)) $prefix = '2'; - else $prefix = '3'; + if (preg_match('/^eldy/i', $file)) { + $prefix = '0'; + } elseif (preg_match('/^smartphone/i', $file)) { + $prefix = '2'; + } else { + $prefix = '3'; + } - if ($file == $selected) - { + if ($file == $selected) { $menuarray[$prefix.'_'.$file] = ''; } else { $menuarray[$prefix.'_'.$file] = ''; @@ -200,20 +220,30 @@ class FormAdmin // Output combo list of menus print ''; $oldprefix = ''; - foreach ($menuarray as $key => $val) - { + foreach ($menuarray as $key => $val) { $tab = explode('_', $key); $newprefix = $tab[0]; print ''."\n"; } print ''; @@ -340,7 +375,9 @@ class FormAdmin ); foreach ($arraytz as $lib => $gmt) { print ''."\n"; } print ''; @@ -368,15 +405,15 @@ class FormAdmin $sql = "SELECT code, label, width, height, unit"; $sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format"; $sql .= " WHERE active=1"; - if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; + if ($filter) { + $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $unitKey = $langs->trans('SizeUnit'.$obj->unit); @@ -391,16 +428,15 @@ class FormAdmin $out = ''; $out .= ''; print ''; print ''; - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { print ''; - else print ''; + } else { + print ''; + } print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; - if (!empty($conf->product->enabled)) - { + if (!empty($conf->product->enabled)) { //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print ''; print ''; print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; } - if (!empty($conf->service->enabled)) - { + if (!empty($conf->service->enabled)) { print ''; print ''; print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; } - if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { print ''; print ''; print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; } print '
    '.$langs->trans("DraftContracts").($num ? ''.$num.'' : '').'
    '.$langs->trans("Services").'
    '; $staticcompany->id = $obj->socid; @@ -388,19 +409,24 @@ $sql .= " s.nom as name,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql .= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql .= " WHERE c.entity IN (".getEntity('contract', 0).")"; $sql .= " AND cd.fk_contrat = c.rowid"; $sql .= " AND c.fk_soc = s.rowid"; -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; +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 cd.tms DESC"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -410,8 +436,7 @@ if ($resql) print '
    '.$langs->trans("LastModifiedServices", $max).'
    '; - if ($obj->fk_product > 0) - { + if ($obj->fk_product > 0) { $productstatic->id = $obj->fk_product; $productstatic->type = $obj->ptype; $productstatic->ref = $obj->pref; @@ -431,8 +455,11 @@ if ($resql) print $productstatic->getNomUrl(1, '', 20); } else { print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + if ($obj->label) { + print ' '.dol_trunc($obj->label, 20).''; + } else { + print ' '.dol_trunc($obj->note, 20); + } } print ''; @@ -462,7 +489,9 @@ $sql .= " s.nom as name,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql .= " WHERE c.entity IN (".getEntity('contract', 0).")"; @@ -470,13 +499,16 @@ $sql .= " AND c.statut = 1"; $sql .= " AND cd.statut = 0"; $sql .= " AND cd.fk_contrat = c.rowid"; $sql .= " AND c.fk_soc = s.rowid"; -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; +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 cd.tms DESC"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -486,8 +518,7 @@ if ($resql) print '
    '.$langs->trans("NotActivatedServices").' '.$num.'
    '; - if ($obj->fk_product > 0) - { + if ($obj->fk_product > 0) { $productstatic->id = $obj->fk_product; $productstatic->type = $obj->ptype; $productstatic->ref = $obj->pref; @@ -507,8 +537,11 @@ if ($resql) print $productstatic->getNomUrl(1, '', 20); } else { print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + if ($obj->label) { + print ' '.dol_trunc($obj->label, 20).''; + } else { + print ' '.dol_trunc($obj->note, 20); + } } print ''; @@ -537,7 +570,9 @@ $sql .= " s.nom as name,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql .= " WHERE c.entity IN (".getEntity('contract', 0).")"; @@ -546,13 +581,16 @@ $sql .= " AND cd.statut = 4"; $sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'"; $sql .= " AND cd.fk_contrat = c.rowid"; $sql .= " AND c.fk_soc = s.rowid"; -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; +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 cd.tms DESC"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -562,8 +600,7 @@ if ($resql) print '
    '.$langs->trans("ListOfExpiredServices").' '.$num.'
    '; - if ($obj->fk_product > 0) - { + if ($obj->fk_product > 0) { $productstatic->id = $obj->fk_product; $productstatic->type = $obj->ptype; $productstatic->ref = $obj->pref; @@ -583,8 +619,11 @@ if ($resql) print $productstatic->getNomUrl(1, '', 20); } else { print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + if ($obj->label) { + print ' '.dol_trunc($obj->label, 20).''; + } else { + print ' '.dol_trunc($obj->note, 20); + } } print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a890b1f3ce2..27cbf5a3a70 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -76,16 +76,24 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'c.ref'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'c.ref'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id); $diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id; @@ -93,7 +101,9 @@ $diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user- $staticcontrat = new Contrat($db); $staticcontratligne = new ContratLigne($db); -if ($search_status == '') $search_status = 1; +if ($search_status == '') { + $search_status = 1; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Contrat($db); @@ -112,7 +122,9 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'c.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall["c.note_private"] = "NotePrivate"; +} $arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>10), @@ -142,18 +154,23 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Action */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $day = ''; $month = ''; $year = ''; @@ -180,8 +197,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options = array(); } -if (empty($reshook)) -{ +if (empty($reshook)) { $objectclass = 'Contrat'; $objectlabel = 'Contracts'; $permissiontoread = $user->rights->contrat->lire; @@ -216,7 +232,9 @@ $sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AN $sql .= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; // 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 : ''); + 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(); @@ -226,34 +244,60 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; -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 (c.rowid = ef.fk_object)"; +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 (c.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; -if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; -if ($search_user > 0) -{ +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +} +if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= ' AND c.entity IN ('.getEntity('contract').')'; -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; -if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; -if ($socid) $sql .= " AND s.rowid = ".$db->escape($socid); -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; +} +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".$search_product_category; +} +if ($socid) { + $sql .= " AND s.rowid = ".$db->escape($socid); +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= dolSqlDateFilter('c.date_contrat', $day, $month, $year); -if ($search_name) $sql .= natural_search('s.nom', $search_name); -if ($search_email) $sql .= natural_search('s.email', $search_email); -if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); -if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer); -if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); -if ($search_sale > 0) -{ +if ($search_name) { + $sql .= natural_search('s.nom', $search_name); +} +if ($search_email) { + $sql .= natural_search('s.email', $search_email); +} +if ($search_contract) { + $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); +} +if (!empty($search_ref_customer)) { + $sql .= natural_search(array('c.ref_customer'), $search_ref_customer); +} +if (!empty($search_ref_supplier)) { + $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); +} +if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; } -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_user > 0) { + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -266,34 +310,36 @@ $sql .= " typent.code,"; $sql .= " state.code_departement, state.nom"; // 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 : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + } } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($search_dfyear > 0 && $search_op2df) -{ - if ($search_op2df == '<=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; - elseif ($search_op2df == '>=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; - else $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; +if ($search_dfyear > 0 && $search_op2df) { + if ($search_op2df == '<=') { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; + } elseif ($search_op2df == '>=') { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + } else { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + } } $sql .= $db->order($sortfield, $sortorder); $totalnboflines = 0; $result = $db->query($sql); -if ($result) -{ +if ($result) { $totalnboflines = $db->num_rows($result); } $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -302,8 +348,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } @@ -311,8 +356,7 @@ if (!$resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id); @@ -329,31 +373,66 @@ $i = 0; $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($socid > 0) -{ +if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - if (empty($search_name)) $search_name = $soc->name; + if (empty($search_name)) { + $search_name = $soc->name; + } } $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($sall != '') $param .= '&sall='.urlencode($sall); -if ($search_contract != '') $param .= '&search_contract='.urlencode($search_contract); -if ($search_name != '') $param .= '&search_name='.urlencode($search_name); -if ($search_email != '') $param .= '&search_email='.urlencode($search_email); -if ($search_ref_customer != '') $param .= '&search_ref_customer='.urlencode($search_ref_customer); -if ($search_ref_supplier != '') $param .= '&search_ref_supplier='.urlencode($search_ref_supplier); -if ($search_op2df != '') $param .= '&search_op2df='.urlencode($search_op2df); -if ($search_dfyear != '') $param .= '&search_dfyear='.urlencode($search_dfyear); -if ($search_dfmonth != '') $param .= '&search_dfmonth='.urlencode($search_dfmonth); -if ($search_sale != '') $param .= '&search_sale='.urlencode($search_sale); -if ($search_user != '') $param .= '&search_user='.urlencode($search_user); -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); -if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); -if ($show_files) $param .= '&show_files='.urlencode($show_files); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall != '') { + $param .= '&sall='.urlencode($sall); +} +if ($search_contract != '') { + $param .= '&search_contract='.urlencode($search_contract); +} +if ($search_name != '') { + $param .= '&search_name='.urlencode($search_name); +} +if ($search_email != '') { + $param .= '&search_email='.urlencode($search_email); +} +if ($search_ref_customer != '') { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); +} +if ($search_ref_supplier != '') { + $param .= '&search_ref_supplier='.urlencode($search_ref_supplier); +} +if ($search_op2df != '') { + $param .= '&search_op2df='.urlencode($search_op2df); +} +if ($search_dfyear != '') { + $param .= '&search_dfyear='.urlencode($search_dfyear); +} +if ($search_dfmonth != '') { + $param .= '&search_dfmonth='.urlencode($search_dfmonth); +} +if ($search_sale != '') { + $param .= '&search_sale='.urlencode($search_sale); +} +if ($search_user != '') { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); +} +if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); +} +if ($show_files) { + $param .= '&show_files='.urlencode($show_files); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -363,16 +442,24 @@ $arrayofmassactions = array( 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->contrat->supprimer) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/contrat/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -388,17 +475,17 @@ $objecttmp = new Contrat($db); $trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } $moreforfilter = ''; // If the user can view prospects other than his' -if ($user->rights->societe->client->voir || $socid) -{ +if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; @@ -406,16 +493,14 @@ if ($user->rights->societe->client->voir || $socid) $moreforfilter .= '
    '; } // If the user can view other users -if ($user->rights->user->user->lire) -{ +if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter .= '
    '; + $moreforfilter .= ''; } // If the user can view categories of products -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -426,11 +511,13 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($use $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; print '
    '; @@ -438,77 +525,75 @@ if (!empty($moreforfilter)) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} print '
    '; print ''."\n"; print ''; -if (!empty($arrayfields['c.ref']['checked'])) -{ +if (!empty($arrayfields['c.ref']['checked'])) { print ''; } -if (!empty($arrayfields['c.ref_customer']['checked'])) -{ +if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; } -if (!empty($arrayfields['c.ref_supplier']['checked'])) -{ +if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } -if (!empty($arrayfields['s.nom']['checked'])) -{ +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } -if (!empty($arrayfields['s.email']['checked'])) -{ +if (!empty($arrayfields['s.email']['checked'])) { print ''; } // Town -if (!empty($arrayfields['s.town']['checked'])) print ''; +if (!empty($arrayfields['s.town']['checked'])) { + print ''; +} // Zip -if (!empty($arrayfields['s.zip']['checked'])) print ''; +if (!empty($arrayfields['s.zip']['checked'])) { + print ''; +} // State -if (!empty($arrayfields['state.nom']['checked'])) -{ +if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country -if (!empty($arrayfields['country.code_iso']['checked'])) -{ +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type -if (!empty($arrayfields['typent.code']['checked'])) -{ +if (!empty($arrayfields['typent.code']['checked'])) { print ''; } -if (!empty($arrayfields['sale_representative']['checked'])) -{ +if (!empty($arrayfields['sale_representative']['checked'])) { print ''; } -if (!empty($arrayfields['c.date_contrat']['checked'])) -{ +if (!empty($arrayfields['c.date_contrat']['checked'])) { // Date contract print ''; } // Date modification -if (!empty($arrayfields['c.tms']['checked'])) -{ +if (!empty($arrayfields['c.tms']['checked'])) { print ''; } // First end date -if (!empty($arrayfields['lower_planned_end_date']['checked'])) -{ +if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; } // Status -if (!empty($arrayfields['status']['checked'])) -{ +if (!empty($arrayfields['status']['checked'])) { print ''; } print ''; print "\n"; print ''; -if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['c.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.ref_customer']['checked'])) { + print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.ref_supplier']['checked'])) { + print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.email']['checked'])) { + print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.date_contrat']['checked'])) { + print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -598,8 +703,7 @@ $totalarray = array(); $typenArray = array(); $cacheCountryIDCode = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $contracttmp->ref = $obj->ref; @@ -632,11 +736,12 @@ while ($i < min($num, $limit)) print ''; // Ref - if (!empty($arrayfields['c.ref']['checked'])) - { + if (!empty($arrayfields['c.ref']['checked'])) { print ''; } - if (!empty($arrayfields['c.ref_customer']['checked'])) - { + if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; } - if (!empty($arrayfields['c.ref_supplier']['checked'])) - { + if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (!empty($arrayfields['s.email']['checked'])) - { + if (!empty($arrayfields['s.email']['checked'])) { print ''; } // Town - if (!empty($arrayfields['s.town']['checked'])) - { + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip - if (!empty($arrayfields['s.zip']['checked'])) - { + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type ent - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['sale_representative']['checked'])) - { + if (!empty($arrayfields['sale_representative']['checked'])) { // Sales representatives print ''; } // Date - if (!empty($arrayfields['c.date_contrat']['checked'])) - { + if (!empty($arrayfields['c.date_contrat']['checked'])) { print ''; } // Extra fields @@ -767,32 +874,34 @@ while ($i < min($num, $limit)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['c.datec']['checked'])) - { + if (!empty($arrayfields['c.datec']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['c.tms']['checked'])) - { + if (!empty($arrayfields['c.tms']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date lower end date - if (!empty($arrayfields['lower_planned_end_date']['checked'])) - { + if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['status']['checked'])) - { + if (!empty($arrayfields['status']['checked'])) { print ''; print ''; print ''; @@ -800,14 +909,17 @@ while ($i < min($num, $limit)) } // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; $i++; @@ -824,7 +936,9 @@ print ''; print ''; $hidegeneratedfilelistifempty = 1; -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; +} // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index c9000c4fb0d..d61ac357a40 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -41,7 +41,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $id); $object = new Contrat($db); @@ -70,8 +72,7 @@ llxHeader('', $langs->trans("Contract"), ""); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = contract_prepare_head($object); @@ -89,9 +90,9 @@ if ($id > 0 || !empty($ref)) //if (! empty($modCodeContract->code_auto)) { $morehtmlref .= $object->ref; /*} else { - $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); - $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); - }*/ + $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); + $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); + }*/ $morehtmlref .= '
    '; // Ref customer @@ -104,15 +105,14 @@ if ($id > 0 || !empty($ref)) // Thirdparty $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').' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') + if ($user->rights->contrat->creer) { + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $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 .= '
    '; @@ -150,12 +150,18 @@ if ($id > 0 || !empty($ref)) // Ligne info remises tiers print '
    '; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 4de651a24f9..072982e56eb 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -39,12 +39,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "c.rowid"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "c.rowid"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $mode = GETPOST("mode"); $filter = GETPOST("filter"); @@ -90,22 +96,32 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Security check $contratid = GETPOST('id', 'int'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'contrat', $contratid); -if ($search_status != '') -{ +if ($search_status != '') { $tmp = explode('&', $search_status); $mode = $tmp[0]; - if (empty($tmp[1])) $filter = ''; - else { - if ($tmp[1] == 'filter=notexpired') $filter = 'notexpired'; - if ($tmp[1] == 'filter=expired') $filter = 'expired'; + if (empty($tmp[1])) { + $filter = ''; + } else { + if ($tmp[1] == 'filter=notexpired') { + $filter = 'notexpired'; + } + if ($tmp[1] == 'filter=expired') { + $filter = 'expired'; + } } } else { $search_status = $mode; - if ($filter == 'expired') $search_status .= '&filter=expired'; - if ($filter == 'notexpired') $search_status .= '&filter=notexpired'; + if ($filter == 'expired') { + $search_status .= '&filter=expired'; + } + if ($filter == 'notexpired') { + $search_status .= '&filter=notexpired'; + } } $staticcontrat = new Contrat($db); @@ -142,21 +158,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $search_product_category = 0; + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + $search_product_category = 0; $search_name = ""; $search_contract = ""; $search_service = ""; @@ -197,7 +217,9 @@ $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref $sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; $sql .= " cd.rowid, cd.description, cd.statut,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " sc.fk_soc, sc.fk_user,"; +} $sql .= " cd.date_ouverture_prevue,"; $sql .= " cd.date_ouverture,"; $sql .= " cd.date_fin_validite,"; @@ -211,7 +233,9 @@ $sql .= " cd.subprice,"; $sql .= " cd.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 : ''); + 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(); @@ -219,50 +243,102 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +} $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; -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 (cd.rowid = ef.fk_object)"; +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 (cd.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +} $sql .= " WHERE c.entity = ".$conf->entity; $sql .= " AND c.rowid = cd.fk_contrat"; -if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".$search_product_category; +} $sql .= " AND c.fk_soc = s.rowid"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($mode == "0") $sql .= " AND cd.statut = 0"; -if ($mode == "4") $sql .= " AND cd.statut = 4"; -if ($mode == "5") $sql .= " AND cd.statut = 5"; -if ($filter == "expired") $sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'"; -if ($filter == "notexpired") $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; -if ($search_name) $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; -if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; -if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; -if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} +if ($mode == "0") { + $sql .= " AND cd.statut = 0"; +} +if ($mode == "4") { + $sql .= " AND cd.statut = 4"; +} +if ($mode == "5") { + $sql .= " AND cd.statut = 5"; +} +if ($filter == "expired") { + $sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'"; +} +if ($filter == "notexpired") { + $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; +} +if ($search_name) { + $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; +} +if ($search_contract) { + $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; +} +if ($search_service) { + $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; +} +if ($socid > 0) { + $sql .= " AND s.rowid = ".$socid; +} $filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); $filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); -if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = ' BETWEEN '; +if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) { + $filter_opouvertureprevue = ' BETWEEN '; +} $filter_date1_start = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); $filter_date1_end = dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); -if ($filter_date1_start != '' && $filter_op1 == -1) $filter_op1 = ' BETWEEN '; +if ($filter_date1_start != '' && $filter_op1 == -1) { + $filter_op1 = ' BETWEEN '; +} $filter_date2_start = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); $filter_date2_end = dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); -if ($filter_date2_start != '' && $filter_op2 == -1) $filter_op2 = ' BETWEEN '; +if ($filter_date2_start != '' && $filter_op2 == -1) { + $filter_op2 = ' BETWEEN '; +} $filter_datecloture_start = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); $filter_datecloture_end = dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); -if ($filter_datecloture_start != '' && $filter_opcloture == -1) $filter_opcloture = ' BETWEEN '; +if ($filter_datecloture_start != '' && $filter_opcloture == -1) { + $filter_opcloture = ' BETWEEN '; +} -if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; -if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; -if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; -if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date1_end)."'"; -if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; -if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date2_end)."'"; -if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; -if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') { + $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; +} +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') { + $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; +} +if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') { + $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; +} +if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') { + $sql .= " AND '".$db->idate($filter_date1_end)."'"; +} +if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') { + $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; +} +if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') { + $sql .= " AND '".$db->idate($filter_date2_end)."'"; +} +if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') { + $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; +} +if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') { + $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -270,12 +346,10 @@ $sql .= $db->order($sortfield, $sortorder); //print $sql; $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -286,8 +360,7 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog("contrat/services_list.php", LOG_DEBUG); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } @@ -297,31 +370,63 @@ $num = $db->num_rows($resql); /* if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->id; - header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->id; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); + exit; }*/ llxHeader(null, $langs->trans("Services")); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($search_contract) $param .= '&search_contract='.urlencode($search_contract); -if ($search_name) $param .= '&search_name='.urlencode($search_name); -if ($search_service) $param .= '&search_service='.urlencode($search_service); -if ($mode) $param .= '&mode='.urlencode($mode); -if ($filter) $param .= '&filter='.urlencode($filter); -if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) $param .= '&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue); -if (!empty($filter_op1) && $filter_op1 != -1) $param .= '&filter_op1='.urlencode($filter_op1); -if (!empty($filter_op2) && $filter_op2 != -1) $param .= '&filter_op2='.urlencode($filter_op2); -if (!empty($filter_opcloture) && $filter_opcloture != -1) $param .= '&filter_opcloture='.urlencode($filter_opcloture); -if ($filter_dateouvertureprevue != '') $param .= '&opouvertureprevueday='.$opouvertureprevueday.'&opouvertureprevuemonth='.$opouvertureprevuemonth.'&opouvertureprevueyear='.$opouvertureprevueyear; -if ($filter_date1 != '') $param .= '&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year; -if ($filter_date2 != '') $param .= '&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year; -if ($filter_datecloture != '') $param .= '&opclotureday='.$op2day.'&opcloturemonth='.$op2month.'&opclotureyear='.$op2year; -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} +if ($search_contract) { + $param .= '&search_contract='.urlencode($search_contract); +} +if ($search_name) { + $param .= '&search_name='.urlencode($search_name); +} +if ($search_service) { + $param .= '&search_service='.urlencode($search_service); +} +if ($mode) { + $param .= '&mode='.urlencode($mode); +} +if ($filter) { + $param .= '&filter='.urlencode($filter); +} +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) { + $param .= '&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue); +} +if (!empty($filter_op1) && $filter_op1 != -1) { + $param .= '&filter_op1='.urlencode($filter_op1); +} +if (!empty($filter_op2) && $filter_op2 != -1) { + $param .= '&filter_op2='.urlencode($filter_op2); +} +if (!empty($filter_opcloture) && $filter_opcloture != -1) { + $param .= '&filter_opcloture='.urlencode($filter_opcloture); +} +if ($filter_dateouvertureprevue != '') { + $param .= '&opouvertureprevueday='.$opouvertureprevueday.'&opouvertureprevuemonth='.$opouvertureprevuemonth.'&opouvertureprevueyear='.$opouvertureprevueyear; +} +if ($filter_date1 != '') { + $param .= '&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year; +} +if ($filter_date2 != '') { + $param .= '&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year; +} +if ($filter_datecloture != '') { + $param .= '&opclotureday='.$op2day.'&opcloturemonth='.$op2month.'&opclotureyear='.$op2year; +} +if ($optioncss != '') { + $param .= '&optioncss='.$optioncss; +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -335,7 +440,9 @@ $arrayofmassactions = array( $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -345,24 +452,32 @@ print ''; print ''; $title = $langs->trans("ListOfServices"); -if ($mode == "0") $title = $langs->trans("ListOfInactiveServices"); // Must use == "0" -if ($mode == "4" && $filter != "expired") $title = $langs->trans("ListOfRunningServices"); -if ($mode == "4" && $filter == "expired") $title = $langs->trans("ListOfExpiredServices"); -if ($mode == "5") $title = $langs->trans("ListOfClosedServices"); +if ($mode == "0") { + $title = $langs->trans("ListOfInactiveServices"); // Must use == "0" +} +if ($mode == "4" && $filter != "expired") { + $title = $langs->trans("ListOfRunningServices"); +} +if ($mode == "4" && $filter == "expired") { + $title = $langs->trans("ListOfExpiredServices"); +} +if ($mode == "5") { + $title = $langs->trans("ListOfClosedServices"); +} print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, '', '', $limit); -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } $morefilter = ''; // If the user can view categories of products -if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) -{ +if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -373,12 +488,14 @@ if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights- $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; print '
    '; @@ -392,33 +509,62 @@ print '
    '; print '
    '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); print ''; //print $langs->trans('Month').': '; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; @@ -523,20 +608,17 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (!empty($arrayfields['c.datec']['checked'])) -{ +if (!empty($arrayfields['c.datec']['checked'])) { print ''; print ''; print ''; $arrayofoperators = array('0'=>'', '='=>'=', '<='=>'<=', '>='=>'>='); print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth50imp'); @@ -547,8 +629,7 @@ if (!empty($arrayfields['lower_planned_end_date']['checked'])) print ''; @@ -558,18 +639,42 @@ print '
    '; print $contracttmp->getNomUrl(1); - if ($obj->nb_late) print img_warning($langs->trans("Late")); + if ($obj->nb_late) { + print img_warning($langs->trans("Late")); + } if (!empty($obj->note_private) || !empty($obj->note_public)) { print ' '; print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; @@ -652,16 +757,13 @@ while ($i < min($num, $limit)) print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.$obj->ref_supplier.''; if ($obj->socid > 0) { // TODO Use a cache for this string @@ -669,57 +771,63 @@ while ($i < min($num, $limit)) } print ''.$obj->email.''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; print $socstatic->country; print ''; - if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } print $typenArray[$obj->typent_code]; print ''; - if ($obj->socid > 0) - { + if ($obj->socid > 0) { $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) dol_print_error($db); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 6) { // We print only number @@ -756,8 +864,7 @@ while ($i < min($num, $limit)) print ''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); print ''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print ''; } print '
    '.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } $absolute_discount = $object->thirdparty->getAvailableDiscounts(); print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + if ($absolute_discount) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + } else { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } print '.'; print '
    '."\n"; print ''; -if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.description']['checked'])) print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['cd.qty']['checked'])) print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['cd.total_ht']['checked'])) print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['cd.total_tva']['checked'])) print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['cd.tva_tx']['checked'])) print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['cd.subprice']['checked'])) print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['cd.date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['cd.date_cloture']['checked'])) print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.description']['checked'])) { + print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['cd.qty']['checked'])) { + print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.tva_tx']['checked'])) { + print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.subprice']['checked'])) { + print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_ouverture']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['cd.tms']['checked'])) print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['cd.datec']['checked'])) { + print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.tms']['checked'])) { + print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['status']['checked'])) { + print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; print ''; -if (!empty($arrayfields['c.ref']['checked'])) -{ +if (!empty($arrayfields['c.ref']['checked'])) { print ''; } // Service label -if (!empty($arrayfields['p.description']['checked'])) -{ +if (!empty($arrayfields['p.description']['checked'])) { print ''; } // detail lines -if (!empty($arrayfields['cd.qty']['checked'])) -{ +if (!empty($arrayfields['cd.qty']['checked'])) { print ''; } -if (!empty($arrayfields['cd.total_ht']['checked'])) -{ +if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; } -if (!empty($arrayfields['cd.total_tva']['checked'])) -{ +if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; } -if (!empty($arrayfields['cd.tva_tx']['checked'])) -{ +if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; } -if (!empty($arrayfields['cd.subprice']['checked'])) -{ +if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; } // Third party -if (!empty($arrayfields['s.nom']['checked'])) -{ +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } -if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) -{ +if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; } -if (!empty($arrayfields['cd.date_ouverture']['checked'])) -{ +if (!empty($arrayfields['cd.date_ouverture']['checked'])) { print ''; } -if (!empty($arrayfields['cd.date_fin_validite']['checked'])) -{ +if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { print ''; } -if (!empty($arrayfields['cd.date_cloture']['checked'])) -{ +if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''; } -if (!empty($arrayfields['cd.tms']['checked'])) -{ +if (!empty($arrayfields['cd.tms']['checked'])) { // Date modification print ''; } -if (!empty($arrayfields['status']['checked'])) -{ +if (!empty($arrayfields['status']['checked'])) { // Status print ''; // Ref - if (!empty($arrayfields['c.ref']['checked'])) - { + if (!empty($arrayfields['c.ref']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Service - if (!empty($arrayfields['p.description']['checked'])) - { + if (!empty($arrayfields['p.description']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cd.qty']['checked'])) - { + if (!empty($arrayfields['cd.qty']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cd.total_ht']['checked'])) - { + if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; + } $totalarray['val']['cd.total_ht'] += $obj->total_ht; } - if (!empty($arrayfields['cd.total_tva']['checked'])) - { + if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; + } $totalarray['val']['cd.total_tva'] += $obj->total_tva; } - if (!empty($arrayfields['cd.tva_tx']['checked'])) - { + if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cd.subprice']['checked'])) - { + if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Third party - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Start date - if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) - { + if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cd.date_ouverture']['checked'])) - { + if (!empty($arrayfields['cd.date_ouverture']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // End date - if (!empty($arrayfields['cd.date_fin_validite']['checked'])) - { + if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Close date (real end date) - if (!empty($arrayfields['cd.date_cloture']['checked'])) - { + if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -691,45 +846,50 @@ while ($i < min($num, $limit)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['cd.datec']['checked'])) - { + if (!empty($arrayfields['cd.datec']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['cd.tms']['checked'])) - { + if (!empty($arrayfields['cd.tms']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['status']['checked'])) - { + if (!empty($arrayfields['status']['checked'])) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; $i++; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 339f51db22c..310e2bd00b9 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -17,8 +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; } @@ -37,24 +36,24 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("contracts"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - - - + + + - '; } print '
    '; print ''; print ''; @@ -426,49 +572,41 @@ if (!empty($arrayfields['c.ref']['checked'])) print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $arrayofoperators = array('<'=>'<', '>'=>'>'); print $form->selectarray('filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1); @@ -477,8 +615,7 @@ if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print $form->selectDate($filter_dateouvertureprevue, 'opouvertureprevue', 0, 0, 1, '', 1, 0); print ''; $arrayofoperators = array('<'=>'<', '>'=>'>'); print $form->selectarray('filter_op1', $arrayofoperators, $filter_op1, 1); @@ -487,8 +624,7 @@ if (!empty($arrayfields['cd.date_ouverture']['checked'])) print $form->selectDate($filter_date1, 'op1', 0, 0, 1, '', 1, 0); print ''; $arrayofoperators = array('<'=>'<', '>'=>'>'); print $form->selectarray('filter_op2', $arrayofoperators, $filter_op2, 1); @@ -497,8 +633,7 @@ if (!empty($arrayfields['cd.date_fin_validite']['checked'])) print $form->selectDate($filter_date2, 'op2', 0, 0, 1, '', 1, 0); print ''; $arrayofoperators = array('<'=>'<', '>'=>'>'); print $form->selectarray('filter_opcloture', $arrayofoperators, $filter_opcloture, 1); @@ -514,20 +649,17 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['cd.datec']['checked'])) -{ +if (!empty($arrayfields['cd.datec']['checked'])) { // Date creation print ''; print ''; print ''; $arrayofstatus = array( @@ -552,8 +684,7 @@ $productstatic = new Product($db); $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $contractstatic->id = $obj->cid; @@ -570,118 +701,142 @@ while ($i < min($num, $limit)) print '
    '; print $contractstatic->getNomUrl(1, 16); print ''; - if ($obj->pid > 0) - { + if ($obj->pid > 0) { $productstatic->id = $obj->pid; $productstatic->type = $obj->ptype; $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 24); print $obj->label ? ' - '.dol_trunc($obj->label, 16) : ''; - if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) print '
    '.dol_nl2br($obj->description); + if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) { + print '
    '.dol_nl2br($obj->description); + } } else { - if ($obj->type == 0) print img_object($obj->description, 'product').' '.dol_trunc($obj->description, 24); - if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); + if ($obj->type == 0) { + print img_object($obj->description, 'product').' '.dol_trunc($obj->description, 24); + } + if ($obj->type == 1) { + print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); + } } print '
    '; print $obj->qty; print ''; print price($obj->total_ht); print ''; print price($obj->total_tva); print ''; print price2num($obj->tva_tx).'%'; print ''; print price($obj->subprice); print ''; print $companystatic->getNomUrl(1, 'customer', 28); print ''; print ($obj->date_ouverture_prevue ?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour') : ' '); - if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) - print ' '.img_picto($langs->trans("Late"), "warning"); - else print '    '; + if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) { + print ' '.img_picto($langs->trans("Late"), "warning"); + } else { + print '    '; + } print ''.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : ' ').''.($obj->date_fin_validite ?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour') : ' '); - if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) - { + if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) { $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print img_warning($textlate); - } else print '    '; + } else { + print '    '; + } print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if ($obj->cstatut == 0) - { + if ($obj->cstatut == 0) { // If contract is draft, we say line is also draft print $contractstatic->LibStatut(0, 5); } else { print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); } print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print ''; } print '
    trans("Contract"); ?>getNomUrl(1); ?>trans("Contract"); ?>getNomUrl(1); ?> date_contrat, 'day'); ?>rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) - { + if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) { $totalcontrat = 0; foreach ($objectlink->lines as $linecontrat) { $totalcontrat = $totalcontrat + $linecontrat->total_ht; From 554e449e407c4caec9bd203e67cab380acc4b53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 22:03:23 +0100 Subject: [PATCH 072/173] code syntax core directory --- htdocs/core/actions_addupdatedelete.inc.php | 207 +- htdocs/core/actions_builddoc.inc.php | 73 +- .../core/actions_changeselectedfields.inc.php | 10 +- htdocs/core/actions_comments.inc.php | 27 +- htdocs/core/actions_dellink.inc.php | 10 +- htdocs/core/actions_extrafields.inc.php | 130 +- htdocs/core/actions_fetchobject.inc.php | 15 +- htdocs/core/actions_lineupdown.inc.php | 22 +- htdocs/core/actions_linkedfiles.inc.php | 124 +- htdocs/core/actions_massactions.inc.php | 836 ++-- htdocs/core/actions_printing.inc.php | 19 +- htdocs/core/actions_setmoduleoptions.inc.php | 69 +- htdocs/core/actions_setnotes.inc.php | 44 +- htdocs/core/ajax/ajaxdirpreview.php | 269 +- htdocs/core/ajax/ajaxdirtree.php | 217 +- htdocs/core/ajax/bankconciliate.php | 32 +- htdocs/core/ajax/box.php | 39 +- htdocs/core/ajax/check_notifications.php | 64 +- htdocs/core/ajax/constantonoff.php | 40 +- htdocs/core/ajax/contacts.php | 19 +- htdocs/core/ajax/extraparams.php | 23 +- htdocs/core/ajax/fileupload.php | 16 +- htdocs/core/ajax/getaccountcurrency.php | 15 +- htdocs/core/ajax/loadinplace.php | 59 +- htdocs/core/ajax/objectonoff.php | 28 +- htdocs/core/ajax/pingresult.php | 33 +- htdocs/core/ajax/price.php | 22 +- htdocs/core/ajax/row.php | 37 +- htdocs/core/ajax/saveinplace.php | 63 +- htdocs/core/ajax/security.php | 30 +- htdocs/core/ajax/selectobject.php | 41 +- htdocs/core/ajax/selectsearchbox.php | 117 +- htdocs/core/ajax/vatrates.php | 18 +- htdocs/core/ajax/ziptown.php | 58 +- htdocs/core/antispamimage.php | 30 +- .../box_accountancy_last_manual_entries.php | 9 +- .../box_accountancy_suspense_account.php | 9 +- htdocs/core/boxes/box_actions.php | 47 +- htdocs/core/boxes/box_activity.php | 39 +- htdocs/core/boxes/box_birthdays.php | 19 +- htdocs/core/boxes/box_birthdays_members.php | 23 +- htdocs/core/boxes/box_boms.php | 13 +- htdocs/core/boxes/box_bookmarks.php | 10 +- htdocs/core/boxes/box_clients.php | 31 +- htdocs/core/boxes/box_commandes.php | 36 +- htdocs/core/boxes/box_comptes.php | 6 +- htdocs/core/boxes/box_contacts.php | 21 +- htdocs/core/boxes/box_contracts.php | 31 +- ...box_customers_outstanding_bill_reached.php | 34 +- .../core/boxes/box_dolibarr_state_board.php | 4 +- htdocs/core/boxes/box_external_rss.php | 50 +- htdocs/core/boxes/box_factures.php | 25 +- htdocs/core/boxes/box_factures_fourn.php | 28 +- htdocs/core/boxes/box_factures_fourn_imp.php | 24 +- htdocs/core/boxes/box_factures_imp.php | 27 +- htdocs/core/boxes/box_ficheinter.php | 27 +- htdocs/core/boxes/box_fournisseurs.php | 23 +- htdocs/core/boxes/box_goodcustomers.php | 23 +- .../boxes/box_graph_invoices_permonth.php | 89 +- .../box_graph_invoices_supplier_permonth.php | 93 +- .../core/boxes/box_graph_orders_permonth.php | 89 +- .../box_graph_orders_supplier_permonth.php | 83 +- .../boxes/box_graph_product_distribution.php | 153 +- .../boxes/box_graph_propales_permonth.php | 89 +- .../core/boxes/box_last_modified_ticket.php | 4 +- htdocs/core/boxes/box_lastlogin.php | 7 +- htdocs/core/boxes/box_mos.php | 13 +- .../core/boxes/box_produits_alerte_stock.php | 36 +- htdocs/core/boxes/box_project.php | 17 +- htdocs/core/boxes/box_prospect.php | 25 +- htdocs/core/boxes/box_services_contracts.php | 36 +- htdocs/core/boxes/box_services_expired.php | 28 +- htdocs/core/boxes/box_shipments.php | 28 +- htdocs/core/boxes/box_supplier_orders.php | 28 +- ...box_supplier_orders_awaiting_reception.php | 28 +- htdocs/core/boxes/box_task.php | 8 +- htdocs/core/boxes/box_validated_projects.php | 15 +- htdocs/core/boxes/modules_boxes.php | 180 +- htdocs/core/class/CSMSFile.class.php | 57 +- htdocs/core/class/antivir.class.php | 22 +- htdocs/core/class/canvas.class.php | 43 +- htdocs/core/class/ccountry.class.php | 109 +- .../core/class/commondocgenerator.class.php | 276 +- htdocs/core/class/commonincoterm.class.php | 21 +- htdocs/core/class/commoninvoice.class.php | 190 +- htdocs/core/class/commonobject.class.php | 3121 +++++++------ htdocs/core/class/commonobjectline.class.php | 14 +- .../class/commonstickergenerator.class.php | 4 +- htdocs/core/class/conf.class.php | 408 +- htdocs/core/class/coreobject.class.php | 156 +- htdocs/core/class/cproductnature.class.php | 35 +- htdocs/core/class/cstate.class.php | 79 +- htdocs/core/class/ctypent.class.php | 103 +- htdocs/core/class/ctyperesource.class.php | 10 +- htdocs/core/class/cunits.class.php | 128 +- htdocs/core/class/discount.class.php | 192 +- htdocs/core/class/doleditor.class.php | 64 +- htdocs/core/class/dolgeoip.class.php | 89 +- htdocs/core/class/dolgraph.class.php | 221 +- htdocs/core/class/dolreceiptprinter.class.php | 34 +- .../core/class/emailsenderprofile.class.php | 35 +- htdocs/core/class/evalmath.class.php | 51 +- htdocs/core/class/events.class.php | 23 +- htdocs/core/class/extrafields.class.php | 625 +-- htdocs/core/class/extralanguages.class.php | 22 +- htdocs/core/class/fileupload.class.php | 55 +- htdocs/core/class/fiscalyear.class.php | 148 +- htdocs/core/class/hookmanager.class.php | 98 +- htdocs/core/class/html.form.class.php | 3477 ++++++++------- .../core/class/html.formaccounting.class.php | 72 +- htdocs/core/class/html.formactions.class.php | 153 +- htdocs/core/class/html.formadmin.class.php | 208 +- htdocs/core/class/html.formbarcode.class.php | 15 +- htdocs/core/class/html.formcategory.class.php | 3 +- htdocs/core/class/html.formcompany.class.php | 348 +- htdocs/core/class/html.formcontract.class.php | 57 +- .../class/html.formexpensereport.class.php | 42 +- htdocs/core/class/html.formfile.class.php | 944 ++-- .../class/html.formintervention.class.php | 42 +- htdocs/core/class/html.formmargin.class.php | 81 +- htdocs/core/class/html.formorder.class.php | 7 +- htdocs/core/class/html.formother.class.php | 492 ++- htdocs/core/class/html.formprojet.class.php | 283 +- htdocs/core/class/html.formpropal.class.php | 32 +- htdocs/core/class/html.formsms.class.php | 94 +- .../class/html.formsocialcontrib.class.php | 35 +- htdocs/core/class/html.formticket.class.php | 68 +- htdocs/core/class/html.formwebsite.class.php | 88 +- htdocs/core/class/infobox.class.php | 43 +- htdocs/core/class/interfaces.class.php | 150 +- htdocs/core/class/ldap.class.php | 344 +- htdocs/core/class/lessc.class.php | 2939 +++++++------ htdocs/core/class/link.class.php | 73 +- htdocs/core/class/menu.class.php | 7 +- htdocs/core/class/menubase.class.php | 127 +- htdocs/core/class/notify.class.php | 38 +- htdocs/core/class/openid.class.php | 93 +- htdocs/core/class/rssparser.class.php | 273 +- htdocs/core/class/smtps.class.php | 481 +- htdocs/core/class/stats.class.php | 280 +- htdocs/core/class/translate.class.php | 444 +- htdocs/core/class/utils.class.php | 500 ++- htdocs/core/class/vcard.class.php | 107 +- htdocs/core/commonfieldsinexport.inc.php | 13 +- htdocs/core/customreports.php | 105 +- htdocs/core/datepicker.php | 132 +- htdocs/core/db/DoliDB.class.php | 50 +- htdocs/core/db/mysqli.class.php | 327 +- htdocs/core/db/pgsql.class.php | 399 +- htdocs/core/db/sqlite3.class.php | 436 +- htdocs/core/extrafieldsinexport.inc.php | 22 +- .../browser/default/frmresourceslist.php | 22 +- .../filemanagerdol/connectors/php/basexml.php | 12 +- .../connectors/php/commands.php | 115 +- .../filemanagerdol/connectors/php/config.php | 28 +- .../connectors/php/connector.php | 24 +- .../core/filemanagerdol/connectors/php/io.php | 70 +- .../filemanagerdol/connectors/php/upload.php | 9 +- .../filemanagerdol/connectors/php/util.php | 36 +- htdocs/core/get_info.php | 65 +- htdocs/core/get_menudiv.php | 72 +- htdocs/core/js/lib_gravatar.js.php | 243 +- htdocs/core/js/lib_head.js.php | 301 +- htdocs/core/js/lib_notification.js.php | 213 +- htdocs/core/js/timepicker.js.php | 39 +- htdocs/core/lib/accounting.lib.php | 55 +- htdocs/core/lib/admin.lib.php | 6 +- htdocs/core/lib/agenda.lib.php | 94 +- htdocs/core/lib/ajax.lib.php | 57 +- htdocs/core/lib/asset.lib.php | 16 +- htdocs/core/lib/bank.lib.php | 65 +- htdocs/core/lib/barcode.lib.php | 162 +- htdocs/core/lib/categories.lib.php | 3 +- htdocs/core/lib/company.lib.php | 398 +- htdocs/core/lib/contact.lib.php | 19 +- htdocs/core/lib/contract.lib.php | 29 +- htdocs/core/lib/cron.lib.php | 18 +- htdocs/core/lib/date.lib.php | 357 +- htdocs/core/lib/doc.lib.php | 85 +- htdocs/core/lib/doleditor.lib.php | 68 +- htdocs/core/lib/donation.lib.php | 16 +- htdocs/core/lib/ecm.lib.php | 18 +- htdocs/core/lib/emailing.lib.php | 10 +- htdocs/core/lib/expedition.lib.php | 25 +- htdocs/core/lib/expensereport.lib.php | 29 +- htdocs/core/lib/fichinter.lib.php | 37 +- htdocs/core/lib/files.lib.php | 1468 +++---- htdocs/core/lib/format_cards.lib.php | 9 +- htdocs/core/lib/fourn.lib.php | 75 +- htdocs/core/lib/functions.lib.php | 3862 ++++++++++------- htdocs/core/lib/functions2.lib.php | 1368 +++--- htdocs/core/lib/functions_ch.lib.php | 3 +- htdocs/core/lib/functionsnumtoword.lib.php | 46 +- htdocs/core/lib/geturl.lib.php | 42 +- htdocs/core/lib/holiday.lib.php | 4 +- htdocs/core/lib/images.lib.php | 206 +- htdocs/core/lib/import.lib.php | 7 +- htdocs/core/lib/invoice.lib.php | 44 +- htdocs/core/lib/invoice2.lib.php | 209 +- htdocs/core/lib/json.lib.php | 124 +- htdocs/core/lib/ldap.lib.php | 75 +- htdocs/core/lib/loan.lib.php | 8 +- htdocs/core/lib/member.lib.php | 42 +- htdocs/core/lib/memory.lib.php | 43 +- htdocs/core/lib/modulebuilder.lib.php | 202 +- htdocs/core/lib/multicurrency.lib.php | 3 +- htdocs/core/lib/oauth.lib.php | 3 +- htdocs/core/lib/order.lib.php | 64 +- htdocs/core/lib/parsemd.lib.php | 15 +- htdocs/core/lib/payments.lib.php | 229 +- htdocs/core/lib/pdf.lib.php | 1106 ++--- htdocs/core/lib/prelevement.lib.php | 20 +- htdocs/core/lib/price.lib.php | 156 +- htdocs/core/lib/product.lib.php | 171 +- htdocs/core/lib/project.lib.php | 1253 +++--- htdocs/core/lib/propal.lib.php | 37 +- htdocs/core/lib/receiptprinter.lib.php | 3 +- htdocs/core/lib/reception.lib.php | 28 +- htdocs/core/lib/report.lib.php | 34 +- htdocs/core/lib/resource.lib.php | 29 +- htdocs/core/lib/salaries.lib.php | 4 +- htdocs/core/lib/security.lib.php | 446 +- htdocs/core/lib/security2.lib.php | 161 +- htdocs/core/lib/sendings.lib.php | 176 +- htdocs/core/lib/signature.lib.php | 27 +- htdocs/core/lib/stock.lib.php | 3 +- htdocs/core/lib/supplier_proposal.lib.php | 26 +- htdocs/core/lib/takepos.lib.php | 3 +- htdocs/core/lib/tax.lib.php | 485 ++- htdocs/core/lib/ticket.lib.php | 135 +- htdocs/core/lib/treeview.lib.php | 87 +- htdocs/core/lib/usergroups.lib.php | 426 +- htdocs/core/lib/vat.lib.php | 4 +- htdocs/core/lib/website.lib.php | 261 +- htdocs/core/lib/website2.lib.php | 96 +- htdocs/core/lib/ws.lib.php | 32 +- htdocs/core/lib/xcal.lib.php | 170 +- htdocs/core/login/functions_dolibarr.php | 51 +- htdocs/core/login/functions_forceuser.php | 8 +- htdocs/core/login/functions_googleoauth.php | 37 +- htdocs/core/login/functions_http.php | 3 +- htdocs/core/login/functions_ldap.php | 102 +- htdocs/core/login/functions_openid.php | 24 +- htdocs/core/menus/standard/auguria.lib.php | 294 +- htdocs/core/menus/standard/auguria_menu.php | 182 +- htdocs/core/modules/DolibarrModules.class.php | 255 +- htdocs/core/modules/action/modules_action.php | 32 +- htdocs/core/modules/action/rapport.pdf.php | 80 +- .../core/modules/bank/doc/pdf_ban.modules.php | 107 +- .../bank/doc/pdf_sepamandate.modules.php | 171 +- .../barcode/doc/phpbarcode.modules.php | 47 +- .../barcode/doc/tcpdfbarcode.modules.php | 8 +- .../barcode/mod_barcode_product_standard.php | 118 +- .../modules/barcode/modules_barcode.class.php | 65 +- .../bom/doc/doc_generic_bom_odt.modules.php | 140 +- htdocs/core/modules/bom/mod_bom_advanced.php | 10 +- htdocs/core/modules/bom/mod_bom_standard.php | 29 +- htdocs/core/modules/bom/modules_bom.php | 16 +- .../modules/cheque/doc/pdf_blochet.class.php | 67 +- .../modules/cheque/mod_chequereceipt_mint.php | 29 +- .../cheque/mod_chequereceipt_thyme.php | 8 +- .../modules/cheque/modules_chequereceipts.php | 28 +- .../doc/doc_generic_order_odt.modules.php | 134 +- .../commande/doc/pdf_einstein.modules.php | 473 +- .../commande/doc/pdf_eratosthene.modules.php | 581 ++- .../modules/commande/mod_commande_marbre.php | 29 +- .../modules/commande/mod_commande_saphir.php | 10 +- .../modules/commande/modules_commande.php | 16 +- .../doc/doc_generic_contract_odt.modules.php | 120 +- .../contract/doc/pdf_strato.modules.php | 174 +- .../modules/contract/mod_contract_magre.php | 10 +- .../modules/contract/mod_contract_olive.php | 6 +- .../modules/contract/mod_contract_serpis.php | 29 +- .../modules/contract/modules_contract.php | 16 +- .../delivery/doc/pdf_storm.modules.php | 293 +- .../delivery/doc/pdf_typhon.modules.php | 209 +- .../modules/delivery/mod_delivery_jade.php | 28 +- .../modules/delivery/mod_delivery_saphir.php | 8 +- .../modules/delivery/modules_delivery.php | 16 +- .../modules/dons/html_cerfafr.modules.php | 99 +- htdocs/core/modules/dons/modules_don.php | 16 +- .../doc/doc_generic_shipment_odt.modules.php | 195 +- .../expedition/doc/pdf_espadon.modules.php | 388 +- .../expedition/doc/pdf_merou.modules.php | 123 +- .../expedition/doc/pdf_rouget.modules.php | 370 +- .../expedition/mod_expedition_ribera.php | 10 +- .../expedition/mod_expedition_safor.php | 29 +- .../modules/expedition/modules_expedition.php | 16 +- .../doc/pdf_standard.modules.php | 199 +- .../expensereport/mod_expensereport_jade.php | 43 +- .../expensereport/mod_expensereport_sand.php | 22 +- .../expensereport/modules_expensereport.php | 16 +- .../modules/export/export_csv.modules.php | 54 +- .../export/export_excel2007.modules.php | 97 +- .../modules/export/export_tsv.modules.php | 27 +- htdocs/core/modules/export/modules_export.php | 12 +- .../doc/doc_generic_invoice_odt.modules.php | 135 +- .../modules/facture/doc/pdf_crabe.modules.php | 626 +-- .../facture/doc/pdf_sponge.modules.php | 650 ++- .../core/modules/facture/mod_facture_mars.php | 78 +- .../modules/facture/mod_facture_mercure.php | 26 +- .../modules/facture/mod_facture_terre.php | 85 +- .../core/modules/facture/modules_facture.php | 16 +- .../fichinter/doc/pdf_soleil.modules.php | 157 +- htdocs/core/modules/fichinter/mod_arctic.php | 10 +- htdocs/core/modules/fichinter/mod_pacific.php | 29 +- .../modules/fichinter/modules_fichinter.php | 48 +- .../holiday/mod_holiday_immaculate.php | 10 +- .../modules/holiday/mod_holiday_madonna.php | 29 +- .../core/modules/holiday/modules_holiday.php | 16 +- .../modules/import/import_csv.modules.php | 285 +- .../modules/import/import_xlsx.modules.php | 180 +- htdocs/core/modules/import/modules_import.php | 9 +- .../mailings/advthirdparties.modules.php | 47 +- .../modules/mailings/contacts1.modules.php | 189 +- .../core/modules/mailings/example.modules.php | 2 +- .../core/modules/mailings/fraise.modules.php | 56 +- .../modules/mailings/modules_mailings.php | 73 +- .../core/modules/mailings/pomme.modules.php | 25 +- .../modules/mailings/thirdparties.modules.php | 56 +- .../thirdparties_services_expired.modules.php | 32 +- .../modules/mailings/xinputfile.modules.php | 37 +- .../modules/mailings/xinputuser.modules.php | 12 +- .../doc/doc_generic_member_odt.class.php | 55 +- .../modules/member/doc/pdf_standard.class.php | 169 +- htdocs/core/modules/member/modules_cards.php | 40 +- htdocs/core/modules/modAdherent.class.php | 36 +- htdocs/core/modules/modAgenda.class.php | 26 +- htdocs/core/modules/modApi.class.php | 3 +- htdocs/core/modules/modAsset.class.php | 3 +- htdocs/core/modules/modBanque.class.php | 3 +- htdocs/core/modules/modBlockedLog.class.php | 25 +- htdocs/core/modules/modBom.class.php | 49 +- htdocs/core/modules/modCategorie.class.php | 71 +- htdocs/core/modules/modCollab.class.php | 28 +- htdocs/core/modules/modCommande.class.php | 17 +- htdocs/core/modules/modContrat.class.php | 6 +- htdocs/core/modules/modDataPolicy.class.php | 44 +- htdocs/core/modules/modDav.class.php | 29 +- htdocs/core/modules/modDeplacement.class.php | 15 +- .../core/modules/modEmailCollector.class.php | 45 +- htdocs/core/modules/modExpedition.class.php | 25 +- htdocs/core/modules/modExternalRss.class.php | 9 +- htdocs/core/modules/modFacture.class.php | 40 +- htdocs/core/modules/modFournisseur.class.php | 122 +- htdocs/core/modules/modHoliday.class.php | 2 +- htdocs/core/modules/modIncoterm.class.php | 3 +- .../core/modules/modIntracommreport.class.php | 3 +- htdocs/core/modules/modMrp.class.php | 116 +- .../core/modules/modMultiCurrency.class.php | 39 +- htdocs/core/modules/modOauth.class.php | 10 +- htdocs/core/modules/modPaypal.class.php | 28 +- htdocs/core/modules/modProduct.class.php | 272 +- htdocs/core/modules/modProductBatch.class.php | 3 +- htdocs/core/modules/modProjet.class.php | 31 +- htdocs/core/modules/modPropale.class.php | 21 +- htdocs/core/modules/modReception.class.php | 25 +- htdocs/core/modules/modRecruitment.class.php | 14 +- htdocs/core/modules/modResource.class.php | 6 +- htdocs/core/modules/modService.class.php | 312 +- htdocs/core/modules/modSociete.class.php | 48 +- htdocs/core/modules/modStock.class.php | 23 +- htdocs/core/modules/modStripe.class.php | 28 +- .../modules/modSupplierProposal.class.php | 8 +- htdocs/core/modules/modTakePos.class.php | 29 +- htdocs/core/modules/modTicket.class.php | 6 +- htdocs/core/modules/modUser.class.php | 9 +- htdocs/core/modules/modVariants.class.php | 3 +- htdocs/core/modules/modWebsite.class.php | 13 +- htdocs/core/modules/modWorkflow.class.php | 64 +- htdocs/core/modules/modWorkstation.class.php | 54 +- htdocs/core/modules/modZapier.class.php | 112 +- .../movement/doc/pdf_standard.modules.php | 428 +- .../mrp/doc/doc_generic_mo_odt.modules.php | 137 +- htdocs/core/modules/mrp/mod_mo_advanced.php | 10 +- htdocs/core/modules/mrp/mod_mo_standard.php | 29 +- htdocs/core/modules/mrp/modules_mo.php | 16 +- .../modules/oauth/github_oauthcallback.php | 16 +- .../modules/oauth/google_oauthcallback.php | 16 +- .../oauth/stripelive_oauthcallback.php | 17 +- .../oauth/stripetest_oauthcallback.php | 17 +- .../core/modules/payment/mod_payment_ant.php | 10 +- .../modules/payment/mod_payment_cicada.php | 29 +- .../core/modules/payment/modules_payment.php | 16 +- .../modules/printing/modules_printing.php | 7 +- .../modules/printing/printgcp.modules.php | 37 +- .../modules/printing/printipp.modules.php | 15 +- .../doc/pdf_standardlabel.class.php | 128 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 114 +- .../modules/printsheet/modules_labels.php | 55 +- .../doc/doc_generic_product_odt.modules.php | 117 +- .../product/doc/pdf_standard.modules.php | 248 +- .../product/mod_codeproduct_elephant.php | 85 +- .../product/mod_codeproduct_leopard.php | 6 +- .../doc/doc_generic_project_odt.modules.php | 286 +- .../project/doc/pdf_baleine.modules.php | 189 +- .../project/doc/pdf_beluga.modules.php | 174 +- .../project/doc/pdf_timespent.modules.php | 189 +- .../modules/project/mod_project_simple.php | 29 +- .../modules/project/mod_project_universal.php | 6 +- .../core/modules/project/modules_project.php | 16 +- .../task/doc/doc_generic_task_odt.modules.php | 213 +- .../modules/project/task/mod_task_simple.php | 29 +- .../modules/project/task/modules_task.php | 12 +- .../doc/doc_generic_proposal_odt.modules.php | 144 +- .../modules/propale/doc/pdf_azur.modules.php | 552 ++- .../modules/propale/doc/pdf_cyan.modules.php | 562 ++- .../modules/propale/mod_propale_marbre.php | 29 +- .../modules/propale/mod_propale_saphir.php | 10 +- .../core/modules/propale/modules_propale.php | 16 +- .../modules/rapport/pdf_paiement.class.php | 137 +- .../doc/doc_generic_reception_odt.modules.php | 139 +- .../reception/doc/pdf_squille.modules.php | 337 +- .../modules/reception/mod_reception_beryl.php | 29 +- .../reception/mod_reception_moonstone.php | 10 +- .../modules/reception/modules_reception.php | 13 +- .../generate/modGeneratePassPerso.class.php | 7 +- .../modGeneratePassStandard.class.php | 10 +- .../societe/doc/doc_generic_odt.modules.php | 125 +- .../societe/mod_codeclient_elephant.php | 66 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 52 +- .../societe/mod_codecompta_aquarium.php | 60 +- .../societe/mod_codecompta_digitaria.php | 60 +- .../societe/mod_codecompta_panicum.php | 7 +- .../doc/doc_generic_stock_odt.modules.php | 120 +- .../stock/doc/pdf_standard.modules.php | 196 +- .../doc/pdf_canelle.modules.php | 348 +- .../mod_facture_fournisseur_cactus.php | 82 +- .../mod_facture_fournisseur_tulip.php | 25 +- .../modules_facturefournisseur.php | 16 +- ...doc_generic_supplier_order_odt.modules.php | 137 +- .../supplier_order/doc/pdf_cornas.modules.php | 474 +- .../doc/pdf_muscadet.modules.php | 415 +- .../mod_commande_fournisseur_muguet.php | 37 +- .../mod_commande_fournisseur_orchidee.php | 6 +- .../modules_commandefournisseur.php | 16 +- .../doc/pdf_standard.modules.php | 172 +- .../mod_supplier_payment_brodator.php | 10 +- .../mod_supplier_payment_bronan.php | 29 +- .../modules_supplier_payment.php | 13 +- ..._generic_supplier_proposal_odt.modules.php | 141 +- .../doc/pdf_aurore.modules.php | 6 +- .../mod_supplier_proposal_marbre.php | 29 +- .../mod_supplier_proposal_saphir.php | 10 +- .../modules_supplier_proposal.php | 16 +- .../core/modules/syslog/mod_syslog_file.php | 43 +- .../core/modules/syslog/mod_syslog_syslog.php | 22 +- .../takepos/mod_takepos_ref_simple.php | 39 +- .../core/modules/takepos/modules_takepos.php | 16 +- .../doc/doc_generic_ticket_odt.modules.php | 96 +- .../user/doc/doc_generic_user_odt.modules.php | 102 +- .../doc/doc_generic_usergroup_odt.modules.php | 126 +- .../workstation/mod_workstation_advanced.php | 6 +- .../workstation/mod_workstation_standard.php | 27 +- .../workstation/modules_workstation.php | 16 +- htdocs/core/photos_resize.php | 316 +- htdocs/core/search.php | 95 +- htdocs/core/search_page.php | 36 +- htdocs/core/tools.php | 4 +- htdocs/core/tpl/admin_extrafields_add.tpl.php | 127 +- .../core/tpl/admin_extrafields_edit.tpl.php | 156 +- .../core/tpl/admin_extrafields_view.tpl.php | 20 +- htdocs/core/tpl/advtarget.tpl.php | 6 +- htdocs/core/tpl/ajax/fileupload_main.tpl.php | 31 +- htdocs/core/tpl/ajax/fileupload_view.tpl.php | 103 +- .../tpl/ajax/objectlinked_lineimport.tpl.php | 90 +- htdocs/core/tpl/ajaxrow.tpl.php | 23 +- htdocs/core/tpl/bloc_comment.tpl.php | 33 +- htdocs/core/tpl/bloc_showhide.tpl.php | 11 +- htdocs/core/tpl/card_presend.tpl.php | 48 +- htdocs/core/tpl/commonfields_add.tpl.php | 62 +- htdocs/core/tpl/commonfields_edit.tpl.php | 55 +- htdocs/core/tpl/commonfields_view.tpl.php | 98 +- htdocs/core/tpl/contacts.tpl.php | 74 +- .../tpl/document_actions_post_headers.tpl.php | 39 +- htdocs/core/tpl/extrafields_add.tpl.php | 11 +- htdocs/core/tpl/extrafields_edit.tpl.php | 7 +- .../tpl/extrafields_list_array_fields.tpl.php | 17 +- .../tpl/extrafields_list_print_fields.tpl.php | 51 +- .../tpl/extrafields_list_search_input.tpl.php | 42 +- .../tpl/extrafields_list_search_param.tpl.php | 17 +- .../tpl/extrafields_list_search_sql.tpl.php | 55 +- .../tpl/extrafields_list_search_title.tpl.php | 31 +- htdocs/core/tpl/extrafields_view.tpl.php | 129 +- htdocs/core/tpl/filemanager.tpl.php | 76 +- htdocs/core/tpl/list_print_total.tpl.php | 25 +- htdocs/core/tpl/login.tpl.php | 138 +- htdocs/core/tpl/massactions_pre.tpl.php | 47 +- htdocs/core/tpl/notes.tpl.php | 26 +- htdocs/core/tpl/object_discounts.tpl.php | 7 +- htdocs/core/tpl/objectline_create.tpl.php | 235 +- htdocs/core/tpl/objectline_edit.tpl.php | 130 +- htdocs/core/tpl/objectline_title.tpl.php | 41 +- htdocs/core/tpl/objectline_view.tpl.php | 147 +- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 51 +- htdocs/core/tpl/originproductline.tpl.php | 13 +- htdocs/core/tpl/passwordforgotten.tpl.php | 89 +- htdocs/core/tpl/resource_add.tpl.php | 3 +- htdocs/core/tpl/resource_view.tpl.php | 15 +- .../core/triggers/dolibarrtriggers.class.php | 2 +- .../interface_20_all_Logevents.class.php | 26 +- ...e_20_modWorkflow_WorkflowManager.class.php | 46 +- ...terface_50_modAgenda_ActionsAuto.class.php | 344 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 17 +- ...interface_50_modLdap_Ldapsynchro.class.php | 68 +- ...odMailmanspip_Mailmanspipsynchro.class.php | 20 +- ..._50_modNotification_Notification.class.php | 37 +- ...terface_50_modTicket_TicketEmail.class.php | 28 +- .../interface_80_modStripe_Stripe.class.php | 40 +- ...rface_90_modSociete_ContactRoles.class.php | 6 +- htdocs/core/website.inc.php | 58 +- 512 files changed, 34726 insertions(+), 28660 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 1c874fd2418..d7dcbf699c8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -30,18 +30,17 @@ // $backtopage may be defined // $triggermodname may be defined -if (!empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility +if (!empty($permissionedit) && empty($permissiontoadd)) { + $permissiontoadd = $permissionedit; // For backward compatibility +} -if ($cancel) -{ +if ($cancel) { /*var_dump($cancel); var_dump($backtopage);exit;*/ - if (!empty($backtopageforcancel)) - { + if (!empty($backtopageforcancel)) { header("Location: ".$backtopageforcancel); exit; - } elseif (!empty($backtopage)) - { + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -50,19 +49,25 @@ if ($cancel) // Action to add record -if ($action == 'add' && !empty($permissiontoadd)) -{ - foreach ($object->fields as $key => $val) - { +if ($action == 'add' && !empty($permissiontoadd)) { + foreach ($object->fields as $key => $val) { if ($object->fields[$key]['type'] == 'duration') { - if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') continue; // The field was not submited to be edited + if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') { + continue; // The field was not submited to be edited + } } else { - if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key)) { + continue; // The field was not submited to be edited + } } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) { + continue; + } if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + if (!in_array(abs($val['visible']), array(1, 3))) { + continue; // Only 1 and 3 that are case to create + } } // Set value to insert @@ -84,17 +89,19 @@ if ($action == 'add' && !empty($permissiontoadd)) } else { $value = GETPOST($key, 'alphanohtml'); } - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field - if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { + $value = ''; // This is an implicit foreign key field + } + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') { + $value = ''; // This is an explicit foreign key field + } //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') - { + if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { $object->$key = '(PROV)'; } - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) - { + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -103,14 +110,14 @@ if ($action == 'add' && !empty($permissiontoadd)) // Fill array 'array_options' with data from add form if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Creation OK $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation @@ -118,8 +125,11 @@ if ($action == 'add' && !empty($permissiontoadd)) exit; } else { // Creation KO - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + if (!empty($object->errors)) { + setEventMessages(null, $object->errors, 'errors'); + } else { + setEventMessages($object->error, null, 'errors'); + } $action = 'create'; } } else { @@ -128,25 +138,31 @@ if ($action == 'add' && !empty($permissiontoadd)) } // Action to update record -if ($action == 'update' && !empty($permissiontoadd)) -{ - foreach ($object->fields as $key => $val) - { +if ($action == 'update' && !empty($permissiontoadd)) { + foreach ($object->fields as $key => $val) { // Check if field was submited to be edited if ($object->fields[$key]['type'] == 'duration') { - if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) { + continue; // The field was not submited to be edited + } } elseif ($object->fields[$key]['type'] == 'boolean') { if (!GETPOSTISSET($key)) { $object->$key = 0; // use 0 instead null if the field is defined as not null continue; } } else { - if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key)) { + continue; // The field was not submited to be edited + } } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) { + continue; + } if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + if (!in_array(abs($val['visible']), array(1, 3, 4))) { + continue; // Only 1 and 3 and 4 that are case to update + } } // Set value to update @@ -176,12 +192,15 @@ if ($action == 'update' && !empty($permissiontoadd)) } else { $value = GETPOST($key, 'alpha'); } - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field - if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { + $value = ''; // This is an implicit foreign key field + } + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') { + $value = ''; // This is an explicit foreign key field + } $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) - { + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -190,14 +209,14 @@ if ($action == 'update' && !empty($permissiontoadd)) // Fill array 'array_options' with data from add form if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { $action = 'view'; } else { // Creation KO @@ -210,8 +229,7 @@ if ($action == 'update' && !empty($permissiontoadd)) } // Action to update one extrafield -if ($action == "update_extras" && !empty($permissiontoadd)) -{ +if ($action == "update_extras" && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); $attributekey = GETPOST('attribute', 'alpha'); @@ -226,8 +244,7 @@ if ($action == "update_extras" && !empty($permissiontoadd)) } $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); $action = 'view'; } else { @@ -237,46 +254,42 @@ if ($action == "update_extras" && !empty($permissiontoadd)) } // Action to delete -if ($action == 'confirm_delete' && !empty($permissiontodelete)) -{ - if (!($object->id > 0)) - { +if ($action == 'confirm_delete' && !empty($permissiontodelete)) { + if (!($object->id > 0)) { dol_print_error('', 'Error, object must be fetched before being deleted'); exit; } $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".$backurlforlist); exit; } else { - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + if (!empty($object->errors)) { + setEventMessages(null, $object->errors, 'errors'); + } else { + setEventMessages($object->error, null, 'errors'); + } } } // Remove a line -if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) -{ +if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { if (method_exists($object, 'deleteline')) { $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); } - if ($result > 0) - { + if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -299,18 +312,20 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto } // Action validate object -if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $result = $object->validate($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -332,18 +347,20 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) } // Action close object -if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) { $result = $object->cancel($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -360,11 +377,9 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) } // Action setdraft object -if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setDraft($user); - if ($result >= 0) - { + if ($result >= 0) { // Nothing else done } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -372,18 +387,20 @@ if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) } // Action reopen object -if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { $result = $object->reopen($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -400,21 +417,21 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) -{ - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { +if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); - if (is_object($result) || $result > 0) - { + if (is_object($result) || $result > 0) { $newid = 0; - if (is_object($result)) $newid = $result->id; - else $newid = $result; + if (is_object($result)) { + $newid = $result->id; + } else { + $newid = $result; + } header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 4ae83829fa4..63cac253976 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -29,27 +29,26 @@ // $upload_dir must be defined (example $conf->projet->dir_output . "/";) // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. -if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility +if (!empty($permissioncreate) && empty($permissiontoadd)) { + $permissiontoadd = $permissioncreate; // For backward compatibility +} // Build doc -if ($action == 'builddoc' && $permissiontoadd) -{ - if (is_numeric(GETPOST('model', 'alpha'))) - { +if ($action == 'builddoc' && $permissiontoadd) { + if (is_numeric(GETPOST('model', 'alpha'))) { $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); } else { - // Reload to get all modified line records and be ready for hooks + // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); $ret = $object->fetch_thirdparty(); /*if (empty($object->id) || ! $object->id > 0) - { - dol_print_error('Object must have been loaded by a fetch'); - exit; - }*/ + { + dol_print_error('Object must have been loaded by a fetch'); + exit; + }*/ // Save last template used to generate document - if (GETPOST('model', 'alpha')) - { + if (GETPOST('model', 'alpha')) { $object->setDocModel($user, GETPOST('model', 'alpha')); } @@ -67,29 +66,40 @@ if ($action == 'builddoc' && $permissiontoadd) $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) { + $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) { + $newlang = $object->default_lang; // for thirdparty + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + if (empty($hidedetails)) { + $hidedetails = 0; + } + if (empty($hidedesc)) { + $hidedesc = 0; + } + if (empty($hideref)) { + $hideref = 0; + } + if (empty($moreparams)) { + $moreparams = null; + } $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { - if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" - { + if (empty($donotredirect)) { // This is set when include is done by bulk action "Bill Orders" setEventMessages($langs->trans("FileGenerated"), null); $urltoredirect = $_SERVER['REQUEST_URI']; @@ -104,13 +114,11 @@ if ($action == 'builddoc' && $permissiontoadd) } // Delete file in doc form -if ($action == 'remove_file' && $permissiontoadd) -{ +if ($action == 'remove_file' && $permissiontoadd) { if (!empty($upload_dir)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || !$object->id > 0) - { + if (empty($object->id) || !$object->id > 0) { // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); $ret = $object->fetch_thirdparty(); @@ -120,8 +128,11 @@ if ($action == 'remove_file' && $permissiontoadd) $filetodelete = GETPOST('file', 'alpha'); $file = $upload_dir.'/'.$filetodelete; $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + } // Make a redirect to avoid to keep the remove_file into the url that create side effects $urltoredirect = $_SERVER['REQUEST_URI']; diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index 4daf53891cf..f0ead24e6b1 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -28,14 +28,16 @@ // $object must be defined (object is loaded in this file with fetch) // Save selection -if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') -{ +if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') { $tabparam = array(); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + if (GETPOST("selectedfields")) { + $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + } else { + $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + } include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index f590adee197..fc6bf11a115 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -33,19 +33,16 @@ $comment = new Comment($db); * Actions */ -if ($action == 'addcomment') -{ +if ($action == 'addcomment') { $description = GETPOST('comment_description', 'restricthtml'); - if (!empty($description)) - { + if (!empty($description)) { $comment->description = $description; $comment->datec = time(); $comment->fk_element = GETPOST('id', 'int'); $comment->element_type = GETPOST('comment_element_type', 'alpha'); $comment->fk_user_author = $user->id; $comment->entity = $conf->entity; - if ($comment->create($user) > 0) - { + if ($comment->create($user) > 0) { setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; @@ -55,13 +52,10 @@ if ($action == 'addcomment') } } } -if ($action === 'updatecomment') -{ - if ($comment->fetch($idcomment) >= 0) - { +if ($action === 'updatecomment') { + if ($comment->fetch($idcomment) >= 0) { $comment->description = GETPOST('comment_description', 'restricthtml'); - if ($comment->update($user) > 0) - { + if ($comment->update($user) > 0) { setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); exit; @@ -71,12 +65,9 @@ if ($action === 'updatecomment') } } } -if ($action == 'deletecomment') -{ - if ($comment->fetch($idcomment) >= 0) - { - if ($comment->delete($user) > 0) - { +if ($action == 'deletecomment') { + if ($comment->fetch($idcomment) >= 0) { + if ($comment->delete($user) > 0) { setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index 2dd2588ca48..a7ac035506f 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -30,16 +30,16 @@ $dellinkid = GETPOST('dellinkid', 'int'); $addlinkid = GETPOST('idtolinkto', 'int'); // Link invoice to order -if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) -{ +if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) { $object->fetch($id); $object->fetch_thirdparty(); $result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid); } // Delete link -if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) -{ +if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) { $result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 7ba4d7d64b9..b03c2c3d192 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -31,91 +31,85 @@ $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 -if ($action == 'add') -{ - if (GETPOST("button") != $langs->trans("Cancel")) - { +if ($action == 'add') { + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values - if (!$type) - { + if (!$type) { $error++; $langs->load("errors"); $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")); $action = 'edit'; } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); $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); $action = 'create'; } - if ($type == 'select' && !$param) - { + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } - if ($type == 'sellist' && !$param) - { + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } - if ($type == 'checkbox' && !$param) - { + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } - if ($type == 'link' && !$param) - { + if ($type == 'link' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } - if ($type == 'radio' && !$param) - { + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); $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 (preg_match_all('/,/', $param_ligne, $matches)) { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); @@ -160,14 +154,12 @@ if ($action == 'add') $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' || $type == 'chkbxlst') { - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } } else { // Else 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); $params['options'][$key] = $value; } @@ -175,7 +167,9 @@ if ($action == 'add') // 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( GETPOST('attrname', 'aZ09'), @@ -199,8 +193,7 @@ if ($action == 'add') (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -223,77 +216,64 @@ if ($action == 'add') } // Rename field -if ($action == 'update') -{ - if (GETPOST("button") != $langs->trans("Cancel")) - { +if ($action == 'update') { + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values - if (!$type) - { + if (!$type) { $error++; $langs->load("errors"); $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")); $action = 'edit'; } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); $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); $action = 'edit'; } - if ($type == 'select' && !$param) - { + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } - if ($type == 'sellist' && !$param) - { + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } - if ($type == 'checkbox' && !$param) - { + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } - if ($type == 'radio' && !$param) - { + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); $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 (preg_match_all('/,/', $param_ligne, $matches)) { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); @@ -329,24 +309,20 @@ if ($action == 'update') } } - if (!$error) - { - if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) - { + if (!$error) { + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { $pos = GETPOST('pos', 'int'); // Construct array for parameter (value of select list) $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' || $type == 'chkbxlst') { - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } } 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); $params['options'][$key] = $value; } @@ -354,7 +330,9 @@ if ($action == 'update') // 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; + } // Example: is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : 'objnotdefined' $computedvalue = GETPOST('computed_value', 'nohtml'); @@ -409,7 +387,9 @@ if ($action == 'delete') { if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else $mesg = $extrafields->error; + } else { + $mesg = $extrafields->error; + } } else { $error++; $langs->load("errors"); diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index c881b335f18..3ca797a9bb3 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -28,20 +28,15 @@ // $cancel must be defined // $id or $ref must be defined (object is loaded in this file with fetch) -if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) -{ - if (($id > 0 && is_numeric($id)) || !empty($ref)) // To discard case when id is list of ids like '1,2,3...' - { +if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { + if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To discard case when id is list of ids like '1,2,3...' $ret = $object->fetch($id, $ref); - if ($ret > 0) - { + if ($ret > 0) { $object->fetch_thirdparty(); $id = $object->id; } else { - if (empty($object->error) && !count($object->errors)) - { - if ($ret < 0) // if $ret == 0, it means not found. - { + if (empty($object->error) && !count($object->errors)) { + if ($ret < 0) { // if $ret == 0, it means not found. setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); } } else { diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php index e5507eeafc0..5aee952292b 100644 --- a/htdocs/core/actions_lineupdown.inc.php +++ b/htdocs/core/actions_lineupdown.inc.php @@ -28,15 +28,18 @@ // $langs must be defined // $hidedetails, $hidedesc, $hideref must de defined -if ($action == 'up' && $permissiontoedit) -{ +if ($action == 'up' && $permissiontoedit) { $object->line_up(GETPOST('rowid')); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -50,15 +53,18 @@ if ($action == 'up' && $permissiontoedit) exit(); } -if ($action == 'down' && $permissiontoedit) -{ +if ($action == 'down' && $permissiontoedit) { $object->line_down(GETPOST('rowid')); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index b0671bbf555..af60583118d 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -27,17 +27,16 @@ // Submit file/link -if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if (!empty($_FILES)) - { - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; - else $userfiles = array($_FILES['userfile']['tmp_name']); +if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { + if (!empty($_FILES)) { + if (is_array($_FILES['userfile']['tmp_name'])) { + $userfiles = $_FILES['userfile']['tmp_name']; + } else { + $userfiles = array($_FILES['userfile']['tmp_name']); + } - foreach ($userfiles as $key => $userfile) - { - if (empty($_FILES['userfile']['tmp_name'][$key])) - { + foreach ($userfiles as $key => $userfile) { + if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); @@ -47,27 +46,24 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) } } - if (!$error) - { + if (!$error) { // Define if we have to generate thumbs or not $generatethumbs = 1; - if (GETPOST('section_dir', 'alpha')) $generatethumbs = 0; + if (GETPOST('section_dir', 'alpha')) { + $generatethumbs = 0; + } $allowoverwrite = (GETPOST('overwritefile', 'int') ? 1 : 0); - if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { + if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object); - } elseif (!empty($upload_dir)) - { + } elseif (!empty($upload_dir)) { $result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object); } } } -} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ +} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) { $link = GETPOST('link', 'alpha'); - if ($link) - { + if ($link) { if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { $link = 'http://'.$link; } @@ -77,17 +73,18 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) // Delete file/link -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ +if ($action == 'confirm_deletefile' && $confirm == 'yes') { $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). if (GETPOST('section', 'alpha')) { // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; } else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. { - $urlfile = basename($urlfile); - $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; - if (!empty($upload_dirold)) $fileold = $upload_dirold."/".$urlfile; + $urlfile = basename($urlfile); + $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; + if (!empty($upload_dirold)) { + $fileold = $upload_dirold."/".$urlfile; + } } $linkid = GETPOST('linkid', 'int'); @@ -97,21 +94,20 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); - if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path + if (!empty($fileold)) { + dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path + } // If it exists, remove thumb. $regs = array(); - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) - { + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } } @@ -149,33 +145,27 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') exit; } } -} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) -{ +} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); $f = $link->fetch(GETPOST('linkid', 'int')); - if ($f) - { + if ($f) { $link->url = GETPOST('link', 'alpha'); - if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') - { + if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') { $link->url = 'http://'.$link->url; } $link->label = GETPOST('label', 'alphanohtml'); $res = $link->update($user); - if (!$res) - { + if (!$res) { setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); } } else { //error fetching } -} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) -{ +} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) { // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - if (!empty($upload_dir)) - { + if (!empty($upload_dir)) { $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents @@ -183,24 +173,23 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $filenameto = dol_string_nohtmltag($filenameto); - if ($filenamefrom != $filenameto) - { + if ($filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. - if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) - { + if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) { // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) { + $publicmediasdirwithslash .= '/'; + } if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory $filenameto .= '.noexe'; } } - if ($filenamefrom && $filenameto) - { + if ($filenamefrom && $filenameto) { $srcpath = $upload_dir.'/'.$filenamefrom; $destpath = $upload_dir.'/'.$filenameto; @@ -208,26 +197,24 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); $reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object); - if (empty($reshook)) - { + if (empty($reshook)) { if (preg_match('/^\./', $filenameto)) { $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors'); } elseif (!file_exists($destpath)) { $result = dol_move($srcpath, $destpath); - if ($result) - { + if ($result) { // Define if we have to generate thumbs or not $generatethumbs = 1; // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) // but when we rename from a tab "Documents", we must regenerate thumbs - if (GETPOST('modulepart') == 'medias') $generatethumbs = 0; + if (GETPOST('modulepart') == 'medias') { + $generatethumbs = 0; + } - if ($generatethumbs) - { - if ($object->id) - { + if ($generatethumbs) { + if ($object->id) { $object->addThumbs($destpath); } @@ -250,19 +237,15 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } // Update properties in ECM table - if (GETPOST('ecmfileid', 'int') > 0) - { + if (GETPOST('ecmfileid', 'int') > 0) { $shareenabled = GETPOST('shareenabled', 'alpha'); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int')); - if ($result > 0) - { - if ($shareenabled) - { - if (empty($ecmfile->share)) - { + if ($result > 0) { + if ($shareenabled) { + if (empty($ecmfile->share)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); } @@ -270,8 +253,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $ecmfile->share = ''; } $result = $ecmfile->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 892cb8ae4e0..057443d09b4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -37,37 +37,38 @@ // Protection -if (empty($objectclass) || empty($uploaddir)) -{ +if (empty($objectclass) || empty($uploaddir)) { dol_print_error(null, 'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined'); exit; } // For backward compatibility -if (!empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; -if (!empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; -if (!empty($permtodelete) && empty($permissiontodelete)) $permissiontodelete = $permtodelete; +if (!empty($permtoread) && empty($permissiontoread)) { + $permissiontoread = $permtoread; +} +if (!empty($permtocreate) && empty($permissiontoadd)) { + $permissiontoadd = $permtocreate; +} +if (!empty($permtodelete) && empty($permissiontodelete)) { + $permissiontodelete = $permtodelete; +} // Mass actions. Controls on number of lines checked. $maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); -if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) -{ +if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) { $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) -{ +if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); $error++; } -if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form -{ +if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) { // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form $massaction = 'presend'; } -if (!$error && $massaction == 'confirm_presend') -{ +if (!$error && $massaction == 'confirm_presend') { $resaction = ''; $nbsent = 0; $nbignored = 0; @@ -82,27 +83,36 @@ if (!$error && $massaction == 'confirm_presend') $attachedfilesThirdpartyObj = array(); $oneemailperrecipient = (GETPOST('oneemailperrecipient') == 'on' ? 1 : 0); - if (!$error) - { + if (!$error) { $thirdparty = new Societe($db); $objecttmp = new $objectclass($db); - if ($objecttmp->element == 'expensereport') $thirdparty = new User($db); - if ($objecttmp->element == 'holiday') $thirdparty = new User($db); + if ($objecttmp->element == 'expensereport') { + $thirdparty = new User($db); + } + if ($objecttmp->element == 'holiday') { + $thirdparty = new User($db); + } - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); - if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id; - if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author; - if ($objecttmp->element == 'holiday') $thirdpartyid = $objecttmp->fk_user; - if (empty($thirdpartyid)) $thirdpartyid = 0; + if ($objecttmp->element == 'societe') { + $thirdpartyid = $objecttmp->id; + } + if ($objecttmp->element == 'expensereport') { + $thirdpartyid = $objecttmp->fk_user_author; + } + if ($objecttmp->element == 'holiday') { + $thirdpartyid = $objecttmp->fk_user; + } + if (empty($thirdpartyid)) { + $thirdpartyid = 0; + } if ($objectclass == 'Facture') { $tmparraycontact = array(); @@ -121,41 +131,37 @@ if (!$error && $massaction == 'confirm_presend') } // Check mandatory parameters - if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) - { + if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) { $error++; setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); $massaction = 'presend'; } $receiver = $_POST['receiver']; - if (!is_array($receiver)) - { - if (empty($receiver) || $receiver == '-1') $receiver = array(); - else $receiver = array($receiver); + if (!is_array($receiver)) { + if (empty($receiver) || $receiver == '-1') { + $receiver = array(); + } else { + $receiver = array($receiver); + } } - if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); - $massaction = 'presend'; + if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) { // if only one recipient, receiver is mandatory + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); + $massaction = 'presend'; } - if (!GETPOST('subject', 'restricthtml')) - { + if (!GETPOST('subject', 'restricthtml')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); $massaction = 'presend'; } // Loop on each recipient/thirdparty - if (!$error) - { - foreach ($listofobjectthirdparties as $thirdpartyid) - { + if (!$error) { + foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); exit; } @@ -167,21 +173,16 @@ if (!$error && $massaction == 'confirm_presend') // Define $sendto $tmparray = array(); - if (trim($_POST['sendto'])) - { + if (trim($_POST['sendto'])) { // Recipients are provided into free text $tmparray[] = trim($_POST['sendto']); } - if (count($receiver) > 0) - { - foreach ($receiver as $key=>$val) - { + if (count($receiver) > 0) { + foreach ($receiver as $key => $val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party or user - { + if ($val == 'thirdparty') { // Id of third party or user $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact - { + } elseif ($val && method_exists($thirdparty, 'contact_get_property')) { // Id of contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; } @@ -191,26 +192,23 @@ if (!$error && $massaction == 'confirm_presend') // Define $sendtocc $receivercc = $_POST['receivercc']; - if (!is_array($receivercc)) - { - if ($receivercc == '-1') $receivercc = array(); - else $receivercc = array($receivercc); + if (!is_array($receivercc)) { + if ($receivercc == '-1') { + $receivercc = array(); + } else { + $receivercc = array($receivercc); + } } $tmparray = array(); - if (trim($_POST['sendtocc'])) - { + if (trim($_POST['sendtocc'])) { $tmparray[] = trim($_POST['sendtocc']); } - if (count($receivercc) > 0) - { - foreach ($receivercc as $key=>$val) - { + if (count($receivercc) > 0) { + foreach ($receivercc as $key => $val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party - { + if ($val == 'thirdparty') { // Id of third party $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val) // Id du contact - { + } elseif ($val) { // Id du contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? } @@ -223,25 +221,21 @@ if (!$error && $massaction == 'confirm_presend') $listofqualifiedref = array(); $thirdpartywithoutemail = array(); - foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) - { + foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut); - if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) - { + if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
    '.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'

    '; continue; // Payment done or started or canceled } - if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) - { + if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
    '.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'

    '; continue; } - if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) - { + if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
    '.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'

    '; @@ -249,23 +243,18 @@ if (!$error && $massaction == 'confirm_presend') } // Test recipient - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - if ($objectobj->element == 'societe') - { + if (empty($sendto)) { // For the case, no recipient were set (multi thirdparties send) + if ($objectobj->element == 'societe') { $sendto = $objectobj->email; - } elseif ($objectobj->element == 'expensereport') - { + } elseif ($objectobj->element == 'expensereport') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; - } elseif ($objectobj->element == 'holiday') - { + } elseif ($objectobj->element == 'holiday') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user); $sendto = $fuser->email; - } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) - { + } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); $objectobj->fetch_thirdparty(); $contactidtosend = array(); @@ -284,25 +273,22 @@ if (!$error && $massaction == 'confirm_presend') } } - if (empty($sendto)) - { + if (empty($sendto)) { if ($objectobj->element == 'societe') { $objectobj->thirdparty = $objectobj; // Hack so following code is comaptible when objectobj is a thirdparty } - //print "No recipient for thirdparty ".$objectobj->thirdparty->name; - $nbignored++; - if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) - { + //print "No recipient for thirdparty ".$objectobj->thirdparty->name; + $nbignored++; + if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) { $resaction .= '
    '.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'

    '; } dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING); $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1; - continue; + continue; } - if ($_POST['addmaindocfile']) - { + if ($_POST['addmaindocfile']) { // TODO Use future field $objectobj->fullpathdoc to know where is stored default file // TODO If not defined, use $objectobj->model_pdf (or defaut invoice config) to know what is template to use to regenerate doc. $filename = dol_sanitizeFileName($objectobj->ref).'.pdf'; @@ -313,16 +299,14 @@ if (!$error && $massaction == 'confirm_presend') $file = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate - if ($objectobj->element == 'invoice_supplier') - { + if ($objectobj->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); $file = $fileparams['fullname']; } $mime = dol_mimetype($file); - if (dol_is_file($file)) - { + if (dol_is_file($file)) { // Create form object $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( 'paths'=>array($file), @@ -347,8 +331,7 @@ if (!$error && $massaction == 'confirm_presend') } // Send email if there is at least one qualified object for current thirdparty - if (count($listofqualifiedobj) > 0) - { + if (count($listofqualifiedobj) > 0) { $langs->load("commercial"); $reg = array(); @@ -367,8 +350,7 @@ if (!$error && $massaction == 'confirm_presend') $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $from = $obj->label.' <'.$obj->email.'>'; } } else { @@ -380,22 +362,34 @@ if (!$error && $massaction == 'confirm_presend') $message = GETPOST('message', 'restricthtml'); $sendtobcc = GETPOST('sendtoccc'); - if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); - if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + if ($objectclass == 'Propal') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + } + if ($objectclass == 'Commande') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + } + if ($objectclass == 'Facture') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + } + if ($objectclass == 'Supplier_Proposal') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); + } + if ($objectclass == 'CommandeFournisseur') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); + } + if ($objectclass == 'FactureFournisseur') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + } + if ($objectclass == 'Project') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + } // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) $looparray = array(); - if (!$oneemailperrecipient) - { + if (!$oneemailperrecipient) { $looparray = $listofqualifiedobj; - foreach ($looparray as $key => $objecttmp) - { + foreach ($looparray as $key => $objecttmp) { $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { @@ -406,11 +400,9 @@ if (!$error && $massaction == 'confirm_presend') //var_dump($looparray);exit; dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); - foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object - { + foreach ($looparray as $objectid => $objecttmp) { // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object // Make substitution in email content - if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) - { + if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { $objecttmp->fetch_projet(); } $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); @@ -434,12 +426,10 @@ if (!$error && $massaction == 'confirm_presend') $messagereplaced = make_substitutions($message, $substitutionarray); $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); - if ($oneemailperrecipient) - { + if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty - if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) - { - foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { + if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { + foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { // Create form object $attachedfiles = array( 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), @@ -459,20 +449,37 @@ if (!$error && $massaction == 'confirm_presend') $mimetype = $attachedfiles['mimes']; // Define the trackid when emails sent from the mass action - if ($oneemailperrecipient) - { + if ($oneemailperrecipient) { $trackid = 'thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') { + $trackid = 'use'.$thirdparty->id; + } + if ($objecttmp->element == 'holiday') { + $trackid = 'use'.$thirdparty->id; + } } else { $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; - if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; - if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; - if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; - if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; - if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; - if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; + if (get_class($objecttmp) == 'Contrat') { + $trackid = 'con'; + } + if (get_class($objecttmp) == 'Propal') { + $trackid = 'pro'; + } + if (get_class($objecttmp) == 'Commande') { + $trackid = 'ord'; + } + if (get_class($objecttmp) == 'Facture') { + $trackid = 'inv'; + } + if (get_class($objecttmp) == 'Supplier_Proposal') { + $trackid = 'spr'; + } + if (get_class($objecttmp) == 'CommandeFournisseur') { + $trackid = 'sor'; + } + if (get_class($objecttmp) == 'FactureFournisseur') { + $trackid = 'sin'; + } $trackid .= $objecttmp->id; } @@ -480,40 +487,42 @@ if (!$error && $massaction == 'confirm_presend') //var_dump($trackid);exit; //var_dump($subjectreplaced); - if (empty($sendcontext)) $sendcontext = 'standard'; + if (empty($sendcontext)) { + $sendcontext = 'standard'; + } // Send mail (substitutionarray must be done just before this) require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); - if ($mailfile->error) - { + if ($mailfile->error) { $resaction .= '
    '.$mailfile->error.'
    '; } else { $result = $mailfile->sendfile(); - if ($result) - { + if ($result) { $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
    '; // Must not contain " $error = 0; // Insert logs into agenda - foreach ($listofqualifiedobj as $objid2 => $objectobj2) - { - if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { + if ((!$oneemailperrecipient) && $objid2 != $objectid) { + continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + } dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; - if ($objectclass == 'Commande') $actiontypecode='AC_COM'; - if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; - if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; - if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; - if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ + if ($objectclass == 'Commande') $actiontypecode='AC_COM'; + if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; + if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; + if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; + if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + if ($message) { + if ($sendtocc) { + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + } $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); @@ -528,24 +537,40 @@ if (!$error && $massaction == 'confirm_presend') $objectobj2->elementtype = $objectobj2->element; $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; - if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; - if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL'; - if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL'; - if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL'; - if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL'; - if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; - if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; - if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + if ($triggername == 'SOCIETE_SENTBYMAIL') { + $triggername = 'COMPANY_SENTBYMAIL'; + } + if ($triggername == 'CONTRAT_SENTBYMAIL') { + $triggername = 'CONTRACT_SENTBYMAIL'; + } + if ($triggername == 'COMMANDE_SENTBYMAIL') { + $triggername = 'ORDER_SENTBYMAIL'; + } + if ($triggername == 'FACTURE_SENTBYMAIL') { + $triggername = 'BILL_SENTBYMAIL'; + } + if ($triggername == 'EXPEDITION_SENTBYMAIL') { + $triggername = 'SHIPPING_SENTBYMAIL'; + } + if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') { + $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; + } + if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') { + $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; + } + if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') { + $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + } - if (!empty($triggername)) - { + if (!empty($triggername)) { // Call trigger $result = $objectobj2->call_trigger($triggername, $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if ($error) - { + if ($error) { setEventMessages($db->lasterror(), $errors, 'errors'); dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR); } @@ -555,8 +580,7 @@ if (!$error && $massaction == 'confirm_presend') } } else { $langs->load("other"); - if ($mailfile->error) - { + if ($mailfile->error) { $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); $resaction .= '
    '.$mailfile->error.'
    '; } else { @@ -574,8 +598,7 @@ if (!$error && $massaction == 'confirm_presend') $resaction .= $langs->trans("NbIgnored").': '.($nbignored ? $nbignored : 0)."\n
    "; $resaction .= $langs->trans("NbSent").': '.($nbsent ? $nbsent : 0)."\n
    "; - if ($nbsent) - { + if ($nbsent) { $action = ''; // Do not show form post if there was at least one successfull sent //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); @@ -591,8 +614,7 @@ if (!$error && $massaction == 'confirm_presend') } // TODO Move this action into commande/list.php if called only by this page. -if ($massaction == 'confirm_createbills') // Create bills from orders. -{ +if ($massaction == 'confirm_createbills') { // Create bills from orders. $orders = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('validate_invoices', 'int'); @@ -606,10 +628,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $db->begin(); - foreach ($orders as $id_order) - { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) { + continue; + } $objecttmp = new Facture($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { @@ -624,11 +647,12 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + if (empty($createbills_onebythird)) { + $objecttmp->ref_client = $cmd->ref_client; + } $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) - { + if (empty($datefacture)) { $datefacture = dol_now(); } @@ -647,8 +671,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. } } - if ($objecttmp->id > 0) - { + if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql .= "fk_source"; $sql .= ", sourcetype"; @@ -661,16 +684,13 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $sql .= ", '".$db->escape($objecttmp->element)."'"; $sql .= ")"; - if (!$db->query($sql)) - { + if (!$db->query($sql)) { $error++; } - if (!$error) - { + if (!$error) { $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) - { + if (empty($lines) && method_exists($cmd, 'fetch_lines')) { $cmd->fetch_lines(); $lines = $cmd->lines; } @@ -678,17 +698,14 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); // If we build one invoice for several order, we must put the invoice of order on the line - if (!empty($createbills_onebythird)) - { + if (!empty($createbills_onebythird)) { $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } - if ($lines[$i]->subprice < 0) - { + if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; @@ -699,8 +716,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $discount->fk_user = $user->id; $discount->description = $desc; $discountid = $discount->create($user); - if ($discountid > 0) - { + if ($discountid > 0) { $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else { @@ -713,17 +729,28 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start $date_start = false; - if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + if ($lines[$i]->date_debut_prevue) { + $date_start = $lines[$i]->date_debut_prevue; + } + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } //Date end $date_end = false; - if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; + if ($lines[$i]->date_fin_prevue) { + $date_end = $lines[$i]->date_fin_prevue; + } + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } @@ -762,9 +789,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. 100, 0, $lines[$i]->fk_unit - ); - if ($result > 0) - { + ); + if ($result > 0) { $lineid = $result; } else { $lineid = 0; @@ -772,8 +798,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. break; } // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { + if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } @@ -783,23 +808,23 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; - else $TFact[$objecttmp->id] = $objecttmp; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { + $TFactThird[$cmd->socid] = $objecttmp; + } else { + $TFact[$objecttmp->id] = $objecttmp; + } } // Build doc with all invoices $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (!$error && $validate_invoices) - { + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach ($TAllFact as &$objecttmp) - { + foreach ($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); - if ($result <= 0) - { + if ($result <= 0) { $error++; setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); break; @@ -815,7 +840,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. // Call action to build doc $savobject = $object; - $object = $objecttmp; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $object = $savobject; } @@ -823,8 +848,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $massaction = $action = 'confirm_createbills'; } - if (!$error) - { + if (!$error) { $db->commit(); if ($nb_bills_created == 1) { @@ -837,29 +861,75 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= '&sall='.urlencode($sall); - if ($socid > 0) $param .= '&socid='.urlencode($socid); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_company) $param .= '&search_company='.urlencode($search_company); - if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); - 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_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($billed != '') $param .= '&billed='.urlencode($billed); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + 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_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($billed != '') { + $param .= '&billed='.urlencode($billed); + } header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; @@ -873,22 +943,20 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. } } -if (!$error && $massaction == 'cancelorders') -{ +if (!$error && $massaction == 'cancelorders') { $db->begin(); $nbok = 0; $orders = GETPOST('toselect', 'array'); - foreach ($orders as $id_order) - { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) + if ($cmd->fetch($id_order) <= 0) { continue; + } - if ($cmd->statut != Commande::STATUS_VALIDATED) - { + if ($cmd->statut != Commande::STATUS_VALIDATED) { $langs->load('errors'); setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); $error++; @@ -898,18 +966,20 @@ if (!$error && $massaction == 'cancelorders') $result = $cmd->cancel(); } - if ($result < 0) - { + if ($result < 0) { setEventMessages($cmd->error, $cmd->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } - if (!$error) - { - if ($nbok > 1) + if (!$error) { + if ($nbok > 1) { setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -917,10 +987,8 @@ if (!$error && $massaction == 'cancelorders') } -if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) -{ - if (empty($diroutputmassaction)) - { +if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { + if (empty($diroutputmassaction)) { dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); exit; } @@ -933,12 +1001,10 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $listofobjectid = array(); $listofobjectthirdparties = array(); $listofobjectref = array(); - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; @@ -947,19 +1013,20 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto } $arrayofinclusion = array(); - foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; - foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; + } + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + } $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); // build list of files with full path $files = array(); - foreach ($listofobjectref as $basename) - { + foreach ($listofobjectref as $basename) { $basename = dol_sanitizeFileName($basename); - foreach ($listoffiles as $filefound) - { - if (strstr($filefound["name"], $basename)) - { + foreach ($listoffiles as $filefound) { + if (strstr($filefound["name"], $basename)) { $files[] = $uploaddir.'/'.$basename.'/'.$filefound["name"]; break; } @@ -969,15 +1036,18 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // Define output language (Here it is not used because we do only merging existing PDF) $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $objecttmp->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) - { + if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { // Create output dir if not exists dol_mkdir($diroutputmassaction); @@ -986,16 +1056,21 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $filename = preg_replace('/\s/', '_', $filename); // Save merged file - if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) - { - if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { + if ($option == 'late') { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + } else { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + } + if ($year) { + $filename .= '_'.$year; + } + if ($month) { + $filename .= '_'.$month; } - if ($year) $filename .= '_'.$year; - if ($month) $filename .= '_'.$month; - if (count($files) > 0) - { + if (count($files) > 0) { $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; @@ -1009,8 +1084,9 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // check if pdftk is installed if (file_exists($file)) { - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -1029,22 +1105,21 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $pdf = pdf_getInstance($format); - if (class_exists('TCPDF')) - { + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } // Add all others - foreach ($files as $file) - { + foreach ($files as $file) { // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { + for ($i = 1; $i <= $pagecount; $i++) { $tplidx = $pdf->importPage($i); $s = $pdf->getTemplatesize($tplidx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); @@ -1060,20 +1135,26 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $filename = preg_replace('/\s/', '_', $filename); // Save merged file - if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) - { - if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { + if ($option == 'late') { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + } else { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } } - if ($year) $filename .= '_'.$year; - if ($month) $filename .= '_'.$month; - if ($pagecount) - { + if ($year) { + $filename .= '_'.$year; + } + if ($month) { + $filename .= '_'.$month; + } + if ($pagecount) { $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -1084,47 +1165,43 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto } // Remove a file from massaction area -if ($action == 'remove_file') -{ +if ($action == 'remove_file') { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $diroutputmassaction; $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + } $action = ''; } // Validate records -if (!$error && $massaction == 'validate' && $permissiontoadd) -{ +if (!$error && $massaction == 'validate' && $permissiontoadd) { $objecttmp = new $objectclass($db); - if (($objecttmp->element == 'facture' || $objecttmp->element == 'invoice') && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { + if (($objecttmp->element == 'facture' || $objecttmp->element == 'invoice') && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) - { + if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $result = $objecttmp->validate($user); if ($result == 0) { $langs->load("errors"); @@ -1174,10 +1251,12 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1200,7 +1279,9 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1209,9 +1290,11 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio } if (!$error) { - if ($nbok > 1) + if ($nbok > 1) { setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1221,47 +1304,45 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio //var_dump($_POST);var_dump($massaction);exit; // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) -if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) -{ +if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { // Refuse deletion for some objects/status - if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) - { + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
    '.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

    '; continue; } - if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) - { + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; $res = $db->query($sql); - if (!$res) - { + if (!$res) { setEventMessage('ErrorRecordParentingNotModified', 'errors'); $error++; } } - if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); + if (in_array($objecttmp->element, array('societe', 'member'))) { + $result = $objecttmp->delete($objecttmp->id, $user, 1); + } else { + $result = $objecttmp->delete($user); + } - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1269,10 +1350,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1282,43 +1365,54 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' // Generate document foreach object according to model linked to object // @todo : propose model selection -if (!$error && $massaction == 'generate_doc' && $permissiontoread) -{ +if (!$error && $massaction == 'generate_doc' && $permissiontoread) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) { + $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) { + $newlang = $objecttmp->default_lang; // for thirdparty + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + if (empty($hidedetails)) { + $hidedetails = 0; + } + if (empty($hidedesc)) { + $hidedesc = 0; + } + if (empty($hideref)) { + $hideref = 0; + } + if (empty($moreparams)) { + $moreparams = null; + } $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1326,10 +1420,12 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1383,10 +1479,12 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null); - else setEventMessages($langs->trans("RecordsModified", $nbok), null); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null); + } $db->commit(); $toselect=array(); } else { @@ -1400,4 +1498,6 @@ $parameters['massaction'] = $massaction; $parameters['diroutputmassaction'] = $diroutputmassaction; $reshook = $hookmanager->executeHooks('doMassActions', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 3838e6963ab..de415bb4ba3 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -55,16 +55,15 @@ if ($action == 'print_file' && $user->rights->printing->read) { $subdir = ''; $module = GETPOST('printer', 'alpha'); - switch ($module) - { - case 'livraison' : + switch ($module) { + case 'livraison': $subdir = 'receipt'; $module = 'expedition'; break; - case 'expedition' : + case 'expedition': $subdir = 'sending'; break; - case 'commande_fournisseur' : + case 'commande_fournisseur': $module = 'fournisseur'; $subdir = 'commande'; break; @@ -75,20 +74,20 @@ if ($action == 'print_file' && $user->rights->printing->read) { //print '
    '.print_r($printer->errors, true).'
    '; setEventMessages($printer->error, $printer->errors, 'errors'); } - if ($ret == 0) - { + if ($ret == 0) { //print '
    '.print_r($printer->errors, true).'
    '; setEventMessages($printer->error, $printer->errors); setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); } - } catch (Exception $e) - { + } catch (Exception $e) { $ret = 1; setEventMessages($e->getMessage(), null, 'errors'); } } } - if ($printerfound == 0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); + if ($printerfound == 0) { + setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); + } } else { setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); } diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index d662d3c85c9..e56c4a95dcd 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -27,66 +27,60 @@ // $nomessageinupdate can be set to 1 // $nomessageinsetmoduleoptions can be set to 1 -if ($action == 'update' && is_array($arrayofparameters)) -{ +if ($action == 'update' && is_array($arrayofparameters)) { $db->begin(); - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { // Modify constant only if key was posted (avoid resetting key to the null value) - if (GETPOSTISSET($key)) - { + if (GETPOSTISSET($key)) { $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } } - if (!$error) - { + if (!$error) { $db->commit(); - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + if (empty($nomessageinupdate)) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } else { $db->rollback(); - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + if (empty($nomessageinupdate)) { + setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } } // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ +if ($action == 'setModuleOptions') { $db->begin(); // Process common param fields - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { + if (is_array($_POST)) { + foreach ($_POST as $key => $val) { $reg = array(); - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... - { + if (preg_match('/^param(\d*)$/', $key, $reg)) { // Works for POST['param'], POST['param1'], POST['param2'], ... $param = GETPOST("param".$reg[1], 'alpha'); $value = GETPOST("value".$reg[1], 'alpha'); - if ($param) - { + if ($param) { $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } } } } // Process upload fields - if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) - { + if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach ($listofdir as $key=>$tmpdir) - { + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { @@ -96,24 +90,27 @@ if ($action == 'setModuleOptions') if (empty($nomessageinsetmoduleoptions)) { setEventMessages($langs->trans("ErrorDirNotFound", $tmpdir), null, 'warnings'); } - } - else { + } else { $upload_dir = $tmpdir; } } - if ($upload_dir) - { + if ($upload_dir) { $result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', ''); - if ($result <= 0) $error++; + if ($result <= 0) { + $error++; + } } } - if (!$error) - { + if (!$error) { $db->commit(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + if (empty($nomessageinsetmoduleoptions)) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } else { $db->rollback(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + if (empty($nomessageinsetmoduleoptions)) { + setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index b9dd4194268..f2426f6523f 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -28,23 +28,29 @@ // $id must be defined (object is loaded in this file with fetch) // Set public note -if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) -{ - if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done +if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) { + if (empty($action) || !is_object($object) || empty($id)) { + dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); + } + if (empty($object->id)) { + $object->fetch($id); // Fetch may not be already done + } $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public'); - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) - { + if ($result_update < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -56,13 +62,21 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } } } elseif ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) { // Set public note - if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + if (empty($action) || !is_object($object) || empty($id)) { + dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); + } + if (empty($object->id)) { + $object->fetch($id); // Fetch may not be already done + } $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private'); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 9575208f485..43438c66dc4 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -27,13 +27,20 @@ * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx */ -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('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 (!isset($mode) || $mode != 'noajax') // For ajax call -{ +if (!isset($mode) || $mode != 'noajax') { // For ajax call require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -50,12 +57,18 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + 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 = "ASC"; - if (!$sortfield) $sortfield = "name"; + if (!$sortorder) { + $sortorder = "ASC"; + } + if (!$sortfield) { + $sortfield = "name"; + } $rootdirfordoc = $conf->ecm->dir_output; @@ -64,8 +77,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); if ($section > 0) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { //dol_print_error($db,$ecmdir->error); //exit; } @@ -76,18 +88,15 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); $relativepath = ''; - if ($section > 0) - { + if ($section > 0) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' - } elseif (GETPOST('section_dir')) - { + } elseif (GETPOST('section_dir')) { $relativepath = GETPOST('section_dir'); } //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); @@ -95,24 +104,27 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $upload_dir = $rootdirfordoc.'/'.$relativepath; } -if (empty($url)) -{ - if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php'; - else $url = DOL_URL_ROOT.'/ecm/index.php'; +if (empty($url)) { + if (GETPOSTISSET('website')) { + $url = DOL_URL_ROOT.'/website/index.php'; + } else { + $url = DOL_URL_ROOT.'/ecm/index.php'; + } } // Load translation files required by the page $langs->loadLangs(array("ecm", "companies", "other")); // Security check -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} //print 'xxx'.$upload_dir; // Security: // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. -if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) -{ +if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) { dol_syslog("Refused to deliver file ".$upload_dir); // Do no show plain path in shown error message dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); @@ -120,12 +132,12 @@ if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) } // Check permissions -if ($modulepart == 'ecm') -{ - if (!$user->rights->ecm->read) accessforbidden(); +if ($modulepart == 'ecm') { + if (!$user->rights->ecm->read) { + accessforbidden(); + } } -if ($modulepart == 'medias') -{ +if ($modulepart == 'medias') { // Always allowed } @@ -142,8 +154,7 @@ if ($modulepart == 'medias') * View */ -if (!isset($mode) || $mode != 'noajax') -{ +if (!isset($mode) || $mode != 'noajax') { // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); header('Pragma: public'); @@ -154,25 +165,27 @@ if (!isset($mode) || $mode != 'noajax') $type = 'directory'; // This test if file exists should be useless. We keep it to find bug more easily -if (!dol_is_dir($upload_dir)) -{ +if (!dol_is_dir($upload_dir)) { //dol_mkdir($upload_dir); /*$langs->load("install"); - dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); - exit;*/ + dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); + exit;*/ } print ''."\n"; //print ''."\n"; $param = ($sortfield ? '&sortfield='.urlencode($sortfield) : '').($sortorder ? '&sortorder='.urlencode($sortorder) : ''); -if (!empty($websitekey)) $param .= '&website='.urlencode($websitekey); -if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid); +if (!empty($websitekey)) { + $param .= '&website='.urlencode($websitekey); +} +if (!empty($pageid)) { + $param .= '&pageid='.urlencode($pageid); +} // Dir scan -if ($type == 'directory') -{ +if ($type == 'directory') { $formfile = new FormFile($db); $maxlengthname = 40; @@ -203,31 +216,48 @@ if ($type == 'directory') $parameters = array('modulepart'=>$module); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); - if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) - { + if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) { $automodules[]=$hookmanager->resArray['module']; } // TODO change for multicompany sharing - if ($module == 'company') $upload_dir = $conf->societe->dir_output; - elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; - elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; - elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; - elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; - elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; - elseif ($module == 'product') $upload_dir = $conf->product->dir_output; - elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; - elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; - elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; - elseif ($module == 'user') $upload_dir = $conf->user->dir_output; - elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; - elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; - elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; - elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; - elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; - else { + if ($module == 'company') { + $upload_dir = $conf->societe->dir_output; + } elseif ($module == 'invoice') { + $upload_dir = $conf->facture->dir_output; + } elseif ($module == 'invoice_supplier') { + $upload_dir = $conf->fournisseur->facture->dir_output; + } elseif ($module == 'propal') { + $upload_dir = $conf->propal->dir_output; + } elseif ($module == 'supplier_proposal') { + $upload_dir = $conf->supplier_proposal->dir_output; + } elseif ($module == 'order') { + $upload_dir = $conf->commande->dir_output; + } elseif ($module == 'order_supplier') { + $upload_dir = $conf->fournisseur->commande->dir_output; + } elseif ($module == 'contract') { + $upload_dir = $conf->contrat->dir_output; + } elseif ($module == 'product') { + $upload_dir = $conf->product->dir_output; + } elseif ($module == 'tax') { + $upload_dir = $conf->tax->dir_output; + } elseif ($module == 'project') { + $upload_dir = $conf->projet->dir_output; + } elseif ($module == 'fichinter') { + $upload_dir = $conf->ficheinter->dir_output; + } elseif ($module == 'user') { + $upload_dir = $conf->user->dir_output; + } elseif ($module == 'expensereport') { + $upload_dir = $conf->expensereport->dir_output; + } elseif ($module == 'holiday') { + $upload_dir = $conf->holiday->dir_output; + } elseif ($module == 'recruitment-recruitmentcandidature') { + $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; + } elseif ($module == 'banque') { + $upload_dir = $conf->bank->dir_output; + } elseif ($module == 'mrp-mo') { + $upload_dir = $conf->mrp->dir_output.'/mo'; + } else { $parameters = array('modulepart'=>$module); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) { @@ -236,14 +266,17 @@ if ($type == 'directory') } // Automatic list - if (in_array($module, $automodules)) - { + if (in_array($module, $automodules)) { $param .= '&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); + if (isset($search_doc_ref) && $search_doc_ref != '') { + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + if ($module == 'company') { + $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + } $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); @@ -254,11 +287,10 @@ if ($type == 'directory') } // Manual list else { - if ($module == 'medias') - { + if ($module == 'medias') { /* - $_POST is array like - 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) + $_POST is array like + 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) 'action' => string 'file_manager' (length=12) 'website' => string 'template' (length=8) 'pageid' => string '124' (length=3) @@ -266,15 +298,20 @@ if ($type == 'directory') 'section_id' => string '0' (length=1) 'max_file_size' => string '2097152' (length=7) 'sendit' => string 'Envoyer fichier' (length=15) - */ + */ $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); - if ($relativepath && $relativepath != '/') $relativepath .= '/'; + if ($relativepath && $relativepath != '/') { + $relativepath .= '/'; + } $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; - if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) - { + if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) { $param .= '&file_manager=1'; - if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); - if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + if (!preg_match('/website=/', $param)) { + $param .= '&website='.urlencode(GETPOST('website', 'alpha')); + } + if (!preg_match('/pageid=/', $param)) { + $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + } //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); } } else { @@ -283,47 +320,46 @@ if ($type == 'directory') } // If $section defined with value 0 - if (($section === '0' || empty($section)) && ($module != 'medias')) - { + if (($section === '0' || empty($section)) && ($module != 'medias')) { $filearray = array(); } else { $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); } - if ($section) - { + if ($section) { $param .= '§ion='.$section; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; + if (isset($search_doc_ref) && $search_doc_ref != '') { + $param .= '&search_doc_ref='.$search_doc_ref; + } $textifempty = $langs->trans('NoFileFound'); - } elseif ($section === '0') - { - if ($module == 'ecm') $textifempty = '
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; - else $textifempty = $langs->trans('NoFileFound'); - } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + } elseif ($section === '0') { + if ($module == 'ecm') { + $textifempty = '
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; + } else { + $textifempty = $langs->trans('NoFileFound'); + } + } else { + $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + } - if ($module == 'medias') - { + if ($module == 'medias') { $useinecm = 6; $modulepart = 'medias'; $perm = ($user->rights->website->write || $user->rights->emailing->creer); $title = 'none'; - } elseif ($module == 'ecm') // DMS/ECM -> manual structure - { - if ($user->rights->ecm->read) - { + } elseif ($module == 'ecm') { // DMS/ECM -> manual structure + if ($user->rights->ecm->read) { // Buttons: Preview $useinecm = 2; } - if ($user->rights->ecm->upload) - { + if ($user->rights->ecm->upload) { // Buttons: Preview + Delete $useinecm = 4; } - if ($user->rights->ecm->setup) - { + if ($user->rights->ecm->setup) { // Buttons: Preview + Delete + Edit $useinecm = 5; } @@ -349,18 +385,27 @@ if ($type == 'directory') // Bottom of page $useajax = 1; -if (!empty($conf->dol_use_jmobile)) $useajax = 0; -if (empty($conf->use_javascript_ajax)) $useajax = 0; -if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; +if (!empty($conf->dol_use_jmobile)) { + $useajax = 0; +} +if (empty($conf->use_javascript_ajax)) { + $useajax = 0; +} +if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) { + $useajax = 0; +} //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); -if ($useajax || $action == 'delete') -{ +if ($useajax || $action == 'delete') { $urlfile = ''; - if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha'); + if ($action == 'delete') { + $urlfile = GETPOST('urlfile', 'alpha'); + } - if (empty($section_dir)) $section_dir = GETPOST("file", "alpha"); + if (empty($section_dir)) { + $section_dir = GETPOST("file", "alpha"); + } $section_id = $section; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -372,22 +417,26 @@ if ($useajax || $action == 'delete') $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is filled by javascript later $formquestion['sortfield'] = array('type'=>'hidden', 'value'=>$sortfield, 'name'=>'sortfield'); // We must always put field, even if empty because it is filled by javascript later $formquestion['sortorder'] = array('type'=>'hidden', 'value'=>$sortorder, 'name'=>'sortorder'); // We must always put field, even if empty because it is filled by javascript later - if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); - if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); - if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); + if (!empty($action) && $action == 'file_manager') { + $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); + } + if (!empty($websitekey)) { + $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); + } + if (!empty($pageid) && $pageid > 0) { + $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); + } print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0)); } -if ($useajax) -{ +if ($useajax) { print ''."\n"; } - if (empty($found)) - { + if (empty($found)) { $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; } - if ($noprint) return $out; - else print $out; + if ($noprint) { + return $out; + } else { + print $out; + } } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 98fbe62e4c5..0eecbbf6d36 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -46,54 +46,48 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if ($type == 'country') - { + if ($type == 'country') { // geoip may have been already included with PEAR - if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { + if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } - } elseif ($type == 'city') - { + } elseif ($type == 'city') { // geoip may have been already included with PEAR - if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { + if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } - } else { print 'ErrorBadParameterInConstructor'; return 0; } + } else { + print 'ErrorBadParameterInConstructor'; return 0; + } // Here, function exists (embedded into PHP or exists because we made include) - if (empty($type) || empty($datfile)) - { + if (empty($type) || empty($datfile)) { $this->errorlabel = 'Constructor was called with no datafile parameter'; dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - if (!file_exists($datfile) || !is_readable($datfile)) - { + if (!file_exists($datfile) || !is_readable($datfile)) { $this->error = 'ErrorGeoIPClassNotInitialized'; $this->errorlabel = "Datafile ".$datfile." not found"; dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $this->gi = new GeoIp2\Database\Reader($datfile); // '/usr/local/share/GeoIP/GeoIP2-City.mmdb' - } catch (Exception $e) - { + } catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - } elseif (function_exists('geoip_open')) - { + } elseif (function_exists('geoip_open')) { $this->gi = geoip_open($datfile, GEOIP_STANDARD); - } - elseif (function_exists('geoip_country_code_by_name')) { + } elseif (function_exists('geoip_country_code_by_name')) { $this->gi = 'NOGI'; // We are using embedded php geoip functions //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); @@ -113,21 +107,19 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if (empty($this->gi)) - { + if (empty($this->gi)) { return ''; } - if ($this->gi == 'NOGI') - { + if ($this->gi == 'NOGI') { // geoip_country_code_by_addr does not exists return strtolower(geoip_country_code_by_name($ip)); } else { - if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) - { - if ($geoipversion == '2') - { + if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { + if ($geoipversion == '2') { try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); @@ -136,12 +128,13 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr')) { + return strtolower(geoip_country_code_by_name($this->gi, $ip)); + } return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } } else { - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); @@ -150,7 +143,9 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr_v6')) return strtolower(geoip_country_code_by_name_v6($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr_v6')) { + return strtolower(geoip_country_code_by_name_v6($this->gi, $ip)); + } return strtolower(geoip_country_code_by_addr_v6($this->gi, $ip)); } } @@ -168,15 +163,15 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if (empty($this->gi)) - { + if (empty($this->gi)) { return ''; } - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $record = $this->gi->country($name); return $record->country->isoCode; @@ -199,12 +194,16 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if ($geoipversion == 'php') - { - if ($this->gi == 'NOGI') return geoip_database_info(); - else return 'geoip_database_info() function not available'; + if ($geoipversion == 'php') { + if ($this->gi == 'NOGI') { + return geoip_database_info(); + } else { + return 'geoip_database_info() function not available'; + } } return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index fada0975938..607993dc325 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -114,9 +114,15 @@ class DolGraph $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; if (is_readable($color_file)) { include_once $color_file; - if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor; - if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor; - if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor; + if (isset($theme_bordercolor)) { + $this->bordercolor = $theme_bordercolor; + } + if (isset($theme_datacolor)) { + $this->datacolor = $theme_datacolor; + } + if (isset($theme_bgcolor)) { + $this->bgcolor = $theme_bgcolor; + } } //print 'bgcolor: '.join(',',$this->bgcolor).'
    '; @@ -597,7 +603,9 @@ 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(); @@ -624,7 +632,9 @@ 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(); @@ -652,7 +662,9 @@ class DolGraph { // phpcs:enable $max = $this->GetMaxValueInData(); - if ($max != 0) $max++; + if ($max != 0) { + $max++; + } $size = dol_strlen(abs(ceil($max))); $factor = 1; for ($i = 0; $i < ($size - 1); $i++) { @@ -660,7 +672,9 @@ class DolGraph } $res = 0; - if (is_numeric($max)) $res = ceil($max / $factor) * $factor; + if (is_numeric($max)) { + $res = ceil($max / $factor) * $factor; + } //print "max=".$max." res=".$res; return $res; @@ -676,8 +690,12 @@ class DolGraph { // phpcs:enable $min = $this->GetMinValueInData(); - if ($min == '') $min = 0; - if ($min != 0) $min--; + if ($min == '') { + $min = 0; + } + if ($min != 0) { + $min--; + } $size = dol_strlen(abs(floor($min))); $factor = 1; for ($i = 0; $i < ($size - 1); $i++) { @@ -751,22 +769,22 @@ class DolGraph if (is_array($this->data) && is_array($this->data[0])) { $nblot = count($this->data[0]) - 1; // -1 to remove legend } - if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + if ($nblot < 0) { + dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + } $firstlot = 0; // Works with line but not with bars //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x $i = $firstlot; $serie = array(); - while ($i < $nblot) // Loop on each serie - { + while ($i < $nblot) { // Loop on each serie $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x $serie[$i] = "var d" . $i . " = [];\n"; // Fill array $values $x = 0; - foreach ($this->data as $valarray) // Loop on each x - { + foreach ($this->data as $valarray) { // Loop on each x $legends[$x] = $valarray[0]; $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null); $x++; @@ -774,11 +792,15 @@ class DolGraph if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { foreach ($values as $x => $y) { - if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; + if (isset($y)) { + $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; + } } } else { foreach ($values as $x => $y) { - if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; + if (isset($y)) { + $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; + } } } @@ -788,7 +810,9 @@ class DolGraph $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); $this->stringtoshow = '' . "\n"; - if (!empty($this->title)) $this->stringtoshow .= '
    ' . $this->title . '
    '; + if (!empty($this->title)) { + $this->stringtoshow .= '
    ' . $this->title . '
    '; + } if (!empty($this->shownographyet)) { $this->stringtoshow .= '
    '; $this->stringtoshow .= '
    ' . $langs->trans("NotEnoughDataYet") . '...
    '; @@ -797,7 +821,9 @@ class DolGraph // Start the div that will contains all the graph $dolxaxisvertical = ''; - if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; + if (count($this->data) > 20) { + $dolxaxisvertical = 'dol-xaxis-vertical'; + } $this->stringtoshow .= '
    ' . "\n"; $this->stringtoshow .= '";*/ + $retstring.=img_object($langs->trans("SelectDate"),'calendarday','id="'.$prefix.'id" class="datecallink"'); + $retstring.="";*/ } else { $retstringbutton = ''; $retsring = $retstringbutton.$retstring; @@ -5818,27 +6148,23 @@ class Form // Day $retstring .= ''; - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } - for ($day = 1; $day <= 31; $day++) - { + for ($day = 1; $day <= 31; $day++) { $retstring .= ''; } $retstring .= ""; $retstring .= ''; - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } // Month - for ($month = 1; $month <= 12; $month++) - { + for ($month = 1; $month <= 12; $month++) { $retstring .= '"; @@ -5846,14 +6172,12 @@ class Form $retstring .= ""; // Year - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } else { $retstring .= ''; - for ($year = $syear - 10; $year < $syear + 10; $year++) - { + for ($year = $syear - 10; $year < $syear + 10; $year++) { $retstring .= ''; } $retstring .= "\n"; @@ -5866,39 +6190,47 @@ class Form $retstring .= ''; } - if ($h) - { + if ($h) { $hourstart = 0; $hourend = 24; if ($openinghours != '') { $openinghours = explode(',', $openinghours); $hourstart = $openinghours[0]; $hourend = $openinghours[1]; - if ($hourend < $hourstart) $hourend = $hourstart; + if ($hourend < $hourstart) { + $hourend = $hourstart; + } } // Show hour $retstring .= ''; - if ($emptyhours) $retstring .= ''; - for ($hour = $hourstart; $hour < $hourend; $hour++) - { - if (strlen($hour) < 2) $hour = "0".$hour; + if ($emptyhours) { + $retstring .= ''; + } + for ($hour = $hourstart; $hour < $hourend; $hour++) { + if (strlen($hour) < 2) { + $hour = "0".$hour; + } $retstring .= ''; } $retstring .= ''; //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; - if ($m) $retstring .= ":"; + if ($m) { + $retstring .= ":"; + } } - if ($m) - { + if ($m) { // Show minutes $retstring .= ''; - if ($emptyhours) $retstring .= ''; - for ($min = 0; $min < 60; $min += $stepminutes) - { - if (strlen($min) < 2) $min = "0".$min; + if ($emptyhours) { + $retstring .= ''; + } + for ($min = 0; $min < 60; $min += $stepminutes) { + if (strlen($min) < 2) { + $min = "0".$min; + } $retstring .= ''; } $retstring .= ''; @@ -5911,8 +6243,7 @@ class Form } // Add a "Now" link - if ($conf->use_javascript_ajax && $addnowlink) - { + if ($conf->use_javascript_ajax && $addnowlink) { // Script which will be inserted in the onClick of the "Now" link $reset_scripts = ""; if ($addnowlink == 2) { // local computer time @@ -5933,64 +6264,65 @@ class Form $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; } elseif ($addnowlink == 2) { /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix. - * This break application for foreign languages. - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; - */ + * This break application for foreign languages. + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; + */ $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; } /*if ($usecalendar == "eldy") - { - $base=DOL_URL_ROOT.'/core/'; - $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');'; - } - else - { - $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); '; - $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); '; - $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); '; - }*/ - // Update the hour part - if ($h) { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + $base=DOL_URL_ROOT.'/core/'; + $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');'; + } + else + { + $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); '; + $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); '; + $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); '; + }*/ + // Update the hour part + if ($h) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - if ($addnowlink == 1) - { + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; - } elseif ($addnowlink == 2) - { + } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; } - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // Update the minute part - if ($m) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($m) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - if ($addnowlink == 1) - { + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; - } elseif ($addnowlink == 2) - { + } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; } - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick - if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) - { + if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { $retstring .= ' '; @@ -5998,8 +6330,7 @@ class Form } // Add a "Plus one hour" link - if ($conf->use_javascript_ajax && $addplusone) - { + if ($conf->use_javascript_ajax && $addplusone) { // Script which will be inserted in the onClick of the "Add plusone" link $reset_scripts = ""; @@ -6009,22 +6340,27 @@ class Form $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; // Update the hour part - if ($h) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($h) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // Update the minute part - if ($m) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($m) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick - if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) - { + if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { $retstring .= ' '; @@ -6032,10 +6368,11 @@ class Form } // Add a link to set data - if ($conf->use_javascript_ajax && $adddateof) - { + if ($conf->use_javascript_ajax && $adddateof) { $tmparray = dol_getdate($adddateof); - if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice"); + if (empty($labeladddateof)) { + $labeladddateof = $langs->trans("DateInvoice"); + } $retstring .= ' -
    '.$langs->trans("None").'
    '; - if (!empty($compatibleImportElementsList)) - { + if (!empty($compatibleImportElementsList)) { $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); } @@ -7199,19 +7601,23 @@ class Form $linktoelemlist = ''; $listofidcompanytoscan = ''; - if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); + if (!is_object($object->thirdparty)) { + $object->fetch_thirdparty(); + } $possiblelinks = array(); - if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) - { + if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) { $listofidcompanytoscan = $object->thirdparty->id; - if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan .= ','.$object->thirdparty->parent; - if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) - { + if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) { + $listofidcompanytoscan .= ','.$object->thirdparty->parent; + } + if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $tmpproject = new Project($this->db); $tmpproject->fetch($object->fk_project); - if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan .= ','.$tmpproject->socid; + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) { + $listofidcompanytoscan .= ','.$tmpproject->socid; + } unset($tmpproject); } @@ -7234,39 +7640,33 @@ class Form $hookmanager->initHooks(array('commonobject')); $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); - if (!empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the object we can link to - { + if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } - if (empty($reshook)) - { - if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) - { + if (empty($reshook)) { + if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) { $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray); } - } elseif ($reshook > 0) - { - if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) - { + } elseif ($reshook > 0) { + if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) { $possiblelinks = $hookmanager->resArray; } } - foreach ($possiblelinks as $key => $possiblelink) - { + foreach ($possiblelinks as $key => $possiblelink) { $num = 0; - if (empty($possiblelink['enabled'])) continue; + if (empty($possiblelink['enabled'])) { + continue; + } - if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) - { + if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) { print '
    use_javascript_ajax) ? '' : ' style="display:none"').'>'; $sql = $possiblelink['sql']; $resqllist = $this->db->query($sql); - if ($resqllist) - { + if ($resqllist) { $num = $this->db->num_rows($resqllist); $i = 0; @@ -7284,8 +7684,7 @@ class Form print '
    '.$langs->trans("AmountHTShort").''.$langs->trans("Company").'
    '; - if (!empty($actioncomm->userownerid)) - { - if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) - { + if (!empty($actioncomm->userownerid)) { + if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) { $tmpuser = $cacheusers[$actioncomm->userownerid]; } else { $tmpuser = new User($this->db); $tmpuser->fetch($actioncomm->userownerid); $cacheusers[$actioncomm->userownerid] = $tmpuser; } - if ($tmpuser->id > 0) - { + if ($tmpuser->id > 0) { print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } } @@ -276,14 +289,16 @@ class FormActions // Date print ''.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); - if ($actioncomm->datef) - { + if ($actioncomm->datef) { $tmpa = dol_getdate($actioncomm->datep); $tmpb = dol_getdate($actioncomm->datef); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) - { - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); - } else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { + print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); + } + } else { + print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); + } } print ''; @@ -297,8 +312,7 @@ class FormActions print '
    '.$langs->trans("None").'
    '.$langs->trans("More").'...
    '.$langs->trans('Margins').''.$langs->trans('SellingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'
    '.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products']).''.price($marginInfo['pa_products']).''.price($marginInfo['margin_on_products']).''.(($marginInfo['margin_rate_products'] == '') ? '' : price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').''.(($marginInfo['mark_rate_products'] == '') ? '' : price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').'
    '.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services']).''.price($marginInfo['pa_services']).''.price($marginInfo['margin_on_services']).''.(($marginInfo['margin_rate_services'] == '') ? '' : price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').''.(($marginInfo['mark_rate_services'] == '') ? '' : price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').'
    '.$langs->trans('TotalMargin').''.price($marginInfo['pv_total']).''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'
    '; diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index be169106621..9c75d15bae5 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -62,8 +62,11 @@ class FormOrder extends Form $options[$value] = $tmpsupplierorder->getLibStatut($short); } - if (is_array($selected)) $selectedarray = $selected; - else $selectedarray = explode(',', $selected); + if (is_array($selected)) { + $selectedarray = $selected; + } else { + $selectedarray = explode(',', $selected); + } print Form::multiselectarray($hmlname, $options, $selectedarray, 0); } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index dc6820c56fc..6fee9eb1000 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -76,21 +76,20 @@ class FormOther $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; $sql .= " WHERE type = '".$this->db->escape($type)."'"; - if (!empty($fk_user)) $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model + if (!empty($fk_user)) { + $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model + } $sql .= " ORDER BY label"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { print ''; - if ($useempty) - { + if ($useempty) { print ''; } $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $label = $obj->label; @@ -165,8 +162,7 @@ class FormOther $label .= ' ('.$tmpuser->getFullName($langs).')'; } - if ($selected == $obj->rowid) - { + if ($selected == $obj->rowid) { print ''."\n"; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if (($selected && $selected == $obj->taux) || $num == 1) - { + if (($selected && $selected == $obj->taux) || $num == 1) { $out .= ''."\n"; //$moreforfilter .= ''; // Should use -1 to say nothing } - if (is_array($tab_categs)) - { - foreach ($tab_categs as $categ) - { + if (is_array($tab_categs)) { + foreach ($tab_categs as $categ) { $moreforfilter .= ''; } @@ -418,13 +407,11 @@ class FormOther $out = ''; // Enhance with select2 - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname); - if ($comboenhancement) - { + if ($comboenhancement) { $out .= $comboenhancement; } } @@ -435,8 +422,12 @@ class FormOther $out .= ''; - if ($useempty) print ''; + if ($useempty) { + print ''; + } $j = 0; $level = 0; $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid); @@ -620,13 +618,15 @@ class FormOther //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines // Break on a new project - if ($parent == 0) // We are on a task at first level - { - if ($lines[$i]->fk_project != $lastprojectid) // Break found on project - { - if ($i > 0) print ''; + if ($parent == 0) { // We are on a task at first level + if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project + if ($i > 0) { + print ''; + } print '
    '; print 'withnotifytiersatcreate ? ' checked="checked"' : '').'>'; print '
    '; print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); @@ -429,14 +428,15 @@ class FormTicket // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { print $ticketstat->showOptionals($extrafields, 'create'); } print '
    '; - if ($withdolfichehead) print dol_get_fiche_end(); + if ($withdolfichehead) { + print dol_get_fiche_end(); + } print '
    '; print ''; @@ -761,7 +761,9 @@ class FormTicket // Set tmp user directory $vardir = $conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path - if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); + if (is_dir($upload_dir)) { + dol_delete_dir_recursive($upload_dir); + } $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined unset($_SESSION["listofpaths".$keytoavoidconflict]); @@ -782,23 +784,25 @@ class FormTicket $formmail = new FormMail($this->db); $addfileaction = 'addfile'; - if (!is_object($form)) $form = new Form($this->db); + if (!is_object($form)) { + $form = new Form($this->db); + } // Load translation files required by the page $langs->loadLangs(array('other', 'mails')); // Clear temp files. Must be done at beginning, before call of triggers - if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) - { + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { $this->clear_attached_files(); } // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels']; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $this->param['langsmodels']; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('other'); @@ -806,11 +810,9 @@ class FormTicket // Get message template for $this->param["models"] into c_email_templates $arraydefaultmessage = -1; - if ($this->param['models'] != 'none') - { + if ($this->param['models'] != 'none') { $model_id = 0; - if (array_key_exists('models_id', $this->param)) - { + if (array_key_exists('models_id', $this->param)) { $model_id = $this->param["models_id"]; } @@ -823,20 +825,23 @@ class FormTicket $listofmimes = array(); $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined - if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) - { - if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) - { - foreach ($this->param['fileinit'] as $file) - { + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { + if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) { + foreach ($this->param['fileinit'] as $file) { $this->add_attached_files($file, basename($file), dol_mimetype($file)); } } } - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } // Define output language $outputlangs = $langs; @@ -902,8 +907,7 @@ class FormTicket print ''; // External users can't send message email - if ($user->rights->ticket->write && !$user->socid) - { + if ($user->rights->ticket->write && !$user->socid) { print '
    '; $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ''); print ' '; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 8cbb7967415..9f1afab13f7 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -68,21 +68,17 @@ class FormWebsite $sql .= " WHERE 1 = 1"; $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $out .= ''; - if ($useempty == 1 || ($useempty == 2 && $num > 1)) - { + if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; } - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid || $selected == $obj->code) - { + if ($selected == $obj->rowid || $selected == $obj->code) { print '
    '; + } } @@ -514,10 +696,14 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 $urlregex = ''; // SCHEME - if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; + if ($http) { + $urlregex .= "^(http:\/\/|https:\/\/)"; + } // USER AND PASS - if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; + if ($pass) { + $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; + } // HOSTNAME OR IP //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) @@ -526,17 +712,24 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 //use only one of the above // PORT - if ($port) $urlregex .= "(\:[0-9]{2,5})"; + if ($port) { + $urlregex .= "(\:[0-9]{2,5})"; + } // PATH - if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; + if ($path) { + $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; + } // GET Query - if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; + if ($query) { + $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; + } // ANCHOR - if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; + if ($anchor) { + $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; + } // check - if (preg_match('/'.$urlregex.'/i', $url)) - { + if (preg_match('/'.$urlregex.'/i', $url)) { $ValidUrl = 1; } //print $urlregex.' - '.$url.' - '.$ValidUrl; @@ -552,16 +745,14 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 */ function isValidVATID($company) { - if ($company->isInEEC()) // Syntax check rules for EEC countries - { + if ($company->isInEEC()) { // Syntax check rules for EEC countries /* Disabled because some companies can have an address in Irland and a vat number in France. - $vatprefix = $company->country_code; - if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; - elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers - else $vatprefix = preg_quote($vatprefix, '/');*/ + $vatprefix = $company->country_code; + if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; + elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers + else $vatprefix = preg_quote($vatprefix, '/');*/ $vatprefix = '[a-zA-Z][a-zA-Z]'; - if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) - { + if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) { return 0; } } @@ -582,8 +773,7 @@ function clean_url($url, $http = 1) // To include the minus sign in a char class, we must not escape it but put it at the end of the class // Also, there's no need of escape a dot sign in a class $regs = array(); - if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) - { + if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) { $proto = $regs[1]; $domain = $regs[2]; $port = isset($regs[3]) ? $regs[3] : ''; @@ -593,10 +783,8 @@ function clean_url($url, $http = 1) // Si http: defini on supprime le http (Si https on ne supprime pas) $newproto = $proto; - if ($http == 0) - { - if (preg_match('/^http:[\\/]+/i', $url)) - { + if ($http == 0) { + if (preg_match('/^http:[\\/]+/i', $url)) { $url = preg_replace('/^http:[\\/]+/i', '', $url); $newproto = ''; } @@ -606,7 +794,9 @@ function clean_url($url, $http = 1) $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain, '/').'/i', $newproto.strtolower($domain), $url); return $CleanUrl; - } else return $url; + } else { + return $url; + } } @@ -624,7 +814,9 @@ function clean_url($url, $http = 1) */ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail = 4, $nbdisplaydomain = 3, $displaytld = true) { - if (!isValidEmail($mail))return ''; + if (!isValidEmail($mail)) { + return ''; + } $tab = explode('@', $mail); $tab2 = explode('.', $tab[1]); $string_replace = ''; @@ -633,8 +825,7 @@ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail $mail_tld = ''; $nbofelem = count($tab2); - for ($i = 1; $i < $nbofelem && $displaytld; $i++) - { + for ($i = 1; $i < $nbofelem && $displaytld; $i++) { $mail_tld .= '.'.$tab2[$i]; } @@ -686,7 +877,9 @@ function array2tr($data, $troptions = '', $tdoptions = '') function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '', $tdoptions = '') { $text = ''; - if ($tableMarkup) $text = ''; + if ($tableMarkup) { + $text = '
    '; + } foreach ($data as $key => $item) { if (is_array($item)) { $text .= array2tr($item, $troptions, $tdoptions); @@ -697,7 +890,9 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' $text .= ''; } } - if ($tableMarkup) $text .= '
    '; + if ($tableMarkup) { + $text .= ''; + } return $text; } @@ -721,15 +916,23 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ { global $conf, $user; - if (!is_object($objsoc)) $valueforccc = $objsoc; - elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); - else $valueforccc = dol_string_unaccent($objsoc->code_client); + if (!is_object($objsoc)) { + $valueforccc = $objsoc; + } elseif ($table == "commande_fournisseur" || $table == "facture_fourn") { + $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); + } else { + $valueforccc = dol_string_unaccent($objsoc->code_client); + } $sharetable = $table; - if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function + if ($table == 'facture' || $table == 'invoice') { + $sharetable = 'invoicenumber'; // for getEntity function + } // Clean parameters - if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers + if ($date == '') { + $date = dol_now(); // We use local year and month of PHP server to search numbers + } // but we should use local year and month of user // For debugging @@ -742,8 +945,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $hasglobalcounter = false; $reg = array(); // Extract value for mask counter, mask raz and mask offset - if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) - { + if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) { $masktri = $reg[1].(!empty($reg[2]) ? $reg[2] : '').(!empty($reg[3]) ? $reg[3] : ''); $maskcounter = $reg[1]; $hasglobalcounter = true; @@ -756,12 +958,13 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskraz = -1; $maskoffset = 0; $resetEveryMonth = false; - if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) { + return 'ErrorCounterMustHaveMoreThan3Digits'; + } // Extract value for third party mask counter $regClientRef = array(); - if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) - { + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) { $maskrefclient = $regClientRef[1].$regClientRef[2]; $maskrefclient_maskclientcode = $regClientRef[1]; $maskrefclient_maskcounter = $regClientRef[2]; @@ -769,19 +972,21 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskrefclient_clientcode = substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code where n is length in mask $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; - } else $maskrefclient = ''; + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { + return 'ErrorCounterMustHaveMoreThan3Digits'; + } + } else { + $maskrefclient = ''; + } // fail if there is neither a global nor a third party counter - if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) - { + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) { return 'ErrorBadMask'; } // Extract value for third party type $regType = array(); - if (preg_match('/\{(t+)\}/i', $mask, $regType)) - { + if (preg_match('/\{(t+)\}/i', $mask, $regType)) { $masktype = $regType[1]; $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask @@ -791,10 +996,12 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } // Extract value for user - $regType = array(); + $regType = array(); if (preg_match('/\{(u+)\}/i', $mask, $regType)) { $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; - if (is_object($objuser)) $lastname = $objuser->lastname; + if (is_object($objuser)) { + $lastname = $objuser->lastname; + } $maskuser = $regType[1]; $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask) @@ -809,15 +1016,13 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskpersonew = array(); $tmpmask = $mask; $regKey = array(); - while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) - { + while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) { $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}'; $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT); $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); } - if (strstr($mask, 'user_extra_')) - { + if (strstr($mask, 'user_extra_')) { $start = "{user_extra_"; $end = "\}"; $extra = get_string_between($mask, "user_extra_", "}"); @@ -831,8 +1036,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); - foreach ($maskperso as $key => $val) - { + foreach ($maskperso as $key => $val) { $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); } $maskwithnocode = $maskwithonlyymcode; @@ -846,8 +1050,12 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ //var_dump($reg); // If an offset is asked - if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) { + $maskoffset = preg_replace('/^\+/', '', $reg[2]); + } + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) { + $maskoffset = preg_replace('/^\+/', '', $reg[3]); + } // Define $sqlwhere $sqlwhere = ''; @@ -855,14 +1063,19 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x // If a restore to zero after a month is asked we check if there is already a value for this year. - if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) { + $yearoffsettype = preg_replace('/^@/', '', $reg[2]); + } + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) { + $yearoffsettype = preg_replace('/^@/', '', $reg[3]); + } //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; - if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) + if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) { $maskraz = $yearoffsettype; // For backward compatibility - elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) + } elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) { $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; + } //print "maskraz=".$maskraz; // -1=no reset if ($maskraz > 0) { // A reset is required @@ -870,27 +1083,44 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskraz = date('m', $date); $resetEveryMonth = true; } - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; + if ($maskraz > 12) { + return 'ErrorBadMaskBadRazMonth'; + } // Define posy, posm and reg - if ($maskraz > 1) // if reset is not first month, we need month and year into mask - { - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz > 1) { // if reset is not first month, we need month and year into mask + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { + $posy = 2; $posm = 3; + } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { + $posy = 3; $posm = 2; + } else { + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + } - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; + if (dol_strlen($reg[$posy]) < 2) { + return 'ErrorCantUseRazWithYearOnOneDigit'; + } } else // if reset is for a specific month in year, we need year { - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 0; } else return 'ErrorCantUseRazIfNoYearInMask'; + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { + $posy = 3; $posm = 2; + } elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { + $posy = 2; $posm = 3; + } elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { + $posy = 2; $posm = 0; + } else { + return 'ErrorCantUseRazIfNoYearInMask'; + } } // Define length $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; // Define pos - $yearpos = (dol_strlen($reg[1]) + 1); + $yearpos = (dol_strlen($reg[1]) + 1); $monthpos = ($yearpos + $yearlen); if ($posy == 3 && $posm == 2) { // if month is before year - $monthpos = (dol_strlen($reg[1]) + 1); - $yearpos = ($monthpos + $monthlen); + $monthpos = (dol_strlen($reg[1]) + 1); + $yearpos = ($monthpos + $monthlen); } //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; @@ -898,8 +1128,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $monthcomp = $maskraz; $yearcomp = 0; - if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + - { + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') { // $yearoffsettype is - or + $currentyear = date("Y", $date); $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear); @@ -907,22 +1136,33 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'
    '; // If after or equal of current fiscal date - if ($date >= $fiscaldate) - { + if ($date >= $fiscaldate) { // If before of next new year date - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; + if ($date < $nextnewyeardate && $yearoffsettype == '+') { + $yearoffset = 1; + } } // If after or equal of current new year date - elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; + elseif ($date >= $newyeardate && $yearoffsettype == '-') { + $yearoffset = -1; + } } // For backward compatibility - elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year + elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { + $yearoffset = -1; + } // If current month lower that month of return to zero, year is previous year - if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); - elseif ($yearlen == 2) $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); - elseif ($yearlen == 1) $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; - if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) - { - if ($yearlen == 4) $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); - elseif ($yearlen == 2) $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); + if ($yearlen == 4) { + $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); + } elseif ($yearlen == 2) { + $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); + } elseif ($yearlen == 1) { + $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; + } + if ($monthcomp > 1 && empty($resetEveryMonth)) { // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) + if ($yearlen == 4) { + $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); + } elseif ($yearlen == 2) { + $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); + } $sqlwhere .= "("; $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$db->escape($yearcomp)."'"; @@ -947,7 +1187,9 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } else { $posnumstart = strrpos($maskwithnocode, $maskcounter); } // Pos of counter in final string (from 0 to ...) - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; + if ($posnumstart < 0) { + return 'ErrorBadMaskFailedToLocatePosOfSequence'; + } $sqlstring = 'SUBSTRING('.$field.', '.($posnumstart + 1).', '.dol_strlen($maskcounter).')'; // Define $maskLike @@ -961,11 +1203,16 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskLike); - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); - foreach ($maskperso as $key => $val) - { + if ($maskrefclient) { + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); + } + if ($masktype) { + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); + } + if ($maskuser) { + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); + } + foreach ($maskperso as $key => $val) { $maskLike = str_replace(dol_string_nospecial($maskperso[$key]), $maskpersonew[$key], $maskLike); } @@ -975,32 +1222,39 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $sql .= " FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; - if ($bentityon) // only if entity enable + if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) + } elseif (!empty($forceentity)) { $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $sql .= $where; - if ($sqlwhere) $sql .= ' AND '.$sqlwhere; + } + if ($where) { + $sql .= $where; + } + if ($sqlwhere) { + $sql .= ' AND '.$sqlwhere; + } //print $sql.'
    '; dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $counter = $obj->val; - } else dol_print_error($db); + } else { + dol_print_error($db); + } // Check if we must force counter to maskoffset - if (empty($counter)) $counter = $maskoffset; - elseif (preg_match('/[^0-9]/i', $counter)) - { + if (empty($counter)) { + $counter = $maskoffset; + } elseif (preg_match('/[^0-9]/i', $counter)) { $counter = 0; dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); - } elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter = $maskoffset; + } elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) { + $counter = $maskoffset; + } - if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. - { + if ($mode == 'last') { // We found value for counter = last counter value. Now need to get corresponding ref of invoice. $counterpadded = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); // Define $maskLike @@ -1013,47 +1267,61 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), $counterpadded, $maskLike); - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); + if ($maskrefclient) { + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); + } + if ($masktype) { + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); + } + if ($maskuser) { + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); + } $ref = ''; $sql = "SELECT ".$field." as ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; $sql .= " AND ".$field." NOT LIKE '%PROV%'"; - if ($bentityon) // only if entity enable + if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) + } elseif (!empty($forceentity)) { $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $sql .= $where; - if ($sqlwhere) $sql .= ' AND '.$sqlwhere; + } + if ($where) { + $sql .= $where; + } + if ($sqlwhere) { + $sql .= ' AND '.$sqlwhere; + } dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $ref = $obj->ref; - } else dol_print_error($db); + if ($obj) { + $ref = $obj->ref; + } + } else { + dol_print_error($db); + } $numFinal = $ref; } elseif ($mode == 'next') { $counter++; // If value for $counter has a length higher than $maskcounter chars - if ($counter >= pow(10, dol_strlen($maskcounter))) - { + if ($counter >= pow(10, dol_strlen($maskcounter))) { $counter = 'ErrorMaxNumberReachForThisMask'; } - if (!empty($maskrefclient_maskcounter)) - { + if (!empty($maskrefclient_maskcounter)) { //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n
    "; // Define $sqlstring $maskrefclient_posnumstart = strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) - if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; + if ($maskrefclient_posnumstart <= 0) { + return 'ErrorBadMask'; + } $maskrefclient_sqlstring = 'SUBSTRING('.$field.', '.($maskrefclient_posnumstart + 1).', '.dol_strlen($maskrefclient_maskcounter).')'; //print "x".$sqlstring; @@ -1075,23 +1343,31 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; //$sql.= " WHERE ".$field." not like '(%'"; $maskrefclient_sql .= " WHERE ".$field." LIKE '".$db->escape($maskrefclient_maskLike)."'"; - if ($bentityon) // only if entity enable + if ($bentityon) { // only if entity enable $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) + } elseif (!empty($forceentity)) { $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $maskrefclient_sql .= $where; //use the same optional where as general mask - if ($sqlwhere) $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask + } + if ($where) { + $maskrefclient_sql .= $where; //use the same optional where as general mask + } + if ($sqlwhere) { + $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask + } $maskrefclient_sql .= ' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient) + 1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$db->escape($maskrefclient_clientcode)."')"; dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); $maskrefclient_resql = $db->query($maskrefclient_sql); - if ($maskrefclient_resql) - { + if ($maskrefclient_resql) { $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); $maskrefclient_counter = $maskrefclient_obj->val; - } else dol_print_error($db); + } else { + dol_print_error($db); + } - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter = $maskrefclient_maskoffset; + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) { + $maskrefclient_counter = $maskrefclient_maskoffset; + } $maskrefclient_counter++; } @@ -1099,8 +1375,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = $mask; // We replace special codes except refclient - if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year - { + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') { // yearoffsettype is - or +, so we don't want current year $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); @@ -1120,8 +1395,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = str_replace($maskbefore, $maskafter, $numFinal); // Now we replace the refclient - if ($maskrefclient) - { + if ($maskrefclient) { //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n
    ";exit; $maskrefclient_maskbefore = '{'.$maskrefclient.'}'; $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); @@ -1129,16 +1403,14 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } // Now we replace the type - if ($masktype) - { + if ($masktype) { $masktype_maskbefore = '{'.$masktype.'}'; $masktype_maskafter = $masktype_value; $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); } // Now we replace the user - if ($maskuser) - { + if ($maskuser) { $maskuser_maskbefore = '{'.$maskuser.'}'; $maskuser_maskafter = $maskuser_value; $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); @@ -1161,7 +1433,9 @@ function get_string_between($string, $start, $end) { $string = " ".$string; $ini = strpos($string, $start); - if ($ini == 0) return ""; + if ($ini == 0) { + return ""; + } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); @@ -1192,12 +1466,13 @@ function check_value($mask, $value) } $maskraz = -1; $maskoffset = 0; - if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskcounter) < 3) { + return 'ErrorCounterMustHaveMoreThan3Digits'; + } // Extract value for third party mask counter $regClientRef = array(); - if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) - { + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) { $maskrefclient = $regClientRef[1].$regClientRef[2]; $maskrefclient_maskclientcode = $regClientRef[1]; $maskrefclient_maskcounter = $regClientRef[2]; @@ -1205,12 +1480,15 @@ function check_value($mask, $value) $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; - } else $maskrefclient = ''; + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { + return 'ErrorCounterMustHaveMoreThan3Digits'; + } + } else { + $maskrefclient = ''; + } // fail if there is neither a global nor a third party counter - if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) - { + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) { return 'ErrorBadMask'; } @@ -1228,46 +1506,62 @@ function check_value($mask, $value) //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
    "; // If an offset is asked - if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) { + $maskoffset = preg_replace('/^\+/', '', $reg[2]); + } + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) { + $maskoffset = preg_replace('/^\+/', '', $reg[3]); + } // Define $sqlwhere // If a restore to zero after a month is asked we check if there is already a value for this year. - if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]); - if ($maskraz >= 0) - { + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) { + $maskraz = preg_replace('/^@/', '', $reg[2]); + } + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) { + $maskraz = preg_replace('/^@/', '', $reg[3]); + } + if ($maskraz >= 0) { if ($maskraz == 99) { $maskraz = date('m'); $resetEveryMonth = true; } - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; + if ($maskraz > 12) { + return 'ErrorBadMaskBadRazMonth'; + } // Define reg - if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; + if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + } + if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { + return 'ErrorCantUseRazIfNoYearInMask'; + } //print "x".$maskwithonlyymcode." ".$maskraz; } //print "masktri=".$masktri." maskcounter=".$maskcounter." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskraz=".$maskraz." maskoffset=".$maskoffset."
    \n"; if (function_exists('mb_strrpos')) { $posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 0, 'UTF-8'); - } - else { + } else { $posnumstart = strrpos($maskwithnocode, $maskcounter); } // Pos of counter in final string (from 0 to ...) - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; + if ($posnumstart < 0) { + return 'ErrorBadMaskFailedToLocatePosOfSequence'; + } // Check we have a number in $value at position ($posnumstart+1).', '.dol_strlen($maskcounter) // TODO - // Check length - $len = dol_strlen($maskwithnocode); - if (dol_strlen($value) != $len) $result = -1; + // Check length + $len = dol_strlen($maskwithnocode); + if (dol_strlen($value) != $len) { + $result = -1; + } - dol_syslog("functions2::check_value result=".$result, LOG_DEBUG); - return $result; + dol_syslog("functions2::check_value result=".$result, LOG_DEBUG); + return $result; } /** @@ -1281,10 +1575,18 @@ function check_value($mask, $value) function binhex($bin, $pad = false, $upper = false) { $last = dol_strlen($bin) - 1; - for ($i = 0; $i <= $last; $i++) { $x += $bin[$last - $i] * pow(2, $i); } + for ($i = 0; $i <= $last; $i++) { + $x += $bin[$last - $i] * pow(2, $i); + } $x = dechex($x); - if ($pad) { while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { $x = "0$x"; } } - if ($upper) { $x = strtoupper($x); } + if ($pad) { + while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { + $x = "0$x"; + } + } + if ($upper) { + $x = strtoupper($x); + } return $x; } @@ -1298,8 +1600,7 @@ function hexbin($hexa) { $bin = ''; $strLength = dol_strlen($hexa); - for ($i = 0; $i < $strLength; $i++) - { + for ($i = 0; $i < $strLength; $i++) { $bin .= str_pad(decbin(hexdec($hexa[$i])), 4, '0', STR_PAD_LEFT); } return $bin; @@ -1315,8 +1616,7 @@ function numero_semaine($time) { $stime = strftime('%Y-%m-%d', $time); - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) - { + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) { // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' $annee = $reg[1]; $mois = $reg[2]; @@ -1324,31 +1624,29 @@ function numero_semaine($time) } /* - * Norme ISO-8601: - * - La semaine 1 de toute annee est celle qui contient le 4 janvier ou que la semaine 1 de toute annee est celle qui contient le 1er jeudi de janvier. - * - La majorite des annees ont 52 semaines mais les annees qui commence un jeudi et les annees bissextiles commencant un mercredi en possede 53. - * - Le 1er jour de la semaine est le Lundi - */ + * Norme ISO-8601: + * - La semaine 1 de toute annee est celle qui contient le 4 janvier ou que la semaine 1 de toute annee est celle qui contient le 1er jeudi de janvier. + * - La majorite des annees ont 52 semaines mais les annees qui commence un jeudi et les annees bissextiles commencant un mercredi en possede 53. + * - Le 1er jour de la semaine est le Lundi + */ // Definition du Jeudi de la semaine - if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) // Dimanche - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) // du Lundi au Mercredi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) // du Vendredi au Samedi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; - else // Jeudi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); + if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) { // Dimanche + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; + } elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) { // du Lundi au Mercredi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; + } elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) { // du Vendredi au Samedi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; + } else { // Jeudi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); + } // Definition du premier Jeudi de l'annee - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) // Dimanche - { + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) { // Dimanche $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60; - } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) // du Lundi au Mercredi - { + } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) { // du Lundi au Mercredi $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; - } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) // du Vendredi au Samedi - { + } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) { // du Vendredi au Samedi $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; } else // Jeudi { @@ -1365,11 +1663,9 @@ function numero_semaine($time) ) + 1; // Cas particulier de la semaine 53 - if ($numeroSemaine == 53) - { + if ($numeroSemaine == 53) { // Les annees qui commence un Jeudi et les annees bissextiles commencant un Mercredi en possede 53 - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) - { + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) { $numeroSemaine = 53; } else { $numeroSemaine = 1; @@ -1392,20 +1688,17 @@ function numero_semaine($time) function weight_convert($weight, &$from_unit, $to_unit) { /* Pour convertire 320 gr en Kg appeler - * $f = -3 - * weigh_convert(320, $f, 0) retournera 0.32 - * - */ - while ($from_unit <> $to_unit) - { - if ($from_unit > $to_unit) - { + * $f = -3 + * weigh_convert(320, $f, 0) retournera 0.32 + * + */ + while ($from_unit <> $to_unit) { + if ($from_unit > $to_unit) { $weight = $weight * 10; $from_unit = $from_unit - 1; $weight = weight_convert($weight, $from_unit, $to_unit); } - if ($from_unit < $to_unit) - { + if ($from_unit < $to_unit) { $weight = $weight / 10; $from_unit = $from_unit + 1; $weight = weight_convert($weight, $from_unit, $to_unit); @@ -1429,7 +1722,9 @@ function weight_convert($weight, &$from_unit, $to_unit) function dol_set_user_param($db, $conf, &$user, $tab) { // Verification parametres - if (count($tab) < 1) return -1; + if (count($tab) < 1) { + return -1; + } $db->begin(); @@ -1439,9 +1734,10 @@ function dol_set_user_param($db, $conf, &$user, $tab) $sql .= " AND entity = ".$conf->entity; $sql .= " AND param in ("; $i = 0; - foreach ($tab as $key => $value) - { - if ($i > 0) $sql .= ','; + foreach ($tab as $key => $value) { + if ($i > 0) { + $sql .= ','; + } $sql .= "'".$db->escape($key)."'"; $i++; } @@ -1449,26 +1745,22 @@ function dol_set_user_param($db, $conf, &$user, $tab) dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); $db->rollback(); return -1; } - foreach ($tab as $key => $value) - { + foreach ($tab as $key => $value) { // Set new parameters - if ($value) - { + if ($value) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; $sql .= " VALUES (".$user->id.",".$conf->entity.","; $sql .= " '".$db->escape($key)."','".$db->escape($value)."')"; dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); $result = $db->query($sql); - if (!$result) - { + if (!$result) { dol_print_error($db); $db->rollback(); return -1; @@ -1494,8 +1786,7 @@ function dol_set_user_param($db, $conf, &$user, $tab) function dol_print_reduction($reduction, $langs) { $string = ''; - if ($reduction == 100) - { + if ($reduction == 100) { $string = $langs->transnoentities("Offered"); } else { $string = vatrate($reduction, true); @@ -1513,8 +1804,11 @@ function dol_print_reduction($reduction, $langs) */ function version_os($option = '') { - if ($option == 'smr') $osversion = php_uname('s').' '.php_uname('m').' '.php_uname('r'); - else $osversion = php_uname(); + if ($option == 'smr') { + $osversion = php_uname('s').' '.php_uname('m').' '.php_uname('r'); + } else { + $osversion = php_uname(); + } return $osversion; } @@ -1573,20 +1867,17 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $found = 1; $obj = $db->fetch_object($resql); // If this generation module needs to scan a directory, then description field is filled // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). - if (!empty($obj->description)) // A list of directories to scan is defined - { + if (!empty($obj->description)) { // A list of directories to scan is defined include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $const = $obj->description; @@ -1597,23 +1888,23 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) // Now we add models found in directories scanned $listofdir = explode(',', $dirtoscan); - foreach ($listofdir as $key=>$tmpdir) - { + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (is_dir($tmpdir)) - { + if (!$tmpdir) { + unset($listofdir[$key]); continue; + } + if (is_dir($tmpdir)) { // all type of template is allowed $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); + if (count($tmpfiles)) { + $listoffiles = array_merge($listoffiles, $tmpfiles); + } } } - if (count($listoffiles)) - { - foreach ($listoffiles as $record) - { + if (count($listoffiles)) { + foreach ($listoffiles as $record) { $max = ($maxfilenamelength ? $maxfilenamelength : 28); $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle'); } @@ -1621,12 +1912,10 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $liste[0] = $obj->label.': '.$langs->trans("None"); } } else { - if ($type == 'member' && $obj->doc_template_name == 'standard') // Special case, if member template, we add variant per format - { + if ($type == 'member' && $obj->doc_template_name == 'standard') { // Special case, if member template, we add variant per format global $_Avery_Labels; include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; - foreach ($_Avery_Labels as $key => $val) - { + foreach ($_Avery_Labels as $key => $val) { $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; } } else { @@ -1641,8 +1930,11 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) return -1; } - if ($found) return $liste; - else return 0; + if ($found) { + return $liste; + } else { + return 0; + } } /** @@ -1657,10 +1949,14 @@ function is_ip($ip) // First we test if it is a valid IPv4 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { // Then we test if it is a private range - if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { + return 2; + } // Then we test if it is a reserved range - if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) { + return 0; + } return 1; } @@ -1715,8 +2011,7 @@ function getSoapParams() $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout //print extension_loaded('soap'); - if ($proxyuse) - { + if ($proxyuse) { $params = array('connection_timeout'=>$timeout, 'response_timeout'=>$response_timeout, 'proxy_use' => 1, @@ -1761,12 +2056,10 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) { $myobject = $regs[1]; $module = $regs[2]; - } - else { + } else { // Parse $objecttype (ex: project_task) $module = $myobject = $objecttype; - if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) - { + if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) { $module = $regs[1]; $myobject = $regs[2]; } @@ -1844,26 +2137,21 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') $classname = 'CommandeFournisseur'; $classpath = 'fourn/class'; $module = 'fournisseur'; - } - elseif ($objecttype == 'supplier_proposal') { + } elseif ($objecttype == 'supplier_proposal') { $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; $classpath = 'supplier_proposal/class'; $module = 'supplier_proposal'; - } - elseif ($objecttype == 'stock') { + } elseif ($objecttype == 'stock') { $classpath = 'product/stock/class'; $classfile = 'entrepot'; $classname = 'Entrepot'; } - if (!empty($conf->$module->enabled)) - { + if (!empty($conf->$module->enabled)) { $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - if ($res) - { - if (class_exists($classname)) - { + if ($res) { + if (class_exists($classname)) { $object = new $classname($db); $res = $object->fetch($objectid); if ($res > 0) { @@ -1872,7 +2160,9 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') $ret = $langs->trans('Deleted'); } unset($object); - } else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); + } else { + dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); + } } } return $ret; @@ -1896,33 +2186,30 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) // Get list of all id in array listofid and all parents in array listofparentid $sql = 'SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $listofid[] = $obj->rowid; - if ($obj->parent_id > 0) $listofparentid[$obj->rowid] = $obj->parent_id; + if ($obj->parent_id > 0) { + $listofparentid[$obj->rowid] = $obj->parent_id; + } $i++; } } else { dol_print_error($db); } - if (count($listofid)) - { + if (count($listofid)) { print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."
    \n"; // Check loops on each other $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $nb = $db->affected_rows($sql); - if ($nb > 0) - { + if ($nb > 0) { print '
    Some record that were parent of themself were cleaned.'; } @@ -1932,17 +2219,14 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) // Check other loops $listofidtoclean = array(); - foreach ($listofparentid as $id => $pid) - { + foreach ($listofparentid as $id => $pid) { // Check depth //print 'Analyse record id='.$id.' with parent '.$pid.'
    '; $cursor = $id; $arrayidparsed = array(); // We start from child $id - while ($cursor > 0) - { + while ($cursor > 0) { $arrayidparsed[$cursor] = 1; - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child - { + if ($arrayidparsed[$listofparentid[$cursor]]) { // We detect a loop. A record with a parent that was already into child print 'Found a loop between id '.$id.' - '.$cursor.'
    '; unset($arrayidparsed); $listofidtoclean[$cursor] = $id; @@ -1951,18 +2235,18 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $cursor = $listofparentid[$cursor]; } - if (count($listofidtoclean)) break; + if (count($listofidtoclean)) { + break; + } } $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; $sql .= " SET ".$fieldfkparent." = 0"; $sql .= " WHERE rowid IN (".join(',', $listofidtoclean).")"; // So we update only records detected wrong $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $nb = $db->affected_rows($sql); - if ($nb > 0) - { + if ($nb > 0) { // Removed orphelins records print '
    Some records were detected to have parent that is a child, we set them as root record for id: '; print join(',', $listofidtoclean); @@ -1977,11 +2261,9 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $sql .= " SET ".$fieldfkparent." = 0"; $sql .= " WHERE ".$fieldfkparent." NOT IN (".join(',', $listofid).")"; // So we update only records linked to a non existing parent $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $nb = $db->affected_rows($sql); - if ($nb > 0) - { + if ($nb > 0) { // Removed orphelins records print '
    Some orphelins were found and modified to be parent so records are visible again for id: '; print join(',', $listofid); @@ -2008,8 +2290,12 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) */ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') { - if (!is_array($arraycolor)) return $colorifnotfound; - if (empty($arraycolor)) return $colorifnotfound; + if (!is_array($arraycolor)) { + return $colorifnotfound; + } + if (empty($arraycolor)) { + return $colorifnotfound; + } return sprintf("%02s", dechex($arraycolor[0])).sprintf("%02s", dechex($arraycolor[1])).sprintf("%02s", dechex($arraycolor[2])); } @@ -2025,13 +2311,16 @@ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') */ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) { - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is + if (is_array($stringcolor)) { + return $stringcolor; // If already into correct output format, we return as is + } $reg = array(); $tmp = preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg); - if (!$tmp) - { + if (!$tmp) { $tmp = explode(',', $stringcolor); - if (count($tmp) < 3) return $colorifnotfound; + if (count($tmp) < 3) { + return $colorifnotfound; + } return $tmp; } return array(hexdec($reg[1]), hexdec($reg[2]), hexdec($reg[3])); @@ -2044,10 +2333,11 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) */ function colorValidateHex($color, $allow_white = true) { - if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false; + if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) { + return false; + } - if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid - { + if (preg_match('/^#[a-f0-9]{6}$/i', $color)) { //hex color is valid return true; } return false; @@ -2064,7 +2354,9 @@ function colorValidateHex($color, $allow_white = true) */ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) { - if (empty($ratio)) $ratio = 0; // To avoid null + if (empty($ratio)) { + $ratio = 0; // To avoid null + } // Steps should be between -255 and 255. Negative = darker, positive = lighter $ratio = max(-100, min(100, $ratio)); @@ -2081,17 +2373,23 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) foreach ($color_parts as $color) { $color = hexdec($color); // Convert to decimal - if ($ratio > 0) // We increase aggressivity - { - if ($color > 127) $color += ((255 - $color) * ($ratio / 100)); - if ($color < 128) $color -= ($color * ($ratio / 100)); + if ($ratio > 0) { // We increase aggressivity + if ($color > 127) { + $color += ((255 - $color) * ($ratio / 100)); + } + if ($color < 128) { + $color -= ($color * ($ratio / 100)); + } } else // We decrease agressiveness { - if ($color > 128) $color -= (($color - 128) * (abs($ratio) / 100)); - if ($color < 127) $color += ((128 - $color) * (abs($ratio) / 100)); + if ($color > 128) { + $color -= (($color - 128) * (abs($ratio) / 100)); + } + if ($color < 127) { + $color += ((128 - $color) * (abs($ratio) / 100)); + } } - if ($brightness > 0) - { + if ($brightness > 0) { $color = ($color * (100 + abs($brightness)) / 100); } else { $color = ($color * (100 - abs($brightness)) / 100); @@ -2228,7 +2526,9 @@ function cartesianArray(array $input) function getModuleDirForApiClass($moduleobject) { $moduledirforclass = $moduleobject; - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); + if ($moduledirforclass != 'api') { + $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); + } if ($moduleobject == 'contracts') { $moduledirforclass = 'contrat'; @@ -2298,8 +2598,7 @@ function randomColor($min = 0, $max = 255) } -if (!function_exists('dolEscapeXML')) -{ +if (!function_exists('dolEscapeXML')) { /** * Encode string for xml usage * @@ -2325,25 +2624,40 @@ function autoOrManual($automaticmanual, $case = 1, $color = 0) { global $langs; $result = 'unknown'; $classname = ''; - if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') // A mettre avant test sur no a cause du == 0 - { + if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') { // A mettre avant test sur no a cause du == 0 $result = $langs->trans('automatic'); - if ($case == 1 || $case == 3) $result = $langs->trans("Automatic"); - if ($case == 2) $result = ''; - if ($case == 3) $result = ' '.$result; + if ($case == 1 || $case == 3) { + $result = $langs->trans("Automatic"); + } + if ($case == 2) { + $result = ''; + } + if ($case == 3) { + $result = ' '.$result; + } $classname = 'ok'; - } elseif ($automaticmanual == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') - { + } elseif ($automaticmanual == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') { $result = $langs->trans("manual"); - if ($case == 1 || $case == 3) $result = $langs->trans("Manual"); - if ($case == 2) $result = ''; - if ($case == 3) $result = ' '.$result; + if ($case == 1 || $case == 3) { + $result = $langs->trans("Manual"); + } + if ($case == 2) { + $result = ''; + } + if ($case == 3) { + $result = ' '.$result; + } - if ($color == 2) $classname = 'ok'; - else $classname = 'error'; + if ($color == 2) { + $classname = 'ok'; + } else { + $classname = 'error'; + } + } + if ($color) { + return ''.$result.''; } - if ($color) return ''.$result.''; return $result; } @@ -2378,7 +2692,9 @@ function price2fec($amount) global $conf; // Clean parameters - if (empty($amount)) $amount = 0; // To have a numeric value if amount not defined or = '' + if (empty($amount)) { + $amount = 0; // To have a numeric value if amount not defined or = '' + } $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) // Output decimal number by default @@ -2402,9 +2718,15 @@ function price2fec($amount) */ function phpSyntaxError($code) { - if (!defined("CR")) define("CR", "\r"); - if (!defined("LF")) define("LF", "\n"); - if (!defined("CRLF")) define("CRLF", "\r\n"); + if (!defined("CR")) { + define("CR", "\r"); + } + if (!defined("LF")) { + define("LF", "\n"); + } + if (!defined("CRLF")) { + define("CRLF", "\r\n"); + } $braces = 0; $inString = 0; @@ -2413,27 +2735,39 @@ function phpSyntaxError($code) switch ($token[0]) { case T_CURLY_OPEN: case T_DOLLAR_OPEN_CURLY_BRACES: - case T_START_HEREDOC: ++$inString; break; - case T_END_HEREDOC: --$inString; break; + case T_START_HEREDOC: + ++$inString; + break; + case T_END_HEREDOC: + --$inString; + break; } } elseif ($inString & 1) { switch ($token) { case '`': case '\'': - case '"': --$inString; break; + case '"': + --$inString; + break; } } else { switch ($token) { case '`': case '\'': - case '"': ++$inString; break; - case '{': ++$braces; break; + case '"': + ++$inString; + break; + case '{': + ++$braces; + break; case '}': if ($inString) { --$inString; } else { --$braces; - if ($braces < 0) break 2; + if ($braces < 0) { + break 2; + } } break; } @@ -2458,7 +2792,9 @@ function phpSyntaxError($code) $code = $code[2] <= $braces ? array($code[1], $code[2]) : array('unexpected $end'.substr($code[1], 14), $braces); - } else $code = array('syntax error', 0); + } else { + $code = array('syntax error', 0); + } } else { ob_end_clean(); $code = false; diff --git a/htdocs/core/lib/functions_ch.lib.php b/htdocs/core/lib/functions_ch.lib.php index 04e74837853..cb683ceec1f 100644 --- a/htdocs/core/lib/functions_ch.lib.php +++ b/htdocs/core/lib/functions_ch.lib.php @@ -158,8 +158,7 @@ function dol_ch_controle_bvrb($bvrb) // Make control $report = 0; - while (dol_strlen($bv) > 1) - { + while (dol_strlen($bv) > 1) { $match = substr($bv, 0, 1); $report = $tableau[$report][$match]; $bv = substr($bv, 1); diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 930c6d06a9e..6de1e69de1f 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -142,10 +142,14 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) $decimalpart = empty($TNum[1]) ? '' : preg_replace('/0+$/', '', $TNum[1]); if ($decimalpart) { - if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); + if (!empty($currency)) { + $concatWords .= ' '.$langs->transnoentities('and'); + } $concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true); - if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); + if (!empty($currency)) { + $concatWords .= ' '.$langs->transnoentities('centimes'); + } } return $concatWords; } @@ -164,7 +168,9 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) function dolNumberToWord($numero, $langs, $numorcurrency = 'number') { // If the number is negative convert to positive and return -1 if it is too long - if ($numero < 0) $numero *= -1; + if ($numero < 0) { + $numero *= -1; + } if ($numero >= 1000000000001) { return -1; } @@ -172,8 +178,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') // Get 2 decimals to cents, another functions round or truncate $strnumber = number_format($numero, 10); $len = strlen($strnumber); - for ($i = 0; $i < $len; $i++) - { + for ($i = 0; $i < $len; $i++) { if ($strnumber[$i] == '.') { $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2]; break; @@ -182,8 +187,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and in case exist why ask $lang like a parameter?*/ - if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') - { + if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { if ($numero >= 1 && $numero < 2) { return ("UN PESO ".$parte_decimal." / 100 M.N."); } elseif ($numero >= 0 && $numero < 1) { @@ -213,9 +217,11 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') $udMILLON = (int) ($numero / 1000000); $numero = $numero - $udMILLON * 1000000; $entexto .= hundreds2text($CdMILLON, $DdMILLON, $udMILLON); - if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) + if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) { $entexto .= " MILLÓN "; - else $entexto .= " MILLONES "; + } else { + $entexto .= " MILLONES "; + } } if ($number >= 1000) { $cdm = (int) ($numero / 100000); @@ -225,16 +231,18 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') $udm = (int) ($numero / 1000); $numero = $numero - $udm * 1000; $entexto .= hundreds2text($cdm, $ddm, $udm); - if ($cdm || $ddm || $udm) + if ($cdm || $ddm || $udm) { $entexto .= " MIL "; + } } $c = (int) ($numero / 100); $numero = $numero - $c * 100; $d = (int) ($numero / 10); $u = (int) $numero - $d * 10; $entexto .= hundreds2text($c, $d, $u); - if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) + if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) { $entexto .= " DE"; + } $entexto .= " PESOS ".$parte_decimal." / 100 M.N."; } return $entexto; @@ -264,7 +272,9 @@ function hundreds2text($hundreds, $tens, $units) $entexto .= $centenas[$hundreds - 1]; } if ($tens > 2) { - if ($hundreds != 0) $entexto .= " "; + if ($hundreds != 0) { + $entexto .= " "; + } $entexto .= $decenas[$tens - 1]; if ($units != 0) { $entexto .= " Y "; @@ -272,16 +282,22 @@ function hundreds2text($hundreds, $tens, $units) } return $entexto; } elseif ($tens == 2) { - if ($hundreds != 0) $entexto .= " "; + if ($hundreds != 0) { + $entexto .= " "; + } $entexto .= " ".$veintis[$units]; return $entexto; } elseif ($tens == 1) { - if ($hundreds != 0) $entexto .= " "; + if ($hundreds != 0) { + $entexto .= " "; + } $entexto .= $diecis[$units]; return $entexto; } if ($units != 0) { - if ($hundreds != 0 || $tens != 0) $entexto .= " "; + if ($hundreds != 0 || $tens != 0) { + $entexto .= " "; + } $entexto .= $unidades[$units - 1]; } return $entexto; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 7e93623f3c1..d624e2e0ace 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -51,9 +51,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $ch = curl_init(); /*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."
    "; - print $USE_PROXY."-".$gv_ApiErrorURL."
    "; - print $nvpStr; - exit;*/ + print $USE_PROXY."-".$gv_ApiErrorURL."
    "; + print $nvpStr; + exit;*/ curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function'); @@ -61,12 +61,16 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = // We force value to false so we will manage redirection ourself later. @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - if (is_array($addheaders) && count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); + if (is_array($addheaders) && 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 // 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). @@ -77,8 +81,12 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $protocols = 0; if (is_array($allowedschemes)) { foreach ($allowedschemes as $allowedscheme) { - if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP; - if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS; + if ($allowedscheme == 'http') { + $protocols |= CURLPROTO_HTTP; + } + if ($allowedscheme == 'https') { + $protocols |= CURLPROTO_HTTPS; + } } curl_setopt($ch, CURLOPT_PROTOCOLS, $protocols); curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, $protocols); @@ -98,8 +106,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } elseif ($postorget == 'PUT') { $array_param = null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' - if (!is_array($param)) parse_str($param, $array_param); - else { + if (!is_array($param)) { + parse_str($param, $array_param); + } else { dol_syslog("parameter param must be a string", LOG_WARNING); $array_param = $param; } @@ -121,7 +130,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 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); + if ($PROXY_USER) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); + } } $newUrl = $url; @@ -130,7 +141,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $response = ''; do { - if ($maxRedirection < 1) break; + if ($maxRedirection < 1) { + break; + } curl_setopt($ch, CURLOPT_URL, $newUrl); @@ -185,8 +198,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } else { $http_code = 0; } - } - while ($http_code); + } while ($http_code); $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request @@ -263,7 +275,9 @@ function getRootURLFromURL($url) $prefix = ''; $tmpurl = $url; $reg = null; - if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1]; + 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 diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index 7b9c5d46da2..4f6da9f6d51 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -47,7 +47,9 @@ function holiday_prepare_head($object) $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/images.lib.php b/htdocs/core/lib/images.lib.php index bd392760cc5..ed7d5b1efcc 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -47,23 +47,41 @@ function image_format_supported($file, $acceptsvg = 0) // Case filename is not a format image $reg = array(); - if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) { + return -1; + } // Case filename is a format image but not supported by this PHP $imgfonction = ''; - if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; - if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; - if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; - if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; - if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; - if (strtolower($reg[1]) == '.webp') $imgfonction = 'imagecreatefromwebp'; - if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; - if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; - if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available - if ($imgfonction) - { - if (!function_exists($imgfonction)) - { + if (strtolower($reg[1]) == '.gif') { + $imgfonction = 'imagecreatefromgif'; + } + if (strtolower($reg[1]) == '.jpg') { + $imgfonction = 'imagecreatefromjpeg'; + } + if (strtolower($reg[1]) == '.jpeg') { + $imgfonction = 'imagecreatefromjpeg'; + } + if (strtolower($reg[1]) == '.png') { + $imgfonction = 'imagecreatefrompng'; + } + if (strtolower($reg[1]) == '.bmp') { + $imgfonction = 'imagecreatefromwbmp'; + } + if (strtolower($reg[1]) == '.webp') { + $imgfonction = 'imagecreatefromwebp'; + } + if (strtolower($reg[1]) == '.xpm') { + $imgfonction = 'imagecreatefromxpm'; + } + if (strtolower($reg[1]) == '.xbm') { + $imgfonction = 'imagecreatefromxbm'; + } + if (strtolower($reg[1]) == '.svg') { + $imgfonction = 'imagecreatefromsvg'; // Never available + } + if ($imgfonction) { + if (!function_exists($imgfonction)) { // Fonctions of conversion not available in this PHP return 0; } @@ -87,16 +105,16 @@ function dol_getImageSize($file, $url = false) { $ret = array(); - if (image_format_supported($file) < 0) return $ret; + if (image_format_supported($file) < 0) { + return $ret; + } $filetoread = $file; - if (!$url) - { + if (!$url) { $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image } - if ($filetoread) - { + if ($filetoread) { $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $ret['width'] = $infoImg[0]; // Largeur de l'image $ret['height'] = $infoImg[1]; // Hauteur de l'image @@ -129,25 +147,19 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $file = trim($file); // Check parameters - if (!$file) - { + if (!$file) { // Si le fichier n'a pas ete indique return 'Bad parameter file'; - } elseif (!file_exists($file)) - { + } elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas return $langs->trans("ErrorFileNotFound", $file); - } elseif (image_format_supported($file) < 0) - { + } elseif (image_format_supported($file) < 0) { return 'This filename '.$file.' does not seem to be an image filename.'; - } elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) - { + } elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; - } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) - { + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) { return 'At least newHeight or newWidth must be defined for resizing'; - } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) - { + } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) { return 'Both newHeight or newWidth must be defined for croping'; } @@ -157,21 +169,17 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $imgWidth = $infoImg[0]; // Largeur de l'image $imgHeight = $infoImg[1]; // Hauteur de l'image - if ($mode == 0) // If resize, we check parameters - { - if ($newWidth <= 0) - { + if ($mode == 0) { // If resize, we check parameters + if ($newWidth <= 0) { $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } - if ($newHeight <= 0) - { + if ($newHeight <= 0) { $newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio } } $imgfonction = ''; - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case 1: // IMG_GIF $imgfonction = 'imagecreatefromgif'; break; @@ -188,18 +196,15 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $imgfonction = 'imagecreatefromwebp'; break; } - if ($imgfonction) - { - if (!function_exists($imgfonction)) - { + if ($imgfonction) { + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; } } // Initialisation des variables selon l'extension de l'image - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case 1: // Gif $img = imagecreatefromgif($filetoread); $extImg = '.gif'; // File name extension of image @@ -228,8 +233,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Create empty image - if ($infoImg[2] == 1) - { + if ($infoImg[2] == 1) { // Compatibilite image GIF $imgThumb = imagecreate($newWidth, $newHeight); } else { @@ -237,20 +241,17 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Activate antialiasing for better quality - if (function_exists('imageantialias')) - { + if (function_exists('imageantialias')) { imageantialias($imgThumb, true); } // This is to keep transparent alpha channel if exists (PHP >= 4.2) - if (function_exists('imagesavealpha')) - { + if (function_exists('imagesavealpha')) { imagesavealpha($imgThumb, true); } // Initialisation des variables selon l'extension de l'image - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case 1: // Gif $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF imagecolortransparent($imgThumb, $trans_colour); @@ -269,7 +270,9 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); break; } - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); + if (function_exists("imagefill")) { + imagefill($imgThumb, 0, 0, $trans_colour); + } dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee @@ -282,8 +285,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //fclose($fp); // Create image on disk - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case 1: // Gif imagegif($imgThumb, $imgThumbName); break; @@ -302,7 +304,9 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + } // Free memory. This does not delete image. imagedestroy($img); @@ -359,8 +363,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) break; } if ($deg) { - 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); $img = imagerotate($img, $deg, imageColorAllocateAlpha($img, 0, 0, 0, 127)); @@ -378,8 +381,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) // Create image on disk $image = false; - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $image = imagegif($img, $fileDest); break; @@ -434,17 +436,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $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) { @@ -471,20 +470,22 @@ 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) - { + if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) { // On cree toujours les vignettes dol_syslog("File size is smaller than thumb size", LOG_DEBUG); //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; } $imgfonction = ''; - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $imgfonction = 'imagecreatefromgif'; break; @@ -501,10 +502,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $imgfonction = 'imagecreatefromwbmp'; break; } - if ($imgfonction) - { - if (!function_exists($imgfonction)) - { + if ($imgfonction) { + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; } @@ -516,8 +515,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Initialisation des variables selon l'extension de l'image $img = null; - switch ($infoImg[2]) - { + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $img = imagecreatefromgif($filetoread); $extImg = '.gif'; // Extension de l'image @@ -540,16 +538,14 @@ 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; } $exifAngle = false; if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { - switch ($ort) - { + switch ($ort) { case 3: // 180 rotate left $exifAngle = 180; break; @@ -568,12 +564,10 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - if ($exifAngle) - { + if ($exifAngle) { $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); $rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127)); @@ -592,15 +586,18 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Initialisation des dimensions de la vignette si elles sont superieures a l'original - if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; } - if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; } + if ($maxWidth > $imgWidth) { + $maxWidth = $imgWidth; + } + if ($maxHeight > $imgHeight) { + $maxHeight = $imgHeight; + } $whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette $imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original // Fixe les dimensions de la vignette - if ($whFact < $imgWhFact) - { + if ($whFact < $imgWhFact) { // Si largeur determinante $thumbWidth = $maxWidth; $thumbHeight = $thumbWidth / $imgWhFact; @@ -613,11 +610,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $thumbWidth = round($thumbWidth); // Define target format - if (empty($targetformat)) $targetformat = $infoImg[2]; + if (empty($targetformat)) { + $targetformat = $infoImg[2]; + } // Create empty image - if ($targetformat == IMAGETYPE_GIF) - { + if ($targetformat == IMAGETYPE_GIF) { // Compatibilite image GIF $imgThumb = imagecreate($thumbWidth, $thumbHeight); } else { @@ -625,21 +623,18 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Activate antialiasing for better quality - if (function_exists('imageantialias')) - { + if (function_exists('imageantialias')) { imageantialias($imgThumb, true); } // This is to keep transparent alpha channel if exists (PHP >= 4.2) - if (function_exists('imagesavealpha')) - { + if (function_exists('imagesavealpha')) { imagesavealpha($imgThumb, true); } // Initialisation des variables selon l'extension de l'image // $targetformat is 0 by default, in such case, we keep original extension - switch ($targetformat) - { + switch ($targetformat) { case IMAGETYPE_GIF: // 1 $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF imagecolortransparent($imgThumb, $trans_colour); @@ -669,7 +664,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $newquality = 'NU'; break; } - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); + if (function_exists("imagefill")) { + imagefill($imgThumb, 0, 0, $trans_colour); + } dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee @@ -686,8 +683,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //fclose($fp); // Create image on disk - switch ($targetformat) - { + switch ($targetformat) { case IMAGETYPE_GIF: // 1 imagegif($imgThumb, $imgThumbName); break; @@ -706,7 +702,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + } // Free memory. This does not delete image. imagedestroy($img); diff --git a/htdocs/core/lib/import.lib.php b/htdocs/core/lib/import.lib.php index 385dee32a86..a9663795988 100644 --- a/htdocs/core/lib/import.lib.php +++ b/htdocs/core/lib/import.lib.php @@ -36,13 +36,14 @@ function import_prepare_head($param, $maxstep = 0) { global $langs; - if (empty($maxstep)) $maxstep = 6; + if (empty($maxstep)) { + $maxstep = 6; + } $h = 0; $head = array(); $i = 1; - while ($i <= $maxstep) - { + while ($i <= $maxstep) { if ($i < 6) { $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param; } else { diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index eda1a901986..89e7f8c8e55 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -45,32 +45,37 @@ function facture_prepare_head($object) $head[$h][2] = 'compta'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $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 (!empty($conf->prelevement->enabled)) - { + if (!empty($conf->prelevement->enabled)) { $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; $sql .= " AND pfd.ext_payment_id IS NULL"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbStandingOrders = $obj->nb; - } else dol_print_error($db); + 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++; } @@ -81,14 +86,19 @@ function facture_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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++; } @@ -100,7 +110,9 @@ function facture_prepare_head($object) $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 f38292cb50d..ca5fc61b60a 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -53,85 +53,106 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sqlwhere = ''; $sqlorder = ''; - if (in_array('all', $filter)) - { + if (in_array('all', $filter)) { $sqlorder = " ORDER BY f.ref ASC"; } - if (in_array('date', $filter)) - { - if (empty($sqlwhere)) $sqlwhere = ' WHERE '; - else $sqlwhere .= " AND"; + 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)."'"; $sqlorder = " ORDER BY f.datef ASC"; } - if (in_array('nopayment', $filter)) - { + 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"; + 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)) - { + 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"; + 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)) - { + if (in_array('payments', $filter)) { $sqlwhere .= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; $sqlwhere .= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; } - if (in_array('bank', $filter)) - { + if (in_array('bank', $filter)) { $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"; + if (in_array('nodeposit', $filter)) { + if (empty($sqlwhere)) { + $sqlwhere = ' WHERE '; + } else { + $sqlwhere .= " AND"; + } $sqlwhere .= ' type <> 3'; } - if (in_array('noreplacement', $filter)) - { - if (empty($sqlwhere)) $sqlwhere = ' WHERE '; - else $sqlwhere .= " AND"; + if (in_array('noreplacement', $filter)) { + if (empty($sqlwhere)) { + $sqlwhere = ' WHERE '; + } else { + $sqlwhere .= " AND"; + } $sqlwhere .= ' type <> 1'; } - if (in_array('nocreditnote', $filter)) - { - if (empty($sqlwhere)) $sqlwhere = ' WHERE '; - else $sqlwhere .= " AND"; + if (in_array('nocreditnote', $filter)) { + 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"; + 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 (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) - { - if (empty($sqlwhere)) $sqlwhere = ' WHERE '; - else $sqlwhere .= " AND"; + if (in_array('onlythirdparties', $filter) && is_array($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); - if ($usestdout) print '--- start'."\n"; + if ($usestdout) { + print '--- start'."\n"; + } // Start of transaction //$db->begin(); @@ -141,54 +162,53 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $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; $oldemail = ''; $message = ''; $total = ''; - if ($num) - { + if ($num) { // First loop on each resultset to build PDF // ----------------------------------------- - while ($cpt < $num) - { + while ($cpt < $num) { $obj = $db->fetch_object($resql); $fac = new Facture($db); $result = $fac->fetch($obj->rowid); - if ($result > 0) - { + if ($result > 0) { $outputlangs = $langs; - if (!empty($newlangid)) - { - if ($outputlangs->defaultlang != $newlangid) - { + if (!empty($newlangid)) { + if ($outputlangs->defaultlang != $newlangid) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlangid); } } $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"; + 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->model_pdf, $outputlangs); } else { - if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n"; + if ($usestdout) { + print "PDF for invoice ".$obj->ref." already exists\n"; + } } // Add file into files array $files[] = $filename; } - if ($result <= 0) - { + 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++; @@ -201,8 +221,11 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $page_hauteur = $formatarray['height']; $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); + if ($usestdout) { + print "Using output PDF format ".join('x', $format)."\n"; + } else { + dol_syslog("Using output PDF format ".join('x', $format), LOG_ERR); + } // Now, build a merged files with all files in $files array @@ -210,26 +233,28 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Create empty PDF $pdf = pdf_getInstance($format); - if (class_exists('TCPDF')) - { + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($langs)); - if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); + if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) { + $pdf->SetCompression(false); + } //$pdf->SetCompression(false); // Add all others - foreach ($files as $file) - { - if ($usestdout) print "Merge PDF file for invoice ".$file."\n"; - else dol_syslog("Merge PDF file for invoice ".$file); + foreach ($files as $file) { + if ($usestdout) { + print "Merge PDF file for invoice ".$file."\n"; + } else { + dol_syslog("Merge PDF file for invoice ".$file); + } // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { + for ($i = 1; $i <= $pagecount; $i++) { $tplidx = $pdf->importPage($i); $s = $pdf->getTemplatesize($tplidx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); @@ -242,27 +267,36 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Save merged file $filename = $fileprefix; - if (empty($filename)) $filename = 'mergedpdf'; - if (!empty($filesuffix)) $filename .= '_'.$filesuffix; + 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"; - else print "Can't build PDF ".$file."\n"; + if ($usestdout) { + if (!$error) { + print "Merged PDF has been built in ".$file."\n"; + } else { + print "Can't build PDF ".$file."\n"; + } } $result = 1; } else { - if ($usestdout) print "No invoices found for criteria.\n"; - else dol_syslog("No invoices found for criteria"); + if ($usestdout) { + print "No invoices found for criteria.\n"; + } else { + dol_syslog("No invoices found for criteria"); + } $result = 0; } } else { @@ -271,6 +305,9 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $error++; } - if ($error) return -1; - else return $result; + if ($error) { + return -1; + } else { + return $result; + } } diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index cd48bbcb3c7..fe50503ed99 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -23,8 +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. * @@ -50,26 +49,32 @@ function dol_json_encode($elements) dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); $num = 0; - if (is_object($elements)) // Count number of properties for an object - { - foreach ($elements as $key => $value) $num++; + if (is_object($elements)) { // Count number of properties for an object + foreach ($elements as $key => $value) { + $num++; + } } else { $num = count($elements); } //var_dump($num); // determine type - if (is_numeric(key($elements)) && key($elements) == 0) - { + 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. $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]]); - else $output .= _val($elements[$keysofelements[$i]]); - if ($i !== $last) $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]]); + } else { + $output .= _val($elements[$keysofelements[$i]]); + } + if ($i !== $last) { + $output .= ','; + } } $output .= ']'; } else { @@ -78,14 +83,22 @@ function dol_json_encode($elements) $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) - { + 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); - else $output .= _val($value); - if ($i !== $last) $output .= ','; + if (is_array($value)) { + $output .= json_encode($value); + } else { + $output .= _val($value); + } + if ($i !== $last) { + $output .= ','; + } ++$i; } $output .= '}'; @@ -109,9 +122,9 @@ function _val($val) $strlen_var = strlen($val); /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ for ($c = 0; $c < $strlen_var; ++$c) { $ord_var_c = ord($val[$c]); @@ -192,14 +205,18 @@ function _val($val) } return '"'.$ascii.'"'; - } elseif (is_int($val)) return sprintf('%d', $val); - elseif (is_float($val)) return sprintf('%F', $val); - elseif (is_bool($val)) return ($val ? 'true' : 'false'); - else return 'null'; + } elseif (is_int($val)) { + return sprintf('%d', $val); + } elseif (is_float($val)) { + return sprintf('%F', $val); + } elseif (is_bool($val)) { + return ($val ? 'true' : 'false'); + } else { + return 'null'; + } } -if (!function_exists('json_decode')) -{ +if (!function_exists('json_decode')) { /** * Implement json_decode for PHP that does not support it * @@ -230,16 +247,23 @@ function dol_json_decode($json, $assoc = 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++) - { - if (!$comment) - { - 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; + for ($i = 0; $i < $strLength; $i++) { + if (!$comment) { + 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; + } } $out = _unval($out); @@ -256,17 +280,16 @@ function dol_json_decode($json, $assoc = false) } // Return an object - if (!$assoc) - { - if (!empty($array)) - { + if (!$assoc) { + if (!empty($array)) { $object = false; if (count($array) > 0) { $object = (object) array(); } - foreach ($array as $key => $value) - { - if ($key) $object->{$key} = $value; + foreach ($array as $key => $value) { + if ($key) { + $object->{$key} = $value; + } } return $object; @@ -287,8 +310,7 @@ function dol_json_decode($json, $assoc = false) function _unval($val) { $reg = array(); - while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) - { + 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])); $utf8 = utf162utf8($utf16); @@ -320,18 +342,18 @@ function utf162utf8($utf16) 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 - return chr($bytes); + return chr($bytes); case (0x07FF & $bytes) == $bytes: // return a 2-byte UTF-8 character // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xC0 | (($bytes >> 6) & 0x1F)) + return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F)); case (0xFFFF & $bytes) == $bytes: // return a 3-byte UTF-8 character // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xE0 | (($bytes >> 12) & 0x0F)) + return chr(0xE0 | (($bytes >> 12) & 0x0F)) . chr(0x80 | (($bytes >> 6) & 0x3F)) . chr(0x80 | ($bytes & 0x3F)); } diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index 640152d5999..9d6e0193108 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -43,40 +43,35 @@ function ldap_prepare_head() $head[$h][2] = 'ldap'; $h++; - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php"; $head[$h][1] = $langs->trans("LDAPUsersSynchro"); $head[$h][2] = 'users'; $h++; } - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php"; $head[$h][1] = $langs->trans("LDAPGroupsSynchro"); $head[$h][2] = 'groups'; $h++; } - if (!empty($conf->societe->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) - { + if (!empty($conf->societe->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php"; $head[$h][1] = $langs->trans("LDAPContactsSynchro"); $head[$h][2] = 'contacts'; $h++; } - if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) - { + if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php"; $head[$h][1] = $langs->trans("LDAPMembersSynchro"); $head[$h][2] = 'members'; $h++; } - if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) - { + if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php"; $head[$h][1] = $langs->trans("LDAPMembersTypesSynchro"); $head[$h][2] = 'memberstypes'; @@ -111,14 +106,11 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass) //print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass; print '
    '; - if (!function_exists("ldap_connect")) - { + if (!function_exists("ldap_connect")) { print ''.$butlabel.''; - } elseif (empty($conf->global->LDAP_SERVER_HOST)) - { + } elseif (empty($conf->global->LDAP_SERVER_HOST)) { print ''.$butlabel.''; - } elseif (empty($key) || empty($dn) || empty($objectclass)) - { + } elseif (empty($key) || empty($dn) || empty($objectclass)) { $langs->load("errors"); print ''.$butlabel.''; } else { @@ -144,39 +136,54 @@ function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = global $bc, $conf; $count--; - if ($count == 0) return -1; // To stop loop - if (!is_array($result)) return -1; + if ($count == 0) { + return -1; // To stop loop + } + if (!is_array($result)) { + return -1; + } - foreach ($result as $key => $val) - { - if ("$key" == "objectclass") continue; - if ("$key" == "count") continue; - if ("$key" == "dn") continue; - if ("$val" == "objectclass") continue; + foreach ($result as $key => $val) { + if ("$key" == "objectclass") { + continue; + } + if ("$key" == "count") { + continue; + } + if ("$key" == "dn") { + continue; + } + if ("$val" == "objectclass") { + continue; + } $lastkey[$level] = $key; - if (is_array($val)) - { + if (is_array($val)) { $hide = 0; - if (!is_numeric($key)) - { + if (!is_numeric($key)) { print ''; print ''; print $key; print ''; - if (strtolower($key) == 'userpassword') $hide = 1; + if (strtolower($key) == 'userpassword') { + $hide = 1; + } } show_ldap_content($val, $level + 1, $count, $var, $hide, $val["count"]); - } elseif ($subcount) - { + } elseif ($subcount) { $subcount--; $newstring = dol_htmlentitiesbr($val); - if ($hide) print preg_replace('/./i', '*', $newstring); - else print $newstring; + if ($hide) { + print preg_replace('/./i', '*', $newstring); + } else { + print $newstring; + } print '
    '; } - if ("$val" != $lastkey[$level] && !$subcount) print ''; + if ("$val" != $lastkey[$level] && !$subcount) { + print ''; + } } return 1; } diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index 3a34d3e57c4..c86d0ecce13 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -60,7 +60,9 @@ function loan_prepare_head($object) $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++; @@ -68,7 +70,9 @@ function loan_prepare_head($object) $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 50330686805..93378d77390 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -43,8 +43,7 @@ function member_prepare_head(Adherent $object) $h++; if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) - { + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id; @@ -53,13 +52,14 @@ 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; $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,21 @@ 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 @@ -87,17 +95,17 @@ function member_prepare_head(Adherent $object) $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"); } @@ -129,8 +137,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"); $head[$h][2] = 'translation'; @@ -138,8 +145,7 @@ function member_type_prepare_head(AdherentType $object) } if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) - { + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id; diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 484b3933e42..ce603415009 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -71,7 +71,9 @@ function dol_setcache($memoryid, $data, $expire = 0) $result = 0; if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...' - if (empty($conf->global->MAIN_CACHE_COUNT)) return 0; + if (empty($conf->global->MAIN_CACHE_COUNT)) { + return 0; + } } if (!empty($conf->memcached->enabled) && class_exists('Memcached')) { @@ -81,7 +83,9 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache = new Memcached(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); - if (!$result) return -1; + if (!$result) { + return -1; + } } $memoryid = session_name() . '_' . $memoryid; @@ -100,7 +104,9 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache = new Memcache(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); - if (!$result) return -1; + if (!$result) { + return -1; + } } $memoryid = session_name() . '_' . $memoryid; @@ -131,7 +137,9 @@ function dol_getcache($memoryid) global $conf; if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...' - if (empty($conf->global->MAIN_CACHE_COUNT)) return null; + if (empty($conf->global->MAIN_CACHE_COUNT)) { + return null; + } } // Using a memcached server @@ -141,7 +149,9 @@ function dol_getcache($memoryid) $m = new Memcached(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); - if (!$result) return -1; + if (!$result) { + return -1; + } } $memoryid = session_name() . '_' . $memoryid; @@ -164,7 +174,9 @@ function dol_getcache($memoryid) $m = new Memcache(); $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); - if (!$result) return -1; + if (!$result) { + return -1; + } } $memoryid = session_name() . '_' . $memoryid; @@ -235,9 +247,13 @@ function dol_setshmop($memoryid, $data, $expire) global $shmkeys, $shmoffset; //print 'dol_setshmop memoryid='.$memoryid."
    \n"; - if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0; + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) { + return 0; + } $shmkey = dol_getshmopaddress($memoryid); - if (empty($shmkey)) return 0; // No key reserved for this memoryid, we can't cache this memoryid + if (empty($shmkey)) { + return 0; // No key reserved for this memoryid, we can't cache this memoryid + } $newdata = serialize($data); $size = strlen($newdata); @@ -273,14 +289,19 @@ function dol_getshmop($memoryid) return null; } $shmkey = dol_getshmopaddress($memoryid); - if (empty($shmkey)) return null; // No key reserved for this memoryid, we can't cache this memoryid + if (empty($shmkey)) { + return null; // No key reserved for this memoryid, we can't cache this memoryid + } //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."
    \n"; $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)); - else return -1; + if ($size) { + $data = unserialize(shmop_read($handle, 6, $size)); + } else { + return -1; + } shmop_close($handle); } else { return null; // Can't open existing block, so we suppose it was not created, so nothing were cached yet for the memoryid diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index ff14ec56e18..0c6029ebb00 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -41,31 +41,30 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = { global $db, $langs; - if (empty($objectname)) return -1; - if (empty($readdir)) $readdir = $destdir; + if (empty($objectname)) { + return -1; + } + if (empty($readdir)) { + $readdir = $destdir; + } - if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) - { + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.'); return -1; } // Check parameters - if (count($addfieldentry) > 0) - { - if (empty($addfieldentry['name'])) - { + if (count($addfieldentry) > 0) { + if (empty($addfieldentry['name'])) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors'); return -2; } - if (empty($addfieldentry['label'])) - { + if (empty($addfieldentry['label'])) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); return -2; } if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type']) - && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type'])) - { + && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type'])) { setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors'); return -2; } @@ -73,8 +72,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php'; $pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : ''); - if (!dol_is_file($pathoffiletoeditsrc)) - { + if (!dol_is_file($pathoffiletoeditsrc)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); return -3; @@ -85,8 +83,11 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = try { include_once $pathoffiletoeditsrc; - if (class_exists($objectname)) $object = new $objectname($db); - else return -4; + if (class_exists($objectname)) { + $object = new $objectname($db); + } else { + return -4; + } // Backup old file dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1); @@ -95,17 +96,14 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); // Update ->fields (add or remove entries) - if (count($object->fields)) - { - if (is_array($addfieldentry) && count($addfieldentry)) - { + if (count($object->fields)) { + if (is_array($addfieldentry) && count($addfieldentry)) { $name = $addfieldentry['name']; unset($addfieldentry['name']); $object->fields[$name] = $addfieldentry; } - if (!empty($delfieldentry)) - { + if (!empty($delfieldentry)) { $name = $delfieldentry; unset($object->fields[$name]); } @@ -120,40 +118,62 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $texttoinsert .= "\t".' */'."\n"; $texttoinsert .= "\t".'public $fields=array('."\n"; - if (count($object->fields)) - { - foreach ($object->fields as $key => $val) - { + if (count($object->fields)) { + foreach ($object->fields as $key => $val) { $i++; $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; $texttoinsert .= " 'enabled'=>'".($val['enabled'] !== '' ? $val['enabled'] : 1)."',"; $texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).","; $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).","; $texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).","; - if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',"; - if ($val['default'] || $val['default'] === '0') $texttoinsert .= " 'default'=>'".$val['default']."',"; - if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].","; - if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',"; - if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].","; - if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',"; - if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',"; - if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; - if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',"; - if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',"; - if ($val['autofocusoncreate']) $texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',"; - if ($val['arrayofkeyval']) - { + if ($val['noteditable']) { + $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',"; + } + if ($val['default'] || $val['default'] === '0') { + $texttoinsert .= " 'default'=>'".$val['default']."',"; + } + if ($val['index']) { + $texttoinsert .= " 'index'=>".$val['index'].","; + } + if ($val['foreignkey']) { + $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',"; + } + if ($val['searchall']) { + $texttoinsert .= " 'searchall'=>".$val['searchall'].","; + } + if ($val['isameasure']) { + $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',"; + } + if ($val['css']) { + $texttoinsert .= " 'css'=>'".$val['css']."',"; + } + if ($val['help']) { + $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; + } + if ($val['showoncombobox']) { + $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',"; + } + if ($val['disabled']) { + $texttoinsert .= " 'disabled'=>'".$val['disabled']."',"; + } + if ($val['autofocusoncreate']) { + $texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',"; + } + if ($val['arrayofkeyval']) { $texttoinsert .= " 'arrayofkeyval'=>array("; $i = 0; - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { - if ($i) $texttoinsert .= ", "; + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + if ($i) { + $texttoinsert .= ", "; + } $texttoinsert .= "'".$key2."'=>'".$val2."'"; $i++; } $texttoinsert .= "),"; } - if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\""; + if ($val['comment']) { + $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\""; + } $texttoinsert .= "),\n"; } @@ -162,12 +182,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $texttoinsert .= "\t".');'."\n"; //print ($texttoinsert);exit; - if (count($object->fields)) - { + if (count($object->fields)) { //$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string'); - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $i++; //$typephp=$typetotypephp[$val['type']]; $texttoinsert .= "\t".'public $'.$key.";"; @@ -192,8 +210,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = @chmod($pathoffiletoedittarget, octdec($newmask)); return $object; - } catch (Exception $e) - { + } catch (Exception $e) { print $e->getMessage(); return -5; } @@ -218,8 +235,12 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $error = 0; - if (empty($objectname)) return -1; - if (empty($readdir)) $readdir = $destdir; + if (empty($objectname)) { + return -1; + } + if (empty($readdir)) { + $readdir = $destdir; + } $pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php'; @@ -232,8 +253,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : ''); } - if (!dol_is_file($pathoffiletoeditsrc)) - { + if (!dol_is_file($pathoffiletoeditsrc)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); return -1; @@ -241,14 +261,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' // Load object from myobject.class.php try { - if (!is_object($object)) - { + if (!is_object($object)) { include_once $pathoffiletoclasssrc; - if (class_exists($objectname)) $object = new $objectname($db); - else return -1; + if (class_exists($objectname)) { + $object = new $objectname($db); + } else { + return -1; + } } - } catch (Exception $e) - { + } catch (Exception $e) { print $e->getMessage(); } @@ -259,31 +280,41 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $i = 0; $texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n"; - if (count($object->fields)) - { - foreach ($object->fields as $key => $val) - { + if (count($object->fields)) { + foreach ($object->fields as $key => $val) { $i++; $type = $val['type']; $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' - if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database - elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database - elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer'; + if ($type == 'html') { + $type = 'text'; // html modulebuilder type is a text type in database + } elseif ($type == 'price') { + $type = 'double'; // html modulebuilder type is a text type in database + } elseif (in_array($type, array('link', 'sellist', 'duration'))) { + $type = 'integer'; + } $texttoinsert .= "\t".$key." ".$type; - if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY'; - if ($key == 'entity') $texttoinsert .= ' DEFAULT 1'; - else { - if ($val['default'] != '') - { - if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL"; - elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'"; - else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : ''); + if ($key == 'rowid') { + $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY'; + } + if ($key == 'entity') { + $texttoinsert .= ' DEFAULT 1'; + } else { + if ($val['default'] != '') { + if (preg_match('/^null$/i', $val['default'])) { + $texttoinsert .= " DEFAULT NULL"; + } elseif (preg_match('/varchar/', $type)) { + $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'"; + } else { + $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : ''); + } } } $texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : ''); - if ($i < count($object->fields)) $texttoinsert .= ", "; + if ($i < count($object->fields)) { + $texttoinsert .= ", "; + } $texttoinsert .= "\n"; } } @@ -292,8 +323,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql); $result = file_put_contents($pathoffiletoedittarget, $contentsql); - if ($result) - { + if ($result) { @chmod($pathoffiletoedittarget, octdec($newmask)); } else { $error++; @@ -312,21 +342,16 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $i = 0; $texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n"; - if (count($object->fields)) - { - foreach ($object->fields as $key => $val) - { + if (count($object->fields)) { + foreach ($object->fields as $key => $val) { $i++; - if (!empty($val['index'])) - { + if (!empty($val['index'])) { $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");"; $texttoinsert .= "\n"; } - if (!empty($val['foreignkey'])) - { + if (!empty($val['foreignkey'])) { $tmp = explode('.', $val['foreignkey']); - if (!empty($tmp[0]) && !empty($tmp[1])) - { + if (!empty($tmp[0]) && !empty($tmp[1])) { $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");"; $texttoinsert .= "\n"; } @@ -340,8 +365,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' dol_mkdir(dirname($pathoffiletoedittarget)); $result2 = file_put_contents($pathoffiletoedittarget, $contentsql); - if ($result) - { + if ($result) { @chmod($pathoffiletoedittarget, octdec($newmask)); } else { $error++; diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php index a3f7d56ec90..e77a9ee8081 100644 --- a/htdocs/core/lib/multicurrency.lib.php +++ b/htdocs/core/lib/multicurrency.lib.php @@ -65,8 +65,7 @@ function multicurrencyLimitPrepareHead($aCurrencies) $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).')'; $head[$i][2] = $currency; diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index a006aad8964..48356868143 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -27,8 +27,7 @@ $supportedoauth2array = array( 'OAUTH_GOOGLE_NAME'=>'google', ); -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = 'stripetest'; $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = 'stripelive'; } diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 9bd92a2c79b..9e7d4f8d55a 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -34,43 +34,58 @@ function commande_prepare_head(Commande $object) { global $db, $langs, $conf, $user; - if (!empty($conf->expedition->enabled)) $langs->load("sendings"); + if (!empty($conf->expedition->enabled)) { + $langs->load("sendings"); + } $langs->load("orders"); $h = 0; $head = array(); - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; $head[$h][1] = $langs->trans("CustomerOrder"); $head[$h][2] = 'order'; $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $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++; } if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) - || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) - { + || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) { $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->delivery_note->enabled) $text .= ' - '; - if ($conf->delivery_note->enabled) $text .= $langs->trans("Receivings"); - if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''.($nbShipments ? $nbShipments : 0); - if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ' - '; - if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0); - if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''; + if ($conf->expedition_bon->enabled) { + $text .= $langs->trans("Shipments"); + } + if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) { + $text .= ' - '; + } + if ($conf->delivery_note->enabled) { + $text .= $langs->trans("Receivings"); + } + if ($nbShipments > 0 || $nbReceiption > 0) { + $text .= ''.($nbShipments ? $nbShipments : 0); + } + if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) { + $text .= ' - '; + } + if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) { + $text .= ($nbReceiption ? $nbReceiption : 0); + } + if ($nbShipments > 0 || $nbReceiption > 0) { + $text .= ''; + } $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; @@ -82,14 +97,19 @@ function commande_prepare_head(Commande $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'order'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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++; } @@ -101,7 +121,9 @@ function commande_prepare_head(Commande $object) $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 ef0de8c1298..72903dd9e76 100644 --- a/htdocs/core/lib/parsemd.lib.php +++ b/htdocs/core/lib/parsemd.lib.php @@ -31,17 +31,14 @@ */ function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null) { - if (is_array($replaceimagepath)) - { - foreach ($replaceimagepath as $key => $val) - { + if (is_array($replaceimagepath)) { + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; $content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content); } } - if ($parser == 'parsedown') - { + if ($parser == 'parsedown') { include_once DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php'; $Parsedown = new Parsedown(); $content = $Parsedown->text($content); @@ -63,10 +60,8 @@ function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null) */ function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null) { - if (is_array($replaceimagepath)) - { - foreach ($replaceimagepath as $key => $val) - { + if (is_array($replaceimagepath)) { + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; $content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content); diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 601dad3275d..835986f5f83 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -137,18 +137,15 @@ function getValidOnlinePaymentMethods($paymentmethod = '') $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'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) - { + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { $langs->load("paybox"); $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'; } @@ -205,102 +202,142 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $urltouse = DOL_MAIN_URL_ROOT; - if ($localorexternal) $urltouse = $urlwithroot; + if ($localorexternal) { + $urltouse = $urlwithroot; + } - if ($type == 'free') - { + if ($type == 'free') { $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)) { + 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') - { + } 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); + 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; - else { + 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='.($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); + 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') - { + } 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); + 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; - else { + 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='.($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); + 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') - { + } 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); + 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; - else { + 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='.($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); + 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') - { + } 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); + 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; - else { + 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='.($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); + 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') - { + 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); + 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; - else { + 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='.($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); + 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; } @@ -323,78 +360,86 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, // Juridical status $line1 = ""; - if ($fromcompany->forme_juridique_code) - { + if ($fromcompany->forme_juridique_code) { $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); } // Capital - if ($fromcompany->capital) - { + if ($fromcompany->capital) { $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) - { + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; } // Prof Id 2 - if ($fromcompany->idprof2) - { + if ($fromcompany->idprof2) { $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; } // Second line of company infos $line2 = ""; // Prof Id 3 - if ($fromcompany->idprof3) - { + if ($fromcompany->idprof3) { $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; } // Prof Id 4 - if ($fromcompany->idprof4) - { + if ($fromcompany->idprof4) { $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; } // IntraCommunautary VAT - if ($fromcompany->tva_intra != '') - { + if ($fromcompany->tva_intra != '') { $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } print '
    '; print '
    '."\n"; - if ($addformmessage) - { + if ($addformmessage) { print ''; print '
    '; $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; - if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); + if (!empty($conf->global->$parammessageform)) { + print $langs->transnoentities($conf->global->$parammessageform); + } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) { + print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); + } // Add other message if VAT exists - if ($object->total_vat != 0 || $object->total_tva != 0) - { + if ($object->total_vat != 0 || $object->total_tva != 0) { $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; - if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); + if (!empty($conf->global->$parammessageform)) { + print $langs->transnoentities($conf->global->$parammessageform); + } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) { + print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); + } } } print '

    '."\n"; print $fromcompany->name.'
    '; print $line1; - if (strlen($line1.$line2) > 50) print '
    '; - else print ' - '; + if (strlen($line1.$line2) > 50) { + print '
    '; + } else { + print ' - '; + } print $line2; print '
    '."\n"; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 613a68b56d8..08559c3ebd6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -51,8 +51,7 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') // Default value if setup was not done and/or entry into c_paper_format not defined $width = 210; $height = 297; $unit = 'mm'; - if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') - { + if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $pdfformat = dol_getDefaultFormat($outputlangs); } else { @@ -62,11 +61,9 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') $sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; $sql .= " WHERE code = '".$db->escape($pdfformat)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $width = (int) $obj->width; $height = (int) $obj->height; $unit = $obj->unit; @@ -90,8 +87,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') global $conf; // Define constant for TCPDF - if (!defined('K_TCPDF_EXTERNAL_CONFIG')) - { + if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); @@ -133,21 +129,27 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') require_once TCPDF_PATH.'tcpdf.php'; // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). - if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; + if (empty($conf->global->MAIN_DISABLE_TCPDI)) { + require_once TCPDI_PATH.'tcpdi.php'; + } //$arrayformat=pdf_getFormat(); //$format=array($arrayformat['width'],$arrayformat['height']); //$metric=$arrayformat['unit']; $pdfa = false; // PDF-1.3 - if (!empty($conf->global->PDF_USE_1A)) $pdfa = true; // PDF1/A + if (!empty($conf->global->PDF_USE_1A)) { + $pdfa = true; // PDF1/A + } - if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); - else $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); + if (class_exists('TCPDI')) { + $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); + } else { + $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); + } // Protection and encryption of pdf - if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) - { + if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) { /* Permission supported by TCPDF - print : Print the document; - modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble'; @@ -223,13 +225,13 @@ function pdf_getPDFFont($outputlangs) { global $conf; - if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) { + return $conf->global->MAIN_PDF_FORCE_FONT; + } $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) - { - if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') - { + if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) + if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') { $font = $outputlangs->trans('FONTFORPDF'); } } @@ -247,14 +249,14 @@ function pdf_getPDFFontSize($outputlangs) global $conf; $size = 10; // By default, for FPDI or ISO language on TCPDF - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) - { - if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') - { + if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) + if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') { $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } - if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) { + $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + } return $size; } @@ -274,10 +276,11 @@ function pdf_getHeightForLogo($logo, $url = false) $maxwidth = 130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $tmp = dol_getImageSize($logo, $url); - if ($tmp['height']) - { + if ($tmp['height']) { $width = round($height * $tmp['width'] / $tmp['height']); - if ($width > $maxwidth) $height = $height * $maxwidth / $width; + if ($width > $maxwidth) { + $height = $height * $maxwidth / $width; + } } //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; return $height; @@ -377,82 +380,103 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { global $conf, $hookmanager; - if ($mode == 'source' && !is_object($sourcecompany)) return -1; - if ($mode == 'target' && !is_object($targetcompany)) return -1; + if ($mode == 'source' && !is_object($sourcecompany)) { + return -1; + } + if ($mode == 'target' && !is_object($targetcompany)) { + return -1; + } - if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state = getState($sourcecompany->state_id); - if (!empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state = getState($targetcompany->state_id); + if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) { + $sourcecompany->state = getState($sourcecompany->state_id); + } + if (!empty($targetcompany->state_id) && empty($targetcompany->state)) { + $targetcompany->state = getState($targetcompany->state_id); + } $reshook = 0; $stringaddress = ''; - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('sourcecompany' => &$sourcecompany, 'targetcompany' => &$targetcompany, 'targetcontact' => &$targetcontact, 'outputlangs' => $outputlangs, 'mode' => $mode, 'usecontact' => $usecontact); $action = ''; $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $stringaddress .= $hookmanager->resPrint; } - if (empty($reshook)) - { - if ($mode == 'source') - { + if (empty($reshook)) { + if ($mode == 'source') { $withCountry = 0; - if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; + if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { + $withCountry = 1; + } $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; - if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) - { + if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) { // Phone - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); + if ($sourcecompany->phone) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); + } // Fax - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); + if ($sourcecompany->fax) { + $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); + } // EMail - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); + if ($sourcecompany->email) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); + } // Web - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); + if ($sourcecompany->url) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); + } } // Intra VAT - if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) - { - if ($sourcecompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); + if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) { + if ($sourcecompany->tva_intra) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); + } } // Professionnal Ids $reg = array(); - if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) - { + if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) { $tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); } - if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) - { + if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) { $tmp = $outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); } - if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) - { + if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) { $tmp = $outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); } - if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) - { + if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) { $tmp = $outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); } - if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) - { + if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) { $tmp = $outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); } - if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) - { + if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) { $tmp = $outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { @@ -460,10 +484,8 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t } } - if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) - { - if ($usecontact) - { + if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) { + if ($usecontact) { $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); if (!empty($targetcontact->address)) { @@ -472,8 +494,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $companytouseforaddress = $targetcompany; // Contact on a thirdparty that is a different thirdparty than the thirdparty of object - if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) - { + if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) { $targetcontact->fetch_thirdparty(); $companytouseforaddress = $targetcontact->thirdparty; } @@ -487,118 +508,142 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); } - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) - { + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) - { - if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; - if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); - if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / "; - if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { + if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + } + if (!empty($targetcontact->phone_pro)) { + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); + } + if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) { + $stringaddress .= " / "; + } + if (!empty($targetcontact->phone_mobile)) { + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + } } // Fax - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) - { - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { + if ($targetcontact->fax) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + } } // EMail - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) - { - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { + if ($targetcontact->email) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + } } // Web - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) - { - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { + if ($targetcontact->url) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + } } } } else { $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); // Country - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + } - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) - { + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) - { - if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; - if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); - if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / "; - if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { + if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + } + if (!empty($targetcompany->phone)) { + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); + } + if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) { + $stringaddress .= " / "; + } + if (!empty($targetcompany->phone_mobile)) { + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + } } // Fax - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) - { - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { + if ($targetcompany->fax) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + } } // EMail - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) - { - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { + if ($targetcompany->email) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + } } // Web - if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) - { - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { + if ($targetcompany->url) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + } } } } // Intra VAT - if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) - { - if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); + if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) { + if ($targetcompany->tva_intra) { + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); + } } // Professionnal Ids - if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) - { + if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) { $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); } - if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) - { + if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) { $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); } - if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) - { + if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) { $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); } - if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) - { + if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) { $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); } - if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) - { + if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) { $tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); } - if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) - { + if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) { $tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + if (preg_match('/\((.+)\)/', $tmp, $reg)) { + $tmp = $reg[1]; + } $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); } // Public note - if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) - { - if ($mode == 'source' && !empty($sourcecompany->note_public)) - { + if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { + if ($mode == 'source' && !empty($sourcecompany->note_public)) { $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public); } - if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) - { + if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) { $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public); } } @@ -622,8 +667,7 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) global $conf; // Add a background image on document - if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image - { + if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak @@ -665,10 +709,15 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) global $langs, $mysoc, $user; // Print Draft Watermark - if ($unit == 'pt') $k = 1; - elseif ($unit == 'mm') $k = 72 / 25.4; - elseif ($unit == 'cm') $k = 72 / 2.54; - elseif ($unit == 'in') $k = 72; + if ($unit == 'pt') { + $k = 1; + } elseif ($unit == 'mm') { + $k = 72 / 25.4; + } elseif ($unit == 'cm') { + $k = 72 / 2.54; + } elseif ($unit == 'in') { + $k = 72; + } // Make substitution $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null); @@ -719,8 +768,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); - if (empty($onlynumber)) - { + if (empty($onlynumber)) { $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); $cury += 4; @@ -730,36 +778,36 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, // Use correct name of bank id according to country $bickey = "BICNumber"; - if ($account->getCountryCode() == 'IN') $bickey = "SWIFT"; + if ($account->getCountryCode() == 'IN') { + $bickey = "SWIFT"; + } // Get format of bank account according to its country $usedetailedbban = $account->useDetailedBBAN(); //$onlynumber=0; $usedetailedbban=1; // For tests - if ($usedetailedbban) - { + if ($usedetailedbban) { $savcurx = $curx; - if (empty($onlynumber)) - { + if (empty($onlynumber)) { $pdf->SetFont('', '', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); $cury += 3; } - if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them - { + if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) { // Note that some countries still need bank number, BIC/IBAN not enougth for them // Note: // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) // desk = code guichet (FR), used only when $usedetailedbban = 1 // number = account number // key = check control key used only when $usedetailedbban = 1 - if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6); + if (empty($onlynumber)) { + $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6); + } - foreach ($account->getFieldsToShow() as $val) - { + foreach ($account->getFieldsToShow() as $val) { $pdf->SetXY($curx, $cury + 4); $pdf->SetFont('', '', $default_font_size - 3); @@ -812,7 +860,9 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0); $cury += 3; - if ($diffsizecontent <= 2) $cury += 1; + if ($diffsizecontent <= 2) { + $cury += 1; + } } $pdf->SetFont('', '', $default_font_size - $diffsizecontent); @@ -840,17 +890,17 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, // Use correct name of bank id according to country $ibankey = FormBank::getIBANLabel($account); - if (!empty($account->iban)) - { + if (!empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); $ibanDisplay = ""; $nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp); - for ($i = 0; $i < $nbIbanDisplay_temp; $i++) - { + for ($i = 0; $i < $nbIbanDisplay_temp; $i++) { $ibanDisplay .= $ibanDisplay_temp[$i]; - if ($i % 4 == 3 && $i > 0) $ibanDisplay .= " "; + if ($i % 4 == 3 && $i > 0) { + $ibanDisplay .= " "; + } } $pdf->SetFont('', 'B', $default_font_size - 3); @@ -859,8 +909,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $cury += 3; } - if (!empty($account->bic)) - { + if (!empty($account->bic)) { $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); @@ -894,8 +943,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $dims = $pdf->getPageDimensions(); // Line of free text - if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) - { + if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) { $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); // More substitution keys $substitutionarray['__FROM_NAME__'] = $fromcompany->name; @@ -915,124 +963,118 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // First line of company infos $line1 = ""; $line2 = ""; $line3 = ""; $line4 = ""; - if ($showdetails == 1 || $showdetails == 3) - { + if ($showdetails == 1 || $showdetails == 3) { // Company name - if ($fromcompany->name) - { + if ($fromcompany->name) { $line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; } // Address - if ($fromcompany->address) - { + if ($fromcompany->address) { $line1 .= ($line1 ? " - " : "").str_replace("\n", ", ", $fromcompany->address); } // Zip code - if ($fromcompany->zip) - { + if ($fromcompany->zip) { $line1 .= ($line1 ? " - " : "").$fromcompany->zip; } // Town - if ($fromcompany->town) - { + if ($fromcompany->town) { $line1 .= ($line1 ? " " : "").$fromcompany->town; } // Country - if ($fromcompany->country) - { + if ($fromcompany->country) { $line1 .= ($line1 ? ", " : "").$fromcompany->country; } // Phone - if ($fromcompany->phone) - { + if ($fromcompany->phone) { $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; } // Fax - if ($fromcompany->fax) - { + if ($fromcompany->fax) { $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; } // URL - if ($fromcompany->url) - { + if ($fromcompany->url) { $line2 .= ($line2 ? " - " : "").$fromcompany->url; } // Email - if ($fromcompany->email) - { + if ($fromcompany->email) { $line2 .= ($line2 ? " - " : "").$fromcompany->email; } } - if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) - { + if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) { // Managers - if ($fromcompany->managers) - { + if ($fromcompany->managers) { $line2 .= ($line2 ? " - " : "").$fromcompany->managers; } } // Line 3 of company infos // Juridical status - if ($fromcompany->forme_juridique_code) - { + if ($fromcompany->forme_juridique_code) { $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital - if ($fromcompany->capital) - { + if ($fromcompany->capital) { $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); - else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { + $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); + } else { + $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + } } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) - { + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 - if ($fromcompany->idprof2) - { + if ($fromcompany->idprof2) { $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); } // Line 4 of company infos // Prof Id 3 - if ($fromcompany->idprof3) - { + if ($fromcompany->idprof3) { $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 - if ($fromcompany->idprof4) - { + if ($fromcompany->idprof4) { $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); } // Prof Id 5 - if ($fromcompany->idprof5) - { + if ($fromcompany->idprof5) { $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); } // Prof Id 6 - if ($fromcompany->idprof6) - { + if ($fromcompany->idprof6) { $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + if (preg_match('/\((.*)\)/i', $field, $reg)) { + $field = $reg[1]; + } $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); } // IntraCommunautary VAT - if ($fromcompany->tva_intra != '') - { + if ($fromcompany->tva_intra != '') { $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); } @@ -1041,11 +1083,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // The start of the bottom of this page footer is positioned according to # of lines $freetextheight = 0; - if ($line) // Free text - { + if ($line) { // Free text //$line="sample text
    \nfdsfsdf
    \nghfghg
    "; - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) - { + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { $width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { $width = 200; $align = 'C'; @@ -1060,11 +1100,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); $posy = $marginwithfooter + 0; - if ($line) // Free text - { + if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default - { + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default $pdf->MultiCell(0, 3, $line, 0, $align, 0); } else { $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); @@ -1076,8 +1114,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); $posy--; - if (!empty($line1)) - { + if (!empty($line1)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); @@ -1085,8 +1122,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetFont('', '', 7); } - if (!empty($line2)) - { + if (!empty($line2)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); @@ -1094,22 +1130,19 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetFont('', '', 7); } - if (!empty($line3)) - { + if (!empty($line3)) { $pdf->SetXY($dims['lm'], -$posy); $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); } - if (!empty($line4)) - { + if (!empty($line4)) { $posy -= 3; $pdf->SetXY($dims['lm'], -$posy); $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); } // Show page nb only on iso languages (so default Helvetica font) - if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') - { + if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { $pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); @@ -1135,13 +1168,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size) { $linkedobjects = pdf_getLinkedObjects($object, $outputlangs); - if (!empty($linkedobjects)) - { - foreach ($linkedobjects as $linkedobject) - { + if (!empty($linkedobjects)) { + foreach ($linkedobjects as $linkedobject) { $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; - if (!empty($linkedobject["date_value"])) - { + if (!empty($linkedobject["date_value"])) { $reftoshow .= ' / '.$linkedobject["date_value"]; } @@ -1178,18 +1208,20 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { + if (empty($reshook)) { $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); //var_dump($labelproductservice);exit; @@ -1229,8 +1261,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); - if ($issupplierline) - { + if ($issupplierline) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $prodser = new ProductFournisseur($db); } else { @@ -1238,16 +1269,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $prodser = new Product($db); if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; } } - if ($idprod) - { + if ($idprod) { $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)) { $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation @@ -1269,11 +1298,15 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } else { $textwasmodified = ($desc == $prodser->description); } - if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) { + $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; + } // Set note $textwasmodified = ($note == $prodser->note); - if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) { + $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; + } } } elseif ($object->element == 'facture' || $object->element == 'facturefourn') { if ($object->type == $object::TYPE_DEPOSIT) { @@ -1299,34 +1332,30 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } // Description long of product line - if (!empty($desc) && ($desc != $label)) - { - if ($libelleproduitservice && empty($hidedesc)) - { + if (!empty($desc) && ($desc != $label)) { + if ($libelleproduitservice && empty($hidedesc)) { $libelleproduitservice .= '__N__'; } - if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) - { + if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); - } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) - { + } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $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).')'; - } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) - { + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { + $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + } + } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); - } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) - { + } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); @@ -1371,7 +1400,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($issupplierline) { if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case $ref_prodserv = $prodser->ref; // Show local ref - if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); + if ($ref_supplier) { + $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); + } } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) { $ref_prodserv = $ref_supplier; } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) { @@ -1381,69 +1412,68 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $ref_prodserv = $prodser->ref; // Show local ref only if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - $productCustomerPriceStatic = new Productcustomerprice($db); - $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); + $productCustomerPriceStatic = new Productcustomerprice($db); + $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); - $nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter); + $nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter); - if ($nbCustomerPrices > 0) { - $productCustomerPrice = $productCustomerPriceStatic->lines[0]; + if ($nbCustomerPrices > 0) { + $productCustomerPrice = $productCustomerPriceStatic->lines[0]; - if (! empty($productCustomerPrice->ref_customer)) { - switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { - case 1: - $ref_prodserv = $productCustomerPrice->ref_customer; - break; + if (! empty($productCustomerPrice->ref_customer)) { + switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { + case 1: + $ref_prodserv = $productCustomerPrice->ref_customer; + break; - case 2: - $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')'; - break; + case 2: + $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')'; + break; - default: - $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')'; - } - } - } + default: + $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')'; + } + } + } } } - if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - "; + if (!empty($libelleproduitservice) && !empty($ref_prodserv)) { + $ref_prodserv .= " - "; + } } - if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $ref_prodserv = ''.$ref_prodserv.''; } + if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + $ref_prodserv = ''.$ref_prodserv.''; + } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; // Add an additional description for the category products - if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) - { + if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categstatic = new Categorie($db); // recovering the list of all the categories linked to product $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT); - foreach ($tblcateg as $cate) - { + foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled $desccateg = $cate->description; - if ($desccateg) + if ($desccateg) { $libelleproduitservice .= '__N__'.$desccateg; + } } } - if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) - { + if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) { $format = 'day'; $period = ''; // Show duration if exists - if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) - { + if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } - if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) - { + if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) { $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; } - if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) - { + if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; @@ -1455,23 +1485,30 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //print $libelleproduitservice; } - if ($dbatch) - { + if ($dbatch) { $format = 'day'; - foreach ($dbatch as $detail) - { + foreach ($dbatch as $detail) { $dte = array(); - if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); - if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); - if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); + if ($detail->eatby) { + $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); + } + if ($detail->sellby) { + $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); + } + if ($detail->batch) { + $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); + } $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->qty); $libelleproduitservice .= "__N__ ".implode(" - ", $dte); } } // Now we convert \n into br - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace('/__N__/', '
    ', $libelleproduitservice); - else $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); + if (dol_textishtml($libelleproduitservice)) { + $libelleproduitservice = preg_replace('/__N__/', '
    ', $libelleproduitservice); + } else { + $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); + } $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1); return $libelleproduitservice; @@ -1493,17 +1530,17 @@ function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $result .= $hookmanager->resPrint; } - if (empty($reshook)) - { + if (empty($reshook)) { $result .= dol_htmlentitiesbr($object->lines[$i]->num); } return $result; @@ -1526,17 +1563,17 @@ function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $result .= $hookmanager->resPrint; } - if (empty($reshook)) - { + if (empty($reshook)) { $result .= dol_htmlentitiesbr($object->lines[$i]->product_ref); } return $result; @@ -1558,17 +1595,17 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $result .= $hookmanager->resPrint; } - if (empty($reshook)) - { + if (empty($reshook)) { $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier); } return $result; @@ -1590,38 +1627,41 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) $result = ''; $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if (empty($hidedetails) || $hidedetails > 1) - { + if (empty($reshook)) { + if (empty($hidedetails) || $hidedetails > 1) { $tmpresult = ''; $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); - if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) - { - if ($object->lines[$i]->total_localtax1 != 0) - { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; - else $tmpresult = ''; + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { + if ($object->lines[$i]->total_localtax1 != 0) { + if (preg_replace('/[\s0%]/', '', $tmpresult)) { + $tmpresult .= '/'; + } else { + $tmpresult = ''; + } $tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0); } } - if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) - { - if ($object->lines[$i]->total_localtax2 != 0) - { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; - else $tmpresult = ''; + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { + if ($object->lines[$i]->total_localtax2 != 0) { + if (preg_replace('/[\s0%]/', '', $tmpresult)) { + $tmpresult .= '/'; + } else { + $tmpresult = ''; + } $tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0); } } @@ -1647,25 +1687,28 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) global $conf, $hookmanager; $sign = 1; - if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { + $sign = -1; + } $result = ''; $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if (empty($hidedetails) || $hidedetails > 1) - { + if (empty($reshook)) { + if (empty($hidedetails) || $hidedetails > 1) { $subprice = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); $result .= price($sign * $subprice, 0, $outputlangs); } @@ -1687,24 +1730,30 @@ function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0) global $hookmanager, $conf; $sign = 1; - if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { + $sign = -1; + } $result = ''; $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs); + if (empty($reshook)) { + if (empty($hidedetails) || $hidedetails > 1) { + $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs); + } } return $result; } @@ -1725,20 +1774,26 @@ function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0) $result = ''; $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result = $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result = $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty; + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + $result .= $object->lines[$i]->qty; + } } return $result; } @@ -1759,20 +1814,26 @@ function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked; + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + $result .= $object->lines[$i]->qty_asked; + } } return $result; } @@ -1793,20 +1854,26 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped; + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + $result .= $object->lines[$i]->qty_shipped; + } } return $result; } @@ -1827,20 +1894,26 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); + } } return $result; } @@ -1862,8 +1935,7 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; if (!empty($object->lines[$i]->fk_parent_line)) { $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1877,11 +1949,14 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); + if (empty($reshook)) { + if (empty($hidedetails) || $hidedetails > 1) { + $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); + } } return $result; } @@ -1905,20 +1980,26 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0) $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); + } } return $result; } @@ -1935,37 +2016,42 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null) { - if (empty($hookmanager)) global $hookmanager; + if (empty($hookmanager)) { + global $hookmanager; + } global $conf; $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) { + return $hookmanager->resPrint; + } } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) - { - if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) - { + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + return ''; + } + if (empty($hidedetails) || $hidedetails > 1) { + if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { $prev_progress = 0; - if (method_exists($object, 'get_prev_progress')) - { - $prev_progress = $object->lines[$i]->get_prev_progress($object->id); + if (method_exists($object, 'get_prev_progress')) { + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } - $result = ($object->lines[$i]->situation_percent - $prev_progress).'%'; - } else $result = $object->lines[$i]->situation_percent.'%'; - } + $result = ($object->lines[$i]->situation_percent - $prev_progress).'%'; + } else { + $result = $object->lines[$i]->situation_percent.'%'; + } + } } return $result; } @@ -1984,37 +2070,36 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) global $conf, $hookmanager; $sign = 1; - if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { + $sign = -1; + } $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code, 'sign'=>$sign); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; - } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) - { - $result .= $outputlangs->transnoentities("Option"); + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; } - elseif (empty($hidedetails) || $hidedetails > 1) - { + } + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + $result .= $outputlangs->transnoentities("Option"); + } elseif (empty($hidedetails) || $hidedetails > 1) { $total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); - if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) - { + if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) { // TODO Remove this. The total should be saved correctly in database instead of being modified here. $prev_progress = 0; $progress = 1; - if (method_exists($object->lines[$i], 'get_prev_progress')) - { + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; } @@ -2041,37 +2126,36 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) global $hookmanager, $conf; $sign = 1; - if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { + $sign = -1; + } $reshook = 0; $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run - { + if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; - } - if (empty($reshook)) - { - if ($object->lines[$i]->special_code == 3) - { - $result .= $outputlangs->transnoentities("Option"); + if (!empty($hookmanager->resPrint)) { + $result .= $hookmanager->resPrint; } - elseif (empty($hidedetails) || $hidedetails > 1) - { + } + if (empty($reshook)) { + if ($object->lines[$i]->special_code == 3) { + $result .= $outputlangs->transnoentities("Option"); + } elseif (empty($hidedetails) || $hidedetails > 1) { $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc); - if ($object->lines[$i]->situation_percent > 0) - { + if ($object->lines[$i]->situation_percent > 0) { // TODO Remove this. The total should be saved correctly in database instead of being modified here. $prev_progress = 0; $progress = 1; - if (method_exists($object->lines[$i], 'get_prev_progress')) - { + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; } @@ -2101,26 +2185,22 @@ function pdf_getTotalQty($object, $type, $outputlangs) $nblines = count($object->lines); // Loop on each lines - for ($i = 0; $i < $nblines; $i++) - { - if ($object->lines[$i]->special_code != 3) - { - if ($type == 'all') - { + for ($i = 0; $i < $nblines; $i++) { + if ($object->lines[$i]->special_code != 3) { + if ($type == 'all') { $total += $object->lines[$i]->qty; - } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) - { + } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks return $hookmanager->resPrint; - } elseif ($type == 0 && $object->lines[$i]->product_type == 0) - { + } elseif ($type == 0 && $object->lines[$i]->product_type == 0) { $total += $object->lines[$i]->qty; - } elseif ($type == 1 && $object->lines[$i]->product_type == 1) - { + } elseif ($type == 1 && $object->lines[$i]->product_type == 1) { $total += $object->lines[$i]->qty; } } @@ -2145,81 +2225,73 @@ function pdf_getLinkedObjects($object, $outputlangs) $object->fetchObjectLinked(); - foreach ($object->linkedObjects as $objecttype => $objects) - { - if ($objecttype == 'facture') - { + foreach ($object->linkedObjects as $objecttype => $objects) { + if ($objecttype == 'facture') { // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. - } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') - { + } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') { $outputlangs->load('propal'); - foreach ($objects as $elementobject) - { + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs); } - } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') - { + } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - foreach ($objects as $elementobject) - { + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs); } - } elseif ($objecttype == 'contrat') - { + } elseif ($objecttype == 'contrat') { $outputlangs->load('contracts'); - foreach ($objects as $elementobject) - { + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs); } - } elseif ($objecttype == 'fichinter') - { + } elseif ($objecttype == 'fichinter') { $outputlangs->load('interventions'); - foreach ($objects as $elementobject) - { + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec, 'day', '', $outputlangs); } - } elseif ($objecttype == 'shipping') - { + } elseif ($objecttype == 'shipping') { $outputlangs->loadLangs(array("orders", "sendings")); - foreach ($objects as $x => $elementobject) - { + foreach ($objects as $x => $elementobject) { $order = null; // We concat this record info into fields xxx_value. title is overwrote. - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order - { + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); if (!empty($elementobject->linkedObjectsIds['commande'])) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $order = new Commande($db); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); - if ($ret < 1) { $order = null; } + if ($ret < 1) { + $order = null; + } } } - if (!is_object($order)) - { + if (!is_object($order)) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); - if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / '; + if (!empty($linkedobjects[$objecttype]['ref_value'])) { + $linkedobjects[$objecttype]['ref_value'] .= ' / '; + } $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); } else { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending"); - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + if (empty($linkedobjects[$objecttype]['ref_value'])) { + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + } $linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); @@ -2230,12 +2302,13 @@ function pdf_getLinkedObjects($object, $outputlangs) } // For add external linked objects - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); $action = ''; $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; + if (!empty($hookmanager->resArray)) { + $linkedobjects = $hookmanager->resArray; + } } return $linkedobjects; @@ -2256,11 +2329,9 @@ function pdf_getSizeForImage($realpath) $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $tmp = dol_getImageSize($realpath); - if ($tmp['height']) - { + if ($tmp['height']) { $width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight - if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth - { + if ($width > $maxwidth) { // Pb with maxheight, so i use maxwidth $width = $maxwidth; $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); } else // No pb with maxheight @@ -2284,15 +2355,17 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = { global $conf, $hookmanager; $sign = 1; - if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - if ($object->lines[$i]->special_code == 3) - { + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { + $sign = -1; + } + if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); } else { - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) { + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + } $parameters = array( 'i'=>$i, @@ -2303,13 +2376,14 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = $action = ''; - if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) - { + if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks } } - if (empty($hidedetails) || $hidedetails > 1) return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht); + if (empty($hidedetails) || $hidedetails > 1) { + return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht); + } } return ''; } diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index 75bf914b964..bc81ee2bfbd 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -85,14 +85,22 @@ function prelevement_prepare_head(BonPrelevement $object) function prelevement_check_config($type = 'direct-debit') { global $conf, $db; - if ($type == 'bank-transfer'){ - if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1; + if ($type == 'bank-transfer') { + if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) { + return -1; + } //if (empty($conf->global->PRELEVEMENT_ICS)) return -1; - if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1; - }else { - if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; + if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) { + return -1; + } + } else { + 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_USER)) { + return -1; + } } return 0; } diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 98311d093cd..3a73f47a6a0 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -90,13 +90,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result = array(); // Clean parameters - if (empty($info_bits)) $info_bits = 0; - if (empty($txtva)) $txtva = 0; - if (empty($seller) || !is_object($seller)) - { + if (empty($info_bits)) { + $info_bits = 0; + } + if (empty($txtva)) { + $txtva = 0; + } + if (empty($seller) || !is_object($seller)) { dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING); - if (!is_object($mysoc)) // mysoc may be not defined (during migration process) - { + if (!is_object($mysoc)) { // mysoc may be not defined (during migration process) $mysoc = new Societe($db); $mysoc->setMysoc($conf); } @@ -116,11 +118,19 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $countryid = $seller->country_id; - if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate = (float) $uselocaltax1_rate; - if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate = (float) $uselocaltax2_rate; + if (is_numeric($uselocaltax1_rate)) { + $uselocaltax1_rate = (float) $uselocaltax1_rate; + } + if (is_numeric($uselocaltax2_rate)) { + $uselocaltax2_rate = (float) $uselocaltax2_rate; + } - if ($uselocaltax1_rate < 0) $uselocaltax1_rate = $seller->localtax1_assuj; - if ($uselocaltax2_rate < 0) $uselocaltax2_rate = $seller->localtax2_assuj; + if ($uselocaltax1_rate < 0) { + $uselocaltax1_rate = $seller->localtax1_assuj; + } + if ($uselocaltax2_rate < 0) { + $uselocaltax2_rate = $seller->localtax2_assuj; + } //var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate); dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress); @@ -144,33 +154,37 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $sql .= " WHERE cv.taux = ".$txtva; $sql .= " AND cv.fk_pays = ".$countryid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $localtax1_rate = (float) $obj->localtax1; // Use float to force to get first numeric value when value is x:y:z $localtax2_rate = (float) $obj->localtax2; // Use float to force to get first numeric value when value is -19:-15:-9 $localtax1_type = $obj->localtax1_type; $localtax2_type = $obj->localtax2_type; //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // pu calculation from pu_devise if pu empty if (empty($pu) && !empty($pu_devise)) { - if (!empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; - else { + if (!empty($multicurrency_tx)) { + $pu = $pu_devise / $multicurrency_tx; + } else { dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); return array(); } } - if ($pu === '') $pu = 0; + if ($pu === '') { + $pu = 0; + } // pu_devise calculation from pu if (empty($pu_devise) && !empty($multicurrency_tx)) { - if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; - else { + if (is_numeric($pu) && is_numeric($multicurrency_tx)) { + $pu_devise = $pu * $multicurrency_tx; + } else { dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR); return array(); } @@ -182,13 +196,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); // initialize result array - for ($i = 0; $i <= 15; $i++) $result[$i] = 0; + for ($i = 0; $i <= 15; $i++) { + $result[$i] = 0; + } // if there's some localtax including vat, we calculate localtaxes (we will add later) // if input unit price is 'HT', we need to have the totals with main VAT for a correct calculation - if ($price_base_type != 'TTC') - { + if ($price_base_type != 'TTC') { $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU'); $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU'); $pu_wt = price2num($pu * (1 + ($txtva / 100)), 'MU'); @@ -207,22 +222,26 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $apply_tax = true; break; case '4': // localtax on product - if ($type == 0) $apply_tax = true; + if ($type == 0) { + $apply_tax = true; + } break; case '6': // localtax on service - if ($type == 1) $apply_tax = true; + if ($type == 1) { + $apply_tax = true; + } break; } if ($uselocaltax1_rate && $apply_tax) { - $result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); - $localtaxes[0] += $result[14]; + $result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); + $localtaxes[0] += $result[14]; - $result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); - $localtaxes[1] += $result[9]; + $result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); + $localtaxes[1] += $result[9]; - $result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU'); - $localtaxes[2] += $result[11]; + $result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU'); + $localtaxes[2] += $result[11]; } $apply_tax = false; @@ -231,26 +250,29 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $apply_tax = true; break; case '4': // localtax on product - if ($type == 0) $apply_tax = true; + if ($type == 0) { + $apply_tax = true; + } break; case '6': // localtax on service - if ($type == 1) $apply_tax = true; + if ($type == 1) { + $apply_tax = true; + } break; } if ($uselocaltax2_rate && $apply_tax) { - $result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); - $localtaxes[0] += $result[15]; + $result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); + $localtaxes[0] += $result[15]; - $result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); - $localtaxes[1] += $result[10]; + $result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); + $localtaxes[1] += $result[10]; - $result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU'); - $localtaxes[2] += $result[12]; + $result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU'); + $localtaxes[2] += $result[12]; } //dol_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type $info_bits"); - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { // We work to define prices using the price without tax $result[6] = price2num($tot_sans_remise, 'MT'); $result[8] = price2num($tot_sans_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non @@ -287,8 +309,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // if there's some localtax without vat, we calculate localtaxes (we will add them at end) //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation - if ($price_base_type == 'TTC') - { + if ($price_base_type == 'TTC') { $tot_sans_remise = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU'); $tot_avec_remise = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU'); $pu = price2num($pu / (1 + ($txtva / 100)), 'MU'); @@ -300,21 +321,25 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $apply_tax = true; break; case '3': // localtax on product - if ($type == 0) $apply_tax = true; + if ($type == 0) { + $apply_tax = true; + } break; case '5': // localtax on service - if ($type == 1) $apply_tax = true; + if ($type == 1) { + $apply_tax = true; + } break; } if ($uselocaltax1_rate && $apply_tax) { - $result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount - $result[8] += $result[14]; // total_ttc_without_discount + tax1 + $result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount + $result[8] += $result[14]; // total_ttc_without_discount + tax1 - $result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht - $result[2] += $result[9]; // total_ttc + tax1 + $result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht + $result[2] += $result[9]; // total_ttc + tax1 - $result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht - $result[5] += $result[11]; // pu_ht + tax1 + $result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht + $result[5] += $result[11]; // pu_ht + tax1 } $apply_tax = false; @@ -323,28 +348,30 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $apply_tax = true; break; case '3': // localtax on product - if ($type == 0) $apply_tax = true; + if ($type == 0) { + $apply_tax = true; + } break; case '5': // localtax on service - if ($type == 1) $apply_tax = true; + if ($type == 1) { + $apply_tax = true; + } break; } if ($uselocaltax2_rate && $apply_tax) { - $result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount - $result[8] += $result[15]; // total_ttc_without_discount + tax2 + $result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount + $result[8] += $result[15]; // total_ttc_without_discount + tax2 - $result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht - $result[2] += $result[10]; // total_ttc + tax2 + $result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht + $result[2] += $result[10]; // total_ttc + tax2 - $result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht - $result[5] += $result[12]; // pu_ht + tax2 + $result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht + $result[5] += $result[12]; // pu_ht + tax2 } // If rounding is not using base 10 (rare) - if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) - { - if ($price_base_type == 'HT') - { + if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) { + if ($price_base_type == 'HT') { $result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; @@ -360,8 +387,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // Multicurrency - if ($multicurrency_tx != 1) - { + if ($multicurrency_tx != 1) { if ($multicurrency_code) { $savMAIN_MAX_DECIMALS_UNIT = $conf->global->MAIN_MAX_DECIMALS_UNIT; $savMAIN_MAX_DECIMALS_TOT = $conf->global->MAIN_MAX_DECIMALS_TOT; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 9ce8d84d7e3..52db9f88e24 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -38,7 +38,9 @@ function product_prepare_head($object) $langs->load("products"); $label = $langs->trans('Product'); - if ($object->isService()) $label = $langs->trans('Service'); + if ($object->isService()) { + $label = $langs->trans('Service'); + } $h = 0; $head = array(); @@ -48,20 +50,17 @@ function product_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (!empty($object->status)) - { + if (!empty($object->status)) { $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; $head[$h][1] = $langs->trans("SellingPrices"); $head[$h][2] = 'price'; $h++; } - if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase - { + if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) - ) - { + ) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; $head[$h][1] = $langs->trans("BuyingPrices"); $head[$h][2] = 'suppliers'; @@ -70,8 +69,7 @@ function product_prepare_head($object) } // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; $head[$h][1] = $langs->trans("Translation"); $head[$h][2] = 'translation'; @@ -79,13 +77,14 @@ function product_prepare_head($object) } // Sub products - if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) - { + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { $head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id; $head[$h][1] = $langs->trans('AssociatedProducts'); $nbFatherAndChild = $object->hasFatherOrChild(); - if ($nbFatherAndChild > 0) $head[$h][1] .= ''.$nbFatherAndChild.''; + if ($nbFatherAndChild > 0) { + $head[$h][1] .= ''.$nbFatherAndChild.''; + } $head[$h][2] = 'subproduct'; $h++; } @@ -97,22 +96,21 @@ function product_prepare_head($object) $prodcomb = new ProductCombination($db); - if ($prodcomb->fetchByFkProductChild($object->id) <= 0) - { + if ($prodcomb->fetchByFkProductChild($object->id) <= 0) { $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; $head[$h][1] = $langs->trans('ProductCombinations'); $head[$h][2] = 'combinations'; $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); - if ($nbVariant > 0) $head[$h][1] .= ''.$nbVariant.''; + if ($nbVariant > 0) { + $head[$h][1] .= ''.$nbVariant.''; + } } $h++; } - if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) - { - if (!empty($conf->stock->enabled) && $user->rights->stock->lire) - { + if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { // If physical product we can stock (or service with option) + if (!empty($conf->stock->enabled) && $user->rights->stock->lire) { $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; $head[$h][1] = $langs->trans("Stock"); $head[$h][2] = 'stock'; @@ -121,17 +119,14 @@ function product_prepare_head($object) } // Tab to link resources - if (!empty($conf->resource->enabled)) - { - if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) - { + if (!empty($conf->resource->enabled)) { + if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; } - if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) - { + if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; @@ -156,14 +151,19 @@ function product_prepare_head($object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'product'); // Notes - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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.'/product/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++; } @@ -171,18 +171,28 @@ function product_prepare_head($object) // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) { + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + } + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) { + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + } $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; - if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) { + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; + } + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) { + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; + } $nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); } $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/product/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++; @@ -191,8 +201,7 @@ function product_prepare_head($object) // Log $head[$h][0] = DOL_URL_ROOT.'/product/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"); } @@ -231,7 +240,9 @@ function productlot_prepare_head($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_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++; @@ -245,11 +256,11 @@ function productlot_prepare_head($object) // Log /* - $head[$h][0] = DOL_URL_ROOT.'/product/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; - */ + $head[$h][0] = DOL_URL_ROOT.'/product/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + */ return $head; } @@ -273,8 +284,7 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { $head[$h] = array( 0 => DOL_URL_ROOT."/product/admin/price_rules.php", 1 => $langs->trans('MultipriceRules'), @@ -358,11 +368,12 @@ function show_stats_for_company($product, $socid) print ''; // Customer proposals - if (!empty($conf->propal->enabled) && $user->rights->propale->lire) - { + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $nblines++; $ret = $product->load_stats_propale($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("propal"); print ''; print ''.img_object('', 'propal').' '.$langs->trans("Proposals").''; @@ -376,11 +387,12 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier proposals - if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) - { + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $nblines++; $ret = $product->load_stats_proposal_supplier($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("propal"); print ''; print ''.img_object('', 'supplier_proposal').' '.$langs->trans("SupplierProposals").''; @@ -394,11 +406,12 @@ function show_stats_for_company($product, $socid) print ''; } // Customer orders - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $nblines++; $ret = $product->load_stats_commande($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("orders"); print ''; print ''.img_object('', 'order').' '.$langs->trans("CustomersOrders").''; @@ -412,11 +425,12 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier orders - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $nblines++; $ret = $product->load_stats_commande_fournisseur($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("orders"); print ''; print ''.img_object('', 'supplier_order').' '.$langs->trans("SuppliersOrders").''; @@ -430,11 +444,12 @@ function show_stats_for_company($product, $socid) print ''; } // Customer invoices - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $nblines++; $ret = $product->load_stats_facture($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("bills"); print ''; print ''.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").''; @@ -448,11 +463,12 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier invoices - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $nblines++; $ret = $product->load_stats_facture_fournisseur($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("bills"); print ''; print ''.img_object('', 'supplier_invoice').' '.$langs->trans("SuppliersInvoices").''; @@ -467,11 +483,12 @@ function show_stats_for_company($product, $socid) } // Contracts - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $nblines++; $ret = $product->load_stats_contrat($socid); - if ($ret < 0) dol_print_error($db); + if ($ret < 0) { + dol_print_error($db); + } $langs->load("contracts"); print ''; print ''.img_object('', 'contract').' '.$langs->trans("Contracts").''; @@ -486,8 +503,7 @@ function show_stats_for_company($product, $socid) } // BOM - if (!empty($conf->bom->enabled) && $user->rights->bom->read) - { + if (!empty($conf->bom->enabled) && $user->rights->bom->read) { $nblines++; $ret = $product->load_stats_bom($socid); if ($ret < 0) { @@ -510,8 +526,7 @@ function show_stats_for_company($product, $socid) } // MO - if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) - { + if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) { $nblines++; $ret = $product->load_stats_mo($socid); if ($ret < 0) { @@ -579,19 +594,16 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho $outputlangs = $langs; } - if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) - { + if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) { require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); - if ($measuring_style == '' && $scale == '') - { + if ($measuring_style == '' && $scale == '') { $arrayforfilter = array( 't.rowid' => $unit, 't.active' => 1 ); - } elseif ($scale !== '') - { + } elseif ($scale !== '') { $arrayforfilter = array( 't.scale' => $scale, 't.unit_type' => $measuring_style, @@ -610,8 +622,11 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho return -1; } else { if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) { - if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label; - else $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); + if ($use_short_label) { + $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label; + } else { + $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); + } } else { $labeltoreturn = ''; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c11cc4a74d6..8f1c457cd15 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -48,12 +48,13 @@ function project_prepare_head(Project $project) $nbContact = count($project->liste_contact(-1, 'internal')) + count($project->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$project->id; $head[$h][1] = $langs->trans("ProjectContact"); - if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; + if ($nbContact > 0) { + $head[$h][1] .= ''.$nbContact.''; + } $head[$h][2] = 'contact'; $h++; - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Then tab for sub level of projet, i mean tasks $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id; $head[$h][1] = $langs->trans("Tasks"); @@ -61,7 +62,9 @@ function project_prepare_head(Project $project) require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($db); $nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0)); - if ($nbTasks > 0) $head[$h][1] .= ''.($nbTasks).''; + if ($nbTasks > 0) { + $head[$h][1] .= ''.($nbTasks).''; + } $head[$h][2] = 'tasks'; $h++; @@ -73,15 +76,20 @@ function project_prepare_head(Project $project) $sql .= " WHERE t.fk_task = pt.rowid"; $sql .= " AND pt.fk_projet =".$project->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent = 1; - } else dol_print_error($db); + if ($obj) { + $nbTimeSpent = 1; + } + } else { + dol_print_error($db); + } $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$project->id; $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1] .= '...'; + if ($nbTimeSpent > 0) { + $head[$h][1] .= '...'; + } $head[$h][2] = 'timespent'; $h++; } @@ -89,34 +97,75 @@ function project_prepare_head(Project $project) if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) - || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) - { + || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) { $count = 0; - if (!empty($conf->propal->enabled)) $count += $project->getElementCount('propal', 'propal'); - if (!empty($conf->commande->enabled)) $count += $project->getElementCount('order', 'commande'); - if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice', 'facture'); - if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice_predefined', 'facture_rec'); - if (!empty($conf->supplier_proposal->enabled)) $count += $project->getElementCount('proposal_supplier', 'supplier_proposal'); - if (!empty($conf->supplier_order->enabled)) $count += $project->getElementCount('order_supplier', 'commande_fournisseur'); - if (!empty($conf->supplier_invoice->enabled)) $count += $project->getElementCount('invoice_supplier', 'facture_fourn'); - if (!empty($conf->contrat->enabled)) $count += $project->getElementCount('contract', 'contrat'); - if (!empty($conf->ficheinter->enabled)) $count += $project->getElementCount('intervention', 'fichinter'); - if (!empty($conf->expedition->enabled)) $count += $project->getElementCount('shipping', 'expedition'); - if (!empty($conf->mrp->enabled)) $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project'); - if (!empty($conf->deplacement->enabled)) $count += $project->getElementCount('trip', 'deplacement'); - if (!empty($conf->expensereport->enabled)) $count += $project->getElementCount('expensereport', 'expensereport'); - if (!empty($conf->don->enabled)) $count += $project->getElementCount('donation', 'don'); - if (!empty($conf->loan->enabled)) $count += $project->getElementCount('loan', 'loan'); - if (!empty($conf->tax->enabled)) $count += $project->getElementCount('chargesociales', 'chargesociales'); - if (!empty($conf->projet->enabled)) $count += $project->getElementCount('project_task', 'projet_task'); - if (!empty($conf->stock->enabled)) $count += $project->getElementCount('stock_mouvement', 'stock'); - if (!empty($conf->salaries->enabled)) $count += $project->getElementCount('salaries', 'payment_salary'); - if (!empty($conf->banque->enabled)) $count += $project->getElementCount('variouspayment', 'payment_various'); + if (!empty($conf->propal->enabled)) { + $count += $project->getElementCount('propal', 'propal'); + } + if (!empty($conf->commande->enabled)) { + $count += $project->getElementCount('order', 'commande'); + } + if (!empty($conf->facture->enabled)) { + $count += $project->getElementCount('invoice', 'facture'); + } + if (!empty($conf->facture->enabled)) { + $count += $project->getElementCount('invoice_predefined', 'facture_rec'); + } + if (!empty($conf->supplier_proposal->enabled)) { + $count += $project->getElementCount('proposal_supplier', 'supplier_proposal'); + } + if (!empty($conf->supplier_order->enabled)) { + $count += $project->getElementCount('order_supplier', 'commande_fournisseur'); + } + if (!empty($conf->supplier_invoice->enabled)) { + $count += $project->getElementCount('invoice_supplier', 'facture_fourn'); + } + if (!empty($conf->contrat->enabled)) { + $count += $project->getElementCount('contract', 'contrat'); + } + if (!empty($conf->ficheinter->enabled)) { + $count += $project->getElementCount('intervention', 'fichinter'); + } + if (!empty($conf->expedition->enabled)) { + $count += $project->getElementCount('shipping', 'expedition'); + } + if (!empty($conf->mrp->enabled)) { + $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project'); + } + if (!empty($conf->deplacement->enabled)) { + $count += $project->getElementCount('trip', 'deplacement'); + } + if (!empty($conf->expensereport->enabled)) { + $count += $project->getElementCount('expensereport', 'expensereport'); + } + if (!empty($conf->don->enabled)) { + $count += $project->getElementCount('donation', 'don'); + } + if (!empty($conf->loan->enabled)) { + $count += $project->getElementCount('loan', 'loan'); + } + if (!empty($conf->tax->enabled)) { + $count += $project->getElementCount('chargesociales', 'chargesociales'); + } + if (!empty($conf->projet->enabled)) { + $count += $project->getElementCount('project_task', 'projet_task'); + } + if (!empty($conf->stock->enabled)) { + $count += $project->getElementCount('stock_mouvement', 'stock'); + } + if (!empty($conf->salaries->enabled)) { + $count += $project->getElementCount('salaries', 'payment_salary'); + } + if (!empty($conf->banque->enabled)) { + $count += $project->getElementCount('variouspayment', 'payment_various'); + } $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$project->id; $head[$h][1] = $langs->trans("ProjectOverview"); - if ($count > 0) $head[$h][1] .= ''.$count.''; + if ($count > 0) { + $head[$h][1] .= ''.$count.''; + } $head[$h][2] = 'element'; $h++; } @@ -127,7 +176,9 @@ function project_prepare_head(Project $project) $nbConfOrBooth = 1; $head[$h][0] = DOL_URL_ROOT . '/projet/event.php?id=' . $project->id; $head[$h][1] = $langs->trans("ConferenceOrBoothTab"); - if ($nbContact > 0) $head[$h][1] .= '' . $nbConfOrBooth . ''; + if ($nbContact > 0) { + $head[$h][1] .= '' . $nbConfOrBooth . ''; + } $head[$h][2] = 'eventorganisation'; $h++; } @@ -139,14 +190,19 @@ function project_prepare_head(Project $project) complete_head_from_modules($conf, $langs, $project, $head, $h, 'project'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if (!empty($project->note_private)) $nbNote++; - if (!empty($project->note_public)) $nbNote++; + if (!empty($project->note_private)) { + $nbNote++; + } + if (!empty($project->note_public)) { + $nbNote++; + } $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$project->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } $head[$h][2] = 'notes'; $h++; } @@ -158,25 +214,27 @@ function project_prepare_head(Project $project) $nbLinks = Link::count($db, $project->element, $project->id); $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$project->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++; // Manage discussion - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) - { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) { $nbComments = $project->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$project->id; $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; + if ($nbComments > 0) { + $head[$h][1] .= ''.$nbComments.''; + } $head[$h][2] = 'project_comment'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$project->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"); } @@ -209,7 +267,9 @@ function task_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TaskRessourceLinks"); - if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; + if ($nbContact > 0) { + $head[$h][1] .= ''.$nbContact.''; + } $head[$h][2] = 'task_contact'; $h++; @@ -221,15 +281,20 @@ function task_prepare_head($object) $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " WHERE t.fk_task =".$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent = 1; - } else dol_print_error($db); + if ($obj) { + $nbTimeSpent = 1; + } + } else { + dol_print_error($db); + } $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1] .= '...'; + if ($nbTimeSpent > 0) { + $head[$h][1] .= '...'; + } $head[$h][2] = 'task_time'; $h++; @@ -239,14 +304,19 @@ function task_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'task'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } $head[$h][2] = 'task_notes'; $h++; } @@ -258,17 +328,20 @@ function task_prepare_head($object) $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $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] = 'task_document'; $h++; // Manage discussion - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) - { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { $nbComments = $object->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; + if ($nbComments > 0) { + $head[$h][1] .= ''.$nbComments.''; + } $head[$h][2] = 'task_comment'; $h++; } @@ -295,26 +368,25 @@ function project_timesheet_prepare_head($mode, $fuser = null) $param = ''; $param .= ($mode ? '&mode='.$mode : ''); - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) { + $param .= '&search_usertoprocessid='.$fuser->id; + } - if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) - { + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) { $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerMonth"); $head[$h][2] = 'inputpermonth'; $h++; } - if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) - { + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][2] = 'inputperweek'; $h++; } - if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) - { + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) { $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerDay"); $head[$h][2] = 'inputperday'; @@ -400,7 +472,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $projectsArrayId = explode(',', $projectsListId); if ($filterprogresscalc !== '') { - foreach ($lines as $key=>$line) { + foreach ($lines as $key => $line) { if (!empty($line->planned_workload) && !empty($line->duration)) { $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); if (!eval($filterprogresscalc)) { @@ -415,8 +487,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // We declare counter as global because we want to edit them into recursive call global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed; - if ($level == 0) - { + if ($level == 0) { $total_projectlinesa_spent = 0; $total_projectlinesa_planned = 0; $total_projectlinesa_spent_if_planned = 0; @@ -425,31 +496,28 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $total_projectlinesa_billed = 0; } - for ($i = 0; $i < $numlines; $i++) - { - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines + for ($i = 0; $i < $numlines; $i++) { + if ($parent == 0 && $level >= 0) { + $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines + } // Process line // print "i:".$i."-".$lines[$i]->fk_project.'
    '; - if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines - { + if ($lines[$i]->fk_parent == $parent || $level < 0) { // if $level = -1, we dont' use sublevel recursion, we show all lines // Show task line. $showline = 1; $showlineingray = 0; // If there is filters to use - if (is_array($taskrole)) - { + if (is_array($taskrole)) { // If task not legitimate to show, search if a legitimate task exists later in tree - if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) - { + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) { // So search if task has a subtask legitimate to show $foundtaskforuserdeeper = 0; searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
    '; - if ($foundtaskforuserdeeper > 0) - { + if ($foundtaskforuserdeeper > 0) { $showlineingray = 1; // We will show line but in gray } else { $showline = 0; // No reason to show line @@ -458,11 +526,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } else { // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project // or into all other projects if user has permission to). - if (empty($user->rights->projet->all->lire)) - { + if (empty($user->rights->projet->all->lire)) { // User is not allowed on this project and project is not public, so we hide line - if (!in_array($lines[$i]->fk_project, $projectsArrayId)) - { + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) { // Note that having a user assigned to a task into a project user has no permission on, should not be possible // because assignement on task can be done only on contact of project. // If assignement was done and after, was removed from contact of project, then we can hide the line. @@ -471,11 +537,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if ($showline) - { + if ($showline) { // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; $lastprojectid = $lines[$i]->fk_project; } @@ -502,13 +566,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $taskstatic->duration_effective = $lines[$i]->duration; - if ($showproject) - { + if ($showproject) { // Project ref print ""; //if ($showlineingray) print ''; - if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); - else print $projectstatic->getNomUrl(1, 'nolink'); + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) { + print $projectstatic->getNomUrl(1); + } else { + print $projectstatic->getNomUrl(1, 'nolink'); + } //if ($showlineingray) print ''; print ""; @@ -533,8 +599,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Title of task if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) { print ""; - if ($showlineingray) + if ($showlineingray) { print ''; + } //else print ''; for ($k = 0; $k < $level; $k++) { print '
    '; @@ -543,8 +610,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t for ($k = 0; $k < $level; $k++) { print '
    '; } - if ($showlineingray) + if ($showlineingray) { print '
    '; + } //else print ''; print "\n"; } @@ -566,15 +634,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) { print ''; print dol_print_date($lines[$i]->date_end, 'dayhour'); - if ($taskstatic->hasDelay()) + if ($taskstatic->hasDelay()) { print img_warning($langs->trans("Late")); + } print ''; } $plannedworkloadoutputformat = 'allhourmin'; $timespentoutputformat = 'allhourmin'; - if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) { + $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + } + 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'])) { @@ -593,15 +666,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Time spent if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; - if ($showlineingray) + if ($showlineingray) { print ''; - else print ''; - if ($lines[$i]->duration) + } else { + print ''; + } + if ($lines[$i]->duration) { print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); - else print '--:--'; - if ($showlineingray) + } else { + print '--:--'; + } + if ($showlineingray) { print ''; - else print ''; + } else { + print ''; + } print ''; } @@ -609,9 +688,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; if ($lines[$i]->planned_workload || $lines[$i]->duration) { - if ($lines[$i]->planned_workload) + if ($lines[$i]->planned_workload) { print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; - else print ''.$langs->trans('WorkloadNotDefined').''; + } else { + print ''.$langs->trans('WorkloadNotDefined').''; + } } print ''; } @@ -634,8 +715,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } - if ($showbilltime) - { + if ($showbilltime) { // Time not billed if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; @@ -662,18 +742,19 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Contacts of task - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) - { + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; - foreach (array('internal', 'external') as $source) - { + foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); $num = count($tab); if (!empty($num)) { foreach ($tab as $contacttask) { //var_dump($contacttask); - if ($source == 'internal') $c = new User($db); - else $c = new Contact($db); + if ($source == 'internal') { + $c = new User($db); + } else { + $c = new Contact($db); + } $c->fetch($contacttask['id']); print $c->getNomUrl(1).' ('.$contacttask['libelle'].')
    '; } @@ -696,19 +777,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; - if (!$showlineingray) $inc++; + if (!$showlineingray) { + $inc++; + } - if ($level >= 0) // Call sublevels - { + if ($level >= 0) { // Call sublevels $level++; - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields); + if ($lines[$i]->id) { + projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields); + } $level--; } $total_projectlinesa_spent += $lines[$i]->duration; $total_projectlinesa_planned += $lines[$i]->planned_workload; - if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; - if ($lines[$i]->planned_workload) $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100; + if ($lines[$i]->planned_workload) { + $total_projectlinesa_spent_if_planned += $lines[$i]->duration; + } + if ($lines[$i]->planned_workload) { + $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100; + } } } else { //$level--; @@ -716,14 +804,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0) - && $level <= 0) - { + && $level <= 0) { 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 ($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'])) { print ''; print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); @@ -731,11 +826,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; - if ($projectidfortotallink > 0) + if ($projectidfortotallink > 0) { print ''; + } print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); - if ($projectidfortotallink > 0) + if ($projectidfortotallink > 0) { print ''; + } print ''; } @@ -764,14 +861,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; - if ($total_projectlinesa_planned) + if ($total_projectlinesa_planned) { print $totalCalculatedProgress.' %'; + } print ''; } if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { print ''; - if ($total_projectlinesa_planned) + if ($total_projectlinesa_planned) { print ''.$totalAverageDeclaredProgress.' %'; + } print ''; } @@ -789,8 +888,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } - if ($showbilltime) - { + if ($showbilltime) { if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin'); @@ -803,8 +901,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } // Contacts of task - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) - { + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; } print ''; @@ -845,45 +942,40 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec $numlines = count($lines); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. - if ($parent == 0) // Always and only if at first level - { - for ($i = 0; $i < $numlines; $i++) - { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; + if ($parent == 0) { // Always and only if at first level + for ($i = 0; $i < $numlines; $i++) { + if ($lines[$i]->fk_task_parent) { + $lineswithoutlevel0[] = $lines[$i]; + } } } - if (empty($oldprojectforbreak)) - { + if (empty($oldprojectforbreak)) { $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break } //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - for ($i = 0; $i < $numlines; $i++) - { - if ($parent == 0) $level = 0; + for ($i = 0; $i < $numlines; $i++) { + if ($parent == 0) { + $level = 0; + } //if ($lines[$i]->fk_task_parent == $parent) //{ // If we want all or we have a role on task, we show it - if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) - { + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $lastprojectid = $lines[$i]->fk_project; - if ($preselectedday) - { + if ($preselectedday) { $projectstatic->id = $lines[$i]->fk_project; } } - if (empty($workloadforid[$projectstatic->id])) - { - if ($preselectedday) - { + if (empty($workloadforid[$projectstatic->id])) { + if ($preselectedday) { $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week $workloadforid[$projectstatic->id] = 1; } @@ -905,13 +997,11 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec $thirdpartystatic->name = $lines[$i]->thirdparty_name; $thirdpartystatic->email = $lines[$i]->thirdparty_email; - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) - { + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { print ''."\n"; print ''; print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - if ($projectstatic->title) - { + if ($projectstatic->title) { print ' - '; print $projectstatic->title; } @@ -919,7 +1009,9 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print ''; } - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + if ($oldprojectforbreak != -1) { + $oldprojectforbreak = $projectstatic->id; + } print ''."\n"; @@ -932,8 +1024,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec // Project print ""; - if ($oldprojectforbreak == -1) - { + if ($oldprojectforbreak == -1) { print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print '
    '.$projectstatic->title; } @@ -941,17 +1032,23 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec // Thirdparty print ''; - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); + if ($thirdpartystatic->id > 0) { + print $thirdpartystatic->getNomUrl(1, 'project', 10); + } print ''; // Ref print ''; print ''; - for ($k = 0; $k < $level; $k++) print "   "; + for ($k = 0; $k < $level; $k++) { + print "   "; + } print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; - for ($k = 0; $k < $level; $k++) print "   "; + for ($k = 0; $k < $level; $k++) { + print "   "; + } print $taskstatic->label; //print "
    "; //for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -968,14 +1065,12 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) - { + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) - { + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } @@ -985,9 +1080,13 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print ''; $cssonholiday = ''; - if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$preselectedday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$preselectedday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } // Duration print ''; @@ -996,7 +1095,9 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; $alreadyspent = ''; - if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); + if ($dayWorkLoad > 0) { + $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); + } print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); @@ -1074,54 +1175,47 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $numlines = count($lines); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. - if ($parent == 0) // Always and only if at first level - { - for ($i = 0; $i < $numlines; $i++) - { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; + if ($parent == 0) { // Always and only if at first level + for ($i = 0; $i < $numlines; $i++) { + if ($lines[$i]->fk_task_parent) { + $lineswithoutlevel0[] = $lines[$i]; + } } } - if (empty($oldprojectforbreak)) - { + if (empty($oldprojectforbreak)) { $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break } //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - for ($i = 0; $i < $numlines; $i++) - { - if ($parent == 0) $level = 0; + for ($i = 0; $i < $numlines; $i++) { + if ($parent == 0) { + $level = 0; + } - if ($lines[$i]->fk_task_parent == $parent) - { + if ($lines[$i]->fk_task_parent == $parent) { $obj = &$lines[$i]; // To display extrafields // If we want all or we have a role on task, we show it - if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) - { + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); - if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases - { + if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases continue; } // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $lastprojectid = $lines[$i]->fk_project; - if ($preselectedday) - { + if ($preselectedday) { $projectstatic->id = $lines[$i]->fk_project; } } - if (empty($workloadforid[$projectstatic->id])) - { - if ($preselectedday) - { + if (empty($workloadforid[$projectstatic->id])) { + if ($preselectedday) { $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - $workloadforid[$projectstatic->id] = 1; + $workloadforid[$projectstatic->id] = 1; } } @@ -1141,91 +1235,98 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $thirdpartystatic->name = $lines[$i]->thirdparty_name; $thirdpartystatic->email = $lines[$i]->thirdparty_email; - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) - { + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { $addcolspan = 0; - if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; - if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; - foreach ($arrayfields as $key => $val) - { - if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; + if (!empty($arrayfields['t.planned_workload']['checked'])) { + $addcolspan++; + } + if (!empty($arrayfields['t.progress']['checked'])) { + $addcolspan++; + } + foreach ($arrayfields as $key => $val) { + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') { + $addcolspan++; + } } print ''."\n"; print ''; print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); - if ($projectstatic->title) - { + if ($thirdpartystatic->id > 0) { + print ' - '.$thirdpartystatic->getNomUrl(1); + } + if ($projectstatic->title) { print ' - '; print ''.$projectstatic->title.''; } /* - $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); - print ''; + $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); + print '
    '; - print ''; + print ''; - // PROJECT fields - if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); + // PROJECT fields + if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); - $extrafieldsobjectkey='projet'; - $extrafieldsobjectprefix='efp.'; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - print ''; - print ''; + print ''; + print ''; - // PROJECT fields - if (! empty($arrayfields['p.fk_opp_status']['checked'])) - { - print '\n"; - } - if (! empty($arrayfields['p.opp_amount']['checked'])) - { - print '\n"; - } - if (! empty($arrayfields['p.opp_percent']['checked'])) - { - print '\n"; - } - if (! empty($arrayfields['p.budget_amount']['checked'])) - { - print '\n"; - } - if (! empty($arrayfields['p.usage_bill_time']['checked'])) - { - print '\n"; - } + // PROJECT fields + if (! empty($arrayfields['p.fk_opp_status']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.opp_amount']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.opp_percent']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.budget_amount']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.usage_bill_time']['checked'])) + { + print '\n"; + } - $extrafieldsobjectkey='projet'; - $extrafieldsobjectprefix='efp.'; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - print ''; - print '
    '; - $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); - print "'; - print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); - print "'; - print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %'; - print "'; - print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); - print "'; - print yn($lines[$i]->usage_bill_time); - print "'; + $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print "'; + print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + print "'; + print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %'; + print "'; + print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + print "'; + print yn($lines[$i]->usage_bill_time); + print "
    '; + print ''; + print ''; */ print ''; print ''; } - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + if ($oldprojectforbreak != -1) { + $oldprojectforbreak = $projectstatic->id; + } print ''."\n"; @@ -1237,30 +1338,36 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr */ // Project - if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) - { + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ""; - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($oldprojectforbreak == -1) { + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + } print ""; } // Thirdparty - if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) - { + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); + if ($thirdpartystatic->id > 0) { + print $thirdpartystatic->getNomUrl(1, 'project', 10); + } print ''; } // Ref print ''; print ''; - for ($k = 0; $k < $level; $k++) print '
    '; + for ($k = 0; $k < $level; $k++) { + print '
    '; + } print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; print ''.$taskstatic->label.''; - for ($k = 0; $k < $level; $k++) print "
    "; + for ($k = 0; $k < $level; $k++) { + print "
    "; + } print "\n"; // TASK extrafields @@ -1269,17 +1376,18 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Planned Workload - if (!empty($arrayfields['t.planned_workload']['checked'])) - { + if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); - else print '--:--'; + if ($lines[$i]->planned_workload) { + print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); + } else { + print '--:--'; + } print ''; } // Progress declared % - if (!empty($arrayfields['t.progress']['checked'])) - { + if (!empty($arrayfields['t.progress']['checked'])) { print ''; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); print ''; @@ -1288,19 +1396,23 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Time spent by everybody print ''; // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user - if ($lines[$i]->duration) - { + if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print ''; - } else print '--:--'; + } else { + print '--:--'; + } print "\n"; // Time spent by user print ''; $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - else print '--:--'; + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -1308,14 +1420,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) - { + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) - { + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } @@ -1326,9 +1436,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; $cssonholiday = ''; - if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$preselectedday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$preselectedday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } global $daytoparse; $tmparray = dol_getdate($daytoparse, true); // detail of current day @@ -1336,8 +1450,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1)); global $numstartworkingday, $numendworkingday; $cssweekend = ''; - if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } @@ -1347,7 +1460,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $totalforeachday[$preselectedday] += $dayWorkLoad; $alreadyspent = ''; - if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); + if ($dayWorkLoad > 0) { + $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); + } $idw = 0; @@ -1377,14 +1492,16 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Warning print ''; - if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); - elseif ($disabledtask) - { - $titleassigntask = $langs->trans("AssignTaskToMe"); - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + if ((!$lines[$i]->public) && $disabledproject) { + print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + } elseif ($disabledtask) { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) { + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + } - print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); - } + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + } print ''; print "\n"; @@ -1392,15 +1509,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $inc++; $level++; - if ($lines[$i]->id > 0) - { + if ($lines[$i]->id > 0) { //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); //var_dump($totalforeachday); $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach ($ret as $key => $val) - { + foreach ($ret as $key => $val) { $totalforeachday[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); @@ -1448,50 +1563,45 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $lineswithoutlevel0 = array(); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. - if ($parent == 0) // Always and only if at first level - { - for ($i = 0; $i < $numlines; $i++) - { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; + if ($parent == 0) { // Always and only if at first level + for ($i = 0; $i < $numlines; $i++) { + if ($lines[$i]->fk_task_parent) { + $lineswithoutlevel0[] = $lines[$i]; + } } } //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - if (empty($oldprojectforbreak)) - { + if (empty($oldprojectforbreak)) { $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break } - for ($i = 0; $i < $numlines; $i++) - { - if ($parent == 0) $level = 0; + for ($i = 0; $i < $numlines; $i++) { + if ($parent == 0) { + $level = 0; + } - if ($lines[$i]->fk_task_parent == $parent) - { + if ($lines[$i]->fk_task_parent == $parent) { $obj = &$lines[$i]; // To display extrafields // If we want all or we have a role on task, we show it - if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) - { + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); - if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases - { + if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases continue; } // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $lastprojectid = $lines[$i]->fk_project; $projectstatic->id = $lines[$i]->fk_project; } //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); //var_dump($projectstatic->weekWorkLoadPerTask); - if (empty($workloadforid[$projectstatic->id])) - { + if (empty($workloadforid[$projectstatic->id])) { $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week $workloadforid[$projectstatic->id] = 1; } @@ -1515,22 +1625,27 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $thirdpartystatic->name = $lines[$i]->thirdparty_name; $thirdpartystatic->email = $lines[$i]->thirdparty_email; - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) - { + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { $addcolspan = 0; - if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; - if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; - foreach ($arrayfields as $key => $val) - { - if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; + if (!empty($arrayfields['t.planned_workload']['checked'])) { + $addcolspan++; + } + if (!empty($arrayfields['t.progress']['checked'])) { + $addcolspan++; + } + foreach ($arrayfields as $key => $val) { + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') { + $addcolspan++; + } } print ''."\n"; print ''; print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); - if ($projectstatic->title) - { + if ($thirdpartystatic->id > 0) { + print ' - '.$thirdpartystatic->getNomUrl(1); + } + if ($projectstatic->title) { print ' - '; print ''.$projectstatic->title.''; } @@ -1541,65 +1656,67 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print ''; // PROJECT fields - if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); - $extrafieldsobjectkey='projet'; - $extrafieldsobjectprefix='efp.'; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - print ''; - print ''; + print ''; + print ''; - // PROJECT fields - if (! empty($arrayfields['p.fk_opp_status']['checked'])) - { - print ''; - $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); - print "\n"; - } - if (! empty($arrayfields['p.opp_amount']['checked'])) - { - print ''; - print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); - print "\n"; - } - if (! empty($arrayfields['p.opp_percent']['checked'])) - { - print ''; - print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %'; - print "\n"; - } - if (! empty($arrayfields['p.budget_amount']['checked'])) - { - print ''; - print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); - print "\n"; - } - if (! empty($arrayfields['p.usage_bill_time']['checked'])) - { - print ''; - print yn($lines[$i]->usage_bill_time); - print "\n"; - } + // PROJECT fields + if (! empty($arrayfields['p.fk_opp_status']['checked'])) + { + print ''; + $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print "\n"; + } + if (! empty($arrayfields['p.opp_amount']['checked'])) + { + print ''; + print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + print "\n"; + } + if (! empty($arrayfields['p.opp_percent']['checked'])) + { + print ''; + print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %'; + print "\n"; + } + if (! empty($arrayfields['p.budget_amount']['checked'])) + { + print ''; + print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + print "\n"; + } + if (! empty($arrayfields['p.usage_bill_time']['checked'])) + { + print ''; + print yn($lines[$i]->usage_bill_time); + print "\n"; + } - $extrafieldsobjectkey='projet'; - $extrafieldsobjectprefix='efp.'; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - print ''; - print ''; + print ''; + print ''; */ print ''; print ''; } - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + if ($oldprojectforbreak != -1) { + $oldprojectforbreak = $projectstatic->id; + } print ''."\n"; @@ -1611,30 +1728,36 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ */ // Project - if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) - { + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($oldprojectforbreak == -1) { + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + } print ""; } // Thirdparty - if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) - { + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); + if ($thirdpartystatic->id > 0) { + print $thirdpartystatic->getNomUrl(1, 'project'); + } print ''; } // Ref print ''; print ''; - for ($k = 0; $k < $level; $k++) print '
    '; + for ($k = 0; $k < $level; $k++) { + print '
    '; + } print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; print ''.$taskstatic->label.''; - for ($k = 0; $k < $level; $k++) print "
    "; + for ($k = 0; $k < $level; $k++) { + print "
    "; + } print "\n"; // TASK extrafields @@ -1643,16 +1766,17 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Planned Workload - if (!empty($arrayfields['t.planned_workload']['checked'])) - { + if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); - else print '--:--'; + if ($lines[$i]->planned_workload) { + print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); + } else { + print '--:--'; + } print ''; } - if (!empty($arrayfields['t.progress']['checked'])) - { + if (!empty($arrayfields['t.progress']['checked'])) { // Progress declared % print ''; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); @@ -1662,19 +1786,23 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Time spent by everybody print ''; // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user - if ($lines[$i]->duration) - { + if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print ''; - } else print '--:--'; + } else { + print '--:--'; + } print "\n"; // Time spent by user print ''; $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - else print '--:--'; + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -1682,14 +1810,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) - { + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) - { + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } @@ -1697,57 +1823,62 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Fields to show current time $tableCell = ''; $modeinput = 'hours'; - for ($idw = 0; $idw < 7; $idw++) - { + for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $cssonholiday = ''; - if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$tmpday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } $tmparray = dol_getdate($tmpday); $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; $totalforeachday[$tmpday] += $dayWorkLoad; $alreadyspent = ''; - if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); + if ($dayWorkLoad > 0) { + $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); + } $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']); global $numstartworkingday, $numendworkingday; $cssweekend = ''; - if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if (($idw + 1 < $numstartworkingday) || ($idw + 1 > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } $tableCell = ''; //$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday; $placeholder = ''; - if ($alreadyspent) - { + if ($alreadyspent) { $tableCell .= ''; //$placeholder=' placeholder="00:00"'; - //$tableCell.='+'; + //$tableCell.='+'; } - $tableCell .= ''; - $tableCell .= ''; + $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; + $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; + $tableCell .= ''; print $tableCell; } // Warning print ''; - if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); - elseif ($disabledtask) - { - $titleassigntask = $langs->trans("AssignTaskToMe"); - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + if ((!$lines[$i]->public) && $disabledproject) { + print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + } elseif ($disabledtask) { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) { + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + } - print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); - } + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + } print ''; print "\n"; @@ -1756,15 +1887,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Call to show task with a lower level (task under the current task) $inc++; $level++; - if ($lines[$i]->id > 0) - { + if ($lines[$i]->id > 0) { //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); //var_dump($totalforeachday); $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach ($ret as $key => $val) - { + foreach ($ret as $key => $val) { $totalforeachday[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); @@ -1810,43 +1939,39 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $lineswithoutlevel0 = array(); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. - if ($parent == 0) // Always and only if at first level - { - for ($i = 0; $i < $numlines; $i++) - { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; + if ($parent == 0) { // Always and only if at first level + for ($i = 0; $i < $numlines; $i++) { + if ($lines[$i]->fk_task_parent) { + $lineswithoutlevel0[] = $lines[$i]; + } } } //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - if (empty($oldprojectforbreak)) - { + if (empty($oldprojectforbreak)) { $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break } - for ($i = 0; $i < $numlines; $i++) - { - if ($parent == 0) $level = 0; + for ($i = 0; $i < $numlines; $i++) { + if ($parent == 0) { + $level = 0; + } - if ($lines[$i]->fk_task_parent == $parent) - { + if ($lines[$i]->fk_task_parent == $parent) { // If we want all or we have a role on task, we show it - if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) - { + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $lastprojectid = $lines[$i]->fk_project; $projectstatic->id = $lines[$i]->fk_project; } //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); //var_dump($projectstatic->weekWorkLoadPerTask); - if (empty($workloadforid[$projectstatic->id])) - { + if (empty($workloadforid[$projectstatic->id])) { $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week $workloadforid[$projectstatic->id] = 1; } @@ -1870,14 +1995,14 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $thirdpartystatic->name = $lines[$i]->thirdparty_name; $thirdpartystatic->email = $lines[$i]->thirdparty_email; - if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) - { + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { print ''."\n"; print ''; print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); - if ($projectstatic->title) - { + if ($thirdpartystatic->id > 0) { + print ' - '.$thirdpartystatic->getNomUrl(1); + } + if ($projectstatic->title) { print ' - '; print ''.$projectstatic->title.''; } @@ -1885,7 +2010,9 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & print ''; } - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + if ($oldprojectforbreak != -1) { + $oldprojectforbreak = $projectstatic->id; + } print ''."\n"; // User @@ -1908,18 +2035,25 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Ref print ''; print ''; - for ($k = 0; $k < $level; $k++) print '
    '; + for ($k = 0; $k < $level; $k++) { + print '
    '; + } print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; print ''.$taskstatic->label.''; - for ($k = 0; $k < $level; $k++) print "
    "; + for ($k = 0; $k < $level; $k++) { + print "
    "; + } print "\n"; // Planned Workload print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); - else print '--:--'; + if ($lines[$i]->planned_workload) { + print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); + } else { + print '--:--'; + } print ''; // Progress declared % @@ -1930,19 +2064,23 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Time spent by everybody print ''; // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user - if ($lines[$i]->duration) - { + if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print ''; - } else print '--:--'; + } else { + print '--:--'; + } print "\n"; // Time spent by user print ''; $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - else print '--:--'; + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -1950,14 +2088,12 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) - { + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit - if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) - { + if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } @@ -1970,20 +2106,20 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & foreach ($TFirstDay as &$fday) { $fday--; } - foreach ($TWeek as $weekNb) - { + foreach ($TWeek as $weekNb) { $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; $totalforeachweek[$weekNb] += $weekWorkLoad; $alreadyspent = ''; - if ($weekWorkLoad > 0) $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin'); + if ($weekWorkLoad > 0) { + $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin'); + } $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb); $tableCell = ''; $placeholder = ''; - if ($alreadyspent) - { + if ($alreadyspent) { $tableCell .= ''; //$placeholder=' placeholder="00:00"'; //$tableCell.='+'; @@ -1999,11 +2135,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Warning print ''; - if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); - elseif ($disabledtask) - { + if ((!$lines[$i]->public) && $disabledproject) { + print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + } elseif ($disabledtask) { $titleassigntask = $langs->trans("AssignTaskToMe"); - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + if ($fuser->id != $user->id) { + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + } print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); } @@ -2015,15 +2153,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Call to show task with a lower level (task under the current task) $inc++; $level++; - if ($lines[$i]->id > 0) - { + if ($lines[$i]->id > 0) { //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); //var_dump($totalforeachday); $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach ($ret as $key => $val) - { + foreach ($ret as $key => $val) { $totalforeachweek[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); @@ -2052,14 +2188,11 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { //print 'Search in line with parent id = '.$parent.'
    '; $numlines = count($lines); - for ($i = 0; $i < $numlines; $i++) - { + for ($i = 0; $i < $numlines; $i++) { // Process line $lines[$i] - if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) - { + if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) { // If task is legitimate to show, no more need to search deeper - if (isset($taskrole[$lines[$i]->id])) - { + if (isset($taskrole[$lines[$i]->id])) { //print 'Found a legitimate task id='.$lines[$i]->id.'
    '; $inc++; return $inc; @@ -2068,7 +2201,9 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); //print 'Found inc='.$inc.'
    '; - if ($inc > 0) return $inc; + if ($inc > 0) { + return $inc; + } } } @@ -2119,7 +2254,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $project_year_filter = 0; $title = $langs->trans("Projects"); - if (strcmp($status, '') && $status >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]); + if (strcmp($status, '') && $status >= 0) { + $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]); + } $arrayidtypeofcontact = array(); @@ -2127,8 +2264,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; $sql = " FROM ".MAIN_DB_PREFIX."projet as p"; - if ($mytasks) - { + if ($mytasks) { $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; @@ -2137,27 +2273,24 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.rowid IN (".$projectsListId.")"; - if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($mytasks) - { + if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } + if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ec.fk_socpeople = ".$user->id; $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact $sql .= " AND ctc.element = 'project_task'"; } - if ($status >= 0) - { + if ($status >= 0) { $sql .= " AND p.fk_statut = ".(int) $status; } - if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) - { + if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { $project_year_filter = GETPOST("project_year_filter"); //Check if empty or invalid year. Wildcard ignores the sql check - if ($project_year_filter != "*") - { - if (empty($project_year_filter) || !ctype_digit($project_year_filter)) - { + if ($project_year_filter != "*") { + if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { $project_year_filter = date("Y"); } $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; @@ -2170,18 +2303,20 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $sql1 = "SELECT p.rowid as projectid"; $sql1 .= $sql; $resql = $db->query($sql1); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } - } else dol_print_error($db); - if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; + } else { + dol_print_error($db); + } + if (empty($arrayidofprojects)) { + $arrayidofprojects[0] = -1; + } // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,"; @@ -2201,8 +2336,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $sql2 .= " ORDER BY p.title, p.ref"; $resql = $db->query($sql2); - if ($resql) - { + if ($resql) { $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; @@ -2213,25 +2347,30 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - if (!in_array('prospectionstatus', $hiddenfields)) print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right '); + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (!in_array('prospectionstatus', $hiddenfields)) { + print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder); } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right '); - if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right '); + if (!in_array('plannedworkload', $hiddenfields)) { + print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right '); + } + if (!in_array('declaredprogress', $hiddenfields)) { + print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right '); + } + } + if (!in_array('projectstatus', $hiddenfields)) { + print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right '); } - if (!in_array('projectstatus', $hiddenfields)) print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right '); print "\n"; $total_plannedworkload = 0; $total_declaredprogressworkload = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; @@ -2240,8 +2379,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); - if ($userAccess >= 0) - { + if ($userAccess >= 0) { $projectstatic->ref = $objp->ref; $projectstatic->status = $objp->status; $projectstatic->title = $objp->title; @@ -2252,12 +2390,13 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { print ''; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''; $plannedworkload = $objp->planned_workload; $total_plannedworkload += $plannedworkload; - if (!in_array('plannedworkload', $hiddenfields)) - { + if (!in_array('plannedworkload', $hiddenfields)) { print ''; } - if (!in_array('declaredprogress', $hiddenfields)) - { + if (!in_array('declaredprogress', $hiddenfields)) { $declaredprogressworkload = $objp->declared_progess_workload; $total_declaredprogressworkload += $declaredprogressworkload; print ''; print '"; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { print ''; } @@ -2361,11 +2497,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency)); print ''; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''; - if (!in_array('plannedworkload', $hiddenfields)) print ''; - if (!in_array('declaredprogress', $hiddenfields)) print ''; + if (!in_array('plannedworkload', $hiddenfields)) { + print ''; + } + if (!in_array('declaredprogress', $hiddenfields)) { + print ''; + } } if (!in_array('projectstatus', $hiddenfields)) { print ''; @@ -2380,8 +2519,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print "
    '; print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall'); - if (!in_array('projectlabel', $hiddenfields)) print '
    '.dol_trunc($objp->title, 24).''; + if (!in_array('projectlabel', $hiddenfields)) { + print '
    '.dol_trunc($objp->title, 24).''; + } print '
    '; - if ($objp->fk_soc > 0) - { + if ($objp->fk_soc > 0) { $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->socname; //$thirdpartystatic->name_alias = $objp->name_alias; @@ -2274,8 +2413,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } print ''; // Because color of prospection status has no meaning yet, it is used if hidden constant is set @@ -2309,22 +2447,21 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency); $ponderated_opp_amount += price2num($opp_weighted_amount); } - if ($objp->opp_amount) print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).''; + if ($objp->opp_amount) { + print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).''; + } print ''.$objp->nb.''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').''; @@ -2351,8 +2488,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print '
    '.$langs->trans("Total")."'.$total_task.''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'
    "; print '
    '; - if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) - { + if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { //Add the year filter input print ''; print ''; @@ -2410,8 +2548,12 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $plannedworkloadoutputformat = 'allhourmin'; $timespentoutputformat = 'allhourmin'; - if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) { + $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + } + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) { + $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; + } if (empty($task->progress) && !empty($hideOnProgressNull)) { return ''; @@ -2450,8 +2592,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out .= '
    '; - if ($label !== false) - { + if ($label !== false) { $out .= ' '; if ($label !== true) { @@ -2463,21 +2604,25 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide } - if ($progressNumber !== false) - { + if ($progressNumber !== false) { $out .= ' '; if ($progressNumber !== true) { $out .= $progressNumber; // replace label by param } else { - if ($task->hasDelay()) $out .= img_warning($langs->trans("Late")).' '; + if ($task->hasDelay()) { + $out .= img_warning($langs->trans("Late")).' '; + } $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id; $out .= !empty($diff) ? $diff.' ' : ''; $out .= ''; $out .= ''; - if ($task->duration_effective) $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat); - else $out .= '--:--'; + if ($task->duration_effective) { + $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat); + } else { + $out .= '--:--'; + } $out .= ''; $out .= ''; @@ -2485,8 +2630,11 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out .= ''; $out .= ''; - if ($task->planned_workload) $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat); - else $out .= '--:--'; + if ($task->planned_workload) { + $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat); + } else { + $out .= '--:--'; + } $out .= ''; } $out .= ' '; @@ -2529,8 +2677,7 @@ function getTaskProgressBadge($task, $label = '', $tooltip = '') $out = ''; $badgeClass = ''; - if ($task->progress != '') - { + if ($task->progress != '') { // TODO : manage 100% // define color according to time spend vs workload @@ -2548,10 +2695,14 @@ function getTaskProgressBadge($task, $label = '', $tooltip = '') } } elseif (doubleval($progressCalculated) > doubleval($task->progress)) { // warning if close at 10% $badgeClass .= 'badge-warning'; - if (empty($tooltip)) $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; + if (empty($tooltip)) { + $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; + } } else { $badgeClass .= 'badge-success'; - if (empty($tooltip)) $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; + if (empty($tooltip)) { + $tooltip = $task->progress.'% >= '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; + } } } } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index bd3a30151da..3ddd3ab1b2b 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -43,24 +43,28 @@ function propal_prepare_head($object) $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->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) - { + || (!empty($conf->expedition->enabled) && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->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->delivery_note->enabled) $text .= '/'.$langs->trans("Receivings"); + if ($conf->expedition_bon->enabled) { + $text = $langs->trans("Shipment"); + } + if ($conf->delivery_note->enabled) { + $text .= '/'.$langs->trans("Receivings"); + } $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $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++; } @@ -71,14 +75,19 @@ function propal_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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++; } @@ -90,7 +99,9 @@ function propal_prepare_head($object) $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/receiptprinter.lib.php b/htdocs/core/lib/receiptprinter.lib.php index e5589f30707..7bbfbc66387 100644 --- a/htdocs/core/lib/receiptprinter.lib.php +++ b/htdocs/core/lib/receiptprinter.lib.php @@ -47,8 +47,7 @@ function receiptprinteradmin_prepare_head($mode) $head[$h][2] = 'template'; $h++; - if ($mode == 'test') - { + if ($mode == 'test') { $head[$h][0] = DOL_URL_ROOT."/admin/receiptprinter.php?mode=test"; $head[$h][1] = $langs->trans("TargetedPrinter"); $head[$h][2] = 'test'; diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index f36295e31f3..42355497286 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -47,18 +47,18 @@ function reception_prepare_head(Reception $object) $head[$h][2] = 'reception'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $objectsrc = $object; - if ($object->origin == 'commande' && $object->origin_id > 0) - { + if ($object->origin == 'commande' && $object->origin_id > 0) { $objectsrc = new Commande($db); $objectsrc->fetch($object->origin_id); } $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,11 +70,17 @@ function reception_prepare_head(Reception $object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception'); $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."/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,16 +109,14 @@ function reception_admin_prepare_head() complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin'); - 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"); $head[$h][2] = 'attributes_reception'; $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"); $head[$h][2] = 'attributeslines_reception'; diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index b23acd76a5b..a4279d27a95 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -44,7 +44,9 @@ function report_header($reportname, $notused, $period, $periodlink, $description print "\n\n\n"; - if (!empty($varlink)) $varlink = '?'.$varlink; + if (!empty($varlink)) { + $varlink = '?'.$varlink; + } $head = array(); @@ -58,8 +60,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print dol_get_fiche_head($head, 'report'); - foreach ($moreparam as $key => $value) - { + foreach ($moreparam as $key => $value) { print ''."\n"; } @@ -73,17 +74,20 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '
    '; - if ($variante) print ''; + if ($variante) { + print ''; + } print ''."\n"; // Calculation mode - if ($calcmode) - { + if ($calcmode) { print ''; print ''; print ''; + if ($variante) { + print ''; + } print ''; print ''."\n"; } @@ -92,8 +96,12 @@ function report_header($reportname, $notused, $period, $periodlink, $description print ''; print ''; print ''; + if ($period) { + print $period; + } + if ($variante) { + print ''; + } print ''; print ''."\n"; @@ -101,7 +109,9 @@ function report_header($reportname, $notused, $period, $periodlink, $description print ''; print ''; print ''; - if ($variante) print ''; + if ($variante) { + print ''; + } print ''."\n"; // Ligne d'export @@ -110,7 +120,9 @@ function report_header($reportname, $notused, $period, $periodlink, $description print ''; - if ($variante) print ''; + if ($variante) { + print ''; + } print ''."\n"; print '
    '; print $reportname; print '
    '.$langs->trans("CalculationMode").''; print $calcmode; - if ($variante) print '
    '.$langs->trans("ReportPeriod").''; - if ($period) print $period; - if ($variante) print ''.$periodlink.''.$periodlink.'
    '.$langs->trans("ReportDescription").''.$description.'
    '; print dol_print_date($builddate, 'dayhour'); print ''.($exportlink ? $langs->trans("Export").': '.$exportlink : '').''.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'
    '."\n"; diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index a4ba796078f..29cd8a5b089 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -40,12 +40,13 @@ function resource_prepare_head($object) $head[$h][2] = 'resource'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY))) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY))) { $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++; } @@ -56,14 +57,19 @@ function resource_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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++; } @@ -73,14 +79,15 @@ function resource_prepare_head($object) $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"); } diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index f4662f43991..c52246203e2 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -50,7 +50,9 @@ function salaries_prepare_head($object) $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/security.lib.php b/htdocs/core/lib/security.lib.php index 9d18dd1dd85..6b95187e5df 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -37,21 +37,17 @@ */ function dol_encode($chain, $key = '1') { - if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char - { + if (is_numeric($key) && $key == '1') { // rule 1 is offset of 17 for char $output_tab = array(); $strlength = dol_strlen($chain); - for ($i = 0; $i < $strlength; $i++) - { + for ($i = 0; $i < $strlength; $i++) { $output_tab[$i] = chr(ord(substr($chain, $i, 1)) + 17); } $chain = implode("", $output_tab); - } elseif ($key) - { + } elseif ($key) { $result = ''; $strlength = dol_strlen($chain); - for ($i = 0; $i < $strlength; $i++) - { + for ($i = 0; $i < $strlength; $i++) { $keychar = substr($key, ($i % strlen($key)) - 1, 1); $result .= chr(ord(substr($chain, $i, 1)) + (ord($keychar) - 65)); } @@ -74,22 +70,18 @@ function dol_decode($chain, $key = '1') { $chain = base64_decode($chain); - if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char - { + if (is_numeric($key) && $key == '1') { // rule 1 is offset of 17 for char $output_tab = array(); $strlength = dol_strlen($chain); - for ($i = 0; $i < $strlength; $i++) - { + for ($i = 0; $i < $strlength; $i++) { $output_tab[$i] = chr(ord(substr($chain, $i, 1)) - 17); } $chain = implode("", $output_tab); - } elseif ($key) - { + } elseif ($key) { $result = ''; $strlength = dol_strlen($chain); - for ($i = 0; $i < $strlength; $i++) - { + for ($i = 0; $i < $strlength; $i++) { $keychar = substr($key, ($i % strlen($key)) - 1, 1); $result .= chr(ord(substr($chain, $i, 1)) - (ord($keychar) - 65)); } @@ -115,21 +107,30 @@ function dol_hash($chain, $type = '0') global $conf; // No need to add salt for password_hash - if (($type == '0' || $type == 'auto') && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) - { + if (($type == '0' || $type == 'auto') && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) { return password_hash($chain, PASSWORD_DEFAULT); } // Salt value - if (!empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'md5openldap') $chain = $conf->global->MAIN_SECURITY_SALT.$chain; + if (!empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'md5openldap') { + $chain = $conf->global->MAIN_SECURITY_SALT.$chain; + } - if ($type == '1' || $type == 'sha1') return sha1($chain); - elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); - elseif ($type == '3' || $type == 'md5') return md5($chain); - elseif ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base) - elseif ($type == '5') return hash('sha256', $chain); - elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); - elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); + if ($type == '1' || $type == 'sha1') { + return sha1($chain); + } elseif ($type == '2' || $type == 'sha1md5') { + return sha1(md5($chain)); + } elseif ($type == '3' || $type == 'md5') { + return md5($chain); + } elseif ($type == '4' || $type == 'md5openldap') { + return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base) + } elseif ($type == '5') { + return hash('sha256', $chain); + } elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') { + return sha1($chain); + } elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') { + return sha1(md5($chain)); + } // No particular encoding defined, use default return md5($chain); @@ -151,9 +152,13 @@ function dol_verifyHash($chain, $hash, $type = '0') global $conf; if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { - if ($hash[0] == '$') return password_verify($chain, $hash); - elseif (strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 - elseif (strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 + if ($hash[0] == '$') { + return password_verify($chain, $hash); + } elseif (strlen($hash) == 32) { + return dol_verifyHash($chain, $hash, '3'); // md5 + } elseif (strlen($hash) == 40) { + return dol_verifyHash($chain, $hash, '2'); // sha1md5 + } return false; } @@ -192,34 +197,57 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f // Fix syntax of $features param $originalfeatures = $features; - if ($features == 'facturerec') $features = 'facture'; - if ($features == 'mo') $features = 'mrp'; - if ($features == 'member') $features = 'adherent'; - if ($features == 'subscription') { $features = 'adherent'; $feature2 = 'cotisation'; }; - if ($features == 'websitepage') { $features = 'website'; $tableandshare = 'website_page'; $parentfortableentity = 'fk_website@website'; } - if ($features == 'project') $features = 'projet'; - if ($features == 'product') $features = 'produit'; + if ($features == 'facturerec') { + $features = 'facture'; + } + if ($features == 'mo') { + $features = 'mrp'; + } + if ($features == 'member') { + $features = 'adherent'; + } + if ($features == 'subscription') { + $features = 'adherent'; $feature2 = 'cotisation'; + }; + if ($features == 'websitepage') { + $features = 'website'; $tableandshare = 'website_page'; $parentfortableentity = 'fk_website@website'; + } + if ($features == 'project') { + $features = 'projet'; + } + if ($features == 'product') { + $features = 'produit'; + } // Get more permissions checks from hooks $parameters = array('features'=>$features, 'originalfeatures'=>$originalfeatures, 'objectid'=>$objectid, 'dbt_select'=>$dbt_select, 'idtype'=>$dbt_select, 'isdraft'=>$isdraft); $reshook = $hookmanager->executeHooks('restrictedArea', $parameters); if (isset($hookmanager->resArray['result'])) { - if ($hookmanager->resArray['result'] == 0) accessforbidden(); // Module returns 0, so access forbidden + if ($hookmanager->resArray['result'] == 0) { + accessforbidden(); // Module returns 0, so access forbidden + } } if ($reshook > 0) { // No other test done. return 1; } - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + if ($dbt_select != 'rowid' && $dbt_select != 'id') { + $objectid = "'".$objectid."'"; + } // Features/modules to check $featuresarray = array($features); - if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); - elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); + if (preg_match('/&/', $features)) { + $featuresarray = explode("&", $features); + } elseif (preg_match('/\|/', $features)) { + $featuresarray = explode("|", $features); + } // More subfeatures to check - if (!empty($feature2)) $feature2 = explode("|", $feature2); + if (!empty($feature2)) { + $feature2 = explode("|", $feature2); + } $listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); @@ -227,33 +255,59 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f $readok = 1; $nbko = 0; foreach ($featuresarray as $feature) { // first we check nb of test ko $featureforlistofmodule = $feature; - if ($featureforlistofmodule == 'produit') $featureforlistofmodule = 'product'; + if ($featureforlistofmodule == 'produit') { + $featureforlistofmodule = 'product'; + } if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users $readok = 0; $nbko++; continue; } if ($feature == 'societe') { - if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { $readok = 0; $nbko++; } + if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'contact') { - if (!$user->rights->societe->contact->lire) { $readok = 0; $nbko++; } + if (!$user->rights->societe->contact->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'produit|service') { - if (!$user->rights->produit->lire && !$user->rights->service->lire) { $readok = 0; $nbko++; } + if (!$user->rights->produit->lire && !$user->rights->service->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'prelevement') { - if (!$user->rights->prelevement->bons->lire) { $readok = 0; $nbko++; } + if (!$user->rights->prelevement->bons->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'cheque') { - if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; } + if (!$user->rights->banque->cheque) { + $readok = 0; $nbko++; + } } elseif ($feature == 'projet') { - if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; } + if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'payment') { - if (!$user->rights->facture->lire) { $readok = 0; $nbko++; } + if (!$user->rights->facture->lire) { + $readok = 0; $nbko++; + } } elseif ($feature == 'payment_supplier') { - if (!$user->rights->fournisseur->facture->lire) { $readok = 0; $nbko++; } + if (!$user->rights->fournisseur->facture->lire) { + $readok = 0; $nbko++; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels $tmpreadok = 1; foreach ($feature2 as $subfeature) { - if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card - if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; } elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; } else { $tmpreadok = 1; break; } // Break is to bypass second test if the first is ok + if ($subfeature == 'user' && $user->id == $objectid) { + continue; // A user can always read its own card + } + if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { + $tmpreadok = 0; + } elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { + $tmpreadok = 0; + } else { + $tmpreadok = 1; break; + } // Break is to bypass second test if the first is ok } if (!$tmpreadok) { // We found a test on feature that is ko $readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). @@ -262,14 +316,20 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) { // This is permissions on 1 level if (empty($user->rights->$feature->lire) && empty($user->rights->$feature->read) - && empty($user->rights->$feature->run)) { $readok = 0; $nbko++; } + && empty($user->rights->$feature->run)) { + $readok = 0; $nbko++; + } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { + $readok = 1; + } - if (!$readok) accessforbidden(); + if (!$readok) { + accessforbidden(); + } //print "Read access is ok"; // Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files) @@ -277,30 +337,48 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f $wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update'); $wemustcheckpermissionfordeletedraft = ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'); - if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) - { - foreach ($featuresarray as $feature) - { + if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) { + foreach ($featuresarray as $feature) { if ($feature == 'contact') { - if (!$user->rights->societe->contact->creer) { $createok = 0; $nbko++; } + if (!$user->rights->societe->contact->creer) { + $createok = 0; $nbko++; + } } elseif ($feature == 'produit|service') { - if (!$user->rights->produit->creer && !$user->rights->service->creer) { $createok = 0; $nbko++; } + if (!$user->rights->produit->creer && !$user->rights->service->creer) { + $createok = 0; $nbko++; + } } elseif ($feature == 'prelevement') { - if (!$user->rights->prelevement->bons->creer) { $createok = 0; $nbko++; } + if (!$user->rights->prelevement->bons->creer) { + $createok = 0; $nbko++; + } } elseif ($feature == 'commande_fournisseur') { - if (!$user->rights->fournisseur->commande->creer) { $createok = 0; $nbko++; } + if (!$user->rights->fournisseur->commande->creer) { + $createok = 0; $nbko++; + } } elseif ($feature == 'banque') { - if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; } + if (!$user->rights->banque->modifier) { + $createok = 0; $nbko++; + } } elseif ($feature == 'cheque') { - if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } + if (!$user->rights->banque->cheque) { + $createok = 0; $nbko++; + } } elseif ($feature == 'import') { - if (!$user->rights->import->run) { $createok = 0; $nbko++; } + if (!$user->rights->import->run) { + $createok = 0; $nbko++; + } } elseif ($feature == 'ecm') { - if (!$user->rights->ecm->upload) { $createok = 0; $nbko++; } + if (!$user->rights->ecm->upload) { + $createok = 0; $nbko++; + } } elseif (!empty($feature2)) { // This is for permissions on one level foreach ($feature2 as $subfeature) { - if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) continue; // User can edit its own card - if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) continue; // User can edit its own password + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) { + continue; // User can edit its own card + } + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) { + continue; // User can edit its own password + } if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write) @@ -325,82 +403,101 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { + $createok = 1; + } - if ($wemustcheckpermissionforcreate && !$createok) accessforbidden(); + if ($wemustcheckpermissionforcreate && !$createok) { + accessforbidden(); + } //print "Write access is ok"; } // Check create user permission $createuserok = 1; - if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') - { - if (!$user->rights->user->user->creer) $createuserok = 0; + if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') { + if (!$user->rights->user->user->creer) { + $createuserok = 0; + } - if (!$createuserok) accessforbidden(); + if (!$createuserok) { + accessforbidden(); + } //print "Create user access is ok"; } // Check delete permission from module $deleteok = 1; $nbko = 0; - if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') - { - foreach ($featuresarray as $feature) - { - if ($feature == 'contact') - { - if (!$user->rights->societe->contact->supprimer) $deleteok = 0; - } elseif ($feature == 'produit|service') - { - if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0; - } elseif ($feature == 'commande_fournisseur') - { - if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0; - } elseif ($feature == 'banque') - { - if (!$user->rights->banque->modifier) $deleteok = 0; - } elseif ($feature == 'cheque') - { - if (!$user->rights->banque->cheque) $deleteok = 0; - } elseif ($feature == 'ecm') - { - if (!$user->rights->ecm->upload) $deleteok = 0; - } elseif ($feature == 'ftp') - { - if (!$user->rights->ftp->write) $deleteok = 0; - } elseif ($feature == 'salaries') - { - if (!$user->rights->salaries->delete) $deleteok = 0; - } elseif ($feature == 'salaries') - { - if (!$user->rights->salaries->delete) $deleteok = 0; - } elseif (!empty($feature2)) // This is for permissions on 2 levels - { - foreach ($feature2 as $subfeature) - { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0; - else { $deleteok = 1; break; } // For bypass the second test if the first is ok + if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') { + foreach ($featuresarray as $feature) { + if ($feature == 'contact') { + if (!$user->rights->societe->contact->supprimer) { + $deleteok = 0; } - } elseif (!empty($feature)) // This is used for permissions on 1 level - { + } elseif ($feature == 'produit|service') { + if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) { + $deleteok = 0; + } + } elseif ($feature == 'commande_fournisseur') { + if (!$user->rights->fournisseur->commande->supprimer) { + $deleteok = 0; + } + } elseif ($feature == 'banque') { + if (!$user->rights->banque->modifier) { + $deleteok = 0; + } + } elseif ($feature == 'cheque') { + if (!$user->rights->banque->cheque) { + $deleteok = 0; + } + } elseif ($feature == 'ecm') { + if (!$user->rights->ecm->upload) { + $deleteok = 0; + } + } elseif ($feature == 'ftp') { + if (!$user->rights->ftp->write) { + $deleteok = 0; + } + } elseif ($feature == 'salaries') { + if (!$user->rights->salaries->delete) { + $deleteok = 0; + } + } elseif ($feature == 'salaries') { + if (!$user->rights->salaries->delete) { + $deleteok = 0; + } + } elseif (!empty($feature2)) { // This is for permissions on 2 levels + foreach ($feature2 as $subfeature) { + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { + $deleteok = 0; + } else { + $deleteok = 1; break; + } // For bypass the second test if the first is ok + } + } elseif (!empty($feature)) { // This is used for permissions on 1 level //print '
    feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) $deleteok = 0; + && empty($user->rights->$feature->run)) { + $deleteok = 0; + } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { + $deleteok = 1; + } - if (!$deleteok && !($isdraft && $createok)) accessforbidden(); + if (!$deleteok && !($isdraft && $createok)) { + accessforbidden(); + } //print "Delete access is ok"; } // If we have a particular object to check permissions on, we check this object // is linked to a company allowed to $user. - if (!empty($objectid) && $objectid > 0) - { + if (!empty($objectid) && $objectid > 0) { $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select, $parentfortableentity); $params = array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); @@ -437,14 +534,19 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $dbtablename = (!empty($params[0]) ? $params[0] : ''); $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); - foreach ($featuresarray as $feature) - { + foreach ($featuresarray as $feature) { $sql = ''; // For backward compatibility - if ($feature == 'member') $feature = 'adherent'; - if ($feature == 'project') $feature = 'projet'; - if ($feature == 'task') $feature = 'projet_task'; + if ($feature == 'member') { + $feature = 'adherent'; + } + if ($feature == 'project') { + $feature = 'projet'; + } + if ($feature == 'task') { + $feature = 'projet_task'; + } $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object @@ -455,15 +557,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name - if (empty($dbtablename)) - { + if (empty($dbtablename)) { $dbtablename = $feature; $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. } // Check permission for object on entity only - if (in_array($feature, $check)) - { + if (in_array($feature, $check)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { // Special for multicompany @@ -496,7 +596,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } elseif (in_array($feature, $checksoc)) { // We check feature = checksoc if ($user->socid > 0) { // If external user: Check permission for external users - if ($user->socid <> $objectid) return false; + if ($user->socid <> $objectid) { + return false; + } } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { // If internal user: Check permission for internal users that are restricted on their objects $sql = "SELECT COUNT(sc.fk_soc) as nb"; @@ -513,18 +615,15 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " WHERE s.rowid IN (".$objectid.")"; $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } - } elseif (in_array($feature, $checkother)) // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...). - { + } elseif (in_array($feature, $checkother)) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...). // If external user: Check permission for external users - if ($user->socid > 0) - { + if ($user->socid > 0) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.fk_soc = ".$user->socid; } // If internal user: Check permission for internal users that are restricted on their objects - elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) - { + elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -532,15 +631,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (!empty($conf->multicompany->enabled)) - { + elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read - { + if ($feature == 'agenda') {// Also check owner or attendee for users without allactions->read if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action = new ActionComm($db); @@ -551,13 +648,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } } } elseif (in_array($feature, $checkproject)) { - if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) - { + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($db); $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); $tmparray = explode(',', $tmps); - if (!in_array($objectid, $tmparray)) return false; + if (!in_array($objectid, $tmparray)) { + return false; + } } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; @@ -565,8 +663,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checktask)) { - if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) - { + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { $task = new Task($db); $task->fetch($objectid); @@ -574,7 +671,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $projectstatic = new Project($db); $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); $tmparray = explode(',', $tmps); - if (!in_array($task->fk_project, $tmparray)) return false; + if (!in_array($task->fk_project, $tmparray)) { + return false; + } } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; @@ -584,7 +683,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } elseif (!in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield // If external user: Check permission for external users if ($user->socid > 0) { - if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); + if (empty($dbt_keyfield)) { + dol_print_error('', 'Param dbt_keyfield is required but not defined'); + } $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$objectid.")"; @@ -592,7 +693,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } elseif (!empty($conf->societe->enabled) && !$user->rights->societe->client->voir) { // If internal user: Check permission for internal users that are restricted on their objects if ($feature != 'ticket') { - if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); + if (empty($dbt_keyfield)) { + dol_print_error('', 'Param dbt_keyfield is required but not defined'); + } $sql = "SELECT COUNT(sc.fk_soc) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -610,8 +713,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND (sc.fk_user = ".$user->id." OR sc.fk_user IS NULL)"; } } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (!empty($conf->multicompany->enabled)) - { + elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; @@ -619,13 +721,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } } - if ($sql) - { + if ($sql) { $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if (!$obj || $obj->nb < count(explode(',', $objectid))) return false; + if (!$obj || $obj->nb < count(explode(',', $objectid))) { + return false; + } } else { return false; } @@ -649,8 +751,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { global $conf, $db, $user, $langs, $hookmanager; - if (!is_object($langs)) - { + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->setDefaultLang(); @@ -658,21 +759,24 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $langs->load("errors"); - if ($printheader) - { - if (function_exists("llxHeader")) llxHeader(''); - elseif (function_exists("llxHeaderVierge")) llxHeaderVierge(''); + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); + } elseif (function_exists("llxHeaderVierge")) { + llxHeaderVierge(''); + } } print '
    '; - if (!$message) print $langs->trans("ErrorForbidden"); - else print $message; + if (!$message) { + print $langs->trans("ErrorForbidden"); + } else { + print $message; + } print '
    '; print '
    '; - if (empty($showonlymessage)) - { + if (empty($showonlymessage)) { global $action, $object; - if (empty($hookmanager)) - { + if (empty($hookmanager)) { $hookmanager = new HookManager($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); @@ -680,10 +784,8 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $parameters = array('message'=>$message, 'params'=>$params); $reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; - if (empty($reshook)) - { - if ($user->login) - { + if (empty($reshook)) { + if ($user->login) { print $langs->trans("CurrentLogin").': '.$user->login.'
    '; print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users")); } else { @@ -691,6 +793,8 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho } } } - if ($printfooter && function_exists("llxFooter")) llxFooter(); + if ($printfooter && function_exists("llxFooter")) { + llxFooter(); + } exit(0); } diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 3527d132cde..9181b3dd07d 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -35,8 +35,12 @@ function dol_getwebuser($mode) { $t = '?'; - if ($mode == 'user') $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty - if ($mode == 'group') $t = getenv('APACHE_RUN_GROUP'); + if ($mode == 'user') { + $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty + } + if ($mode == 'group') { + $t = getenv('APACHE_RUN_GROUP'); + } return $t; } @@ -56,44 +60,44 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth //global $dolauthmode; // To return authentication finally used // Check parameters - if ($entitytotest == '') $entitytotest = 1; + if ($entitytotest == '') { + $entitytotest = 1; + } dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',', $authmode)); $login = ''; // Validation of login/pass/entity with standard modules - if (empty($login)) - { + if (empty($login)) { $test = true; - foreach ($authmode as $mode) - { - if ($test && $mode && !$login) - { + foreach ($authmode as $mode) { + if ($test && $mode && !$login) { // Validation of login/pass/entity for mode $mode $mode = trim($mode); $authfile = 'functions_'.$mode.'.php'; $fullauthfile = ''; $dirlogin = array_merge(array("/core/login"), (array) $conf->modules_parts['login']); - foreach ($dirlogin as $reldir) - { + foreach ($dirlogin as $reldir) { $dir = dol_buildpath($reldir, 0); $newdir = dol_osencode($dir); // Check if file found (do not use dol_is_file to avoid loading files.lib.php) $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir) ? '' : '/').$authfile; - if (is_file($tmpnewauthfile)) $fullauthfile = $tmpnewauthfile; + if (is_file($tmpnewauthfile)) { + $fullauthfile = $tmpnewauthfile; + } } $result = false; - if ($fullauthfile) $result = include_once $fullauthfile; - if ($fullauthfile && $result) - { + if ($fullauthfile) { + $result = include_once $fullauthfile; + } + if ($fullauthfile && $result) { // Call function to check user/password $function = 'check_user_password_'.$mode; $login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context); - if ($login && $login != '--bad-login-validity--') // Login is successfull - { + if ($login && $login != '--bad-login-validity--') { // Login is successfull $test = false; // To stop once at first login success $conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used $dol_tz = GETPOST('tz'); @@ -117,8 +121,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth } -if (!function_exists('dol_loginfunction')) -{ +if (!function_exists('dol_loginfunction')) { /** * Show Dolibarr default login page. * Part of this code is also duplicated into main.inc.php::top_htmlhead @@ -147,7 +150,9 @@ if (!function_exists('dol_loginfunction')) // Title $appli = constant('DOL_APPLICATION_TITLE'); $title = $appli.' '.constant('DOL_VERSION'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $title = $conf->global->MAIN_APPLICATION_TITLE; + } $titletruedolibarrversion = constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version // Note: $conf->css looks like '/theme/eldy/style.css.php' @@ -169,13 +174,13 @@ if (!function_exists('dol_loginfunction')) */ // Select templates dir - if (!empty($conf->modules_parts['tpl'])) // Using this feature slow down application - { + if (!empty($conf->modules_parts['tpl'])) { // Using this feature slow down application $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); - foreach ($dirtpls as $reldir) - { + foreach ($dirtpls as $reldir) { $tmp = dol_buildpath($reldir.'login.tpl.php'); - if (file_exists($tmp)) { $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); break; } + if (file_exists($tmp)) { + $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); break; + } } } else { $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; @@ -184,18 +189,25 @@ if (!function_exists('dol_loginfunction')) // Set cookie for timeout management $prefix = dol_getprefix(''); $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; - if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, (empty($dolibarr_main_force_https) ? false : true), true); + if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { + setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, (empty($dolibarr_main_force_https) ? false : true), true); + } - if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); - else unset($_SESSION["urlfrom"]); + if (GETPOST('urlfrom', 'alpha')) { + $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); + } else { + unset($_SESSION["urlfrom"]); + } - if (!GETPOST("username", 'alpha')) $focus_element = 'username'; - else $focus_element = 'password'; + if (!GETPOST("username", 'alpha')) { + $focus_element = 'username'; + } else { + $focus_element = 'password'; + } $demologin = ''; $demopassword = ''; - if (!empty($dolibarr_main_demo)) - { + if (!empty($dolibarr_main_demo)) { $tab = explode(',', $dolibarr_main_demo); $demologin = $tab[0]; $demopassword = $tab[1]; @@ -233,8 +245,7 @@ if (!function_exists('dol_loginfunction')) // Security graphical code $captcha = 0; $captcha_refresh = ''; - if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) - { + if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha = 1; $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } @@ -242,23 +253,19 @@ if (!function_exists('dol_loginfunction')) // Extra link $forgetpasslink = 0; $helpcenterlink = 0; - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) - { - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) - { + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink = 1; } - if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) - { + if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink = 1; } } // Home message $main_home = ''; - if (!empty($conf->global->MAIN_HOME)) - { + if (!empty($conf->global->MAIN_HOME)) { $substitutionarray = getCommonSubstitutionArray($langs); complete_substitutions_array($substitutionarray, $langs); $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); @@ -273,11 +280,17 @@ if (!function_exists('dol_loginfunction')) $dol_loginmesg = (!empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : ''); $favicon = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; - if (!empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); - if (!empty($conf->global->MAIN_FAVICON_URL)) $favicon = $conf->global->MAIN_FAVICON_URL; + if (!empty($mysoc->logo_squarred_mini)) { + $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + } + if (!empty($conf->global->MAIN_FAVICON_URL)) { + $favicon = $conf->global->MAIN_FAVICON_URL; + } $jquerytheme = 'base'; - if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; + if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) { + $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; + } // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover $dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); @@ -307,18 +320,22 @@ if (!function_exists('dol_loginfunction')) function makesalt($type = CRYPT_SALT_LENGTH) { dol_syslog("makesalt type=".$type); - switch ($type) - { + switch ($type) { case 12: // 8 + 4 - $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break; + $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; + break; case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise) - $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break; + $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; + break; case 2: // 2 default: // by default, fall back on Standard DES (should work everywhere) - $saltlen = 2; $saltprefix = ''; $saltsuffix = ''; break; + $saltlen = 2; $saltprefix = ''; $saltsuffix = ''; + break; } $salt = ''; - while (dol_strlen($salt) < $saltlen) $salt .= chr(mt_rand(64, 126)); + while (dol_strlen($salt) < $saltlen) { + $salt .= chr(mt_rand(64, 126)); + } $result = $saltprefix.$salt.$saltsuffix; dol_syslog("makesalt return=".$result); @@ -338,33 +355,27 @@ function encodedecode_dbpassconf($level = 0) $passwd = ''; $passwd_crypted = ''; - if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r')) - { - while (!feof($fp)) - { + if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r')) { + while (!feof($fp)) { $buffer = fgets($fp, 4096); $lineofpass = 0; - if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) // Old way to save crypted value - { + if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { // Old way to save crypted value $val = trim($reg[1]); // This also remove CR/LF $val = preg_replace('/^["\']/', '', $val); $val = preg_replace('/["\'][\s;]*$/', '', $val); - if (!empty($val)) - { + if (!empty($val)) { $passwd_crypted = $val; $val = dol_decode($val); $passwd = $val; $lineofpass = 1; } - } elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) - { + } elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { $val = trim($reg[1]); // This also remove CR/LF $val = preg_replace('/^["\']/', '', $val); $val = preg_replace('/["\'][\s;]*$/', '', $val); - if (preg_match('/crypted:/i', $buffer)) - { + if (preg_match('/crypted:/i', $buffer)) { $val = preg_replace('/crypted:/i', '', $val); $passwd_crypted = $val; $val = dol_decode($val); @@ -378,15 +389,12 @@ function encodedecode_dbpassconf($level = 0) } // Output line - if ($lineofpass) - { + if ($lineofpass) { // Add value at end of file - if ($level == 0) - { + if ($level == 0) { $config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n"; } - if ($level == 1) - { + if ($level == 1) { $config .= '$dolibarr_main_db_pass=\'crypted:'.$passwd_crypted.'\';'."\n"; } @@ -400,8 +408,7 @@ function encodedecode_dbpassconf($level = 0) // Write new conf file $file = DOL_DOCUMENT_ROOT.'/conf/conf.php'; - if ($fp = @fopen($file, 'w')) - { + if ($fp = @fopen($file, 'w')) { fputs($fp, $config); fflush($fp); fclose($fp); @@ -436,8 +443,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len global $db, $conf, $langs, $user; $generated_password = ''; - if ($generic) - { + if ($generic) { $lowercase = "qwertyuiopasdfghjklzxcvbnm"; $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; $numbers = "1234567890"; @@ -445,8 +451,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $nbofchar = round($length / 3); $nbofcharlast = ($length - 2 * $nbofchar); //var_dump($nbofchar.'-'.$nbofcharlast); - if (function_exists('random_int')) // Cryptographic random - { + if (function_exists('random_int')) { // Cryptographic random $max = strlen($lowercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { $tmp = random_int(0, $max); @@ -484,8 +489,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $generated_password = str_shuffle($randomCode); } - } elseif (!empty($conf->global->USER_PASSWORD_GENERATED)) - { + } elseif (!empty($conf->global->USER_PASSWORD_GENERATED)) { $nomclass = "modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); $nomfichier = $nomclass.".class.php"; //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass; @@ -496,8 +500,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len } // Do we have to discard some alphabetic characters ? - if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0) - { + if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0) { $numbers = "ABCDEF"; $max = strlen($numbers) - 1; if (function_exists('random_int')) { // Cryptographic random diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 0bb0db6afd1..15e7286ab08 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,12 +47,10 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; - if ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire) - { + if ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire) { // delivery link $object->fetchObjectLinked($object->id, $object->element); - if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery - { + if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) { // If there is a delivery // Take first one element of array $tmp = reset($object->linkedObjectsIds['delivery']); @@ -63,18 +61,18 @@ function shipping_prepare_head($object) } } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $objectsrc = $object; - if ($object->origin == 'commande' && $object->origin_id > 0) - { + if ($object->origin == 'commande' && $object->origin_id > 0) { $objectsrc = new Commande($db); $objectsrc->fetch($object->origin_id); } $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++; } @@ -86,16 +84,24 @@ function shipping_prepare_head($object) $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++; $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."/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++; @@ -127,8 +133,7 @@ function delivery_prepare_head($object) $h = 0; $head = array(); - if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) - { + if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) { $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; $head[$h][1] = $langs->trans("SendingCard"); $head[$h][2] = 'shipping'; @@ -157,18 +162,18 @@ function delivery_prepare_head($object) $tmpobject = $object; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $objectsrc = $tmpobject; - if ($tmpobject->origin == 'commande' && $tmpobject->origin_id > 0) - { + if ($tmpobject->origin == 'commande' && $tmpobject->origin_id > 0) { $objectsrc = new Commande($db); $objectsrc->fetch($tmpobject->origin_id); } $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$tmpobject->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++; } @@ -180,16 +185,24 @@ function delivery_prepare_head($object) $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++; $nbNote = 0; - if (!empty($tmpobject->note_private)) $nbNote++; - if (!empty($tmpobject->note_public)) $nbNote++; + if (!empty($tmpobject->note_private)) { + $nbNote++; + } + 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++; @@ -236,21 +249,24 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $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; + if ($filter) { + $sql .= $filter; + } $sql .= " ORDER BY obj.fk_product"; dol_syslog("show_list_sending_receive", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); - else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); + if ($num) { + if ($filter) { + print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); + } else { + print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); + } print ''; print ''; @@ -260,26 +276,23 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; print ''; print ''; - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { print ''; } /*TODO Add link to expeditiondet_batch if (! empty($conf->productbatch->enabled)) { - print ''; + print ''; }*/ - if (!empty($conf->delivery_note->enabled)) - { + if (!empty($conf->delivery_note->enabled)) { print ''; //print ''; print ''; } print "\n"; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -290,11 +303,9 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; // Description - if ($objp->fk_product > 0) - { + 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(); @@ -305,10 +316,13 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $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)) - { + 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); } @@ -334,16 +348,18 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') 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 ''; } else { print "'; // Warehouse - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { print ''; - } else { - print ''; - } + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); + } + else + { + print $langs->trans("NA"); + } + print ''; + } else { + print ''; + } }*/ // Informations on receipt - if (!empty($conf->delivery_note->enabled)) - { + if (!empty($conf->delivery_note->enabled)) { include_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php'; $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); //var_dump($expedition->linkedObjects); $receiving = ''; - if (!empty($expedition->linkedObjects['delivery'])) $receiving = reset($expedition->linkedObjects['delivery']); // Take first link + if (!empty($expedition->linkedObjects['delivery'])) { + $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 // $receiving->origin may be 'shipping' diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 14ca70926d3..8b49b01ae35 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -56,18 +56,24 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') $ref = str_replace(' ', '', $ref); $out = ''; - if ($type == 'proposal') - { + if ($type == 'proposal') { $out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '' : ''); - if ($mode == 1) $out .= 'proposal_ref'; - if ($mode == 0) $out .= urlencode($ref); + if ($mode == 1) { + $out .= 'proposal_ref'; + } + if ($mode == 0) { + $out .= urlencode($ref); + } $out .= ($mode ? '' : ''); - if ($mode == 1) $out .= '&hashp=hash_of_file'; - else { + if ($mode == 1) { + $out .= '&hashp=hash_of_file'; + } else { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $propaltmp = new Propal($db); $res = $propaltmp->fetch(0, $ref); - if ($res <= 0) return 'FailedToGetProposal'; + if ($res <= 0) { + return 'FailedToGetProposal'; + } include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); @@ -75,8 +81,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') $ecmfile->fetch(0, '', $propaltmp->last_main_doc); $hashp = $ecmfile->share; - if (empty($hashp)) - { + if (empty($hashp)) { $out = $langs->trans("FeatureOnlineSignDisabled"); return $out; } else { @@ -86,7 +91,9 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') } // For multicompany - if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + if (!empty($out)) { + $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + } return $out; } diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 2d6768010fb..2e58e6c8082 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -39,8 +39,7 @@ function stock_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (!empty($user->rights->stock->mouvement->lire)) - { + if (!empty($user->rights->stock->mouvement->lire)) { $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; $head[$h][1] = $langs->trans("StockMovements"); $head[$h][2] = 'movements'; diff --git a/htdocs/core/lib/supplier_proposal.lib.php b/htdocs/core/lib/supplier_proposal.lib.php index ec782350c9d..a7720bd9ef4 100644 --- a/htdocs/core/lib/supplier_proposal.lib.php +++ b/htdocs/core/lib/supplier_proposal.lib.php @@ -44,12 +44,13 @@ function supplier_proposal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $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++; } @@ -60,14 +61,19 @@ function supplier_proposal_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + 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++; } @@ -79,7 +85,9 @@ function supplier_proposal_prepare_head($object) $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 dfddc95d733..db1623387c1 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -54,8 +54,7 @@ function takepos_admin_prepare_head() $h++; $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for ($i = 1; $i <= $numterminals; $i++) - { + 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][2] = 'terminal'.$i; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 36ce55f7c85..e2257369865 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -59,7 +59,9 @@ function tax_prepare_head(ChargeSociales $object) $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,14 +95,12 @@ 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(); - if ($direction == 'sell') - { + if ($direction == 'sell') { $invoicetable = 'facture'; $invoicedettable = 'facturedet'; $fk_facture = 'fk_facture'; @@ -110,8 +110,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $paymenttable = 'paiement'; $paymentfacturetable = 'paiement_facture'; $invoicefieldref = 'ref'; - } elseif ($direction == 'buy') - { + } elseif ($direction == 'buy') { $invoicetable = 'facture_fourn'; $invoicedettable = 'facture_fourn_det'; $fk_facture = 'fk_facture_fourn'; @@ -138,8 +137,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // Define sql request $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_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, "; @@ -153,24 +151,31 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 @@ -189,49 +194,64 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 == 'TODO') return -2; - if ($sql != 'TODO') - { + if (!$sql) { + return -1; + } + if ($sql == 'TODO') { + return -2; + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $company_id = -1; $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; + 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 ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; @@ -280,8 +300,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // Define sql request $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_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, "; @@ -295,24 +314,31 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 @@ -331,52 +357,64 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 } - if ($sql == 'TODO') return -2; // -2 = Feature not yet available - if ($sql != 'TODO') - { + if ($sql == 'TODO') { + return -2; // -2 = Feature not yet available + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $company_id = -1; $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; + 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 ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; @@ -422,8 +460,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // CASE OF EXPENSE REPORT - if ($direction == 'buy') // buy only for expense reports - { + if ($direction == 'buy') { // buy only for expense reports // Define sql request $sql = ''; @@ -438,45 +475,54 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 } - if ($sql == 'TODO') return -2; // -2 = Feature not yet available - if ($sql != 'TODO') - { + if ($sql == 'TODO') { + return -2; // -2 = Feature not yet available + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $company_id = -1; $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; + 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 ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; @@ -545,15 +591,13 @@ 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(); - if ($direction == 'sell') - { + if ($direction == 'sell') { $invoicetable = 'facture'; $invoicedettable = 'facturedet'; $fk_facture = 'fk_facture'; @@ -590,8 +634,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // Define sql request $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_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, "; @@ -605,24 +648,31 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 @@ -641,50 +691,65 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 == 'TODO') return -2; - if ($sql != 'TODO') - { + if (!$sql) { + return -1; + } + if ($sql == 'TODO') { + return -2; + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $rate = -1; $oldrowid = ''; - while ($assoc = $db->fetch_array($resql)) - { + 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 - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; @@ -732,8 +797,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // Define sql request $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_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, "; @@ -747,24 +811,31 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 @@ -783,53 +854,65 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $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)"; + 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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 } - if ($sql == 'TODO') return -2; // -2 = Feature not yet available - if ($sql != 'TODO') - { + if ($sql == 'TODO') { + return -2; // -2 = Feature not yet available + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $rate = -1; $oldrowid = ''; - while ($assoc = $db->fetch_array($resql)) - { + 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 - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; @@ -874,8 +957,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // CASE OF EXPENSE REPORT - if ($direction == 'buy') // buy only for expense reports - { + if ($direction == 'buy') { // buy only for expense reports // Define sql request $sql = ''; @@ -890,46 +972,55 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $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) - { + 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))."'"; - } elseif ($y) - { + } 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))."'"; } - 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)."'"; + 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_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (!empty($conf->global->MAIN_NOT_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 } - if ($sql == 'TODO') return -2; // -2 = Feature not yet available - if ($sql != 'TODO') - { + if ($sql == 'TODO') { + return -2; // -2 = Feature not yet available + } + if ($sql != 'TODO') { dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $rate = -1; $oldrowid = ''; - while ($assoc = $db->fetch_array($resql)) - { + 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 - { + if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index c90892d603c..c7f3e0612ce 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -88,7 +88,9 @@ 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++; } @@ -124,8 +126,7 @@ function ticket_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_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"); } @@ -150,8 +151,7 @@ function showDirectPublicLink($object) require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $email = CMailFile::getValidAddress($object->origin_email, 2); $url = ''; - if ($email) - { + if ($email) { $url = dol_buildpath('/public/ticket/view.php', 3).'?track_id='.$object->track_id.'&email='.$email; } @@ -278,7 +278,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) { + dol_print_error('', 'BadParameter'); + } $out = ''; $histo = array(); @@ -294,8 +296,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } $sortfield_new = implode(',', $sortfield_new_list); - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { $sql = "SELECT DISTINCT a.id, a.label as label,"; @@ -365,22 +366,34 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $sql .= " AND a.fk_project = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + if ($filterobj->id) { + $sql .= " AND a.fk_element = ".$filterobj->id; + } } } @@ -399,20 +412,28 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } } } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } else { + $sql .= " AND c.code = '".$db->escape($actioncode)."'"; + } } } - if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') { + $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + } elseif ($donetodo == 'done') { + $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + } + if (is_array($filters) && $filters['search_agenda_label']) { + $sql .= natural_search('a.label', $filters['search_agenda_label']); + } } // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. if (!empty($conf->mailing->enabled) && !empty($objcon->email) - && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) - { + && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; @@ -467,7 +488,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; $tododone = ''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) { + $tododone = 'todo'; + } $histo[$numaction] = array( 'type'=>$obj->type, @@ -549,7 +572,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } else { $out .= ''; } - if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; + if ($filterobj && get_class($filterobj) == 'Societe') { + $out .= ''; + } $out .= "\n"; @@ -591,12 +616,16 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($donetodo) { $tmp = ''; - if (get_class($filterobj) == 'Societe') $tmp .= ''; + if (get_class($filterobj) == 'Societe') { + $tmp .= ''; + } $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') $tmp .= ''; + if (get_class($filterobj) == 'Societe') { + $tmp .= ''; + } $out .= getTitleFieldOfList($tmp); } @@ -607,8 +636,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $actualCycleDate = false; - foreach ($histo as $key=>$value) - { + foreach ($histo as $key => $value) { $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo $actionstatic->type_picto = $histo[$key]['apicto']; @@ -652,8 +680,7 @@ 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)) - { + (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { $out .= ''; } @@ -671,11 +698,21 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } } $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")).' '; + 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 @@ -683,8 +720,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no // Author of event $out .= ''; - if ($histo[$key]['userid'] > 0) - { + if ($histo[$key]['userid'] > 0) { 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', ''); @@ -723,8 +759,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if (!empty($histo[$key]['message']) && $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_MODIFY' - ) - { + ) { $out .= '
    '; $out .= $histo[$key]['message']; $out .= '
    '; @@ -748,8 +783,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $contactList .= !empty($contactList) ? ', ' : ''; $contactList .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (!empty($contact->phone_pro)) + if (!empty($contact->phone_pro)) { $contactList .= '('.dol_print_phone($contact->phone_pro).')'; + } } } } @@ -759,24 +795,24 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $contact = new Contact($db); $result = $contact->fetch($histo[$key]['contact_id']); - if ($result < 0) + if ($result < 0) { dol_print_error($db, $contact->error); + } if ($result > 0) { $footer .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (!empty($contact->phone_pro)) + if (!empty($contact->phone_pro)) { $footer .= '('.dol_print_phone($contact->phone_pro).')'; + } } } } $documents = getTicketActionCommEcmList($actionstatic); - if (!empty($documents)) - { + if (!empty($documents)) { $footer .= '
    '; - foreach ($documents as $doc) - { + foreach ($documents as $doc) { $footer .= 'id.'" '; $footer .= ' data-path="'.$doc->filepath.'"'; @@ -819,8 +855,11 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= "\n"; } - if ($noprint) return $out; - else print $out; + if ($noprint) { + return $out; + } else { + print $out; + } } /** diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 9df0f8d9ddf..a20170e3a95 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -38,8 +38,7 @@ function tree_showpad(&$fulltree, $key, $silent = 0) $pos = 1; // Loop on each pos, because we will output an img for each pos - while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) - { + while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) { // Process for column $pos $atleastoneofthislevelafter = 0; @@ -47,41 +46,41 @@ function tree_showpad(&$fulltree, $key, $silent = 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 - { - if ($fulltree[$key2]['level'] > $pos) - { + if ($found == 1) { // We are after the entry to show + 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) - { + if ($fulltree[$key2]['level'] == $pos) { $atleastoneofthislevelafter = 1; } - if ($fulltree[$key2]['level'] <= $pos) - { + if ($fulltree[$key2]['level'] <= $pos) { break; } } - if ($key2 == $key) // We found ourself, so now every lower level will be counted - { + if ($key2 == $key) { // We found ourself, so now every lower level will be counted $found = 1; } } //print $atleastoneofthislevelafter; - if (!$silent) - { - if ($atleastoneofthislevelafter) - { - if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branch.gif'); - else print img_picto_common('', 'treemenu/line.gif'); + if (!$silent) { + if ($atleastoneofthislevelafter) { + if ($fulltree[$key]['level'] == $pos) { + print img_picto_common('', 'treemenu/branch.gif'); + } else { + print img_picto_common('', 'treemenu/line.gif'); + } } else { - if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branchbottom.gif'); - else print img_picto_common('', 'treemenu/linebottom.gif'); + if ($fulltree[$key]['level'] == $pos) { + print img_picto_common('', 'treemenu/branchbottom.gif'); + } else { + print img_picto_common('', 'treemenu/linebottom.gif'); + } } } $pos++; @@ -116,10 +115,11 @@ 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) - { + if ($rang == 0) { // Test also done with jstree and dynatree (not able to have inside label) print ''."\n"; - } elseif ($type == 'organization') - { + } elseif ($type == 'organization') { $companyname = $mysoc->name; $url = $mysoc->url; @@ -603,16 +596,16 @@ function getStructuredData($type, $data = array()) $ret .= '"https://www.'.$key.'.com/'.dol_escape_json($value).'"'; } $i++; - if ($i < count($mysoc->socialnetworks)) $ret .= ', '; + if ($i < count($mysoc->socialnetworks)) { + $ret .= ', '; + } } $ret .= ']'."\n"; } $ret .= '}'."\n"; $ret .= ''."\n"; - } elseif ($type == 'blogpost') - { - if (!empty($websitepage->author_alias)) - { + } elseif ($type == 'blogpost') { + if (!empty($websitepage->author_alias)) { //include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; //$tmpuser = new User($db); //$restmpuser = $tmpuser->fetch($websitepage->fk_user_creat); @@ -664,7 +657,9 @@ function getStructuredData($type, $data = array()) foreach ($arrayofkeywords as $keyword) { $ret .= '"'.dol_escape_json($keyword).'"'; $i++; - if ($i < count($arrayofkeywords)) $ret .= ', '; + if ($i < count($arrayofkeywords)) { + $ret .= ', '; + } } $ret .= '],'."\n"; } @@ -672,8 +667,7 @@ function getStructuredData($type, $data = array()) $ret .= "\n".'}'."\n"; $ret .= ''."\n"; } - } elseif ($type == 'product') - { + } elseif ($type == 'product') { $ret = ''."\n"; $ret .= ''."\n"; - } elseif ($type == 'qa') - { + } elseif ($type == 'qa') { $ret = ''."\n"; $ret .= ' " method="post"> @@ -163,18 +160,18 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con trans("Value"); ?>
    @@ -210,7 +207,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con
    multicompany->enabled) { ?> - +
    '.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").''.$langs->trans("QtyPreparedOrShipped").''.$langs->trans("Warehouse").''; - print ''; + print ''.$langs->trans("DeliveryOrder").''.$langs->trans("QtyReceived").''.$langs->trans("DeliveryDate").'
    "; - if ($objp->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); + 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.''; @@ -369,11 +385,9 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$objp->qty_shipped.''; - if ($objp->warehouse_id > 0) - { + if ($objp->warehouse_id > 0) { $warehousestatic->fetch($objp->warehouse_id); print $warehousestatic->getNomUrl(1); } @@ -384,47 +398,47 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') /*TODO Add link to expeditiondet_batch if (! empty($conf->productbatch->enabled)) { - var_dump($objp->edrowid); - $lines[$i]->detail_batch - if (isset($lines[$i]->detail_batch)) - { - print ''; - if ($lines[$i]->product_tobatch) - { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) - { + var_dump($objp->edrowid); + $lines[$i]->detail_batch + if (isset($lines[$i]->detail_batch)) + { + print ''; + if ($lines[$i]->product_tobatch) + { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) + { $detail.= $langs->trans("Batch").': '.$dbatch->batch; $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; $detail.= '
    '; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); - } - else - { - print $langs->trans("NA"); - } - print '
    - - -
    - - - textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'

    '.$langs->trans("Examples").':
    '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
    - textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?> -
    + + +
    + + + textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'

    '.$langs->trans("Examples").':
    '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
    + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?> +
    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 5239a93fdf7..bba6fd1bb7c 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -27,8 +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; } @@ -42,60 +41,58 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con @@ -171,18 +168,14 @@ $entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrna $printable = $extrafields->attributes[$elementtype]['printable'][$attrname]; $enabled = $extrafields->attributes[$elementtype]['enabled'][$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)) - { + foreach ($param['options'] as $key => $value) { + 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']); $param_chain = $paramlist[0]; } @@ -215,16 +208,19 @@ if ($size <= 255 && in_array($type, array('text', 'html'))) { $typewecanchangeinto['text'][] = 'varchar'; }*/ -if (in_array($type, array_keys($typewecanchangeinto))) -{ +if (in_array($type, array_keys($typewecanchangeinto))) { $newarray = array(); print ''; print ajax_combobox('type'); @@ -244,18 +240,18 @@ if (in_array($type, array_keys($typewecanchangeinto))) trans("Value"); ?> - - -
    - - - textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'

    '.$langs->trans("Examples").':
    '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
    - textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?> - textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?> -
    + + +
    + + + textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'

    '.$langs->trans("Examples").':
    '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
    + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?> +
    @@ -301,7 +297,7 @@ if (in_array($type, array_keys($typewecanchangeinto))) multicompany->enabled) { ?> - 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 c62a95ec12b..829ccaee903 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -25,8 +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; } @@ -72,10 +71,8 @@ if ($conf->multicompany->enabled) { print ' '; print "\n"; -if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) -{ - foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) - { +if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) { + foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) { /*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1)) { // TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled" // continue; @@ -102,12 +99,13 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel print ''.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."\n"; if (!empty($conf->multicompany->enabled)) { print ''; - if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) - { + if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) { print $langs->trans("All"); } 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]); @@ -123,7 +121,9 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } } else { $colspan = 13; - if (!empty($conf->multicompany->enabled)) $colspan++; + if (!empty($conf->multicompany->enabled)) { + $colspan++; + } print ''; print ''; diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 590a65f1286..86292ec0ff4 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -154,7 +154,8 @@ if (!empty($array_query['cust_status'])) { } print ''; print $formadvtargetemaling->advMultiselectarray( - 'cust_status', array( + 'cust_status', + array( '0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity') ), @@ -473,8 +474,9 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $extrafields->fetch_name_optionals_label($elementype); if (!empty($extrafields->attributes[$elementtype]['type'])) { foreach ($extrafields->attributes[$elementtype]['type'] as $key => &$value) { - if ($value == 'radio') + if ($value == 'radio') { $value = 'select'; + } } } if (!empty($extrafields->attributes[$elementtype]['label'])) { diff --git a/htdocs/core/tpl/ajax/fileupload_main.tpl.php b/htdocs/core/tpl/ajax/fileupload_main.tpl.php index 6b7e21b5261..a4563c7536a 100644 --- a/htdocs/core/tpl/ajax/fileupload_main.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_main.tpl.php @@ -16,8 +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; } @@ -27,20 +26,20 @@ if (empty($conf) || !is_object($conf))
    diff --git a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php index 119e27a705b..3193f3db96d 100644 --- a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php +++ b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php @@ -16,15 +16,13 @@ */ // 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; } $objectUrl = $object->getNomUrl(0, '', 0, 1); -if ($object->element == 'propal') -{ +if ($object->element == 'propal') { $objectUrl = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; } @@ -36,67 +34,67 @@ if ($object->element == 'propal') $(document).ready(function(){ $('.objectlinked_importbtn').click(function (e) { - e.preventDefault(); - var page = $(this).attr("href"); + e.preventDefault(); + var page = $(this).attr("href"); - var fromelement = $(this).attr("data-element"); - var fromelementid = $(this).attr("data-id"); + var fromelement = $(this).attr("data-element"); + var fromelementid = $(this).attr("data-id"); if( page != undefined && fromelement != undefined && fromelementid != undefined) { - var windowWidth = $(window).width()*0.8; //retrieve current window width - var windowHeight = $(window).height()*0.8; //retrieve current window height + var windowWidth = $(window).width()*0.8; //retrieve current window width + var windowHeight = $(window).height()*0.8; //retrieve current window height var htmlLines; var formId = "ajaxloaded_tablelinesform_" + fromelement + "_" + fromelementid; - $.get(page, function (data) { - htmlLines = $(data).find('#tablelines') ; - }); + $.get(page, function (data) { + htmlLines = $(data).find('#tablelines') ; + }); - var $dialog = $('') - .load( page + " #tablelines", function() { + var $dialog = $('
    ') + .load( page + " #tablelines", function() { - $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute + $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute - $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default + $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default - // reload checkbox toggle function - $("#" + formId + " .linecheckboxtoggle").click(function(){ - var checkBoxes = $("#" + formId + " .linecheckbox"); - checkBoxes.prop("checked", this.checked); - }); + // reload checkbox toggle function + $("#" + formId + " .linecheckboxtoggle").click(function(){ + var checkBoxes = $("#" + formId + " .linecheckbox"); + checkBoxes.prop("checked", this.checked); + }); - }) - .html(htmlLines) - .dialog({ - autoOpen: false, - modal: true, - height: windowHeight, - width: windowWidth, - title: "transnoentities('LinesToImport'); ?>", - buttons: { - "trans('Import'); ?>": function() { - $( this ).dialog( "close" ); - $("#" + formId).append(''); - $("#" + formId).append(''); - $("#" + formId).append(''); - $("#" + formId).submit(); - }, - "trans("Cancel"); ?>": function() { - $( this ).dialog( "close" ); - } - } - }); + }) + .html(htmlLines) + .dialog({ + autoOpen: false, + modal: true, + height: windowHeight, + width: windowWidth, + title: "transnoentities('LinesToImport'); ?>", + buttons: { + "trans('Import'); ?>": function() { + $( this ).dialog( "close" ); + $("#" + formId).append(''); + $("#" + formId).append(''); + $("#" + formId).append(''); + $("#" + formId).submit(); + }, + "trans("Cancel"); ?>": function() { + $( this ).dialog( "close" ); + } + } + }); - $dialog.dialog('open'); + $dialog.dialog('open'); } else { $.jnotify("trans('ErrorNoUrl'); ?>", "error", true); } - }); + }); @@ -106,7 +104,7 @@ $(document).ready(function(){ diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 1a797b936c3..6d6df3a5408 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -26,8 +26,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || !is_object($object)) -{ +if (empty($object) || !is_object($object)) { print "Error, template page ".basename(__FILE__)." can't be called with no object defined."; exit; } @@ -50,13 +49,13 @@ if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1 && $conf->browser- $(document).ready(function(){ $(".imgupforline").hide(); $(".imgdownforline").hide(); - $(".lineupdown").removeAttr('href'); - $(".tdlineupdown").css("background-image",'url(theme.'/img/grip.png'; ?>)'); - $(".tdlineupdown").css("background-repeat","no-repeat"); - $(".tdlineupdown").css("background-position","center center"); + $(".lineupdown").removeAttr('href'); + $(".tdlineupdown").css("background-image",'url(theme.'/img/grip.png'; ?>)'); + $(".tdlineupdown").css("background-repeat","no-repeat"); + $(".tdlineupdown").css("background-position","center center"); - console.log("Prepare tableDnd for #"); - $("#").tableDnD({ + console.log("Prepare tableDnd for #"); + $("#").tableDnD({ onDrop: function(table, row) { var reloadpage = ""; console.log("tableDND onDrop"); @@ -100,9 +99,9 @@ $(document).ready(function(){ onDragClass: "dragClass", dragHandle: "td.tdlineupdown" }); - $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); }, - function() { $(this).removeClass('showDragHandle'); } - ); + $(".tdlineupdown").hover( function() { $(this).addClass('showDragHandle'); }, + function() { $(this).removeClass('showDragHandle'); } + ); }); @@ -110,7 +109,7 @@ $(document).ready(function(){ $(document).ready(function(){ $(".imgupforline").hide(); $(".imgdownforline").hide(); - $(".lineupdown").removeAttr('href'); + $(".lineupdown").removeAttr('href'); }); diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php index 6dae2c713f2..bf148c2124f 100644 --- a/htdocs/core/tpl/bloc_comment.tpl.php +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -1,8 +1,7 @@ '; print ''; print "\n"; -if ($action !== 'editcomment') -{ +if ($action !== 'editcomment') { print ''; // Description @@ -58,21 +56,17 @@ if ($action !== 'editcomment') print ''; // List of comments -if (!empty($object->comments)) -{ +if (!empty($object->comments)) { // Default color for current user $TColors = array($user->id => array('bgcolor'=>'efefef', 'color'=>'555')); $first = true; - foreach ($object->comments as $comment) - { + foreach ($object->comments as $comment) { $fk_user = $comment->fk_user_author; $userstatic->fetch($fk_user); - if (empty($TColors[$fk_user])) - { + if (empty($TColors[$fk_user])) { $bgcolor = randomColor(180, 240); - if (!empty($userstatic->color)) - { + if (!empty($userstatic->color)) { $bgcolor = $userstatic->color; } $color = (colorIsLight($bgcolor)) ? '555' : 'fff'; @@ -85,8 +79,7 @@ if (!empty($object->comments)) print '
    '; print '
    '; - if (!empty($user->photo)) - { + if (!empty($user->photo)) { print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'
    '; } print $langs->trans('User').' : '.$userstatic->getNomUrl().'
    '; @@ -96,8 +89,7 @@ if (!empty($object->comments)) print '
    '; print '
    '; - if ($action === 'editcomment' && $comment->id == $idcomment) - { + if ($action === 'editcomment' && $comment->id == $idcomment) { print '
    '; print ''; print ''; @@ -107,8 +99,7 @@ if (!empty($object->comments)) } print '
    '; - if ($action === 'editcomment' && $comment->id == $idcomment) - { + if ($action === 'editcomment' && $comment->id == $idcomment) { $doleditor = new DolEditor('comment_description', $comment->description, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); print $doleditor->Create(1); } else { @@ -116,15 +107,13 @@ if (!empty($object->comments)) } print '
    '; // End comment-description - if ($action === 'editcomment' && $comment->id == $idcomment) - { + if ($action === 'editcomment' && $comment->id == $idcomment) { print ''; print ''; print '
    '; } else { - if ($fk_user == $user->id || $user->admin == 1) - { + if ($fk_user == $user->id || $user->admin == 1) { print '
    '; print img_picto('', 'edit.png'); print ''; diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index d654f2b97b3..ee67fa6b74a 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -18,15 +18,18 @@ */ // Protection to avoid direct call of template -if (empty($blocname)) -{ +if (empty($blocname)) { print "Error, template page can't be called as URL"; exit; } $hide = true; // Hide by default -if (isset($parameters['showblocbydefault'])) $hide = (empty($parameters['showblocbydefault']) ? true : false); -if (isset($object->extraparams[$blocname]['showhide'])) $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); +if (isset($parameters['showblocbydefault'])) { + $hide = (empty($parameters['showblocbydefault']) ? true : false); +} +if (isset($object->extraparams[$blocname]['showhide'])) { + $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); +} ?> diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 0a7ed20981e..de10465a736 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -33,23 +33,20 @@ if (empty($conf) || !is_object($conf)) { } -if ($action == 'presend') -{ +if ($action == 'presend') { $langs->load("mails"); $titreform = 'SendMail'; $object->fetch_projet(); - if (!in_array($object->element, array('societe', 'user', 'member'))) - { + if (!in_array($object->element, array('societe', 'user', 'member'))) { // TODO get also the main_lastdoc field of $object. If not found, try to guess with following code $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Special case - if ($object->element == 'invoice_supplier') - { + if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); @@ -61,17 +58,14 @@ if ($action == 'presend') // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) { $newlang = $_REQUEST['lang_id']; } - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } - if (!empty($newlang)) - { + if (!empty($newlang)) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); // Load traductions files required by page @@ -87,19 +81,20 @@ if ($action == 'presend') // Build document if it not exists $forcebuilddoc = true; - if (in_array($object->element, array('societe', 'user', 'member'))) $forcebuilddoc = false; - if ($object->element == 'invoice_supplier' && empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) $forcebuilddoc = false; - if ($forcebuilddoc) // If there is no default value for supplier invoice, we do not generate file, even if modelpdf was set by a manual generation - { - if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) - { + if (in_array($object->element, array('societe', 'user', 'member'))) { + $forcebuilddoc = false; + } + if ($object->element == 'invoice_supplier' && empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { + $forcebuilddoc = false; + } + if ($forcebuilddoc) { // If there is no default value for supplier invoice, we do not generate file, even if modelpdf was set by a manual generation + if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { dol_print_error($db, $object->error, $object->errors); exit(); } - if ($object->element == 'invoice_supplier') - { + if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); @@ -123,8 +118,7 @@ if ($action == 'presend') $formmail->param['langsmodels'] = (empty($newlang) ? $langs->defaultlang : $newlang); $formmail->fromtype = (GETPOST('fromtype') ?GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); - if ($formmail->fromtype === 'user') - { + if ($formmail->fromtype === 'user') { $formmail->fromid = $user->id; } @@ -145,8 +139,7 @@ if ($action == 'presend') } $formmail->trackid = $trackid; - if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { + if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) { // If bit 2 is set include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid); } @@ -170,8 +163,7 @@ if ($action == 'presend') if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) { $object->fetch_thirdparty(); } - if (is_object($object->thirdparty)) - { + if (is_object($object->thirdparty)) { foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; } @@ -206,7 +198,9 @@ if ($action == 'presend') $formmail->withcancel = 1; //$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...); - if (!isset($arrayoffamiliestoexclude)) $arrayoffamiliestoexclude = null; + if (!isset($arrayoffamiliestoexclude)) { + $arrayoffamiliestoexclude = null; + } // Make substitution in email content $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 388b4b63926..526d640b62a 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -23,8 +23,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; } @@ -35,34 +34,57 @@ if (empty($conf) || !is_object($conf)) $object->fields = dol_sort_array($object->fields, 'position'); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form - if (abs($val['visible']) != 1 && abs($val['visible']) != 3) continue; + if (abs($val['visible']) != 1 && abs($val['visible']) != 3) { + continue; + } - if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) { + continue; // We don't want this field + } print ''; print ''; - if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); - else print $langs->trans($val['label']); + if (!empty($val['help'])) { + print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + } else { + print $langs->trans($val['label']); + } print ''; print ''; - if (!empty($val['picto'])) { print img_picto('', $val['picto']); } - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int'); - elseif ($val['type'] == 'double') $value = price2num(GETPOST($key, 'alphanohtml')); - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'restricthtml'); - elseif ($val['type'] == 'date') $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); - elseif ($val['type'] == 'datetime') $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); - elseif ($val['type'] == 'boolean') $value = (GETPOST($key) == 'on' ? 1 : 0); - else $value = GETPOST($key, 'alphanohtml'); - if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0); - else print $object->showInputField($val, $key, $value, '', '', '', 0); + if (!empty($val['picto'])) { + print img_picto('', $val['picto']); + } + if (in_array($val['type'], array('int', 'integer'))) { + $value = GETPOST($key, 'int'); + } elseif ($val['type'] == 'double') { + $value = price2num(GETPOST($key, 'alphanohtml')); + } elseif ($val['type'] == 'text' || $val['type'] == 'html') { + $value = GETPOST($key, 'restricthtml'); + } elseif ($val['type'] == 'date') { + $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); + } elseif ($val['type'] == 'datetime') { + $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); + } elseif ($val['type'] == 'boolean') { + $value = (GETPOST($key) == 'on' ? 1 : 0); + } else { + $value = GETPOST($key, 'alphanohtml'); + } + if ($val['noteditable']) { + print $object->showOutputField($val, $key, $value, '', '', '', 0); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } print ''; print ''; } diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 76a9fafe417..8ea1befa009 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -22,12 +22,13 @@ */ // 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; } -if (!is_object($form)) $form = new Form($db); +if (!is_object($form)) { + $form = new Form($db); +} ?> @@ -35,26 +36,40 @@ if (!is_object($form)) $form = new Form($db); $object->fields = dol_sort_array($object->fields, 'position'); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form - if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) continue; + if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) { + continue; + } - if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) { + continue; // We don't want this field + } print ''; - if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); - else print $langs->trans($val['label']); + if (!empty($val['help'])) { + print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + } else { + print $langs->trans($val['label']); + } print ''; print ''; - if (!empty($val['picto'])) { print img_picto('', $val['picto']); } - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key; - elseif ($val['type'] == 'double') $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key; - elseif (preg_match('/^(text|html)/', $val['type'])) { + if (!empty($val['picto'])) { + print img_picto('', $val['picto']); + } + if (in_array($val['type'], array('int', 'integer'))) { + $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key; + } elseif ($val['type'] == 'double') { + $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key; + } elseif (preg_match('/^(text|html)/', $val['type'])) { $tmparray = explode(':', $val['type']); if (!empty($tmparray[1])) { $check = $tmparray[1]; @@ -62,11 +77,15 @@ foreach ($object->fields as $key => $val) $check = 'restricthtml'; } $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; + } else { + $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; } - else $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; //var_dump($val.' '.$key.' '.$value); - if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0); - else print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($val['noteditable']) { + print $object->showOutputField($val, $key, $value, '', '', '', 0); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } print ''; print ''; } diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 5f58ba9e7e9..8fbd5aa2fb3 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -24,12 +24,13 @@ */ // 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; } -if (!is_object($form)) $form = new Form($db); +if (!is_object($form)) { + $form = new Form($db); +} ?> @@ -37,34 +38,54 @@ if (!is_object($form)) $form = new Form($db); $object->fields = dol_sort_array($object->fields, 'position'); -foreach ($object->fields as $key => $val) -{ - if (!empty($keyforbreak) && $key == $keyforbreak) break; // key used for break on second column +foreach ($object->fields as $key => $val) { + if (!empty($keyforbreak) && $key == $keyforbreak) { + break; // key used for break on second column + } // Discard if extrafield is a hidden field on form - if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue; + if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) { + continue; + } - if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field - if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) { + continue; // We don't want this field + } + if (in_array($key, array('ref', 'status'))) { + continue; // Ref and status are already in dol_banner + } $value = $object->$key; print ''; - if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); - else print $langs->trans($val['label']); + if (!empty($val['help'])) { + print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + } else { + print $langs->trans($val['label']); + } print ''; print ''; - if (in_array($val['type'], array('text', 'html'))) print '
    '; + if (in_array($val['type'], array('text', 'html'))) { + print '
    '; + } print $object->showOutputField($val, $key, $value, '', '', '', 0); //print dol_escape_htmltag($object->$key, 1, 1); - if (in_array($val['type'], array('text', 'html'))) print '
    '; + if (in_array($val['type'], array('text', 'html'))) { + print '
    '; + } print ''; print ''; } @@ -79,10 +100,8 @@ print '
    '; print ''; $alreadyoutput = 1; -foreach ($object->fields as $key => $val) -{ - if ($alreadyoutput) - { +foreach ($object->fields as $key => $val) { + if ($alreadyoutput) { if (!empty($keyforbreak) && $key == $keyforbreak) { $alreadyoutput = 0; // key used for break on second column } else { @@ -91,29 +110,48 @@ foreach ($object->fields as $key => $val) } // Discard if extrafield is a hidden field on form - if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue; + if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) { + continue; + } - if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) continue; // We don't want this field - if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) { + continue; // We don't want this field + } + if (in_array($key, array('ref', 'status'))) { + continue; // Ref and status are already in dol_banner + } $value = $object->$key; print ''; - if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); - else print $langs->trans($val['label']); + if (!empty($val['help'])) { + print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + } else { + print $langs->trans($val['label']); + } print ''; print ''; print ''; } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e3c45b788c6..4c57ec953d4 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -24,8 +24,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; } @@ -73,8 +72,7 @@ $userstatic = new User($db); '."\n"; print '
    '."\n"; @@ -91,15 +89,16 @@ if ($permission)
    " /> - '; ?> + '; + } ?>
    global->MAIN_INFO_SOCIETE_NOM; ?>
    @@ -107,14 +106,16 @@ if ($permission)
    element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + $tmpobject = $objectsrc; + } $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal'); ?>
     
    ">
    - id; ?>" /> - '; ?> + '; + } ?>
    socid; ?> @@ -145,8 +147,7 @@ if ($permission) $nbofcontacts = $form->num; $newcardbutton = ''; - if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) - { + if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) { $newcardbutton .= ''; } print $newcardbutton; @@ -155,17 +156,21 @@ if ($permission)
    element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + $tmpobject = $objectsrc; + } $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact, 'typecontact', 'external', 'position', 0, 'minwidth100imp'); ?>
     
    - "> + ">
    - "; @@ -179,17 +184,14 @@ if ($permission) // TODO: replace this with direct SQL string to use $db->sort($sortfield, $sortorder) $list = array(); -foreach (array('internal', 'external') as $source) -{ - if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) - { +foreach (array('internal', 'external') as $source) { + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { $contactlist = $objectsrc->liste_contact(-1, $source); } else { $contactlist = $object->liste_contact(-1, $source); } - foreach ($contactlist as $contact) - { + foreach ($contactlist as $contact) { $entry = new stdClass(); $entry->id = $contact['rowid']; $entry->type = $contact['libelle']; @@ -200,15 +202,13 @@ foreach (array('internal', 'external') as $source) $entry->contact_name = ""; $entry->status = ""; - if ($contact['source'] == 'internal') - { + if ($contact['source'] == 'internal') { $entry->nature = $langs->trans("User"); } elseif ($contact['source'] == 'external') { $entry->nature = $langs->trans("ThirdPartyContact"); } - if ($contact['socid'] > 0) - { + if ($contact['socid'] > 0) { $companystatic->fetch($contact['socid']); $entry->thirdparty_html = $companystatic->getNomUrl(1); $entry->thirdparty_name = strtolower($companystatic->getFullName($langs)); @@ -217,8 +217,7 @@ foreach (array('internal', 'external') as $source) $entry->thirdparty_name = strtolower($conf->global->MAIN_INFO_SOCIETE_NOM); } - if ($contact['source'] == 'internal') - { + if ($contact['source'] == 'internal') { $userstatic->fetch($contact['id']); $entry->contact_html = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); $entry->contact_name = strtolower($userstatic->getFullName($langs)); @@ -228,8 +227,7 @@ foreach (array('internal', 'external') as $source) $entry->contact_name = strtolower($contactstatic->getFullName($langs)); } - if ($contact['source'] == 'internal') - { + if ($contact['source'] == 'internal') { $entry->status = $userstatic->LibStatut($contact['statuscontact'], 3); } elseif ($contact['source'] == 'external') { $entry->status = $contactstatic->LibStatut($contact['statuscontact'], 3); @@ -243,8 +241,12 @@ foreach (array('internal', 'external') as $source) $sortfield = GETPOST("sortfield", "aZ09comma"); $sortorder = GETPOST("sortorder", 'aZ09comma'); -if (!$sortfield) $sortfield = "nature"; -if (!$sortorder) $sortorder = "asc"; +if (!$sortfield) { + $sortfield = "nature"; +} +if (!$sortorder) { + $sortorder = "asc"; +} // Re-sort list $list = dol_sort_array($list, $sortfield, $sortorder, 1, 0, 1); @@ -286,8 +288,7 @@ print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], " print_liste_field_titre('', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch '); print ""; -foreach ($list as $entry) -{ +foreach ($list as $entry) { print '
    '; print ''; @@ -296,8 +297,7 @@ foreach ($list as $entry) print ''; print ''; - if ($permission) - { + if ($permission) { $href = $_SERVER["PHP_SELF"]; $href .= '?id='.$object->id; $href .= '&action=deletecontact&token='.newToken(); diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 80fd0d7df12..0dc0962af56 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -30,25 +30,32 @@ // $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; // 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; } $langs->load("link"); -if (empty($relativepathwithnofile)) $relativepathwithnofile = ''; +if (empty($relativepathwithnofile)) { + $relativepathwithnofile = ''; +} -if (!isset($permission)) $permission = $permissiontoadd; -if (!isset($permtoedit)) $permtoedit = $permissiontoadd; +if (!isset($permission)) { + $permission = $permissiontoadd; +} +if (!isset($permtoedit)) { + $permtoedit = $permissiontoadd; +} // Drag and drop for up and down allowed on product, thirdparty, ... // The drag and drop call the page core/ajax/row.php // If you enable the move up/down of files here, check that page that include template set its sortorder on 'position_name' instead of 'name' // Also the object->fk_element must be defined. $disablemove = 1; -if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) $disablemove = 0; +if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) { + $disablemove = 0; +} @@ -56,17 +63,16 @@ if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket * Confirm form to delete */ -if ($action == 'delete') -{ +if ($action == 'delete') { $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles print $form->formconfirm( - $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param), - $langs->trans('DeleteFile'), - $langs->trans('ConfirmDeleteFile'), - 'confirm_deletefile', - '', - 0, - 1 + $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param), + $langs->trans('DeleteFile'), + $langs->trans('ConfirmDeleteFile'), + 'confirm_deletefile', + '', + 0, + 1 ); } @@ -99,8 +105,7 @@ if (!isset($savingdocmask) || !empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_ 'product_batch', 'bom', 'mrp' - ))) - { + ))) { $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; } /*if (in_array($modulepart,array('member'))) diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 53cbe3d99cf..f194a177178 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -26,8 +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,13 +36,17 @@ 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; + if (isset($tpl_context)) { + $params['tpl_context'] = $tpl_context; + } $params['cols'] = $parameters['colspanvalue']; print $object->showOptionals($extrafields, 'create', $params); } diff --git a/htdocs/core/tpl/extrafields_edit.tpl.php b/htdocs/core/tpl/extrafields_edit.tpl.php index dbc2b9745cd..5915fb8a633 100644 --- a/htdocs/core/tpl/extrafields_edit.tpl.php +++ b/htdocs/core/tpl/extrafields_edit.tpl.php @@ -26,8 +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,7 +36,9 @@ 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)) { diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php index bbc5ba3370b..d1fe41d8c1f 100644 --- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php @@ -3,22 +3,24 @@ // So no output must be done. // 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; } -if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) { + $extrafieldsobjectkey = $object->table_element; +} // Loop to show all columns of extrafields from $obj, $extrafields and $db -if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... -{ +if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']) > 0) { - if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; + if (empty($extrafieldsobjectprefix)) { + $extrafieldsobjectprefix = 'ef.'; + } foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) + if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) { $arrayfields[$extrafieldsobjectprefix.$key] = array( 'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 'checked' => (($extrafields->attributes[$extrafieldsobjectkey]['list'][$key] < 0) ? 0 : 1), @@ -27,6 +29,7 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e 'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key], 'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key], ); + } } } } diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 8c46e34b428..5ea0e4821d6 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -1,37 +1,36 @@ table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) { + $extrafieldsobjectkey = $object->table_element; +} // Loop to show all columns of extrafields from $obj, $extrafields and $db -if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... -{ - if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) - { - if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; +if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... + if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { + if (empty($extrafieldsobjectprefix)) { + $extrafieldsobjectprefix = 'ef.'; + } - foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) - { - if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) - { + foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { + if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { $align = $extrafields->getAlignFlag($key, $extrafieldsobjectkey); print ''; $tmpkey = 'options_'.$key; - if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey)) - { + if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey)) { $datenotinstring = $obj->$tmpkey; - if (!is_numeric($obj->$tmpkey)) // For backward compatibility - { + if (!is_numeric($obj->$tmpkey)) { // For backward compatibility $datenotinstring = $db->jdate($datenotinstring); } $value = $datenotinstring; @@ -39,8 +38,7 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e $value = $obj->$tmpkey; } // If field is a computed field, we make computation to get value - if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) - { + if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) { //global $obj, $object; //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); //var_dump($obj); @@ -51,18 +49,23 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } if ($extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) { if (!$i) { // we keep position for the first line $totalarray['totalizable'][$key]['pos'] = $totalarray['nbfield']; } - if (is_numeric($obj->$tmpkey)) $totalarray['totalizable'][$key]['total'] += $obj->$tmpkey; + if (is_numeric($obj->$tmpkey)) { + $totalarray['totalizable'][$key]['total'] += $obj->$tmpkey; + } } - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = $extrafieldsobjectprefix.$tmpkey; + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = $extrafieldsobjectprefix.$tmpkey; + } $totalarray['val'][$extrafieldsobjectprefix.$tmpkey] += $obj->$tmpkey; } } diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index d69c045641d..77329eb06a4 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -3,44 +3,50 @@ print ''."\n"; // 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; } -if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) { + $extrafieldsobjectkey = $object->table_element; +} // Loop to show all columns of extrafields for the search title line -if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... -{ - if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) - { - if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; - if (empty($search_options_pattern)) $search_options_pattern = 'search_options_'; +if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... + if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { + if (empty($extrafieldsobjectprefix)) { + $extrafieldsobjectprefix = 'ef.'; + } + if (empty($search_options_pattern)) { + $search_options_pattern = 'search_options_'; + } - foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) - { + foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { $align = $extrafields->getAlignFlag($key); $typeofextrafield = $extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; print ''; diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index 5fca6bc70a9..56652b87dd3 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -1,19 +1,18 @@ table_element like 'societe', 'socpeople', ... -{ - if (empty($search_options_pattern)) $search_options_pattern = 'search_options_'; +if (!empty($search_array_options) && is_array($search_array_options)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... + if (empty($search_options_pattern)) { + $search_options_pattern = 'search_options_'; + } - foreach ($search_array_options as $key => $val) - { + foreach ($search_array_options as $key => $val) { $crit = $val; $tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key); if (is_array($val) && array_key_exists('start', $val) && array_key_exists('end', $val)) { @@ -32,6 +31,8 @@ if (!empty($search_array_options) && is_array($search_array_options)) // $extraf $param .= '&' . $search_options_pattern.$tmpkey.'_endmin=' . dol_print_date($val['end'], '%M'); $val = ''; } - if ($val != '') $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + if ($val != '') { + $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + } } } diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index b0fb03f2709..7268da76007 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -1,28 +1,30 @@ table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) { + $extrafieldsobjectkey = $object->table_element; +} // Loop to complete the sql search criterias from extrafields -if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... -{ - if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; - if (empty($search_options_pattern)) $search_options_pattern = 'search_options_'; +if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($search_array_options)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... + if (empty($extrafieldsobjectprefix)) { + $extrafieldsobjectprefix = 'ef.'; + } + if (empty($search_options_pattern)) { + $search_options_pattern = 'search_options_'; + } - foreach ($search_array_options as $key => $val) - { + foreach ($search_array_options as $key => $val) { $crit = $val; $tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key); $typ = $extrafields->attributes[$extrafieldsobjectkey]['type'][$tmpkey]; - if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp'))) - { + if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp'))) { if (is_numeric($crit)) { $sql .= " AND ".$extrafieldsobjectprefix.$tmpkey." = '".$db->idate($crit)."'"; } elseif (is_array($crit)) { @@ -34,22 +36,31 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($ $sql .= ' AND ('.$extrafieldsobjectprefix.$tmpkey." <= '". $db->idate($crit['end'])."')"; } } - } elseif (in_array($typ, array('boolean'))) - { + } elseif (in_array($typ, array('boolean'))) { if ($crit !== '-1' && $crit !== '') { $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." = '".$db->escape($crit)."'"; - if ($crit == '0') $sql .= " OR ".$extrafieldsobjectprefix.$tmpkey." IS NULL"; + if ($crit == '0') { + $sql .= " OR ".$extrafieldsobjectprefix.$tmpkey." IS NULL"; + } $sql .= ")"; } - } elseif ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) - { + } elseif ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) { $mode_search = 0; - if (in_array($typ, array('int', 'double', 'real', 'price'))) $mode_search = 1; // Search on a numeric - if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int - if (in_array($typ, array('sellist')) && !is_numeric($crit)) $mode_search = 0;// Search on a foreign key string - if (in_array($typ, array('chkbxlst', 'checkbox'))) $mode_search = 4; // Search on a multiselect field with sql type = text - if (is_array($crit)) $crit = implode(' ', $crit); // natural_search() expects a string - elseif ($typ === 'select' and is_string($crit) and strpos($crit, ' ') === false) { + if (in_array($typ, array('int', 'double', 'real', 'price'))) { + $mode_search = 1; // Search on a numeric + } + if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') { + $mode_search = 2; // Search on a foreign key int + } + if (in_array($typ, array('sellist')) && !is_numeric($crit)) { + $mode_search = 0;// Search on a foreign key string + } + if (in_array($typ, array('chkbxlst', 'checkbox'))) { + $mode_search = 4; // Search on a multiselect field with sql type = text + } + if (is_array($crit)) { + $crit = implode(' ', $crit); // natural_search() expects a string + } elseif ($typ === 'select' and is_string($crit) and strpos($crit, ' ') === false) { $sql .= ' AND ('.$extrafieldsobjectprefix.$tmpkey.' = "'.$db->escape($crit).'")'; continue; } diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index f1ea80871b8..0a61e51d33d 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -1,29 +1,32 @@ table_element; -if (!isset($disablesortlink)) $disablesortlink = 0; +if (empty($extrafieldsobjectkey) && is_object($object)) { + $extrafieldsobjectkey = $object->table_element; +} +if (!isset($disablesortlink)) { + $disablesortlink = 0; +} // Loop to show all columns of extrafields for the title line -if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... -{ - if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) - { - if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; +if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... + if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { + if (empty($extrafieldsobjectprefix)) { + $extrafieldsobjectprefix = 'ef.'; + } - foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) - { - if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) - { + foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { + if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { $align = $extrafields->getAlignFlag($key); $sortonfield = $extrafieldsobjectprefix.$key; - if (!empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield = ''; + if (!empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { + $sortonfield = ''; + } if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') { print ''; } else { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index f8d86f2abee..1721f686776 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -26,74 +26,86 @@ */ // 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; } -if (!is_object($form)) $form = new Form($db); +if (!is_object($form)) { + $form = new Form($db); +} ?> fk_soc)) $parameters['socid'] = $object->fk_soc; +if (!is_array($parameters)) { + $parameters = array(); +} +if (!empty($cols)) { + $parameters['colspan'] = ' colspan="'.$cols.'"'; +} +if (!empty($cols)) { + $parameters['cols'] = $cols; +} +if (!empty($object->fk_soc)) { + $parameters['socid'] = $object->fk_soc; +} $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} //var_dump($extrafields->attributes[$object->table_element]); -if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label'])) -{ +if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label'])) { $lastseparatorkeyfound = ''; $extrafields_collapse_num = ''; $extrafields_collapse_num_old = ''; $i = 0; - foreach ($extrafields->attributes[$object->table_element]['label'] as $tmpkeyextra => $tmplabelextra) - { + foreach ($extrafields->attributes[$object->table_element]['label'] as $tmpkeyextra => $tmplabelextra) { $i++; // Discard if extrafield is a hidden field on form $enabled = 1; - if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra])) - { + if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra])) { $enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra], 1); } - if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra])) - { + if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra])) { $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra], 1); } $perms = 1; - if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra])) - { + if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra])) { $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra], 1); } //print $tmpkeyextra.'-'.$enabled.'-'.$perms.'-'.$tmplabelextra.$_POST["options_" . $tmpkeyextra].'
    '."\n"; - if (empty($enabled)) continue; // 0 = Never visible field - if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation - if (empty($perms)) continue; // 0 = Not visible + if (empty($enabled)) { + continue; // 0 = Never visible field + } + if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) { + continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation + } + if (empty($perms)) { + continue; // 0 = Not visible + } // Load language if required - if (!empty($extrafields->attributes[$object->table_element]['langfile'][$tmpkeyextra])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$tmpkeyextra]); - if ($action == 'edit_extras') - { + if (!empty($extrafields->attributes[$object->table_element]['langfile'][$tmpkeyextra])) { + $langs->load($extrafields->attributes[$object->table_element]['langfile'][$tmpkeyextra]); + } + if ($action == 'edit_extras') { $value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]); } else { - $value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); + $value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); //var_dump($tmpkeyextra.' - '.$value); } // Print line tr of extra field - if ($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra] == 'separate') - { + if ($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra] == 'separate') { $extrafields_collapse_num = ''; $extrafield_param = $extrafields->attributes[$object->table_element]['param'][$tmpkeyextra]; if (!empty($extrafield_param) && is_array($extrafield_param)) { @@ -126,7 +138,9 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print ''; print ''; } print '
    '; - if (in_array($val['type'], array('text', 'html'))) print '
    '; + if (in_array($val['type'], array('text', 'html'))) { + print '
    '; + } print $object->showOutputField($val, $key, $value, '', '', '', 0); //print dol_escape_htmltag($object->$key, 1, 1); - if (in_array($val['type'], array('text', 'html'))) print '
    '; + if (in_array($val['type'], array('text', 'html'))) { + print '
    '; + } print '
    '.$entry->thirdparty_html.''.$entry->type.''.$entry->status.''; $tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key); - if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) - { + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { $searchclass = ''; - if (in_array($typeofextrafield, array('varchar'))) $searchclass = 'searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass = 'searchnum'; + if (in_array($typeofextrafield, array('varchar'))) { + $searchclass = 'searchstring'; + } + if (in_array($typeofextrafield, array('int', 'double'))) { + $searchclass = 'searchnum'; + } print ''; - } elseif (in_array($typeofextrafield, array('datetime', 'timestamp'))) - { + } elseif (in_array($typeofextrafield, array('datetime', 'timestamp'))) { $morecss = ''; echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1); } else { // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') $morecss = ''; - if (in_array($typeofextrafield, array('link', 'sellist', 'text', 'html'))) $morecss = 'maxwidth200'; + if (in_array($typeofextrafield, array('link', 'sellist', 'text', 'html'))) { + $morecss = 'maxwidth200'; + } echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1); } print '
    '; if (!empty($extrafields->attributes[$object->table_element]['help'][$tmpkeyextra])) { // You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. @@ -141,23 +155,42 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] //var_dump($user->rights); $permok = false; $keyforperm = $object->element; - if ($object->element == 'fichinter') $keyforperm = 'ficheinter'; - if (isset($user->rights->$keyforperm)) $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write; - if ($object->element == 'order_supplier') $permok = $user->rights->fournisseur->commande->creer; - if ($object->element == 'invoice_supplier') $permok = $user->rights->fournisseur->facture->creer; - if ($object->element == 'shipping') $permok = $user->rights->expedition->creer; - if ($object->element == 'delivery') $permok = $user->rights->expedition->delivery->creer; - if ($object->element == 'productlot') $permok = $user->rights->stock->creer; - if ($object->element == 'facturerec') $permok = $user->rights->facture->creer; - if ($object->element == 'mo') $permok = $user->rights->mrp->write; + if ($object->element == 'fichinter') { + $keyforperm = 'ficheinter'; + } + if (isset($user->rights->$keyforperm)) { + $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write; + } + if ($object->element == 'order_supplier') { + $permok = $user->rights->fournisseur->commande->creer; + } + if ($object->element == 'invoice_supplier') { + $permok = $user->rights->fournisseur->facture->creer; + } + if ($object->element == 'shipping') { + $permok = $user->rights->expedition->creer; + } + if ($object->element == 'delivery') { + $permok = $user->rights->expedition->delivery->creer; + } + if ($object->element == 'productlot') { + $permok = $user->rights->stock->creer; + } + if ($object->element == 'facturerec') { + $permok = $user->rights->facture->creer; + } + if ($object->element == 'mo') { + $permok = $user->rights->mrp->write; + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) && $permok && $enabled != 5 && ($action != 'edit_extras' || GETPOST('attribute') != $tmpkeyextra) - && empty($extrafields->attributes[$object->table_element]['computed'][$tmpkeyextra])) - { + && empty($extrafields->attributes[$object->table_element]['computed'][$tmpkeyextra])) { $fieldid = 'id'; - if ($object->table_element == 'societe') $fieldid = 'socid'; + if ($object->table_element == 'societe') { + $fieldid = 'socid'; + } print ''.img_edit().'
    '; @@ -168,12 +201,10 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) - { + if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) { $datenotinstring = $object->array_options['options_'.$tmpkeyextra]; // print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x'; - if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) // For backward compatibility - { + if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) { // For backward compatibility $datenotinstring = $db->jdate($datenotinstring); } //print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); @@ -181,10 +212,11 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } //TODO Improve element and rights detection - if ($action == 'edit_extras' && $permok && GETPOST('attribute', 'restricthtml') == $tmpkeyextra) - { + if ($action == 'edit_extras' && $permok && GETPOST('attribute', 'restricthtml') == $tmpkeyextra) { $fieldid = 'id'; - if ($object->table_element == 'societe') $fieldid = 'socid'; + if ($object->table_element == 'societe') { + $fieldid = 'socid'; + } print '
    '; print ''; print ''; @@ -208,8 +240,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] // Add code to manage list depending on others // TODO Test/enhance this with a more generic solution - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n"; print ' + }); + use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section ? $section : -1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir); -} else print ' '; +} else { + print ' '; +} print '
    '; // End "Add new file" area @@ -131,15 +127,13 @@ print '
    '; // Ask confirmation of deletion of directory -if ($action == 'delete_section') -{ +if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); } // End confirm -if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') -{ +if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { $langs->load("ecm"); print ''."\n"; @@ -155,14 +149,15 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg // Manual section $htmltooltip = $langs->trans("ECMAreaDesc2"); - if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) - { + if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { // Show the link to "Root" - if ($showroot) - { + if ($showroot) { print ''; } @@ -171,7 +166,9 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg // Show filemanager tree (will be filled by a call of ajax /ecm/tpl/enablefiletreeajax.tpl.php, later, that executes ajaxdirtree.php) print '
    '; - if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); + if ($action == 'deletefile') { + print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); + } print ''; } else { // Show filtree when ajax is disabled (rare) @@ -188,7 +185,9 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder'] // $_POST['dir'] $mode = 'noajax'; - if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php'; + if (empty($url)) { + $url = DOL_URL_ROOT.'/ecm/index.php'; + } include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php'; print ''; @@ -211,7 +210,9 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg $mode = 'noajax'; -if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php'; +if (empty($url)) { + $url = DOL_URL_ROOT.'/ecm/index.php'; +} include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // Show content of a directory on right side @@ -225,14 +226,15 @@ include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // Show content of a use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) // Show filtree when ajax is enabled -{ +if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { // Show filtree when ajax is enabled //var_dump($modulepart); // Variables that may be defined: // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder'] // $_POST['dir'] // $_POST['section_dir'], $_POST['section_id'], $_POST['token'], $_POST['max_file_size'], $_POST['sendit'] - if (GETPOST('section_dir', 'alpha')) { $preopened = GETPOST('section_dir', 'alpha'); } + if (GETPOST('section_dir', 'alpha')) { + $preopened = GETPOST('section_dir', 'alpha'); + } include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php'; } diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 2cd485a9510..80baabf8a1e 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -7,20 +7,23 @@ if (is_array($totalarray['totalizable'])) { } } // Show total line -if (isset($totalarray['pos'])) -{ +if (isset($totalarray['pos'])) { print ''; $i = 0; - while ($i < $totalarray['nbfield']) - { + while ($i < $totalarray['nbfield']) { $i++; - if (!empty($totalarray['pos'][$i])) print ''; - else { - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } else print ''; + if (!empty($totalarray['pos'][$i])) { + print ''; + } else { + if ($i == 1) { + if ($num < $limit) { + print ''; + } else { + print ''; + } + } else { + print ''; + } } } print ''; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 8d9c79f807d..b5dc9b90be0 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -20,7 +20,9 @@ // Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...); -if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', 1); +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', 1); +} // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { @@ -34,18 +36,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); -if (GETPOST('dol_hide_topmenu')) $conf->dol_hide_topmenu = 1; -if (GETPOST('dol_hide_leftmenu')) $conf->dol_hide_leftmenu = 1; -if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen = 1; -if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover = 1; -if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile = 1; +if (GETPOST('dol_hide_topmenu')) { + $conf->dol_hide_topmenu = 1; +} +if (GETPOST('dol_hide_leftmenu')) { + $conf->dol_hide_leftmenu = 1; +} +if (GETPOST('dol_optimize_smallscreen')) { + $conf->dol_optimize_smallscreen = 1; +} +if (GETPOST('dol_no_mouse_hover')) { + $conf->dol_no_mouse_hover = 1; +} +if (GETPOST('dol_use_jmobile')) { + $conf->dol_use_jmobile = 1; +} // If we force to use jmobile, then we reenable javascript -if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1; +if (!empty($conf->dol_use_jmobile)) { + $conf->use_javascript_ajax = 1; +} $php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; -if (!preg_match('/mainmenu=/', $php_self)) $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home'; +if (!preg_match('/mainmenu=/', $php_self)) { + $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home'; +} // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second $arrayofjs = array( @@ -62,14 +78,20 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $titleofloginpage .= ' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version. $disablenofollow = 1; -if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) $disablenofollow = 0; -if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $disablenofollow = 0; +if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) { + $disablenofollow = 0; +} +if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $disablenofollow = 0; +} print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu -if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +} $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1); $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' @@ -91,7 +113,9 @@ if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { @@ -122,9 +146,13 @@ $(document).ready(function () { @@ -147,7 +175,9 @@ if ($disablenofollow) echo '';
    -global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + ?> " name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autofocus="autofocus" /> @@ -157,7 +187,9 @@ if ($disablenofollow) echo '';
    -global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> +global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + ?> " name="password" class="flat input-icon-password minwidth150" type="password" value="" tabindex="2" autocomplete="global->MAIN_LOGIN_ENABLE_PASSWORD_AUTOCOMPLETE) ? 'off' : 'on'; ?>" /> @@ -167,8 +199,11 @@ if ($disablenofollow) echo ''; if ($captcha) { // Add a variable param to force not using cache (jmobile) $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time - if (preg_match('/\?/', $php_self)) $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog'); - else $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog'); + if (preg_match('/\?/', $php_self)) { + $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog'); + } else { + $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog'); + } // TODO: provide accessible captcha variants ?> @@ -190,8 +225,7 @@ if ($captcha) { if (!empty($morelogincontent)) { if (is_array($morelogincontent)) { - foreach ($morelogincontent as $format => $option) - { + foreach ($morelogincontent as $format => $option) { if ($format == 'table') { echo ''; echo $option; @@ -221,29 +255,42 @@ if (!empty($morelogincontent)) {
    '; echo '
    '; if ($forgetpasslink) { $url = DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam; - if (!empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url = $conf->global->MAIN_PASSWORD_FORGOTLINK; + if (!empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) { + $url = $conf->global->MAIN_PASSWORD_FORGOTLINK; + } echo ''; echo $langs->trans('PasswordForgotten'); echo ''; } - if ($forgetpasslink && $helpcenterlink) echo ' - '; + if ($forgetpasslink && $helpcenterlink) { + echo ' - '; + } if ($helpcenterlink) { $url = DOL_URL_ROOT.'/support/index.php'.$moreparam; - if (!empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url = $conf->global->MAIN_HELPCENTER_LINKTOUSE; + if (!empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) { + $url = $conf->global->MAIN_HELPCENTER_LINKTOUSE; + } echo ''; echo $langs->trans('NeedHelpCenter'); echo ''; @@ -251,8 +298,7 @@ if ($forgetpasslink || $helpcenterlink) echo '
    '; } -if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication)) -{ +if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication)) { $langs->load("users"); //if (! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $url= @@ -260,8 +306,9 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil echo '
    '; $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; - if (!empty($url)) print ''.$langs->trans("LoginUsingOpenID").''; - else { + if (!empty($url)) { + print ''.$langs->trans("LoginUsingOpenID").''; + } else { $langs->load("errors"); print ''.$langs->trans("ErrorOpenIDSetupNotComplete", 'MAIN_AUTHENTICATION_OPENID_URL').''; } @@ -282,8 +329,7 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil
    '; // Multicurrency -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + print ''; +} -if ($inputalsopricewithtax) print ''; +if ($inputalsopricewithtax) { + print ''; +} // Qty print ''; // Unit -if (!empty($conf->global->PRODUCT_USE_UNITS)) -{ +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; } @@ -107,10 +109,8 @@ if ($this->situation_cycle_ref) { } // Purchase price -if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) -{ - if (!empty($user->rights->margins->creer)) - { +if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) { + if (!empty($user->rights->margins->creer)) { if ($conf->global->MARGIN_TYPE == "1") { print ''; } else { @@ -130,9 +130,13 @@ if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) print ''; // Multicurrency -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + print ''; +} -if ($outputalsopricetotalwithtax) print ''; +if ($outputalsopricetotalwithtax) { + print ''; +} print ''; // No width to allow autodim @@ -140,8 +144,7 @@ print ''; print ''; -if ($action == 'selectlines') -{ +if ($action == 'selectlines') { print ''; -if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines -{ +if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { // We must have same test in printObjectLines print ''; @@ -203,10 +225,18 @@ if ($object->element == 'supplier_proposal' || $object->element == 'order_suppli print ' @@ -229,11 +259,12 @@ if ((($line->info_bits & 2) != 2) && $line->special_code != 3) { // 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 price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price -} else print ' '; +} else { + print ' '; +} print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) -{ +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; @@ -264,8 +294,7 @@ if ($this->situation_cycle_ref) print ''; } -if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) -{ +if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) { if (!empty($user->rights->margins->creer)) { ?> margin->enabled) && empty($user->socid)) global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> - - marque_tx, 'MT')).'%'; ?> + special_code == 3) { ?> @@ -282,8 +311,7 @@ if ($line->special_code == 3) { ?> '; $coldisplay++; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); $tooltiponprice .= '
    '.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); if (!$senderissupplier && is_object($object->thirdparty)) { @@ -307,8 +335,7 @@ if ($line->special_code == 3) { ?> print ''; } print price($sign * $line->total_ht); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { print ''; } print ''; diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index 959bf7fd6ad..c4b2ad5e3e4 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -16,8 +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; } @@ -30,13 +29,11 @@ print ''; print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':

    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'free')."

    \n"; -if (!empty($conf->commande->enabled)) -{ +if (!empty($conf->commande->enabled)) { print '
    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'order')."
    \n"; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("orders"); print ''; print ''; @@ -44,8 +41,7 @@ if (!empty($conf->commande->enabled)) print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; - if (GETPOST('generate_order_ref', 'alpha')) - { + if (GETPOST('generate_order_ref', 'alpha')) { print '
    -> '; $url = getOnlinePaymentUrl(0, 'order', GETPOST('generate_order_ref', 'alpha')); print $url; @@ -55,13 +51,11 @@ if (!empty($conf->commande->enabled)) } print '
    '; } -if (!empty($conf->facture->enabled)) -{ +if (!empty($conf->facture->enabled)) { print '
    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'invoice')."
    \n"; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("bills"); print ''; print ''; @@ -69,8 +63,7 @@ if (!empty($conf->facture->enabled)) print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Invoice")).': '; print ''; print ''; - if (GETPOST('generate_invoice_ref', 'alpha')) - { + if (GETPOST('generate_invoice_ref', 'alpha')) { print '
    -> '; $url = getOnlinePaymentUrl(0, 'invoice', GETPOST('generate_invoice_ref', 'alpha')); print $url; @@ -80,13 +73,11 @@ if (!empty($conf->facture->enabled)) } print '
    '; } -if (!empty($conf->contrat->enabled)) -{ +if (!empty($conf->contrat->enabled)) { print '
    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'contractline')."
    \n"; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("contracts"); print ''; print ''; @@ -94,8 +85,7 @@ if (!empty($conf->contrat->enabled)) print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("ContractLine")).': '; print ''; print ''; - if (GETPOST('generate_contract_ref')) - { + if (GETPOST('generate_contract_ref')) { print '
    -> '; $url = getOnlinePaymentUrl(0, 'contractline', GETPOST('generate_contract_ref', 'alpha')); print $url; @@ -105,13 +95,11 @@ if (!empty($conf->contrat->enabled)) } print '
    '; } -if (!empty($conf->adherent->enabled)) -{ +if (!empty($conf->adherent->enabled)) { print '
    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'membersubscription')."
    \n"; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); print ''; print ''; @@ -119,8 +107,7 @@ if (!empty($conf->adherent->enabled)) print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Member")).': '; print ''; print ''; - if (GETPOST('generate_member_ref')) - { + if (GETPOST('generate_member_ref')) { print '
    -> '; $url = getOnlinePaymentUrl(0, 'membersubscription', GETPOST('generate_member_ref', 'alpha')); print $url; @@ -130,13 +117,11 @@ if (!empty($conf->adherent->enabled)) } print '
    '; } -if (!empty($conf->don->enabled)) -{ +if (!empty($conf->don->enabled)) { print '
    '; print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'donation')."
    \n"; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN) && !empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); print ''; print ''; @@ -144,8 +129,7 @@ if (!empty($conf->don->enabled)) print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Don")).': '; print ''; print ''; - if (GETPOST('generate_donation_ref')) - { + if (GETPOST('generate_donation_ref')) { print '
    -> '; $url = getOnlinePaymentUrl(0, 'donation', GETPOST('generate_donation_ref', 'alpha')); print $url; @@ -156,8 +140,7 @@ if (!empty($conf->don->enabled)) print '
    '; } -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print "\n".' @@ -81,9 +98,13 @@ $(document).ready(function () { @@ -116,8 +137,11 @@ if (!empty($disablenofollow)) echo ''; if (!empty($captcha)) { // Add a variable param to force not using cache (jmobile) $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time - if (preg_match('/\?/', $php_self)) $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog'); - else $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog'); + if (preg_match('/\?/', $php_self)) { + $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog'); + } else { + $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog'); + } // TODO: provide accessible captcha variants ?> @@ -139,8 +163,7 @@ if (!empty($captcha)) { if (!empty($morelogincontent)) { if (is_array($morelogincontent)) { - foreach ($morelogincontent as $format => $option) - { + foreach ($morelogincontent as $format => $option) { if ($format == 'table') { echo ''; echo $option; @@ -169,10 +192,18 @@ if (!empty($morelogincontent)) {
    dol_hide_topmenu)) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu; - if (!empty($conf->dol_hide_leftmenu)) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu; - if (!empty($conf->dol_no_mouse_hover)) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover; - if (!empty($conf->dol_use_jmobile)) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile; + if (!empty($conf->dol_hide_topmenu)) { + $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu; + } + if (!empty($conf->dol_hide_leftmenu)) { + $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu; + } + if (!empty($conf->dol_no_mouse_hover)) { + $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover; + } + if (!empty($conf->dol_use_jmobile)) { + $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile; + } print ''.$langs->trans('BackToLoginPage').''; ?> @@ -210,11 +241,12 @@ if (!empty($morelogincontent)) { global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; +if (!empty($conf->global->MAIN_HTML_FOOTER)) { + print $conf->global->MAIN_HTML_FOOTER; +} if (!empty($morelogincontent) && is_array($morelogincontent)) { - foreach ($morelogincontent as $format => $option) - { + foreach ($morelogincontent as $format => $option) { if ($format == 'js') { echo "\n".''; echo $option."\n"; @@ -227,8 +259,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Add a hook here -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) -{ +if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -249,10 +280,8 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) -{ - if (empty($conf->dol_use_jmobile)) - { +if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { + if (empty($conf->dol_use_jmobile)) { ?>

    '; + + +print '
    '.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
    '.$langs->trans('PriceUHT').''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUTTC').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('BuyingPrice').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalTTCShort').''.$langs->trans('TotalTTCShort').''; print ''; print ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index e3516b8b2fc..1a223416787 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -39,8 +39,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; } @@ -49,13 +48,25 @@ global $mysoc; global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax; $usemargins = 0; -if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) $usemargins = 1; +if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) { + $usemargins = 1; +} -if (empty($dateSelector)) $dateSelector = 0; -if (empty($forceall)) $forceall = 0; -if (empty($senderissupplier)) $senderissupplier = 0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; -if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax = 0; +if (empty($dateSelector)) { + $dateSelector = 0; +} +if (empty($forceall)) { + $forceall = 0; +} +if (empty($senderissupplier)) { + $senderissupplier = 0; +} +if (empty($inputalsopricewithtax)) { + $inputalsopricewithtax = 0; +} +if (empty($outputalsopricetotalwithtax)) { + $outputalsopricetotalwithtax = 0; +} // add html5 elements $domData = ' data-element="'.$line->element.'"'; @@ -81,34 +92,34 @@ if (($line->info_bits & 2) == 2) { print ''; $txt = ''; print img_object($langs->trans("ShowReduc"), 'reduc').' '; - if ($line->description == '(DEPOSIT)') $txt = $langs->trans("Deposit"); - elseif ($line->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived"); - elseif ($line->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); + if ($line->description == '(DEPOSIT)') { + $txt = $langs->trans("Deposit"); + } elseif ($line->description == '(EXCESS RECEIVED)') { + $txt = $langs->trans("ExcessReceived"); + } elseif ($line->description == '(EXCESS PAID)') { + $txt = $langs->trans("ExcessPaid"); + } //else $txt=$langs->trans("Discount"); print $txt; print ''; - if ($line->description) - { - if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) - { + if ($line->description) { + if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) { $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); - } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) - { + } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit - if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { print ' ('.dol_print_date($discount->datec).')'; - } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) - { + } + } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) - { + } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); @@ -123,14 +134,19 @@ if (($line->info_bits & 2) == 2) { print $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); - if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); + if ($type == 1) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } if (!empty($line->label)) { $text .= ' '.$line->label.''; print $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { - if (!empty($line->fk_parent_line)) print img_picto('', 'rightarrow'); + if (!empty($line->fk_parent_line)) { + print img_picto('', 'rightarrow'); + } if (preg_match('/^\(DEPOSIT\)/', $line->description)) { $newdesc = preg_replace('/^\(DEPOSIT\)/', $langs->trans("Deposit"), $line->description); print $text.' '.dol_htmlentitiesbr($newdesc); @@ -142,24 +158,34 @@ if (($line->info_bits & 2) == 2) { // Show date range if ($line->element == 'facturedetrec') { - if ($line->date_start_fill || $line->date_end_fill) print '
    '; - if ($line->date_start_fill) print $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill); - if ($line->date_start_fill && $line->date_end_fill) print ' - '; - if ($line->date_end_fill) print $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill); - if ($line->date_start_fill || $line->date_end_fill) print '
    '; + if ($line->date_start_fill || $line->date_end_fill) { + print '
    '; + } + if ($line->date_start_fill) { + print $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill); + } + if ($line->date_start_fill && $line->date_end_fill) { + print ' - '; + } + if ($line->date_end_fill) { + print $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill); + } + if ($line->date_start_fill || $line->date_end_fill) { + print '
    '; + } } else { - if ($line->date_start || $line->date_end) print '
    '.get_date_range($line->date_start, $line->date_end, $format).'
    '; + if ($line->date_start || $line->date_end) { + print '
    '.get_date_range($line->date_start, $line->date_end, $format).'
    '; + } //print get_date_range($line->date_start, $line->date_end, $format); } // Add description in form - if ($line->fk_product > 0 && !empty($conf->global->PRODUIT_DESC_IN_FORM)) - { + if ($line->fk_product > 0 && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($line->description) && $line->description != $line->product_label) ? '
    '.dol_htmlentitiesbr($line->description) : ''; } //Line extrafield - if (!empty($extrafields)) - { + if (!empty($extrafields)) { $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); if (!empty($temps)) { print '
    '; @@ -169,32 +195,28 @@ if (($line->info_bits & 2) == 2) { } } -if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0 && empty($conf->global->SUPPLIER_HIDE_SUPPLIER_OBJECTLINES)) -{ +if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0 && empty($conf->global->SUPPLIER_HIDE_SUPPLIER_OBJECTLINES)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productfourn = new ProductFournisseur($this->db); $productfourn->fetch_product_fournisseur_price($line->fk_fournprice); print '
    '; print ''.$langs->trans('Supplier').' : '.$productfourn->getSocNomUrl(1, 'supplier').' - '.$langs->trans('Ref').' : '; // Supplier ref - if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here - { + if ($user->rights->produit->creer || $user->rights->service->creer) { // change required right here print $productfourn->getNomUrl(); } else { print $productfourn->ref_supplier; } } -if (!empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) -{ +if (!empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { $accountingaccount = new AccountingAccount($this->db); $accountingaccount->fetch($line->fk_accounting_account); print '

    '.$langs->trans('AccountingAffectation').' : '.$accountingaccount->getNomUrl(0, 1, 1); } print '
    '; print ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; $coldisplay++; $positiverates = ''; -if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); -if (price2num($line->total_localtax1)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); -if (price2num($line->total_localtax2)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); -if (empty($positiverates)) $positiverates = '0'; +if (price2num($line->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); +} +if (price2num($line->total_localtax1)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); +} +if (price2num($line->total_localtax2)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); +} +if (empty($positiverates)) { + $positiverates = '0'; +} print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); //print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); ?>'; $label = $line->getLabelOfUnit('short'); if ($label !== '') { @@ -253,8 +284,7 @@ if (!empty($line->remise_percent) && $line->special_code != 3) { } // Fields for situation invoices -if ($this->situation_cycle_ref) -{ +if ($this->situation_cycle_ref) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; print ''.$line->situation_percent.'%'.price($sign * $tmp[0]).'pa_ht); ?> pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?> marque_tx, 'MT')).'%'; ?>
    '."\n"; + +// Lastname +print ''."\n"; +// Firstname +print ''."\n"; +// Company +print ''."\n"; +// Address +print ''."\n"; +// Zip / Town +print ''; +// Country +print ''; +// State +if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; +} +// EMail +print ''."\n"; +// Other attributes +$tpl_context = 'public'; // define template context to public +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; +// Comments +print ''; +print ''; +print ''; +print ''."\n"; + +print "
    '.$langs->trans("Lastname").' *
    '.$langs->trans("Firstname").' *
    '.$langs->trans("Company").'
    '.$langs->trans("Address").''."\n"; +print '
    '.$langs->trans('Zip').' / '.$langs->trans('Town').''; +print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); +print ' / '; +print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); +print '
    '.$langs->trans('Country').''; +$country_id = GETPOST('country_id'); +if (!$country_id && !empty($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); +} +if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) $country_id = $new_country_id; + } +} +$country_code = getCountry($country_id, 2, $db, $langs); +print $form->select_country($country_id, 'country_id'); +print '
    '.$langs->trans('State').''; + if ($country_code) print $formcompany->select_state(GETPOST("state_id"), $country_code); + else print ''; + print '
    '.$langs->trans("Email").' *
    '.$langs->trans("Comments").'
    \n"; + +print dol_get_fiche_end(); + +// Save +print '
    '; +print ''; +if (!empty($backtopage)) { + print '     '; +} +print '
    '; + + +print "\n"; +print "
    "; +print '
    '; + + +llxFooterVierge(); + +$db->close(); From 22208b622f5d378ffdbea010946d701ef3ddae5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Feb 2021 12:55:24 +0100 Subject: [PATCH 078/173] WIP Add lead --- htdocs/public/project/new.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 3c1c4169286..caee1a6235b 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -41,6 +41,7 @@ if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -137,10 +138,27 @@ function llxFooterVierge() } +$arrayofdata = array(); +if (GETPOST('action') == 'addlead') { + // When a json request is sent + $entityBody = file_get_contents('php://input'); + + if ($entityBody) { + $arrayofdata = dol_json_decode($entityBody, true); + } + + print 'Date received and lead created'; + + $db->close(); + exit; +} + + /* * Actions */ + $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -289,6 +307,13 @@ if (empty($reshook) && $action == 'add') { } } +// Create lead from $arrayofdata +if (empty($reshook) && !empty($arrayofdata)) { + // TODO + dol_syslog(var_export($arrayofdata, true)); + // ... +} + // Action called after a submitted was send and member created successfully // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url. // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url. From f7c119e48c47ab8fef2630644bafee4ccb7c506b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Feb 2021 13:02:36 +0100 Subject: [PATCH 079/173] Fix json decode --- htdocs/public/project/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index caee1a6235b..39c0e952880 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -144,7 +144,7 @@ if (GETPOST('action') == 'addlead') { $entityBody = file_get_contents('php://input'); if ($entityBody) { - $arrayofdata = dol_json_decode($entityBody, true); + $arrayofdata = json_decode($entityBody, true); } print 'Date received and lead created'; From 3b497929853010e562079f8792da41d923b567ea Mon Sep 17 00:00:00 2001 From: dvdwalker Date: Wed, 24 Feb 2021 10:38:11 -0300 Subject: [PATCH 080/173] Update product.class.php --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9a71faa5665..31886b5d662 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4590,7 +4590,7 @@ class Product extends CommonObject $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } if ($this->type == Product::TYPE_SERVICE) { - $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddinright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); + $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } } $result .= $newref; From 49c0967a3e8240e73ef0022c503f4690a2d0af4e Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 24 Feb 2021 15:48:15 +0100 Subject: [PATCH 081/173] NEW option for Takepos to show the total price without tax --- htdocs/langs/en_US/cashdesk.lang | 4 ++- htdocs/takepos/admin/receipt.php | 9 +++++++ htdocs/takepos/admin/setup.php | 8 ++++++ htdocs/takepos/invoice.php | 44 +++++++++++++++++++++++++++++--- htdocs/takepos/receipt.php | 10 ++++++++ 5 files changed, 71 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 7263b04730a..a24109fa3d0 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -124,4 +124,6 @@ GiftReceipt=Gift receipt ModuleReceiptPrinterMustBeEnabled=Module Receipt printer must have been enabled first AllowDelayedPayment=Allow delayed payment PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts -WeighingScale=Weighing scale \ No newline at end of file +WeighingScale=Weighing scale +ShowPriceHT = Display the price excluding tax column +ShowPriceHTOnReceipt = Display the price excluding tax column on receipt diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 01873d317c4..aec1e9343a4 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008-2011 Laurent Destailleur * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2019 Andreu Bisquerra Gaya + * Copyright (C) 2021 Nicolas ZABOURI * * 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 @@ -233,6 +234,14 @@ print ''; print $form->selectyesno("TAKEPOS_AUTO_PRINT_TICKETS", $conf->global->TAKEPOS_AUTO_PRINT_TICKETS, 1); print "\n"; + +// Show price without vat +print ''; +print $langs->trans('ShowPriceHTOnReceipt'); +print ''; +print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { print ''; print $langs->trans('WeighingScale'); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index f3c17f6ee23..6d0949389a5 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -1,6 +1,7 @@ * Copyright (C) 2011-2017 Juanjo Menent + * Copyright (C) 2021 Nicolas ZABOURI * * 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 @@ -371,6 +372,13 @@ print ''; print ajax_constantonoff("TAKEPOS_DELAYED_PAYMENT", array(), $conf->entity, 0, 0, 1, 0); print "\n"; +// Show price without vat +print ''; +print $langs->trans('ShowPriceHT'); +print ''; +print ajax_constantonoff("TAKEPOS_SHOW_HT", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + // Numbering module //print ''; //print $langs->trans("BillsNumberingModule"); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 243b6b5bc49..8c5ecdc7a65 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1,6 +1,7 @@ + * Copyright (C) 2021 Nicolas ZABOURI * * 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 @@ -1120,7 +1121,10 @@ print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; print showOnlinePaymentUrl('donation', $object->ref).'
    '; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 18a8563fd89..ab0d6e5f483 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -32,7 +32,7 @@ class Donations extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'socid' ); @@ -109,18 +109,22 @@ 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) + 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." "; + 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 ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -129,8 +133,7 @@ class Donations extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -141,13 +144,11 @@ class Donations extends DolibarrApi dol_syslog("API Rest request"); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $don_static = new Don($this->db); if ($don_static->fetch($obj->rowid)) { @@ -185,12 +186,12 @@ class Donations extends DolibarrApi $this->don->$field = $value; } /*if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->don->lines = $lines; - }*/ + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->don->lines = $lines; + }*/ if ($this->don->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating order", array_merge(array($this->don->error), $this->don->errors)); @@ -222,12 +223,13 @@ class Donations extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->don->$field = $value; } - if ($this->don->update(DolibarrApiAccess::$user) > 0) - { + if ($this->don->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { throw new RestException(500, $this->don->error); @@ -356,8 +358,9 @@ class Donations extends DolibarrApi { $don = array(); foreach (Orders::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, $field." field missing"); + } $don[$field] = $data[$field]; } return $don; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 7e9b913312a..5cf550258ab 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -171,8 +171,7 @@ class Don extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("donations"); $this->labelStatus[-1] = $langs->transnoentitiesnoconv("Canceled"); @@ -186,8 +185,12 @@ class Don extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_CANCELED) $statusType = 'status9'; - if ($status == self::STATUS_PAID) $statusType = 'status6'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status9'; + } + if ($status == self::STATUS_PAID) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -216,12 +219,10 @@ class Don extends CommonObject $sql .= " LIMIT 10"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_socs = $this->db->num_rows($resql); $i = 0; - while ($i < $num_socs) - { + while ($i < $num_socs) { $i++; $row = $this->db->fetch_row($resql); @@ -269,35 +270,29 @@ class Don extends CommonObject $error_string = array(); $err = 0; - if (dol_strlen(trim($this->societe)) == 0) - { - if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0) - { + if (dol_strlen(trim($this->societe)) == 0) { + if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Company').'/'.$langs->transnoentitiesnoconv('Firstname').'-'.$langs->transnoentitiesnoconv('Lastname')); $err++; } } - if (dol_strlen(trim($this->address)) == 0) - { + if (dol_strlen(trim($this->address)) == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Address')); $err++; } - if (dol_strlen(trim($this->zip)) == 0) - { + if (dol_strlen(trim($this->zip)) == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Zip')); $err++; } - if (dol_strlen(trim($this->town)) == 0) - { + if (dol_strlen(trim($this->town)) == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Town')); $err++; } - if (dol_strlen(trim($this->email)) == 0) - { + if (dol_strlen(trim($this->email)) == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMail')); $err++; } @@ -306,10 +301,8 @@ class Don extends CommonObject $map = range(0, 9); $len = dol_strlen($this->amount); - for ($i = 0; $i < $len; $i++) - { - if (!isset($map[substr($this->amount, $i, 1)])) - { + for ($i = 0; $i < $len; $i++) { + if (!isset($map[substr($this->amount, $i, 1)])) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount')); $err++; $amount_invalid = 1; @@ -317,23 +310,19 @@ class Don extends CommonObject } } - if (!$amount_invalid) - { - if ($this->amount == 0) - { + if (!$amount_invalid) { + if ($this->amount == 0) { $error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount')); $err++; } else { - if ($this->amount < $minimum && $minimum > 0) - { + if ($this->amount < $minimum && $minimum > 0) { $error_string[] = $langs->trans('MinimumAmount', $langs->transnoentitiesnoconv('$minimum')); $err++; } } } - if ($err) - { + if ($err) { $this->errors = $error_string; return 0; } else { @@ -404,7 +393,7 @@ class Don extends CommonObject $sql .= ", ".(int) ($this->country_id > 0 ? $this->country_id : 0); $sql .= ", ".(int) $this->public; $sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null"); - $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "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 .= ", ".$user->id; $sql .= ", null"; @@ -415,16 +404,16 @@ class Don extends CommonObject $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); $ret = $this->id; - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('DON_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } else { @@ -441,14 +430,12 @@ class Don extends CommonObject } } - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) - { + if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { //$res = $this->setValid($user); //if ($res < 0) $error++; } - if (!$error) - { + if (!$error) { $this->db->commit(); return $ret; } else { @@ -503,28 +490,25 @@ class Don extends CommonObject dol_syslog(get_class($this)."::Update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$notrigger) - { + if ($resql) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('DON_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } // Update extrafield - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $this->db->commit(); $result = 1; } else { @@ -557,7 +541,7 @@ class Don extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('DON_DELETE', $user); @@ -568,39 +552,33 @@ class Don extends CommonObject } // Delete donation - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."don_extrafields"; $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."don"; $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { - 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); } @@ -633,20 +611,16 @@ class Don extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid"; $sql .= " WHERE d.entity IN (".getEntity('donation').")"; - if (!empty($id)) - { + if (!empty($id)) { $sql .= " AND d.rowid=".$id; - } elseif (!empty($ref)) - { + } elseif (!empty($ref)) { $sql .= " AND d.ref='".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -731,14 +705,14 @@ class Don extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0"; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->affected_rows($resql)) - { + if ($resql) { + if ($this->db->affected_rows($resql)) { if (!$notrigger) { // Call trigger $result = $this->call_trigger('DON_VALIDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -784,8 +758,7 @@ class Don extends CommonObject public function setPaid($id, $modepayment = 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; - if ($modepayment) - { + if ($modepayment) { $sql .= ", fk_payment=".$modepayment; } $sql .= " WHERE rowid = ".$id." AND fk_statut = 1"; @@ -874,8 +847,7 @@ class Don extends CommonObject $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $result = $obj->total; } @@ -902,10 +874,8 @@ class Don extends CommonObject $sql .= " AND d.entity IN (".getEntity('donation').")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["donations"] = $obj->nb; } $this->db->free($resql); @@ -930,7 +900,9 @@ class Don extends CommonObject { global $conf, $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 = ''; $label = img_picto('', $this->picto).' '.$langs->trans("Donation").''; @@ -941,20 +913,30 @@ class Don extends CommonObject $label .= '
    '.$langs->trans('Ref').': '.$this->id; $label .= '
    '.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); } - if ($moretitle) $label .= ' - '.$moretitle; + if ($moretitle) { + $label .= ' - '.$moretitle; + } $url = DOL_URL_ROOT.'/don/card.php?id='.$this->id; - $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 = ''; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; return $result; @@ -976,20 +958,16 @@ class Don extends CommonObject dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_modification = $vuser; @@ -1045,8 +1023,7 @@ class Don extends CommonObject // If selected modele is a filename template (then $modele="modelname:filename") $tmp = explode(':', $modele, 2); - if (!empty($tmp[1])) - { + if (!empty($tmp[1])) { $modele = $tmp[0]; $srctemplatepath = $tmp[1]; } @@ -1054,28 +1031,28 @@ class Don extends CommonObject // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - foreach (array('html', 'doc', 'pdf') as $prefix) - { + if (is_array($conf->modules_parts['models'])) { + $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); + } + foreach ($dirmodels as $reldir) { + foreach (array('html', 'doc', 'pdf') as $prefix) { $file = $prefix."_".preg_replace('/^html_/', '', $modele).".modules.php"; // On verifie l'emplacement du modele $file = dol_buildpath($reldir."core/modules/dons/".$file, 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = $prefix.'_'.$modele; break; } } - if ($filefound) break; + if ($filefound) { + break; + } } // Charge le modele - if ($filefound) - { + if ($filefound) { require_once $file; $object = $this; @@ -1086,8 +1063,7 @@ class Don extends CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output = $outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) - { + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output = $sav_charset_output; // we delete preview files diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 684c04ead44..e3deff2dc2d 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -84,7 +84,9 @@ class DonationStats extends Stats //$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; + if ($this->userid > 0) { + $this->where .= ' WHERE c.fk_user_author = '.$this->userid; + } } /** diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 710e21f76b7..5f03215efac 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -120,25 +120,39 @@ class PaymentDonation extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datepaid) - { + if (!$this->datepaid) { $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->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; + 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->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; + } $totalamount = 0; - foreach ($this->amounts as $key => $value) // How payment is dispatch - { + foreach ($this->amounts as $key => $value) { // How payment is dispatch $newvalue = price2num($value, 'MT'); $this->amounts[$key] = $newvalue; $totalamount += $newvalue; @@ -146,13 +160,14 @@ class PaymentDonation extends CommonObject $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + if ($totalamount == 0) { + return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + } $this->db->begin(); - if ($totalamount != 0) - { + 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)."',"; @@ -163,8 +178,7 @@ class PaymentDonation extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation"); $this->ref = $this->id; } else { @@ -172,16 +186,16 @@ class PaymentDonation extends CommonObject } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount = $totalamount; $this->total = $totalamount; // deprecated $this->db->commit(); @@ -224,10 +238,8 @@ class PaymentDonation extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -275,14 +287,30 @@ class PaymentDonation extends CommonObject // 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->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; + 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->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; + } // Check parameters // Put here code to add control on parameters values @@ -311,25 +339,22 @@ class PaymentDonation extends CommonObject $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - if (!$error && !$notrigger) - { + if (!$error) { + if (!$notrigger) { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -356,18 +381,18 @@ class PaymentDonation extends CommonObject $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; 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; @@ -379,25 +404,22 @@ class PaymentDonation extends CommonObject } } - if (!$error) - { - if (!$notrigger) - { - if (!$error && !$notrigger) - { + if (!$error) { + if (!$notrigger) { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -439,21 +461,18 @@ class PaymentDonation extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $error++; } - if (!$error) - { + if (!$error) { } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -534,15 +553,16 @@ class PaymentDonation extends CommonObject $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; + if ($mode == 'payment_donation') { + $amount = $total; + } // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -559,23 +579,21 @@ class PaymentDonation extends CommonObject // Update fk_bank in llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } // 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='; - if ($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); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } @@ -586,8 +604,7 @@ class PaymentDonation extends CommonObject } } - if (!$error) - { + if (!$error) { return 1; } else { return -1; @@ -609,8 +626,7 @@ class PaymentDonation extends CommonObject dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else { $this->error = $this->db->error(); @@ -635,14 +651,19 @@ class PaymentDonation extends CommonObject $label .= '
    '; $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->id)) - { + if (!empty($this->id)) { $link = ''; $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 a211f076253..08667c6ab4c 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -34,8 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.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'; } @@ -50,7 +49,9 @@ $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, ''); @@ -59,12 +60,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Don($db); @@ -80,8 +87,7 @@ $modulepart = 'don'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; -if ($action == 'classin' && $user->rights->don->creer) -{ +if ($action == 'classin' && $user->rights->don->creer) { $object->fetch($id); $object->setProject($projectid); } @@ -91,15 +97,16 @@ if ($action == 'classin' && $user->rights->don->creer) */ $form = new Form($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $title = $langs->trans('Donation')." - ".$langs->trans('Documents'); $helpurl = ""; llxHeader('', $title, $helpurl); -if ($object->id) -{ +if ($object->id) { $object->fetch_thirdparty(); $head = donation_prepare_head($object); @@ -110,8 +117,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -119,12 +125,10 @@ if ($object->id) $morehtmlref = '
    '; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->don->creer) - { + if ($user->rights->don->creer) { if ($action != 'classify') { // $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; } @@ -166,7 +170,7 @@ if ($object->id) print ''.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print ''; - */ + */ // Societe //print "".$langs->trans("Company")."".$object->client->getNomUrl(1).""; diff --git a/htdocs/don/index.php b/htdocs/don/index.php index ce47e6ca89b..9415a1e928b 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -66,12 +66,10 @@ $sql .= " GROUP BY d.fk_statut"; $sql .= " ORDER BY d.fk_statut"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $i = 0; $num = $db->num_rows($result); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $somme[$objp->fk_statut] = $objp->somme; @@ -90,25 +88,25 @@ print load_fiche_titre($langs->trans("DonationsArea"), '', 'object_donation'); print '
    '; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - if (!empty($conf->don->enabled) && $user->rights->don->lire) - { +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + if (!empty($conf->don->enabled) && $user->rights->don->lire) { $listofsearchfields['search_donation'] = array('text'=>'Donation'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '
    '; print ''; print ''; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -129,17 +127,23 @@ print ''; print "\n"; $listofstatus = array(0, 1, -1, 2); -foreach ($listofstatus as $status) -{ +foreach ($listofstatus as $status) { $dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (int) $nb[$status] : 0)); - if ($status == Don::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Don::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Don::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; - if ($status == Don::STATUS_PAID) $colorseries[$status] = $badgeStatus6; + if ($status == Don::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Don::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Don::STATUS_CANCELED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == Don::STATUS_PAID) { + $colorseries[$status] = $badgeStatus6; + } } -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ''; $total = 0; $totalnb = 0; -foreach ($listofstatus as $status) -{ +foreach ($listofstatus as $status) { print ''; print ''; print ''; @@ -203,18 +206,15 @@ $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '
    '.$langs->trans("Search").'
    '.$langs->trans("Search").'
    '.$langs->trans("Statistics").'
    '; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -165,8 +169,7 @@ print '
    '.$donstatic->LibStatut($status, 4).''.(!empty($nb[$status]) ? $nb[$status] : ' ').'
    '; print ''; print ''; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; @@ -246,7 +246,9 @@ if ($resql) } } print "
    '.$langs->trans("LastModifiedDonations", $max).'

    "; -} else dol_print_error($db); +} else { + dol_print_error($db); +} print '
    '; diff --git a/htdocs/don/info.php b/htdocs/don/info.php index 1e7e18c9baf..866ff4baf22 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -25,8 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.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'; } @@ -39,7 +38,9 @@ $action = GETPOST('action', 'aZ09'); $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); @@ -47,8 +48,7 @@ $object->fetch($id); /* * Actions */ -if ($action == 'classin' && $user->rights->don->creer) -{ +if ($action == 'classin' && $user->rights->don->creer) { $object->fetch($id); $object->setProject($projectid); } @@ -61,7 +61,9 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $form = new Form($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $object->info($id); @@ -73,12 +75,10 @@ $linkback = ''; // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->don->creer) - { + if ($user->rights->don->creer) { if ($action != 'classify') { // $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index b81b5eaa231..9798cd02eea 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -27,7 +27,9 @@ 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")); @@ -38,12 +40,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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')); @@ -53,10 +61,11 @@ $search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -if (!$user->rights->don->lire) accessforbidden(); +if (!$user->rights->don->lire) { + accessforbidden(); +} -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 -{ +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 $search_all = ""; $search_ref = ""; $search_company = ""; @@ -84,7 +93,9 @@ $fieldstosearchall = array( $donationstatic = new Don($db); $form = new Form($db); -if (!empty($conf->projet->enabled)) $projectstatic = new Project($db); +if (!empty($conf->projet->enabled)) { + $projectstatic = new Project($db); +} llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'); @@ -94,37 +105,32 @@ $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') -{ +if ($search_status != '' && $search_status != '-4') { $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; } -if (trim($search_ref) != '') -{ +if (trim($search_ref) != '') { $sql .= natural_search('d.ref', $search_ref); } -if (trim($search_all) != '') -{ +if (trim($search_all) != '') { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if (trim($search_company) != '') -{ +if (trim($search_company) != '') { $sql .= natural_search('d.societe', $search_company); } -if (trim($search_name) != '') -{ +if (trim($search_name) != '') { $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name); } -if ($search_amount) $sql .= natural_search('d.amount', $search_amount, 1); +if ($search_amount) { + $sql .= natural_search('d.amount', $search_amount, 1); +} $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -133,29 +139,45 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - 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); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + 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 = ''; - if ($user->rights->don->creer) - { + if ($user->rights->don->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } print ''."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -165,9 +187,10 @@ if ($resql) print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); - if ($search_all) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
    '.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
    '; } @@ -194,8 +217,7 @@ if ($resql) print ''; print ' '; print ''; - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { print ''; print ' '; print ''; @@ -225,8 +247,7 @@ if ($resql) } 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); } @@ -235,8 +256,7 @@ if ($resql) print_liste_field_titre(''); print "\n"; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); print ''; @@ -258,18 +278,18 @@ if ($resql) } print "".$donationstatic->getFullName($langs).""; print ''.dol_print_date($db->jdate($objp->datedon), 'day').''; - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { print ""; - if ($objp->pid) - { + if ($objp->pid) { $projectstatic->id = $objp->pid; $projectstatic->ref = $objp->ref; $projectstatic->id = $objp->pid; $projectstatic->public = $objp->public; $projectstatic->title = $objp->title; print $projectstatic->getNomUrl(1); - } else print ' '; + } else { + print ' '; + } print "\n"; } print ''.price($objp->amount).''; diff --git a/htdocs/don/note.php b/htdocs/don/note.php index d1bbd0642d9..fa0122eaba2 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -29,8 +29,7 @@ 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'; } @@ -45,7 +44,9 @@ $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check $socid = 0; -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'don', $id, ''); $object = new Don($db); @@ -59,8 +60,7 @@ $permissionnote = $user->rights->don->creer; // Used by the include of actions_s */ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -if ($action == 'classin' && $user->rights->don->creer) -{ +if ($action == 'classin' && $user->rights->don->creer) { $object->fetch($id); $object->setProject($projectid); } @@ -74,10 +74,11 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $form = new Form($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new Don($db); $object->fetch($id, $ref); @@ -89,12 +90,10 @@ if ($id > 0 || !empty($ref)) $morehtmlref = '
    '; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->don->creer) - { + if ($user->rights->don->creer) { if ($action != 'classify') { // $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; } diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index e827bca338d..bc14780c1b2 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -27,7 +27,9 @@ 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", "donations")); @@ -36,15 +38,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "donations")); $id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -if ($user->socid) $socid = $user->socid; +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) -{ +if ($id > 0) { $result = $object->fetch($id); - if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); + if (!$result) { + dol_print_error($db, 'Failed to get payment id '.$id); + } } @@ -53,13 +58,11 @@ if ($id > 0) */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer) { $db->begin(); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/don/index.php"); exit; @@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1 /* * Confirm deleting of the payment */ -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } @@ -122,10 +124,8 @@ print ''.$langs->trans('Amount').''.price($object->amount, 0, $ print ''.$langs->trans('Note').''.nl2br($object->note_public).''; // Bank account -if (!empty($conf->banque->enabled)) -{ - if ($object->bank_account) - { +if (!empty($conf->banque->enabled)) { + if ($object->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); @@ -154,8 +154,7 @@ $sql .= ' AND pd.rowid = '.$id; dol_syslog("don/payment/card.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -168,10 +167,8 @@ if ($resql) print ''.$langs->trans('PayedByThisPayment').''; print "\n"; - if ($num > 0) - { - while ($i < $num) - { + if ($num > 0) { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -213,12 +210,9 @@ print dol_get_fiche_end(); */ print '
    '; -if (empty($action)) -{ - if ($user->rights->don->supprimer) - { - if (!$disable_delete) - { +if (empty($action)) { + if ($user->rights->don->supprimer) { + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index 9f944fe65b3..ca33d6ffc23 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -46,12 +46,10 @@ $object = new Don($db); * Actions */ -if ($action == 'add_payment') -{ +if ($action == 'add_payment') { $error = 0; - if ($_POST["cancel"]) - { + if ($_POST["cancel"]) { $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; header("Location: ".$loc); exit; @@ -59,45 +57,37 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (!$_POST["paymenttype"] > 0) - { + if (!$_POST["paymenttype"] > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } - if ($datepaid == '') - { + if ($datepaid == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0) - { + if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $paymentid = 0; // Read possible payments - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_') - { + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_') { $other_chid = substr($key, 7); $amounts[$other_chid] = price2num($_POST[$key]); } } - if (count($amounts) <= 0) - { + if (count($amounts) <= 0) { $error++; $errmsg = 'ErrorNoPaymentDefined'; setEventMessages($errmsg, null, 'errors'); } - if (!$error) - { + if (!$error) { $db->begin(); // Create a line of payments @@ -109,30 +99,25 @@ if ($action == 'add_payment') $payment->num_payment = GETPOST("num_payment", 'alphanohtml'); $payment->note_public = GETPOST("note_public", 'restricthtml'); - if (!$error) - { + if (!$error) { $paymentid = $payment->create($user); - if ($paymentid < 0) - { + if ($paymentid < 0) { $errmsg = $payment->error; setEventMessages($errmsg, null, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', ''); - if (!$result > 0) - { + if (!$result > 0) { $errmsg = $payment->error; setEventMessages($errmsg, null, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; header('Location: '.$loc); @@ -160,8 +145,7 @@ $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; $sql .= " WHERE p.fk_donation = ".$chid; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); @@ -169,16 +153,14 @@ if ($resql) // Form to create donation payment -if ($action == 'create') -{ +if ($action == 'create') { $object->fetch($chid); $total = $object->amount; print load_fiche_titre($langs->trans("DoPayment")); - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".''; + '; print ''; print dol_get_fiche_end(); - } // end edit or not edit - } // end of if result - else { + } + } else { dol_print_error($db); } - } //fin si id > 0 + } } /* @@ -2532,8 +2490,7 @@ if ($action == 'create') print '
    '; -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { $object = new ExpenseReport($db); $object->fetch($id, $ref); @@ -2552,16 +2509,13 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_DRAFT) - { - if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) - { + if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_DRAFT) { + if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) { // Modify print ''; // Validate - if (count($object->lines) > 0) - { + if (count($object->lines) > 0) { print ''; } } @@ -2572,10 +2526,8 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_REFUSED) - { - if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) - { + if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_REFUSED) { + if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // Modify print ''; @@ -2586,10 +2538,8 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->to_paid && $object->status == ExpenseReport::STATUS_APPROVED) - { - if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) - { + if ($user->rights->expensereport->to_paid && $object->status == ExpenseReport::STATUS_APPROVED) { + if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // setdraft print ''; } @@ -2600,17 +2550,14 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_validator == user courant * Afficher : "Valider" / "Refuser" / "Supprimer" */ - if ($object->status == ExpenseReport::STATUS_VALIDATED) - { - if (in_array($object->fk_user_author, $user->getAllChildIds(1))) - { + if ($object->status == ExpenseReport::STATUS_VALIDATED) { + if (in_array($object->fk_user_author, $user->getAllChildIds(1))) { // set draft print ''; } } - if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_VALIDATED) - { + if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_VALIDATED) { //if($object->fk_user_validator==$user->id) //{ // Validate @@ -2619,8 +2566,7 @@ if ($action != 'create' && $action != 'edit') print ''; //} - if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) - { + if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // Cancel print ''; } @@ -2630,17 +2576,14 @@ if ($action != 'create' && $action != 'edit') // If status is Approved // --------------------- - if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_APPROVED) - { + if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_APPROVED) { print ''; } // If bank module is used - if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->status == ExpenseReport::STATUS_APPROVED) - { + if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->status == ExpenseReport::STATUS_APPROVED) { // Pay - if ($remaintopay == 0) - { + if ($remaintopay == 0) { print '
    '.$langs->trans('DoPayment').'
    '; } else { print ''; @@ -2648,30 +2591,25 @@ if ($action != 'create' && $action != 'edit') } // If bank module is not used - if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED) - { + if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED) { //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) - if ($object->paid == 0) - { + if ($object->paid == 0) { print '"; } } - if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status == ExpenseReport::STATUS_APPROVED) - { - // Cancel - print ''; - } - - // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. - if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status == ExpenseReport::STATUS_CLOSED) - { + if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status == ExpenseReport::STATUS_APPROVED) { // Cancel print ''; } - if ($user->rights->expensereport->to_paid && $object->paid && $object->status == ExpenseReport::STATUS_CLOSED) - { + // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. + if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status == ExpenseReport::STATUS_CLOSED) { + // Cancel + print ''; + } + + if ($user->rights->expensereport->to_paid && $object->paid && $object->status == ExpenseReport::STATUS_CLOSED) { // Set unpaid print ''; } @@ -2682,12 +2620,10 @@ if ($action != 'create' && $action != 'edit') } /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ - if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED) - { + if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED) { // Delete print ''; - } elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED) - { + } elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED) { // Delete print ''; } @@ -2704,8 +2640,7 @@ if (GETPOST('modelselected', 'alpha')) { $action = 'presend'; } -if ($action != 'presend') -{ +if ($action != 'presend') { /* * Generate documents */ @@ -2713,8 +2648,7 @@ if ($action != 'presend') print '
    '; print ''; // ancre - if ($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') - { + if ($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; @@ -2732,7 +2666,7 @@ if ($action != 'presend') $linktoelem = $form->showLinkToObjectBlock($object, null, array('expensereport')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); } - */ + */ print '
    '; // List of actions on element diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index aa892e50fc0..98da4534e0c 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -33,7 +33,7 @@ class ExpenseReports extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'fk_user_author' ); @@ -107,11 +107,12 @@ class ExpenseReports extends DolibarrApi $sql = "SELECT t.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t"; $sql .= ' WHERE t.entity IN ('.getEntity('expensereport').')'; - if ($user_ids) $sql .= " AND t.fk_user_author IN (".$user_ids.")"; + if ($user_ids) { + $sql .= " AND t.fk_user_author IN (".$user_ids.")"; + } // Add sql filters - if ($sqlfilters) - { + if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } @@ -131,13 +132,11 @@ class ExpenseReports extends DolibarrApi $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $expensereport_static = new ExpenseReport($this->db); if ($expensereport_static->fetch($obj->rowid)) { @@ -172,12 +171,12 @@ class ExpenseReports extends DolibarrApi $this->expensereport->$field = $value; } /*if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->expensereport->lines = $lines; - }*/ + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->expensereport->lines = $lines; + }*/ if ($this->expensereport->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating expensereport", array_merge(array($this->expensereport->error), $this->expensereport->errors)); } @@ -195,28 +194,28 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - public function getLines($id) - { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { - throw new RestException(401); - } + public function getLines($id) + { + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->expensereport->getLinesArray(); - $result = array(); - foreach ($this->expensereport->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; - } - */ + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->expensereport->getLinesArray(); + $result = array(); + foreach ($this->expensereport->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ /** * Add a line to given Expense Report @@ -229,56 +228,56 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - public function postLine($id, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + public function postLine($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, - 'HT', - 0, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->rang, - $request_data->special_code, - $fk_parent_line, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->array_options, - $request_data->fk_unit, - $this->element, - $request_data->id - ); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); - if ($updateRes > 0) { - return $updateRes; + if ($updateRes > 0) { + return $updateRes; - } - return false; - } - */ + } + return false; + } + */ /** * Update a line to given Expense Report @@ -292,53 +291,53 @@ class ExpenseReports extends DolibarrApi * @return object */ /* - public function putLine($id, $lineid, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + public function putLine($id, $lineid, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->fk_unit - ); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; - } - */ + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + } + */ /** * Delete a line of given Expense Report @@ -351,30 +350,30 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - public function deleteLine($id, $lineid) - { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + public function deleteLine($id, $lineid) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $updateRes = $this->expensereport->deleteline($lineid); - if ($updateRes == 1) { - return $this->get($id); - } - return false; - } - */ + $updateRes = $this->expensereport->deleteline($lineid); + if ($updateRes == 1) { + return $this->get($id); + } + return false; + } + */ /** * Update Expense Report general fields (won't touch lines of expensereport) @@ -403,12 +402,13 @@ class ExpenseReports extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->expensereport->$field = $value; } - if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) - { + if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { throw new RestException(500, $this->expensereport->error); @@ -464,31 +464,31 @@ class ExpenseReports extends DolibarrApi * } */ /* - public function validate($id, $idwarehouse=0) - { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + public function validate($id, $idwarehouse=0) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { - throw new RestException(500, 'Error when validate expensereport'); - } + if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { + throw new RestException(500, 'Error when validate expensereport'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'expensereport validated' - ) - ); - }*/ + return array( + 'success' => array( + 'code' => 200, + 'message' => 'expensereport validated' + ) + ); + }*/ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** @@ -555,8 +555,9 @@ class ExpenseReports extends DolibarrApi { $expensereport = array(); foreach (ExpenseReports::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $expensereport[$field] = $data[$field]; } return $expensereport; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index cdc4fe4da5d..f95302cdba2 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -237,14 +237,15 @@ class ExpenseReport extends CommonObject $error = 0; // Check parameters - if (empty($this->date_debut) || empty($this->date_fin)) - { + if (empty($this->date_debut) || empty($this->date_fin)) { $this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Date')); return -1; } $fuserid = $this->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. - if (empty($fuserid)) $fuserid = $user->id; + if (empty($fuserid)) { + $fuserid = $user->id; + } $this->db->begin(); @@ -289,25 +290,20 @@ class ExpenseReport extends CommonObject $sql .= ")"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->ref = '(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->lasterror(); $error++; } - if (!$error) - { - if (is_array($this->lines) && count($this->lines) > 0) - { - foreach ($this->lines as $line) - { + if (!$error) { + if (is_array($this->lines) && count($this->lines) > 0) { + foreach ($this->lines as $line) { // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. if (!is_object($line)) { @@ -334,8 +330,7 @@ class ExpenseReport extends CommonObject //$newndfline=new ExpenseReportLine($this->db); $newndfline->fk_expensereport = $this->id; $result = $newndfline->insert(); - if ($result < 0) - { + if ($result < 0) { $this->error = $newndfline->error; $this->errors = $newndfline->errors; $error++; @@ -345,19 +340,17 @@ class ExpenseReport extends CommonObject } } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $this->update_price(); - if ($result > 0) - { - if (!$notrigger) - { + if ($result > 0) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_CREATE', $user); @@ -367,8 +360,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return $this->id; } else { @@ -405,7 +397,9 @@ class ExpenseReport extends CommonObject $error = 0; - if (empty($fk_user_author)) $fk_user_author = $user->id; + if (empty($fk_user_author)) { + $fk_user_author = $user->id; + } $this->db->begin(); @@ -430,10 +424,8 @@ class ExpenseReport extends CommonObject $this->date_validation = ''; // Remove link on lines to a joined file - if (is_array($this->lines) && count($this->lines) > 0) - { - foreach ($this->lines as $key => $line) - { + if (is_array($this->lines) && count($this->lines) > 0) { + foreach ($this->lines as $key => $line) { $this->lines[$key]->fk_ecm_files = 0; } } @@ -441,25 +433,26 @@ class ExpenseReport extends CommonObject // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Hook of thirdparty module - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('objFrom'=>$objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + if ($reshook < 0) { + $error++; + } } } unset($this->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -490,8 +483,7 @@ class ExpenseReport extends CommonObject $sql .= " , total_tva = ".$this->total_tva; $sql .= " , date_debut = '".$this->db->idate($this->date_debut)."'"; $sql .= " , date_fin = '".$this->db->idate($this->date_fin)."'"; - if ($userofexpensereport && is_object($userofexpensereport)) - { + if ($userofexpensereport && is_object($userofexpensereport)) { $sql .= " , fk_user_author = ".($userofexpensereport->id > 0 ? $userofexpensereport->id : "null"); // Note fk_user_author is not the 'author' but the guy the expense report is for. } $sql .= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator : "null"); @@ -507,10 +499,8 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if (!$notrigger) - { + if ($result) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_UPDATE', $user); @@ -520,8 +510,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -556,17 +545,18 @@ class ExpenseReport extends CommonObject $sql .= " d.fk_user_valid, d.fk_user_approve,"; $sql .= " d.fk_statut as status, d.fk_c_paiement, d.paid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; - if ($ref) $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; - else $sql .= " WHERE d.rowid = ".$id; + if ($ref) { + $sql .= " WHERE d.ref = '".$this->db->escape($ref)."'"; + } else { + $sql .= " WHERE d.rowid = ".$id; + } //$sql.= $restrict; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->ref = $obj->ref; @@ -599,13 +589,18 @@ class ExpenseReport extends CommonObject $this->fk_user_approve = $obj->fk_user_approve; $user_author = new User($this->db); - if ($this->fk_user_author > 0) $user_author->fetch($this->fk_user_author); + if ($this->fk_user_author > 0) { + $user_author->fetch($this->fk_user_author); + } $this->user_author_infos = dolGetFirstLastname($user_author->firstname, $user_author->lastname); $user_approver = new User($this->db); - if ($this->fk_user_approve > 0) $user_approver->fetch($this->fk_user_approve); - elseif ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); // For backward compatibility + if ($this->fk_user_approve > 0) { + $user_approver->fetch($this->fk_user_approve); + } elseif ($this->fk_user_validator > 0) { + $user_approver->fetch($this->fk_user_validator); // For backward compatibility + } $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); $this->fk_statut = $obj->status; // deprecated @@ -613,10 +608,11 @@ class ExpenseReport extends CommonObject $this->fk_c_paiement = $obj->fk_c_paiement; $this->paid = $obj->paid; - if ($this->status == self::STATUS_APPROVED || $this->status == self::STATUS_CLOSED) - { + if ($this->status == self::STATUS_APPROVED || $this->status == self::STATUS_CLOSED) { $user_valid = new User($this->db); - if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid); + if ($this->fk_user_valid > 0) { + $user_valid->fetch($this->fk_user_valid); + } $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname); } @@ -671,12 +667,9 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->affected_rows($resql)) - { - if (!$notrigger) - { + if ($resql) { + if ($this->db->affected_rows($resql)) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_PAID', $fuser); @@ -686,8 +679,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -763,10 +755,8 @@ class ExpenseReport extends CommonObject $sql .= " AND f.entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -780,26 +770,22 @@ class ExpenseReport extends CommonObject $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; - if ($obj->fk_user_creation) - { + if ($obj->fk_user_creation) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creation); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_modification) - { + if ($obj->fk_user_modification) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modification); $this->user_modification = $muser; } - if ($obj->fk_user_approve) - { + if ($obj->fk_user_approve) { $auser = new User($this->db); $auser->fetch($obj->fk_user_approve); $this->user_approve = $auser; @@ -898,15 +884,13 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; $total_HT = 0; $total_TTC = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($result); $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut as status"; @@ -953,13 +937,13 @@ class ExpenseReport extends CommonObject break; } /* - if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); - if ($status==1) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); - if ($status==2) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); - if ($status==2) return img_picto($langs->trans('StatusOrderOnProcess'),'statut3'); - if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4'); - if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6'); - */ + if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); + if ($status==1) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); + if ($status==2) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); + if ($status==2) return img_picto($langs->trans('StatusOrderOnProcess'),'statut3'); + if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4'); + if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6'); + */ print ''; print ''; @@ -994,11 +978,10 @@ class ExpenseReport extends CommonObject $total_ht = 0; $total_tva = 0; $total_ttc = 0; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num): + while ($i < $num) : $objp = $this->db->fetch_object($result); $total_ht += $objp->total_ht; $total_tva += $objp->total_tva; @@ -1012,7 +995,7 @@ class ExpenseReport extends CommonObject $sql .= " , total_tva = ".$total_tva; $sql .= " WHERE rowid = ".$id; $result = $this->db->query($sql); - if ($result): + if ($result) : $this->db->free($result); return 1; else : @@ -1049,20 +1032,17 @@ class ExpenseReport extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid'; $sql .= ' WHERE de.'.$this->fk_element.' = '.$this->id; - if (!empty($conf->global->EXPENSEREPORT_LINES_SORTED_BY_ROWID)) - { + if (!empty($conf->global->EXPENSEREPORT_LINES_SORTED_BY_ROWID)) { $sql .= ' ORDER BY de.rang ASC, de.rowid ASC'; } else { $sql .= ' ORDER BY de.rang ASC, de.date ASC'; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($resql); $deplig = new ExpenseReportLine($this->db); @@ -1128,7 +1108,9 @@ class ExpenseReport extends CommonObject if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSEREPORT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -1148,13 +1130,17 @@ class ExpenseReport extends CommonObject if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } // Removed extrafields of object @@ -1239,8 +1225,7 @@ class ExpenseReport extends CommonObject $now = dol_now(); // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING); return 0; } @@ -1248,13 +1233,14 @@ class ExpenseReport extends CommonObject $this->date_valid = $now; // Required for the getNextNum later. // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef(); } else { $num = $this->ref; } - if (empty($num) || $num < 0) return -1; + if (empty($num) || $num < 0) { + return -1; + } $this->newref = dol_sanitizeFileName($num); @@ -1269,10 +1255,8 @@ class ExpenseReport extends CommonObject $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { - if (!$error && !$notrigger) - { + if ($resql) { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_VALIDATE', $fuser); if ($result < 0) { @@ -1281,37 +1265,34 @@ class ExpenseReport extends CommonObject // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + if (preg_match('/^[\(]?PROV/i', $this->ref)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // 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 = 'expensereport/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$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($num); $dirsource = $conf->expensereport->dir_output.'/'.$oldref; $dirdest = $conf->expensereport->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -1324,14 +1305,12 @@ class ExpenseReport extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -1369,16 +1348,14 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->status != self::STATUS_VALIDATED) - { + if ($this->status != self::STATUS_VALIDATED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET fk_statut = ".self::STATUS_VALIDATED; $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { return 1; } else { $this->error = $this->db->lasterror(); @@ -1403,18 +1380,15 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $now; - if ($this->status != self::STATUS_APPROVED) - { + if ($this->status != self::STATUS_APPROVED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; $sql .= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql .= ' WHERE rowid = '.$this->id; - if ($this->db->query($sql)) - { - if (!$notrigger) - { + if ($this->db->query($sql)) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_APPROVE', $fuser); @@ -1424,8 +1398,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -1459,24 +1432,21 @@ class ExpenseReport extends CommonObject $error = 0; // date de refus - if ($this->status != self::STATUS_REFUSED) - { + if ($this->status != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; $sql .= " date_refuse='".$this->db->idate($now)."',"; $sql .= " detail_refuse='".$this->db->escape($details)."',"; $sql .= " fk_user_approve = NULL"; $sql .= ' WHERE rowid = '.$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->fk_statut = 99; // deprecated $this->status = 99; $this->fk_user_refuse = $fuser->id; $this->detail_refuse = $details; $this->date_refuse = $now; - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_DENY', $fuser); @@ -1486,8 +1456,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -1533,8 +1502,7 @@ class ExpenseReport extends CommonObject { $error = 0; - if ($this->paid) - { + if ($this->paid) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; @@ -1543,10 +1511,8 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!$notrigger) - { + if ($this->db->query($sql)) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_UNPAID', $fuser); @@ -1556,8 +1522,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -1589,8 +1554,7 @@ class ExpenseReport extends CommonObject // phpcs:enable $error = 0; $this->date_cancel = $this->db->idate(dol_now()); - if ($this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_CANCELED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; @@ -1601,10 +1565,8 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::set_cancel sql=".$sql, LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!$notrigger) - { + if ($this->db->query($sql)) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('EXPENSE_REPORT_CANCEL', $fuser); @@ -1614,8 +1576,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { @@ -1643,8 +1604,7 @@ class ExpenseReport extends CommonObject global $langs, $conf; $langs->load("trips"); - if (!empty($conf->global->EXPENSEREPORT_ADDON)) - { + if (!empty($conf->global->EXPENSEREPORT_ADDON)) { $mybool = false; $file = $conf->global->EXPENSEREPORT_ADDON.".php"; @@ -1652,8 +1612,7 @@ class ExpenseReport extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/expensereport/"); // Load file with numbering class (if found) @@ -1668,8 +1627,7 @@ class ExpenseReport extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -1702,38 +1660,50 @@ class ExpenseReport extends CommonObject $url = DOL_URL_ROOT.'/expensereport/card.php?id='.$this->id; - if ($short) return $url; + if ($short) { + return $url; + } $label = img_picto('', $this->picto).' '.$langs->trans("ExpenseReport").''; if (isset($this->status)) { $label .= ' '.$this->getLibStatut(5); } - if (!empty($this->ref)) + if (!empty($this->ref)) { $label .= '
    '.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->total_ht)) + } + if (!empty($this->total_ht)) { $label .= '
    '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) + } + if (!empty($this->total_tva)) { $label .= '
    '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) + } + if (!empty($this->total_ttc)) { $label .= '
    '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label .= ' - '.$moretitle; + } + if ($moretitle) { + $label .= ' - '.$moretitle; + } //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'; + 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'; + } //} $ref = $this->ref; - if (empty($ref)) $ref = $this->id; + if (empty($ref)) { + $ref = $this->id; + } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowExpenseReport"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -1746,8 +1716,12 @@ class ExpenseReport extends CommonObject $linkend = ''; $result .= $linkstart; - 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($ref, $max) : $ref); + 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($ref, $max) : $ref); + } $result .= $linkend; return $result; @@ -1775,7 +1749,7 @@ class ExpenseReport extends CommonObject $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); - if ($result): + if ($result) : return 1; else : $this->error = $this->db->error(); @@ -1805,7 +1779,7 @@ class ExpenseReport extends CommonObject $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); - if ($result): + if ($result) : return 1; else : $this->error = $this->db->error(); @@ -1834,14 +1808,25 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG); - if ($this->status == self::STATUS_DRAFT) - { - if (empty($qty)) $qty = 0; - if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0; - if (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) $fk_c_exp_tax_cat = 0; - if (empty($vatrate) || $vatrate < 0) $vatrate = 0; - if (empty($date)) $date = ''; - if (empty($fk_project)) $fk_project = 0; + if ($this->status == self::STATUS_DRAFT) { + if (empty($qty)) { + $qty = 0; + } + if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) { + $fk_c_type_fees = 0; + } + if (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) { + $fk_c_exp_tax_cat = 0; + } + if (empty($vatrate) || $vatrate < 0) { + $vatrate = 0; + } + if (empty($date)) { + $date = ''; + } + if (empty($fk_project)) { + $fk_project = 0; + } $qty = price2num($qty); if (!preg_match('/\s*\((.*)\)/', $vatrate)) { @@ -1857,8 +1842,7 @@ class ExpenseReport extends CommonObject $vat_src_code = ''; $reg = array(); - if (preg_match('/\s*\((.*)\)/', $vatrate, $reg)) - { + if (preg_match('/\s*\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } @@ -1890,11 +1874,9 @@ class ExpenseReport extends CommonObject $this->checkRules($type, $seller); $result = $this->line->insert(0, true); - if ($result > 0) - { + if ($result > 0) { $result = $this->update_price(); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return $this->line->id; } else { @@ -1927,7 +1909,9 @@ class ExpenseReport extends CommonObject $langs->load('trips'); - if (empty($conf->global->MAIN_USE_EXPENSE_RULE)) return true; // if don't use rules + if (empty($conf->global->MAIN_USE_EXPENSE_RULE)) { + return true; // if don't use rules + } $rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); @@ -1938,19 +1922,19 @@ class ExpenseReport extends CommonObject $new_current_total_ttc = $this->line->total_ttc; // check if one is violated - foreach ($rulestocheck as $rule) - { - if (in_array($rule->code_expense_rules_type, array('EX_DAY', 'EX_MON', 'EX_YEA'))) $amount_to_test = $this->line->getExpAmount($rule, $this->fk_user_author, $rule->code_expense_rules_type); - else $amount_to_test = $current_total_ttc; // EX_EXP + foreach ($rulestocheck as $rule) { + if (in_array($rule->code_expense_rules_type, array('EX_DAY', 'EX_MON', 'EX_YEA'))) { + $amount_to_test = $this->line->getExpAmount($rule, $this->fk_user_author, $rule->code_expense_rules_type); + } else { + $amount_to_test = $current_total_ttc; // EX_EXP + } $amount_to_test = $amount_to_test - $current_total_ttc + $new_current_total_ttc; // if amount as been modified by a previous rule - if ($amount_to_test > $rule->amount) - { + if ($amount_to_test > $rule->amount) { $violation++; - if ($rule->restrictive) - { + if ($rule->restrictive) { $this->error = 'ExpenseReportConstraintViolationError'; $this->errors[] = $this->error; @@ -1969,8 +1953,7 @@ class ExpenseReport extends CommonObject $this->line->rule_warning_message = implode('\n', $rule_warning_message_tab); - if ($violation > 0) - { + if ($violation > 0) { $tmp = calcul_price_total($this->line->qty, $new_current_total_ttc / $this->line->qty, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); $this->line->value_unit = $tmp[5]; @@ -1979,7 +1962,9 @@ class ExpenseReport extends CommonObject $this->line->total_tva = $tmp[1]; return false; - } else return true; + } else { + return true; + } } /** @@ -1991,11 +1976,12 @@ class ExpenseReport extends CommonObject { global $conf; - if (empty($conf->global->MAIN_USE_EXPENSE_IK)) return false; + if (empty($conf->global->MAIN_USE_EXPENSE_IK)) { + return false; + } $userauthor = new User($this->db); - if ($userauthor->fetch($this->fk_user_author) <= 0) - { + if ($userauthor->fetch($this->fk_user_author) <= 0) { $this->error = 'ErrorCantFetchUser'; $this->errors[] = 'ErrorCantFetchUser'; return false; @@ -2003,19 +1989,20 @@ class ExpenseReport extends CommonObject $range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); - if (empty($range)) - { + if (empty($range)) { $this->error = 'ErrorNoRangeAvailable'; $this->errors[] = 'ErrorNoRangeAvailable'; return false; } - if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) $ikoffset = $range->ikoffset; - else $ikoffset = $range->ikoffset / 12; // The amount of offset is a global value for the year + if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) { + $ikoffset = $range->ikoffset; + } else { + $ikoffset = $range->ikoffset / 12; // The amount of offset is a global value for the year + } // Test if ikoffset has been applied for the current month - if (!$this->offsetAlreadyGiven()) - { + if (!$this->offsetAlreadyGiven()) { $new_up = $range->coef + ($ikoffset / $this->line->qty); $tmp = calcul_price_total($this->line->qty, $new_up, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); @@ -2042,14 +2029,17 @@ class ExpenseReport extends CommonObject $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees f ON (d.fk_c_type_fees = f.id AND f.code = "EX_KME")'; $sql .= ' WHERE e.fk_user_author = '.(int) $this->fk_user_author; $sql .= ' AND YEAR(d.date) = "'.dol_print_date($this->line->date, '%Y').'" AND MONTH(d.date) = "'.dol_print_date($this->line->date, '%m').'"'; - if (!empty($this->line->id)) $sql .= ' AND d.rowid <> '.$this->line->id; + if (!empty($this->line->id)) { + $sql .= ' AND d.rowid <> '.$this->line->id; + } dol_syslog(get_class($this)."::offsetAlreadyGiven sql=".$sql); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 0) return true; + if ($num > 0) { + return true; + } } else { dol_print_error($this->db); } @@ -2077,8 +2067,7 @@ class ExpenseReport extends CommonObject { global $user, $mysoc; - if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) - { + if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) { $this->db->begin(); $type = 0; // TODO What if type is service ? @@ -2092,8 +2081,7 @@ class ExpenseReport extends CommonObject // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $vatrate, $reg)) - { + if (preg_match('/\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } @@ -2138,8 +2126,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; $sql .= " WHERE c.id = ".$type_fees_id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $objp_fees = $this->db->fetch_object($resql); $this->line->type_fees_code = $objp_fees->code_type_fees; $this->line->type_fees_libelle = $objp_fees->libelle_type_fees; @@ -2162,8 +2149,7 @@ class ExpenseReport extends CommonObject $this->checkRules(); $result = $this->line->update($user); - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return 1; } else { @@ -2191,8 +2177,7 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::deleteline sql=".$sql); $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->error = $this->db->error(); dol_syslog(get_class($this)."::deleteline Error ".$this->error, LOG_ERR); $this->db->rollback(); @@ -2225,27 +2210,30 @@ class ExpenseReport extends CommonObject if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; - if ($num_rows > 0) - { + if ($num_rows > 0) { $date_d_form = $date_debut; $date_f_form = $date_fin; $existe = false; - while ($i < $num_rows) - { + while ($i < $num_rows) { $objp = $this->db->fetch_object($result); $date_d_req = $this->db->jdate($objp->date_debut); // 3 $date_f_req = $this->db->jdate($objp->date_fin); // 4 - if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) $existe = true; + if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) { + $existe = true; + } $i++; } - if ($existe) return 1; - else return 0; + if ($existe) { + return 1; + } else { + return 0; + } } else { return 0; } @@ -2280,11 +2268,9 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; - while ($i < $num_rows) - { + while ($i < $num_rows) { $objp = $this->db->fetch_object($result); array_push($users_validator, $objp->fk_user); $i++; @@ -2348,12 +2334,10 @@ class ExpenseReport extends CommonObject $sql .= " WHERE active = ".$active; dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $ret[$obj->code] = (($langs->transnoentitiesnoconv($obj->code) != $obj->code) ? $langs->transnoentitiesnoconv($obj->code) : $obj->label); $i++; @@ -2381,8 +2365,7 @@ class ExpenseReport extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; $sql .= " WHERE ex.fk_statut > 0"; $sql .= " AND ex.entity IN (".getEntity('expensereport').")"; - if (empty($user->rights->expensereport->readall)) - { + if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); $sql .= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; $sql .= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; @@ -2415,30 +2398,32 @@ class ExpenseReport 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 + } $now = dol_now(); $sql = "SELECT ex.rowid, ex.date_valid"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; - if ($option == 'toapprove') $sql .= " WHERE ex.fk_statut = ".self::STATUS_VALIDATED; - else $sql .= " WHERE ex.fk_statut = ".self::STATUS_APPROVED; + if ($option == 'toapprove') { + $sql .= " WHERE ex.fk_statut = ".self::STATUS_VALIDATED; + } else { + $sql .= " WHERE ex.fk_statut = ".self::STATUS_APPROVED; + } $sql .= " AND ex.entity IN (".getEntity('expensereport').")"; - if (empty($user->rights->expensereport->readall)) - { + if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); $sql .= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; $sql .= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $langs->load("trips"); $response = new WorkboardResponse(); - if ($option == 'toapprove') - { + if ($option == 'toapprove') { $response->warning_delay = $conf->expensereport->approve->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("ExpenseReportsToApprove"); $response->labelShort = $langs->trans("ToApprove"); @@ -2451,12 +2436,10 @@ class ExpenseReport extends CommonObject } $response->img = img_object('', "trip"); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; - if ($option == 'toapprove') - { + if ($option == 'toapprove') { if ($this->db->jdate($obj->date_valid) < ($now - $conf->expensereport->approve->warning_delay)) { $response->nbtodolate++; } @@ -2486,8 +2469,12 @@ class ExpenseReport extends CommonObject global $conf; // Only valid expenses reports - if ($option == 'toapprove' && $this->status != 2) return false; - if ($option == 'topay' && $this->status != 5) return false; + if ($option == 'toapprove' && $this->status != 2) { + return false; + } + if ($option == 'topay' && $this->status != 5) { + return false; + } $now = dol_now(); if ($option == 'toapprove') { @@ -2510,11 +2497,9 @@ class ExpenseReport extends CommonObject $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $alreadydispatched = $obj->nb; } } else { @@ -2522,8 +2507,7 @@ class ExpenseReport extends CommonObject return -1; } - if ($alreadydispatched) - { + if ($alreadydispatched) { return 1; } return 0; @@ -2545,8 +2529,7 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::getSumPayments", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $this->db->free($resql); return (empty($obj->amount) ? 0 : $obj->amount); @@ -2649,8 +2632,7 @@ class ExpenseReportLine $result = $this->db->query($sql); - if ($result) - { + if ($result) { $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; @@ -2700,10 +2682,14 @@ class ExpenseReportLine // Clean parameters $this->comments = trim($this->comments); - if (empty($this->value_unit)) $this->value_unit = 0; + if (empty($this->value_unit)) { + $this->value_unit = 0; + } $this->qty = price2num($this->qty); $this->vatrate = price2num($this->vatrate); - if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0; + if (empty($this->fk_c_exp_tax_cat)) { + $this->fk_c_exp_tax_cat = 0; + } $this->db->begin(); @@ -2728,17 +2714,14 @@ class ExpenseReportLine $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det'); - if (!$fromaddline) - { + if (!$fromaddline) { $tmpparent = new ExpenseReport($this->db); $tmpparent->fetch($this->fk_expensereport); $result = $tmpparent->update_price(); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $tmpparent->error; $this->errors = $tmpparent->errors; @@ -2748,8 +2731,7 @@ class ExpenseReportLine $error++; } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -2776,20 +2758,24 @@ class ExpenseReportLine $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)'; $sql .= ' WHERE e.fk_user_author = '.$fk_user; - if (!empty($this->id)) $sql .= ' AND d.rowid <> '.$this->id; + if (!empty($this->id)) { + $sql .= ' AND d.rowid <> '.$this->id; + } $sql .= ' AND d.fk_c_type_fees = '.$rule->fk_c_type_fees; - if ($mode == 'day' || $mode == 'EX_DAY') $sql .= ' AND d.date = \''.dol_print_date($this->date, '%Y-%m-%d').'\''; - elseif ($mode == 'mon' || $mode == 'EX_MON') $sql .= ' AND DATE_FORMAT(d.date, \'%Y-%m\') = \''.dol_print_date($this->date, '%Y-%m').'\''; // @todo DATE_FORMAT is forbidden - elseif ($mode == 'year' || $mode == 'EX_YEA') $sql .= ' AND DATE_FORMAT(d.date, \'%Y\') = \''.dol_print_date($this->date, '%Y').'\''; // @todo DATE_FORMAT is forbidden + if ($mode == 'day' || $mode == 'EX_DAY') { + $sql .= ' AND d.date = \''.dol_print_date($this->date, '%Y-%m-%d').'\''; + } elseif ($mode == 'mon' || $mode == 'EX_MON') { + $sql .= ' AND DATE_FORMAT(d.date, \'%Y-%m\') = \''.dol_print_date($this->date, '%Y-%m').'\''; // @todo DATE_FORMAT is forbidden + } elseif ($mode == 'year' || $mode == 'EX_YEA') { + $sql .= ' AND DATE_FORMAT(d.date, \'%Y\') = \''.dol_print_date($this->date, '%Y').'\''; // @todo DATE_FORMAT is forbidden + } dol_syslog('ExpenseReportLine::getExpAmount'); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { $obj = $this->db->fetch_object($resql); $amount = (double) $obj->total_amount; } @@ -2816,7 +2802,9 @@ class ExpenseReportLine $this->comments = trim($this->comments); $this->vatrate = price2num($this->vatrate); $this->value_unit = price2num($this->value_unit); - if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0; + if (empty($this->fk_c_exp_tax_cat)) { + $this->fk_c_exp_tax_cat = 0; + } $this->db->begin(); @@ -2834,24 +2822,27 @@ class ExpenseReportLine $sql .= ",rule_warning_message='".$this->db->escape($this->rule_warning_message)."'"; $sql .= ",fk_c_exp_tax_cat=".$this->db->escape($this->fk_c_exp_tax_cat); $sql .= ",fk_ecm_files=".($this->fk_ecm_files > 0 ? $this->fk_ecm_files : 'null'); - if ($this->fk_c_type_fees) $sql .= ",fk_c_type_fees=".$this->db->escape($this->fk_c_type_fees); - else $sql .= ",fk_c_type_fees=null"; - if ($this->fk_project > 0) $sql .= ",fk_projet=".$this->db->escape($this->fk_project); - else $sql .= ",fk_projet=null"; + if ($this->fk_c_type_fees) { + $sql .= ",fk_c_type_fees=".$this->db->escape($this->fk_c_type_fees); + } else { + $sql .= ",fk_c_type_fees=null"; + } + if ($this->fk_project > 0) { + $sql .= ",fk_projet=".$this->db->escape($this->fk_project); + } else { + $sql .= ",fk_projet=null"; + } $sql .= " WHERE rowid = ".$this->db->escape($this->rowid ? $this->rowid : $this->id); dol_syslog("ExpenseReportLine::update sql=".$sql); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $tmpparent = new ExpenseReport($this->db); $result = $tmpparent->fetch($this->fk_expensereport); - if ($result > 0) - { + if ($result > 0) { $result = $tmpparent->update_price(); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $tmpparent->error; $this->errors = $tmpparent->errors; @@ -2866,8 +2857,7 @@ class ExpenseReportLine dol_print_error($this->db); } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php index 55af1eb00ed..18a0503cdd7 100644 --- a/htdocs/expensereport/class/expensereport_ik.class.php +++ b/htdocs/expensereport/class/expensereport_ik.class.php @@ -111,15 +111,16 @@ class ExpenseReportIk extends CoreObject $sql = 'SELECT rowid, label, entity, active'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat'; $sql .= ' WHERE entity IN ('.getEntity('c_exp_tax_cat').')'; - if ($mode == 1) $sql .= ' AND active = 1'; - elseif ($mode == 2) $sql .= 'AND active = 0'; + if ($mode == 1) { + $sql .= ' AND active = 1'; + } elseif ($mode == 2) { + $sql .= 'AND active = 0'; + } dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $categories[$obj->rowid] = $obj; } } else { @@ -142,8 +143,11 @@ class ExpenseReportIk extends CoreObject $ranges = self::getRangesByCategory($fk_c_exp_tax_cat); // substract 1 because array start from 0 - if (empty($ranges) || !isset($ranges[$default_range - 1])) return false; - else return $ranges[$default_range - 1]; + if (empty($ranges) || !isset($ranges[$default_range - 1])) { + return false; + } else { + return $ranges[$default_range - 1]; + } } /** @@ -160,20 +164,21 @@ class ExpenseReportIk extends CoreObject $ranges = array(); $sql = 'SELECT r.rowid FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; - if ($active) $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; + if ($active) { + $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; + } $sql .= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat; - if ($active) $sql .= ' AND r.active = 1 AND c.active = 1'; + if ($active) { + $sql .= ' AND r.active = 1 AND c.active = 1'; + } $sql .= ' ORDER BY r.range_ik'; dol_syslog(get_called_class().'::getRangesByCategory sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num > 0) - { - while ($obj = $db->fetch_object($resql)) - { + if ($num > 0) { + while ($obj = $db->fetch_object($resql)) { $object = new ExpenseReportIk($db); $object->fetch($obj->rowid); @@ -207,15 +212,17 @@ class ExpenseReportIk extends CoreObject dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $ik = new ExpenseReportIk($db); - if ($obj->fk_expense_ik > 0) $ik->fetch($obj->fk_expense_ik); + if ($obj->fk_expense_ik > 0) { + $ik->fetch($obj->fk_expense_ik); + } $obj->ik = $ik; - if (!isset($ranges[$obj->fk_c_exp_tax_cat])) $ranges[$obj->fk_c_exp_tax_cat] = array('label' => $obj->label, 'active' => $obj->cat_active, 'ranges' => array()); + if (!isset($ranges[$obj->fk_c_exp_tax_cat])) { + $ranges[$obj->fk_c_exp_tax_cat] = array('label' => $obj->label, 'active' => $obj->cat_active, 'ranges' => array()); + } $ranges[$obj->fk_c_exp_tax_cat]['ranges'][] = $obj; } } else { @@ -239,14 +246,15 @@ class ExpenseReportIk extends CoreObject $sql .= ' SELECT COUNT(*) as counted'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; $sql .= ' WHERE r.entity IN (0, '.$conf->entity.')'; - if ($default_c_exp_tax_cat > 0) $sql .= ' AND r.fk_c_exp_tax_cat = '.$default_c_exp_tax_cat; + if ($default_c_exp_tax_cat > 0) { + $sql .= ' AND r.fk_c_exp_tax_cat = '.$default_c_exp_tax_cat; + } $sql .= ' GROUP BY r.fk_c_exp_tax_cat'; $sql .= ') as counts'; dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); return $obj->nbRange; } else { diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php index 9a172cd7563..4e4d1009750 100644 --- a/htdocs/expensereport/class/expensereport_rule.class.php +++ b/htdocs/expensereport/class/expensereport_rule.class.php @@ -156,18 +156,15 @@ class ExpenseReportRule extends CoreObject $sql = 'SELECT er.rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er'; $sql .= ' WHERE er.entity IN (0,'.getEntity('').')'; - if (!empty($fk_c_type_fees)) - { + if (!empty($fk_c_type_fees)) { $sql .= ' AND er.fk_c_type_fees IN (-1, '.$fk_c_type_fees.')'; } - if (!empty($date)) - { + if (!empty($date)) { $date = dol_print_date($date, '%Y-%m-%d'); $sql .= ' AND er.dates <= \''.$date.'\''; $sql .= ' AND er.datee >= \''.$date.'\''; } - if ($fk_user > 0) - { + if ($fk_user > 0) { $sql .= ' AND (er.is_for_all = 1'; $sql .= ' OR er.fk_user = '.$fk_user; $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )'; @@ -177,13 +174,14 @@ class ExpenseReportRule extends CoreObject dol_syslog("ExpenseReportRule::getAllRule sql=".$sql); $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $rule = new ExpenseReportRule($db); - if ($rule->fetch($obj->rowid) > 0) $rules[$rule->id] = $rule; - else dol_print_error($db); + if ($rule->fetch($obj->rowid) > 0) { + $rules[$rule->id] = $rule; + } else { + dol_print_error($db); + } } } else { dol_print_error($db); @@ -201,11 +199,9 @@ class ExpenseReportRule extends CoreObject { include_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; - if ($this->fk_usergroup > 0) - { + if ($this->fk_usergroup > 0) { $group = new UserGroup($this->db); - if ($group->fetch($this->fk_usergroup) > 0) - { + if ($group->fetch($this->fk_usergroup) > 0) { return $group->nom; } else { $this->error = $group->error; @@ -225,11 +221,9 @@ class ExpenseReportRule extends CoreObject { include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - if ($this->fk_user > 0) - { + if ($this->fk_user > 0) { $u = new User($this->db); - if ($u->fetch($this->fk_user) > 0) - { + if ($u->fetch($this->fk_user) > 0) { return dolGetFirstLastname($u->firstname, $u->lastname); } else { $this->error = $u->error; diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index c4167e3002f..3d627cbce8d 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -70,20 +70,20 @@ class ExpenseReportStats extends Stats $this->where .= ' e.entity IN ('.getEntity('expensereport').')'; //$this->where.= " AND entity = ".$conf->entity; - if ($this->socid) - { + if ($this->socid) { $this->where .= " AND e.fk_soc = ".$this->socid; } // Only me and subordinates - if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) - { + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { $childids = $user->getAllChildIds(); $childids[] = $user->id; $this->where .= " AND e.fk_user_author IN (".(join(',', $childids)).")"; } - if ($this->userid > 0) $this->where .= ' AND e.fk_user_author = '.$this->userid; + if ($this->userid > 0) { + $this->where .= ' AND e.fk_user_author = '.$this->userid; + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index be8693f223e..56525e7b99c 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -119,19 +119,36 @@ class PaymentExpenseReport extends CommonObject } // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport = trim($this->fk_expensereport); - 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)) $this->note = trim($this->note); - 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->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat); - if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif); + if (isset($this->fk_expensereport)) { + $this->fk_expensereport = trim($this->fk_expensereport); + } + 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)) { + $this->note = trim($this->note); + } + 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->fk_user_creat)) { + $this->fk_user_creat = trim($this->fk_user_creat); + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = trim($this->fk_user_modif); + } $totalamount = 0; - foreach ($this->amounts as $key => $value) // How payment is dispatch - { + foreach ($this->amounts as $key => $value) { // How payment is dispatch $newvalue = price2num($value, 'MT'); $this->amounts[$key] = $newvalue; $totalamount += $newvalue; @@ -139,13 +156,14 @@ class PaymentExpenseReport extends CommonObject $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + if ($totalamount == 0) { + return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + } $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->fk_expensereport, '".$this->db->idate($now)."',"; @@ -156,16 +174,14 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_expensereport"); } else { $error++; } } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount = $totalamount; $this->db->commit(); return $this->id; @@ -206,10 +222,8 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -258,14 +272,30 @@ class PaymentExpenseReport extends CommonObject // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport = trim($this->fk_expensereport); - 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)) $this->note = trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); - if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat); - if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif); + if (isset($this->fk_expensereport)) { + $this->fk_expensereport = trim($this->fk_expensereport); + } + 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)) { + $this->note = trim($this->note); + } + if (isset($this->fk_bank)) { + $this->fk_bank = trim($this->fk_bank); + } + if (isset($this->fk_user_creat)) { + $this->fk_user_creat = trim($this->fk_user_creat); + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = trim($this->fk_user_modif); + } // Check parameters @@ -293,13 +323,13 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -327,18 +357,18 @@ class PaymentExpenseReport extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; $sql .= " WHERE type='payment_expensereport' AND url_id=".$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_expensereport"; $sql .= " WHERE rowid=".$this->id; @@ -351,10 +381,8 @@ class PaymentExpenseReport extends CommonObject } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -396,8 +424,7 @@ class PaymentExpenseReport extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $error++; } @@ -405,8 +432,7 @@ class PaymentExpenseReport extends CommonObject unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -487,8 +513,7 @@ class PaymentExpenseReport extends CommonObject $error = 0; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); @@ -497,7 +522,9 @@ class PaymentExpenseReport extends CommonObject //Fix me field $total = $this->amount; - if ($mode == 'payment_expensereport') $amount = $total; + if ($mode == 'payment_expensereport') { + $amount = $total; + } // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -514,35 +541,30 @@ class PaymentExpenseReport extends CommonObject // Update fk_bank in llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment', 'payment_supplier', 'payment_expensereport' in bank_url between payment and bank transaction $url = ''; - if ($mode == 'payment_expensereport') $url = DOL_URL_ROOT.'/expensereport/payment/card.php?rowid='; - if ($url) - { + if ($mode == 'payment_expensereport') { + $url = DOL_URL_ROOT.'/expensereport/payment/card.php?rowid='; + } + if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } } // Add link 'user' in bank_url between user and bank transaction - if (!$error) - { - foreach ($this->amounts as $key => $value) // We should have always same user but we loop in case of. - { - if ($mode == 'payment_expensereport') - { + if (!$error) { + foreach ($this->amounts as $key => $value) { // We should have always same user but we loop in case of. + if ($mode == 'payment_expensereport') { $fuser = new User($this->db); $fuser->fetch($key); @@ -553,8 +575,7 @@ class PaymentExpenseReport extends CommonObject $fuser->getFullName($langs), 'user' ); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::addPaymentToBank '.$this->error); $error++; @@ -568,8 +589,7 @@ class PaymentExpenseReport extends CommonObject } } - if (!$error) - { + if (!$error) { return 1; } else { return -1; @@ -591,8 +611,7 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else { $this->error = $this->db->error(); @@ -613,17 +632,24 @@ class PaymentExpenseReport extends CommonObject $result = ''; - if (empty($this->ref)) $this->ref = $this->label; + if (empty($this->ref)) { + $this->ref = $this->label; + } $label = $langs->trans("ShowPayment").': '.$this->ref; - if (!empty($this->id)) - { + if (!empty($this->id)) { $link = ''; $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; @@ -644,20 +670,16 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_creat) - { + if ($obj->fk_user_creat) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creat); $this->user_creation = $cuser; } - if ($obj->fk_user_modif) - { + if ($obj->fk_user_modif) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 55799b10589..7713745a0a3 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -45,7 +45,9 @@ $confirm = GETPOST('confirm', 'alpha'); $childids = $user->getAllChildIds(1); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); @@ -54,17 +56,22 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $object = new ExpenseReport($db); -if (!$object->fetch($id, $ref) > 0) -{ +if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); } @@ -74,14 +81,16 @@ $modulepart = 'trip'; // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($object->id > 0) -{ +if ($object->id > 0) { // Check current user can read this expense report $canread = 0; - if (!empty($user->rights->expensereport->readall)) $canread = 1; - if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; - if (!$canread) - { + if (!empty($user->rights->expensereport->readall)) { + $canread = 1; + } + if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -104,8 +113,7 @@ $title = $langs->trans("ExpenseReport")." - ".$langs->trans("Documents"); $helpurl = "EN:Module_Expense_Reports"; llxHeader("", $title, $helpurl); -if ($object->id) -{ +if ($object->id) { $object->fetch_thirdparty(); $head = expensereport_prepare_head($object); @@ -124,8 +132,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 046bde4efa1..541c2c0738e 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -42,19 +42,27 @@ $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, 'expensereport', '', ''); $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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.date_create"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "d.date_create"; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -80,8 +88,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."expensere $sql .= " WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity('expensereport').") AND de.fk_c_type_fees = tf.id"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) - && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) -{ + && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { $childids = $user->getAllChildIds(); $childids[] = $user->id; $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; @@ -90,12 +97,10 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense $sql .= " GROUP BY tf.code, tf.label"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $somme[$objp->code] = $objp->km; @@ -123,13 +128,11 @@ print ''.$langs->trans("Statistics").''; print "\n"; $listoftype = $tripandexpense_static->listOfTypes(); -foreach ($listoftype as $code => $label) -{ +foreach ($listoftype as $code => $label) { $dataseries[] = array($label, (isset($somme[$code]) ? (int) $somme[$code] : 0)); } -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ''; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -168,25 +171,29 @@ $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo, u.email, u.admin,"; $sql .= " d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport 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"; +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_author"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) - && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) -{ + && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { $childids = $user->getAllChildIds(); $childids[] = $user->id; $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; } $sql .= ' AND d.entity IN ('.getEntity('expensereport').')'; -if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($socid) $sql .= " AND d.fk_user_author = ".$socid; +if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} +if ($socid) { + $sql .= " AND d.fk_user_author = ".$socid; +} $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($max, 0); $result = $db->query($sql); -if ($result) -{ +if ($result) { $var = false; $num = $db->num_rows($result); @@ -201,14 +208,12 @@ if ($result) print ''.$langs->trans("DateModificationShort").''; print ' '; print ''; - if ($num) - { + if ($num) { $total_ttc = $totalam = $total = 0; $expensereportstatic = new ExpenseReport($db); $userstatic = new User($db); - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $expensereportstatic->id = $obj->rowid; @@ -241,7 +246,9 @@ if ($result) print ''.$langs->trans("None").''; } print '

    '; -} else dol_print_error($db); +} else { + dol_print_error($db); +} print '
    '; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 53d1531f4b9..605197d14ac 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -37,23 +37,26 @@ $ref = GETPOST('ref', 'alpha'); $childids = $user->getAllChildIds(1); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); $object = new ExpenseReport($db); -if (!$object->fetch($id, $ref) > 0) -{ +if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); } -if ($object->id > 0) -{ +if ($object->id > 0) { // Check current user can read this expense report $canread = 0; - if (!empty($user->rights->expensereport->readall)) $canread = 1; - if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; - if (!$canread) - { + if (!empty($user->rights->expensereport->readall)) { + $canread = 1; + } + if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -69,8 +72,7 @@ $title = $langs->trans("ExpenseReport")." - ".$langs->trans("Info"); $helpurl = "EN:Module_Expense_Reports"; llxHeader("", $title, $helpurl); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new ExpenseReport($db); $object->fetch($id, $ref); $object->info($object->id); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 7afb464e4f4..ea3a034e252 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -54,18 +54,24 @@ $childids = $user->getAllChildIds(1); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOST('id', 'int'); // If we are on the view of a specific user -if ($id > 0) -{ +if ($id > 0) { $canread = 0; - if ($id == $user->id) $canread = 1; - if (!empty($user->rights->expensereport->readall)) $canread = 1; - if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread = 1; - if (!$canread) - { + if ($id == $user->id) { + $canread = 1; + } + if (!empty($user->rights->expensereport->readall)) { + $canread = 1; + } + if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -78,12 +84,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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.date_debut"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "d.date_debut"; +} $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -101,8 +113,12 @@ $month_end = GETPOST("month_end", "int"); $year_end = GETPOST("year_end", "int"); $optioncss = GETPOST('optioncss', 'alpha'); -if ($search_status == '') $search_status = -1; -if ($search_user == '') $search_user = -1; +if ($search_status == '') { + $search_status = -1; +} +if ($search_user == '') { + $search_user = -1; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ExpenseReport($db); @@ -123,7 +139,9 @@ $fieldstosearchall = array( 'u.firstname'=>"Firstname", 'u.login'=>"Login", ); -if (empty($user->socid)) $fieldstosearchall["d.note_private"] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall["d.note_private"] = "NotePrivate"; +} $arrayfields = array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -151,21 +169,25 @@ $objectuser = new User($db); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_ref = ""; $search_user = ""; $search_amount_ht = ""; @@ -181,8 +203,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -216,8 +237,7 @@ $min_year = 10; // Get current user id $user_id = $user->id; -if ($id > 0) -{ +if ($id > 0) { // Charge utilisateur edite $fuser->fetch($id, '', '', 1); $fuser->getrights(); @@ -231,35 +251,50 @@ $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_v $sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; // 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 : ''); + 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."expensereport as d"; -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 (d.rowid = ef.fk_object)"; +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 (d.rowid = ef.fk_object)"; +} $sql .= ", ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; // Search all -if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if (!empty($sall)) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} // Ref -if (!empty($search_ref)) $sql .= natural_search('d.ref', $search_ref); +if (!empty($search_ref)) { + $sql .= natural_search('d.ref', $search_ref); +} // Date Start $sql .= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start); // Date End $sql .= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end); -if ($search_amount_ht != '') $sql .= natural_search('d.total_ht', $search_amount_ht, 1); -if ($search_amount_ttc != '') $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1); +if ($search_amount_ht != '') { + $sql .= natural_search('d.total_ht', $search_amount_ht, 1); +} +if ($search_amount_ttc != '') { + $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1); +} // User -if ($search_user != '' && $search_user >= 0) $sql .= " AND u.rowid = '".$db->escape($search_user)."'"; +if ($search_user != '' && $search_user >= 0) { + $sql .= " AND u.rowid = '".$db->escape($search_user)."'"; +} // Status -if ($search_status != '' && $search_status >= 0) $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; +if ($search_status != '' && $search_status >= 0) { + $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; +} // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) - && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) -{ + && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; } // Add where from extra fields @@ -273,12 +308,10 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -288,22 +321,39 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $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); - if ($sall) $param .= "&sall=".urlencode($sall); - if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); - if ($search_user) $param .= "&search_user=".urlencode($search_user); - if ($search_amount_ht) $param .= "&search_amount_ht=".urlencode($search_amount_ht); - if ($search_amount_ttc) $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); - if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } + if ($search_ref) { + $param .= "&search_ref=".urlencode($search_ref); + } + if ($search_user) { + $param .= "&search_user=".urlencode($search_user); + } + if ($search_amount_ht) { + $param .= "&search_amount_ht=".urlencode($search_amount_ht); + } + if ($search_amount_ttc) { + $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); + } + if ($search_status >= 0) { + $param .= "&search_status=".urlencode($search_status); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -313,23 +363,30 @@ if ($resql) 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->rights->expensereport->supprimer) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print '
    '."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; print ''; print ''; print ''; - if ($id > 0) print ''; + if ($id > 0) { + print ''; + } - if ($id > 0) // For user tab - { + if ($id > 0) { // For user tab $title = $langs->trans("User"); $linkback = ''.$langs->trans("BackToList").''; $head = user_prepare_head($fuser); @@ -340,8 +397,7 @@ if ($resql) print dol_get_fiche_end(); - if ($action != 'edit') - { + if ($action != 'edit') { print '
    '; $childids = $user->getAllChildIds(1); @@ -366,7 +422,9 @@ if ($resql) $title = $langs->trans("ListTripsAndExpenses"); $url = DOL_URL_ROOT.'/expensereport/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -378,9 +436,10 @@ if ($resql) $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } @@ -388,11 +447,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; print '
    '; @@ -407,17 +468,14 @@ if ($resql) // Filters print ''; - if (!empty($arrayfields['d.ref']['checked'])) - { + if (!empty($arrayfields['d.ref']['checked'])) { print ''; print ''; print ''; } // User - if (!empty($arrayfields['user']['checked'])) - { - if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) - { + if (!empty($arrayfields['user']['checked'])) { + if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) { print ''; print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); print ''; @@ -426,8 +484,7 @@ if ($resql) } } // Date start - if (!empty($arrayfields['d.date_debut']['checked'])) - { + if (!empty($arrayfields['d.date_debut']['checked'])) { print ''; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; @@ -438,8 +495,7 @@ if ($resql) print ''; } // Date end - if (!empty($arrayfields['d.date_fin']['checked'])) - { + if (!empty($arrayfields['d.date_fin']['checked'])) { print ''; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; @@ -449,33 +505,28 @@ if ($resql) print ''; } // Date valid - if (!empty($arrayfields['d.date_valid']['checked'])) - { + if (!empty($arrayfields['d.date_valid']['checked'])) { print ''; //print ''; //$formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; } // Date approve - if (!empty($arrayfields['d.date_approve']['checked'])) - { + if (!empty($arrayfields['d.date_approve']['checked'])) { print ''; //print ''; //$formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; } // Amount with no tax - if (!empty($arrayfields['d.total_ht']['checked'])) - { + if (!empty($arrayfields['d.total_ht']['checked'])) { print ''; } - if (!empty($arrayfields['d.total_vat']['checked'])) - { + if (!empty($arrayfields['d.total_vat']['checked'])) { print ''; } // Amount with all taxes - if (!empty($arrayfields['d.total_ttc']['checked'])) - { + if (!empty($arrayfields['d.total_ttc']['checked'])) { print ''; } // Extra fields @@ -486,20 +537,17 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['d.date_create']['checked'])) - { + if (!empty($arrayfields['d.date_create']['checked'])) { print ''; print ''; } // Date modification - if (!empty($arrayfields['d.tms']['checked'])) - { + if (!empty($arrayfields['d.tms']['checked'])) { print ''; print ''; } // Status - if (!empty($arrayfields['d.fk_statut']['checked'])) - { + if (!empty($arrayfields['d.fk_statut']['checked'])) { print ''; $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1); print ''; @@ -513,24 +561,48 @@ if ($resql) print "\n"; print ''; - if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); - if (!empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); - if (!empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.ref']['checked'])) { + print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['user']['checked'])) { + print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.date_debut']['checked'])) { + print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.date_fin']['checked'])) { + print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.date_valid']['checked'])) { + print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.date_approve']['checked'])) { + print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (!empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_create']['checked'])) { + print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.tms']['checked'])) { + print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + } + if (!empty($arrayfields['d.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -541,12 +613,10 @@ if ($resql) $expensereportstatic = new ExpenseReport($db); $usertmp = new User($db); - if ($num > 0) - { + if ($num > 0) { $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $expensereportstatic->id = $obj->rowid; @@ -572,10 +642,13 @@ if ($resql) print ''; // Warning late icon and note print ''; - if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late")); - if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late")); - if (!empty($obj->note_private) || !empty($obj->note_public)) - { + if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) { + print img_warning($langs->trans("Late")); + } + if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) { + print img_warning($langs->trans("Late")); + } + if (!empty($obj->note_private) || !empty($obj->note_public)) { print ' '; print ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; print ''; @@ -589,7 +662,9 @@ if ($resql) print ''; print ''; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // User if (!empty($arrayfields['user']['checked'])) { @@ -603,50 +678,69 @@ if ($resql) $usertmp->email = $obj->email; print $usertmp->getNomUrl(-1); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Start date if (!empty($arrayfields['d.date_debut']['checked'])) { print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // End date if (!empty($arrayfields['d.date_fin']['checked'])) { print ''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date validation if (!empty($arrayfields['d.date_valid']['checked'])) { print ''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date approval if (!empty($arrayfields['d.date_approve']['checked'])) { print ''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['d.total_ht']['checked'])) - { + if (!empty($arrayfields['d.total_ht']['checked'])) { print ''.price($obj->total_ht)."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; + } $totalarray['val']['d.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['d.total_vat']['checked'])) - { + if (!empty($arrayfields['d.total_vat']['checked'])) { print ''.price($obj->total_tva)."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; + } $totalarray['val']['d.total_tva'] += $obj->total_tva; } // Amount TTC - if (!empty($arrayfields['d.total_ttc']['checked'])) - { + if (!empty($arrayfields['d.total_ttc']['checked'])) { print ''.price($obj->total_ttc)."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; + } $totalarray['val']['d.total_ttc'] += $obj->total_ttc; } @@ -658,37 +752,43 @@ if ($resql) print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['d.date_create']['checked'])) - { + if (!empty($arrayfields['d.date_create']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_create), 'dayhour'); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['d.tms']['checked'])) - { + if (!empty($arrayfields['d.tms']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['d.fk_statut']['checked'])) - { + if (!empty($arrayfields['d.fk_statut']['checked'])) { print ''.$expensereportstatic->getLibStatut(5).''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print ''; } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; @@ -700,7 +800,11 @@ if ($resql) } } else { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''.$langs->trans("NoRecordFound").''; } @@ -718,10 +822,11 @@ if ($resql) print ''."\n"; - if (empty($id)) - { + if (empty($id)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index ebb66ce42fd..b0156c6a475 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -41,26 +41,29 @@ $childids = $user->getAllChildIds(1); // Security check $socid = 0; -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); $object = new ExpenseReport($db); -if (!$object->fetch($id, $ref) > 0) -{ +if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); } $permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php -if ($object->id > 0) -{ +if ($object->id > 0) { // Check current user can read this expense report $canread = 0; - if (!empty($user->rights->expensereport->readall)) $canread = 1; - if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; - if (!$canread) - { + if (!empty($user->rights->expensereport->readall)) { + $canread = 1; + } + if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -82,8 +85,7 @@ llxHeader("", $title, $helpurl); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new ExpenseReport($db); $object->fetch($id, $ref); $object->info($object->id); diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 14c95f2d68a..608309ceee0 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -26,7 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.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', 'trips')); @@ -36,16 +38,19 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentExpenseReport($db); -if ($id > 0) -{ +if ($id > 0) { $result = $object->fetch($id); - if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); + if (!$result) { + dol_print_error($db, 'Failed to get payment id '.$id); + } } @@ -54,13 +59,11 @@ if ($id > 0) */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) { $db->begin(); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/expensereport/index.php"); exit; @@ -86,8 +89,7 @@ print dol_get_fiche_head($head, 'payment', $langs->trans("ExpenseReportPayment") /* * Confirm deleting of the payment */ -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } @@ -118,14 +120,11 @@ print ''.$langs->trans('Note').''.nl2 $disable_delete = 0; // Bank account -if (!empty($conf->banque->enabled)) -{ - if ($object->bank_account) - { +if (!empty($conf->banque->enabled)) { + if ($object->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); - if ($bankline->rappro) - { + if ($bankline->rappro) { $disable_delete = 1; $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); } @@ -167,8 +166,7 @@ $sql .= ' AND per.rowid = '.$id; dol_syslog("expensereport/payment/card.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -186,10 +184,8 @@ if ($resql) print ''.$langs->trans('Status').''; print "\n"; - if ($num > 0) - { - while ($i < $num) - { + if ($num > 0) { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -216,8 +212,7 @@ if ($resql) print "\n"; - if ($objp->paid == 1) // If at least one invoice is paid, disable delete - { + if ($objp->paid == 1) { // If at least one invoice is paid, disable delete $disable_delete = 2; $title_button = $langs->trans("CantRemovePaymentWithOneInvoicePaid"); } @@ -242,12 +237,9 @@ if ($resql) */ print '
    '; -if ($action == '') -{ - if ($user->rights->expensereport->supprimer) - { - if (!$disable_delete) - { +if ($action == '') { + if ($user->rights->expensereport->supprimer) { + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index b66103f38f5..926559769b4 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -39,8 +39,7 @@ $accountid = GETPOST('accountid', 'int'); // Security check $socid = 0; -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } @@ -49,12 +48,10 @@ if ($user->socid > 0) * Actions */ -if ($action == 'add_payment') -{ +if ($action == 'add_payment') { $error = 0; - if ($_POST["cancel"]) - { + if ($_POST["cancel"]) { $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; header("Location: ".$loc); exit; @@ -62,53 +59,44 @@ if ($action == 'add_payment') $expensereport = new ExpenseReport($db); $result = $expensereport->fetch($id, $ref); - if (!$result) - { + if (!$result) { $error++; setEventMessages($expensereport->error, $expensereport->errors, 'errors'); } $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++; } - if ($datepaid == '') - { + if ($datepaid == '') { 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; // Read possible payments - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_') - { + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_') { $amounts[$expensereport->fk_user_author] = price2num($_POST[$key]); $total += price2num($_POST[$key]); } } - if (count($amounts) <= 0) - { + if (count($amounts) <= 0) { $error++; $errmsg = 'ErrorNoPaymentDefined'; } - if (!$error) - { + if (!$error) { $db->begin(); // Create a line of payments @@ -121,21 +109,17 @@ if ($action == 'add_payment') $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); $payment->note_public = GETPOST("note_public", 'restricthtml'); - if (!$error) - { + if (!$error) { $paymentid = $payment->create($user); - if ($paymentid < 0) - { + if ($paymentid < 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (!$result > 0) - { + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } @@ -152,8 +136,7 @@ if ($action == 'add_payment') } } - if (!$error) - { + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; header('Location: '.$loc); @@ -178,8 +161,7 @@ $form = new Form($db); // Form to create expense report payment -if ($action == 'create' || empty($action)) -{ +if ($action == 'create' || empty($action)) { $expensereport = new ExpenseReport($db); $expensereport->fetch($id, $ref); @@ -226,8 +208,7 @@ if ($action == 'create' || empty($action)) $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id; $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); @@ -257,8 +238,7 @@ if ($action == 'create' || empty($action)) print "\n"; print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; print ''.$langs->trans('AccountToDebit').''; print ''; @@ -299,8 +279,7 @@ if ($action == 'create' || empty($action)) $total = 0; $totalrecu = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $expensereport; print ''; @@ -310,12 +289,12 @@ if ($action == 'create' || empty($action)) print ''.price($sumpaid).""; print ''.price($objp->total_ttc - $sumpaid).""; print ''; - if ($sumpaid < $objp->total_ttc) - { + if ($sumpaid < $objp->total_ttc) { $namef = "amount_".$objp->id; $nameRemain = "remain_".$objp->id; // autofill remainder amount - if (!empty($conf->use_javascript_ajax)) // autofill remainder amount + if (!empty($conf->use_javascript_ajax)) { // autofill remainder amount print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->total_ttc - $sumpaid)."'"); // autofill remainder amount + } $remaintopay = $objp->total_ttc - $sumpaid; // autofill remainder amount print ''; // autofill remainder amount print ''; @@ -331,8 +310,7 @@ if ($action == 'create' || empty($action)) $totalrecu += $objp->am; $i++; } - if ($i > 1) - { + if ($i > 1) { // Print total print ''; print ''.$langs->trans("Total").':'; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index f3a3e263fa7..87bac2dde1a 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -38,16 +38,19 @@ $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; $object_status = GETPOST('object_status', 'intcomma'); $userid = GETPOST('userid', 'int'); -$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; +$socid = GETPOST('socid', 'int'); if ($socid < 0) { + $socid = 0; +} $id = GETPOST('id', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'expensereport', $id, ''); $nowyear = strftime("%Y", dol_now()); @@ -75,7 +78,9 @@ print load_fiche_titre($title, '', 'trip'); dol_mkdir($dir); $stats = new ExpenseReportStats($db, $socid, $userid); -if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($object_status != '' && $object_status >= -1) { + $stats->where .= ' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +} // Build graphic number of object // $data = array(array('Lib',val1,val2,val3),...) @@ -88,12 +93,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -120,12 +123,10 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats& $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px2->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -146,25 +147,30 @@ if (!$mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + } + if ($mode == 'supplier') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + } } else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + if ($mode == 'customer') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + } + if ($mode == 'supplier') { + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + } } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px3->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -189,7 +195,9 @@ $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; @@ -223,7 +231,9 @@ print ''; // User print ''.$langs->trans("User").''; $include = ''; -if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include = 'hierarchy'; +if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { + $include = 'hierarchy'; +} print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; // Status @@ -235,7 +245,9 @@ print ''; print ''; print $form->textwithpicto($langs->trans("Year"), $langs->trans("DateValidation")); print ''; -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 ''; @@ -254,11 +266,9 @@ print ''.$langs->trans("AmountAverage").''; print ''; $oldyear = 0; -foreach ($data as $val) -{ +foreach ($data as $val) { $year = $val['year']; - while ($year && $oldyear > $year + 1) - { // If we have empty year + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -287,7 +297,9 @@ print '
    '; // Show graphs print ''; diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index 04bb2a71990..640f4c17b5d 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -1,7 +1,6 @@ global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) -{ +if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -12,23 +11,20 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) $nbFiles = count($arrayoffiles); $nbLinks = Link::count($db, $object->element, $object->id); - if ($nbFiles > 0) - { + if ($nbFiles > 0) { print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display: none"' : '').'>'; print ' > - - + + "; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c80ee4d248f..f1099f9692f 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -54,14 +54,14 @@ $entitytoicon = array( 'subscription' => 'payment', 'payment' => 'payment', 'tax' => 'generic', - 'tax_type' => 'generic', - 'other' => 'generic', + 'tax_type' => 'generic', + 'other' => 'generic', 'account' => 'account', 'product' => 'product', 'virtualproduct'=>'product', 'subproduct' => 'product', 'product_supplier_ref' => 'product', - 'stock' => 'stock', + 'stock' => 'stock', 'warehouse' => 'stock', 'batch' => 'stock', 'stockbatch' => 'stock', @@ -159,17 +159,16 @@ $usefilters = 1; * Actions */ -if ($action == 'selectfield') // Selection of field at step 2 -{ +if ($action == 'selectfield') { // Selection of field at step 2 $fieldsarray = $objexport->array_export_fields[0]; $fieldsentitiesarray = $objexport->array_export_entities[0]; $fieldsdependenciesarray = $objexport->array_export_dependencies[0]; - if ($field == 'all') - { - foreach ($fieldsarray as $key=>$val) - { - if (!empty($array_selected[$key])) continue; // If already selected, check next + if ($field == 'all') { + foreach ($fieldsarray as $key => $val) { + if (!empty($array_selected[$key])) { + continue; // If already selected, check next + } $array_selected[$key] = count($array_selected) + 1; //print_r($array_selected); $_SESSION["export_selected_fields"] = $array_selected; @@ -180,29 +179,30 @@ if ($action == 'selectfield') // Selection of field at step 2 $array_selected[$field] = count($array_selected) + 1; // We tag the key $field as "selected" // We check if there is a dependency to activate /*var_dump($field); - var_dump($fieldsentitiesarray[$field]); - var_dump($fieldsdependenciesarray);*/ + var_dump($fieldsentitiesarray[$field]); + var_dump($fieldsdependenciesarray);*/ $listofdependencies = array(); - if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) - { + if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) { // We found a dependency on the type of field $tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid')) - if (is_array($tmp)) $listofdependencies = $tmp; - else $listofdependencies = array($tmp); - } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) - { + if (is_array($tmp)) { + $listofdependencies = $tmp; + } else { + $listofdependencies = array($tmp); + } + } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) { // We found a dependency on a dedicated field $tmp = $fieldsdependenciesarray[$field]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid')) - if (is_array($tmp)) $listofdependencies = $tmp; - else $listofdependencies = array($tmp); + if (is_array($tmp)) { + $listofdependencies = $tmp; + } else { + $listofdependencies = array($tmp); + } } - if (count($listofdependencies)) - { - foreach ($listofdependencies as $fieldid) - { - if (empty($array_selected[$fieldid])) - { + if (count($listofdependencies)) { + foreach ($listofdependencies as $fieldid) { + if (empty($array_selected[$fieldid])) { $array_selected[$fieldid] = count($array_selected) + 1; // We tag the key $fieldid as "selected" $warnings[] = $langs->trans("ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid])); } @@ -214,10 +214,8 @@ if ($action == 'selectfield') // Selection of field at step 2 setEventMessages($warnings, null, 'warnings'); } } -if ($action == 'unselectfield') -{ - if ($_GET["field"] == 'all') - { +if ($action == 'unselectfield') { + if ($_GET["field"] == 'all') { $array_selected = array(); $_SESSION["export_selected_fields"] = $array_selected; } else { @@ -226,8 +224,7 @@ if ($action == 'unselectfield') asort($array_selected); $i = 0; $array_selected_save = $array_selected; - foreach ($array_selected as $code=>$value) - { + foreach ($array_selected as $code => $value) { $i++; $array_selected[$code] = $i; //print "x $code x $i y
    "; @@ -236,52 +233,48 @@ if ($action == 'unselectfield') } } -if ($action == 'downfield' || $action == 'upfield') -{ +if ($action == 'downfield' || $action == 'upfield') { $pos = $array_selected[$_GET["field"]]; - if ($action == 'downfield') $newpos = $pos + 1; - if ($action == 'upfield') $newpos = $pos - 1; + if ($action == 'downfield') { + $newpos = $pos + 1; + } + if ($action == 'upfield') { + $newpos = $pos - 1; + } // Recherche code avec qui switcher $newcode = ""; - foreach ($array_selected as $code=>$value) - { - if ($value == $newpos) - { + foreach ($array_selected as $code => $value) { + if ($value == $newpos) { $newcode = $code; break; } } //print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)"); - if ($newcode) // Si newcode trouve (protection contre resoumission de page) - { + if ($newcode) { // Si newcode trouve (protection contre resoumission de page) $array_selected[$_GET["field"]] = $newpos; $array_selected[$newcode] = $pos; $_SESSION["export_selected_fields"] = $array_selected; } } -if ($step == 1 || $action == 'cleanselect') -{ +if ($step == 1 || $action == 'cleanselect') { $_SESSION["export_selected_fields"] = array(); $_SESSION["export_filtered_fields"] = array(); $array_selected = array(); $array_filtervalue = array(); } -if ($action == 'builddoc') -{ +if ($action == 'builddoc') { $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); - if ($max_time && $max_time < $max_execution_time_for_importexport) - { + if ($max_time && $max_time < $max_execution_time_for_importexport) { dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 } // Build export file $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue); - if ($result < 0) - { + if ($result < 0) { setEventMessages($objexport->error, $objexport->errors, 'errors'); $sqlusedforexport = $objexport->sqlusedforexport; } else { @@ -291,47 +284,46 @@ if ($action == 'builddoc') } // Delete file -if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes') -{ +if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes') { $file = $upload_dir."/".GETPOST('file'); // 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('file')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + } header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport); exit; } -if ($action == 'deleteprof') -{ - if (GETPOST("id", 'int')) - { +if ($action == 'deleteprof') { + if (GETPOST("id", 'int')) { $objexport->fetch(GETPOST('id', 'int')); $result = $objexport->delete($user); } } // TODO The export for filter is not yet implemented (old code created conflicts with step 2). We must use same way of working and same combo list of predefined export than step 2. -if ($action == 'add_export_model') -{ - if ($export_name) - { +if ($action == 'add_export_model') { + if ($export_name) { asort($array_selected); // Set save string $hexa = ''; - foreach ($array_selected as $key=>$val) - { - if ($hexa) $hexa .= ','; + foreach ($array_selected as $key => $val) { + if ($hexa) { + $hexa .= ','; + } $hexa .= $key; } $hexafiltervalue = ''; - if (!empty($array_filtervalue) && is_array($array_filtervalue)) - { - foreach ($array_filtervalue as $key=>$val) - { - if ($hexafiltervalue) $hexafiltervalue .= ','; + if (!empty($array_filtervalue) && is_array($array_filtervalue)) { + foreach ($array_filtervalue as $key => $val) { + if ($hexafiltervalue) { + $hexafiltervalue .= ','; + } $hexafiltervalue .= $key.'='.$val; } } @@ -342,14 +334,15 @@ if ($action == 'add_export_model') $objexport->hexafiltervalue = $hexafiltervalue; $result = $objexport->create($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("ExportModelSaved", $objexport->model_name), null, 'mesgs'); } else { $langs->load("errors"); - if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ErrorExportDuplicateProfil"), null, 'errors'); - else setEventMessages($objexport->error, $objexport->errors, 'errors'); + } else { + setEventMessages($objexport->error, $objexport->errors, 'errors'); + } } } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportModelName")), null, 'errors'); @@ -357,8 +350,7 @@ if ($action == 'add_export_model') } // Reload a predefined export model -if ($step == 2 && $action == 'select_model') -{ +if ($step == 2 && $action == 'select_model') { $_SESSION["export_selected_fields"] = array(); $_SESSION["export_filtered_fields"] = array(); @@ -366,12 +358,10 @@ if ($step == 2 && $action == 'select_model') $array_filtervalue = array(); $result = $objexport->fetch($exportmodelid); - if ($result > 0) - { + if ($result > 0) { $fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa); $i = 1; - foreach ($fieldsarray as $val) - { + foreach ($fieldsarray as $val) { $array_selected[$val] = $i; $i++; } @@ -379,8 +369,7 @@ if ($step == 2 && $action == 'select_model') $fieldsarrayvalue = explode(',', $objexport->hexafiltervalue); $i = 1; - foreach ($fieldsarrayvalue as $val) - { + foreach ($fieldsarrayvalue as $val) { $tmp = explode('=', $val); $array_filtervalue[$tmp[0]] = $tmp[1]; $i++; @@ -390,21 +379,20 @@ if ($step == 2 && $action == 'select_model') } // Get form with filters -if ($step == 4 && $action == 'submitFormField') -{ +if ($step == 4 && $action == 'submitFormField') { // on boucle sur les champs selectionne pour recuperer la valeur - if (is_array($objexport->array_export_TypeFields[0])) - { + if (is_array($objexport->array_export_TypeFields[0])) { $_SESSION["export_filtered_fields"] = array(); - foreach ($objexport->array_export_TypeFields[0] as $code => $type) // $code: s.fieldname $value: Text|Boolean|List:ccc - { + foreach ($objexport->array_export_TypeFields[0] as $code => $type) { // $code: s.fieldname $value: Text|Boolean|List:ccc $newcode = (string) preg_replace('/\./', '_', $code); //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
    "; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0; - elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0; - if ($filterqualified) - { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') { + $filterqualified = 0; + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) { + $filterqualified = 0; + } + if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml'); } @@ -419,8 +407,7 @@ if ($step == 4 && $action == 'submitFormField') * View */ -if ($step == 1 || !$datatoexport) -{ +if ($step == 1 || !$datatoexport) { llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); $h = 0; @@ -443,13 +430,11 @@ if ($step == 1 || !$datatoexport) print ''; print ''; - if (count($objexport->array_export_module)) - { + if (count($objexport->array_export_module)) { asort($objexport->array_export_code_for_sort); //var_dump($objexport->array_export_code_for_sort); //$sortedarrayofmodules = dol_sort_array($objexport->array_export_module, 'module_position', 'asc', 0, 0, 1); - foreach ($objexport->array_export_code_for_sort as $key => $value) - { + foreach ($objexport->array_export_code_for_sort as $key => $value) { print ''; + print ''; } } else { print ''; @@ -477,8 +462,7 @@ if ($step == 1 || !$datatoexport) print ''; } -if ($step == 2 && $datatoexport) -{ +if ($step == 2 && $datatoexport) { llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); $h = 0; @@ -505,14 +489,14 @@ if ($step == 2 && $datatoexport) print $objexport->array_export_module[0]->getName(); print ''; - // Lot de donnees a exporter - print ''; - print ''; + // Lot de donnees a exporter + print ''; + print ''; print '
    '; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { print $px1->show(); print "
    \n"; print $px2->show(); diff --git a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php index 9b2cd49faec..c27136ebd38 100644 --- a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php @@ -9,11 +9,9 @@ $permission = $user->rights->expensereport->creer; // We define var to enable the feature to add prefix of uploaded files $savingdocmask = ''; -if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) -{ +if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) { //var_dump($modulepart); - if (in_array($modulepart, array('facture_fournisseur', 'commande_fournisseur', 'facture', 'commande', 'propal', 'supplier_proposal', 'ficheinter', 'contract', 'expedition', 'project', 'project_task', 'expensereport', 'tax', 'produit', 'product_batch'))) - { + if (in_array($modulepart, array('facture_fournisseur', 'commande_fournisseur', 'facture', 'commande', 'propal', 'supplier_proposal', 'ficheinter', 'contract', 'expedition', 'project', 'project_task', 'expensereport', 'tax', 'produit', 'product_batch'))) { $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; } } @@ -35,6 +33,6 @@ $formfile->form_attach_new_file( 'accept', '', 1 - ); +); print '
    '; //print ''.$langs->trans("AttachTheNewLineToTheDocument").'
    '; $modulepart = 'expensereport'; $maxheightmini = 48; $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; $filei = 0; - foreach ($arrayoffiles as $file) - { + foreach ($arrayoffiles as $file) { $urlforhref = array(); $filei++; print '
    '; $fileinfo = pathinfo($file['fullname']); - if (image_format_supported($file['name']) > 0) - { + if (image_format_supported($file['name']) > 0) { $minifile = getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original //print $file['path'].'/'.$minifile.'
    '; $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); @@ -46,8 +42,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) $error = 0; $thumbshown = ''; - if (preg_match('/\.pdf$/i', $file['name'])) - { + if (preg_match('/\.pdf$/i', $file['name'])) { $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$file['name']; @@ -56,27 +51,26 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) $pdfexists = file_exists($filepdf); - if ($pdfexists) - { + if ($pdfexists) { // Conversion du PDF en image png si fichier png non existant - if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) - { - if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. - { + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { + if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experience trouble with pdf thumb generation and imagick, you can disable here. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } } } - if ($pdfexists && !$error) - { + if ($pdfexists && !$error) { $heightforphotref = 70; - if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60; + if (!empty($conf->dol_optimize_smallscreen)) { + $heightforphotref = 60; + } // If the preview file is found - if (file_exists($fileimage)) - { + if (file_exists($fileimage)) { $thumbshown = ''; } } @@ -98,10 +92,8 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) //var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']); // If a file was just uploaded, we check to preselect it if (is_array($_FILES['userfile']['name'])) { - foreach ($_FILES['userfile']['name'] as $tmpfile) - { - if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) - { + foreach ($_FILES['userfile']['name'] as $tmpfile) { + if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) { $checked = ' checked'; break; } elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile', 'array'))) { @@ -111,8 +103,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) } } // If we edit a line already linked, then $filenamelinked is defined to the filename (without path) of linked file - if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) - { + if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) { $checked = ' checked'; } print '
    '; diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index a0ef7c353c6..31c5526903b 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -18,8 +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; } @@ -35,13 +34,12 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $var = true; $total = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { ?>
    trans("ExpenseReport"); ?>getNomUrl(1); ?>getNomUrl(1); ?> date_debut, 'day'); ?> rights->expensereport->lire) { From d6ffdfe8356933665f8d2f4bf33c6c990b5c3f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 25 Feb 2021 22:50:40 +0100 Subject: [PATCH 105/173] code syntax exports externalsite directory --- htdocs/exports/class/export.class.php | 296 +++++++------- htdocs/exports/export.php | 431 +++++++++------------ htdocs/exports/index.php | 9 +- htdocs/externalsite/admin/externalsite.php | 13 +- htdocs/externalsite/frames.php | 31 +- 5 files changed, 364 insertions(+), 416 deletions(-) diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index e4725db3946..174a7271d25 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -96,50 +96,49 @@ class Export $modulesdir = dolGetModulesDirs(); - foreach ($modulesdir as $dir) - { + foreach ($modulesdir as $dir) { // Search available exports $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { + if (is_resource($handle)) { // Search module files - while (($file = readdir($handle)) !== false) - { + while (($file = readdir($handle)) !== false) { $reg = array(); - if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) - { + if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) { $modulename = $reg[1]; // Defined if module is enabled $enabled = true; $part = strtolower(preg_replace('/^mod/i', '', $modulename)); - if ($part == 'propale') $part = 'propal'; - if (empty($conf->$part->enabled)) $enabled = false; + if ($part == 'propale') { + $part = 'propal'; + } + if (empty($conf->$part->enabled)) { + $enabled = false; + } - if ($enabled) - { + if ($enabled) { // Loading Class $file = $dir.$modulename.".class.php"; $classname = $modulename; require_once $file; $module = new $classname($this->db); - if (isset($module->export_code) && is_array($module->export_code)) - { - foreach ($module->export_code as $r => $value) - { + if (isset($module->export_code) && is_array($module->export_code)) { + foreach ($module->export_code as $r => $value) { //print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).'
    '; - if ($filter && ($filter != $module->export_code[$r])) continue; + if ($filter && ($filter != $module->export_code[$r])) { + continue; + } // Test if condition to show are ok - if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) continue; + if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) { + continue; + } // Test if permissions are ok $bool = true; - if (isset($module->export_permission)) - { - foreach ($module->export_permission[$r] as $val) - { + if (isset($module->export_permission)) { + foreach ($module->export_permission[$r] as $val) { $perm = $val; //print_r("$perm[0]-$perm[1]-$perm[2]
    "); if (!empty($perm[2])) { @@ -147,8 +146,12 @@ class Export } else { $bool = isset($user->rights->{$perm[0]}->{$perm[1]}) ? $user->rights->{$perm[0]}->{$perm[1]} : false; } - if ($perm[0] == 'user' && $user->admin) $bool = true; - if (!$bool) break; + if ($perm[0] == 'user' && $user->admin) { + $bool = true; + } + if (!$bool) { + break; + } } } //print $bool." $perm[0]"."
    "; @@ -158,10 +161,8 @@ class Export // { // Charge fichier lang en rapport $langtoload = $module->getLangFilesArray(); - if (is_array($langtoload)) - { - foreach ($langtoload as $key) - { + if (is_array($langtoload)) { + foreach ($langtoload as $key) { $langs->load($key); } } @@ -234,12 +235,18 @@ class Export $i = 0; //print_r($array_selected); - foreach ($this->array_export_fields[$indice] as $key => $value) - { - if (!array_key_exists($key, $array_selected)) continue; // Field not selected - if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL - if ($i > 0) $sql .= ', '; - else $i++; + foreach ($this->array_export_fields[$indice] as $key => $value) { + if (!array_key_exists($key, $array_selected)) { + continue; // Field not selected + } + if (preg_match('/^none\./', $key)) { + continue; // A field that must not appears into SQL + } + if ($i > 0) { + $sql .= ', '; + } else { + $i++; + } if (strpos($key, ' as ') === false) { $newfield = $key.' as '.str_replace(array('.', '-', '(', ')'), '_', $key); @@ -252,14 +259,16 @@ class Export $sql .= $this->array_export_sql_end[$indice]; // Add the WHERE part. Filtering into sql if a filtering array is provided - if (is_array($array_filterValue) && !empty($array_filterValue)) - { + if (is_array($array_filterValue) && !empty($array_filterValue)) { $sqlWhere = ''; // Loop on each condition to add - foreach ($array_filterValue as $key => $value) - { - if (preg_match('/GROUP_CONCAT/i', $key)) continue; - if ($value != '') $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); + foreach ($array_filterValue as $key => $value) { + if (preg_match('/GROUP_CONCAT/i', $key)) { + continue; + } + if ($value != '') { + $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); + } } $sql .= $sqlWhere; } @@ -268,12 +277,12 @@ class Export $sql .= $this->array_export_sql_order[$indice]; // Add the HAVING part. - if (is_array($array_filterValue) && !empty($array_filterValue)) - { + if (is_array($array_filterValue) && !empty($array_filterValue)) { // Loop on each condition to add - foreach ($array_filterValue as $key => $value) - { - if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); + foreach ($array_filterValue as $key => $value) { + if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') { + $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); + } } } @@ -297,37 +306,41 @@ class Export // build the input field on depend of the type of file switch ($InfoFieldList[0]) { case 'Text': - if (!(strpos($ValueField, '%') === false)) + if (!(strpos($ValueField, '%') === false)) { $szFilterQuery .= " ".$NameField." LIKE '".$ValueField."'"; - else $szFilterQuery .= " ".$NameField." = '".$ValueField."'"; + } else { + $szFilterQuery .= " ".$NameField." = '".$ValueField."'"; + } break; case 'Date': - if (strpos($ValueField, "+") > 0) - { + if (strpos($ValueField, "+") > 0) { // mode plage $ValueArray = explode("+", $ValueField); $szFilterQuery = "(".$this->conditionDate($NameField, trim($ValueArray[0]), ">="); $szFilterQuery .= " AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")"; } else { - if (is_numeric(substr($ValueField, 0, 1))) + if (is_numeric(substr($ValueField, 0, 1))) { $szFilterQuery = $this->conditionDate($NameField, trim($ValueField), "="); - else $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1)); + } else { + $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1)); + } } break; case 'Duree': break; case 'Numeric': // si le signe - - if (strpos($ValueField, "+") > 0) - { + if (strpos($ValueField, "+") > 0) { // mode plage $ValueArray = explode("+", $ValueField); $szFilterQuery = "(".$NameField.">=".$ValueArray[0]; $szFilterQuery .= " AND ".$NameField."<=".$ValueArray[1].")"; } else { - if (is_numeric(substr($ValueField, 0, 1))) + if (is_numeric(substr($ValueField, 0, 1))) { $szFilterQuery = " ".$NameField."=".$ValueField; - else $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1); + } else { + $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1); + } } break; case 'Boolean': @@ -335,12 +348,14 @@ class Export break; case 'Status': case 'List': - if (is_numeric($ValueField)) + if (is_numeric($ValueField)) { $szFilterQuery = " ".$NameField."=".$ValueField; - else { - if (!(strpos($ValueField, '%') === false)) + } else { + if (!(strpos($ValueField, '%') === false)) { $szFilterQuery = " ".$NameField." LIKE '".$ValueField."'"; - else $szFilterQuery = " ".$NameField." = '".$ValueField."'"; + } else { + $szFilterQuery = " ".$NameField." = '".$ValueField."'"; + } } break; default: @@ -361,9 +376,13 @@ class Export public function conditionDate($Field, $Value, $Sens) { // TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN - if (strlen($Value) == 4) $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; - elseif (strlen($Value) == 6) $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; - else $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; + if (strlen($Value) == 4) { + $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; + } elseif (strlen($Value) == 6) { + $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; + } else { + $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; + } return $Condition; } @@ -385,8 +404,7 @@ class Export $InfoFieldList = explode(":", $TypeField); // build the input field on depend of the type of file - switch ($InfoFieldList[0]) - { + switch ($InfoFieldList[0]) { case 'Text': case 'Date': $szFilterField = ''; @@ -403,15 +421,21 @@ class Export case 'Boolean': $szFilterField = '"; break; @@ -422,51 +446,50 @@ class Export // 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list. // 4 : Name of element for getEntity(). - if (!empty($InfoFieldList[3])) + if (!empty($InfoFieldList[3])) { $keyList = $InfoFieldList[3]; - else $keyList = 'rowid'; + } else { + $keyList = 'rowid'; + } $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code'); - if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code'); - if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code'; + if ($InfoFieldList[1] == 'c_stcomm') { + $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code'); + } + if ($InfoFieldList[1] == 'c_country') { + $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code'; + } $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[1]; if (!empty($InfoFieldList[4])) { $sql .= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')'; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $szFilterField = '"; $this->db->free($resql); - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } break; } @@ -542,8 +567,7 @@ class Export dol_syslog(__METHOD__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected)); // Check parameters or context properties - if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) - { + if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) { $this->error = "ErrorBadParameter"; dol_syslog($this->error, LOG_ERR); return -1; @@ -556,22 +580,20 @@ class Export require_once $dir.$file; $objmodel = new $classname($this->db); - if (!empty($sqlquery)) $sql = $sqlquery; - else { + if (!empty($sqlquery)) { + $sql = $sqlquery; + } else { // Define value for indice from $datatoexport $foundindice = 0; - foreach ($this->array_export_code as $key => $dataset) - { - if ($datatoexport == $dataset) - { + foreach ($this->array_export_code as $key => $dataset) { + if ($datatoexport == $dataset) { $indice = $key; $foundindice++; //print "Found indice = ".$indice." for dataset=".$datatoexport."\n"; break; } } - if (empty($foundindice)) - { + if (empty($foundindice)) { $this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code"; return -1; } @@ -582,13 +604,11 @@ class Export $this->sqlusedforexport = $sql; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { //$this->array_export_label[$indice] if (!empty($conf->global->EXPORT_PREFIX_SPEC)) { $filename = $conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport; - } - else { + } else { $filename = "export_".$datatoexport; } $filename .= '.'.$objmodel->getDriverExtension(); @@ -600,55 +620,48 @@ class Export dol_mkdir($dirname); $result = $objmodel->open_file($dirname."/".$filename, $outputlangs); - if ($result >= 0) - { + if ($result >= 0) { // Genere en-tete $objmodel->write_header($outputlangs); // Genere ligne de titre $objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, isset($this->array_export_TypeFields[$indice]) ? $this->array_export_TypeFields[$indice] : null); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { // Process special operations - if (!empty($this->array_export_special[$indice])) - { - foreach ($this->array_export_special[$indice] as $key => $value) - { - if (!array_key_exists($key, $array_selected)) continue; // Field not selected + if (!empty($this->array_export_special[$indice])) { + foreach ($this->array_export_special[$indice] as $key => $value) { + if (!array_key_exists($key, $array_selected)) { + continue; // Field not selected + } // Operation NULLIFNEG - if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') - { + if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') { //$alias=$this->array_export_alias[$indice][$key]; $alias = str_replace(array('.', '-', '(', ')'), '_', $key); - if ($obj->$alias < 0) $obj->$alias = ''; - } - // Operation ZEROIFNEG - elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') - { + if ($obj->$alias < 0) { + $obj->$alias = ''; + } + } elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') { + // Operation ZEROIFNEG //$alias=$this->array_export_alias[$indice][$key]; $alias = str_replace(array('.', '-', '(', ')'), '_', $key); - if ($obj->$alias < 0) $obj->$alias = '0'; - } - // Operation GETNUMOPENDAYS (for Holiday module) - elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays') - { + if ($obj->$alias < 0) { + $obj->$alias = '0'; + } + } elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays') { + // Operation GETNUMOPENDAYS (for Holiday module) include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; //$alias=$this->array_export_alias[$indice][$key]; $alias = str_replace(array('.', '-', '(', ')'), '_', $key); $obj->$alias = num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code); - } - // Operation INVOICEREMAINTOPAY - elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay') - { + } elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay') { + // Operation INVOICEREMAINTOPAY //$alias=$this->array_export_alias[$indice][$key]; $alias = str_replace(array('.', '-', '(', ')'), '_', $key); $remaintopay = ''; - if ($obj->f_rowid > 0) - { + if ($obj->f_rowid > 0) { global $tmpobjforcomputecall; - if (!is_object($tmpobjforcomputecall)) - { + if (!is_object($tmpobjforcomputecall)) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $tmpobjforcomputecall = new Facture($this->db); } @@ -725,8 +738,7 @@ class Export dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -751,11 +763,9 @@ class Export dol_syslog("Export::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->model_name = $obj->label; $this->datatoexport = $obj->type; @@ -794,13 +804,13 @@ class Export 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -829,12 +839,10 @@ class Export $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $keyModel = array_search($obj->type, $this->array_export_code); print "
     
    '; //print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' '; print $objexport->array_export_module[$key]->getName(); @@ -466,7 +451,7 @@ if ($step == 1 || !$datatoexport) } else { print $langs->trans("NotEnoughPermissions"); } - print '
    '.$langs->trans("NoExportableData").'
    '.$langs->trans("DatasetToExport").''; - $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]); - $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); - print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; - print $objexport->array_export_label[0]; - print '
    '.$langs->trans("DatasetToExport").''; + $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]); + $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); + print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; + print $objexport->array_export_label[0]; + print '
    '; print '
    '; @@ -568,8 +552,7 @@ if ($step == 2 && $datatoexport) $i = 0; - foreach ($fieldsarray as $code=>$label) - { + foreach ($fieldsarray as $code => $label) { print ''; $i++; @@ -583,8 +566,7 @@ if ($step == 2 && $datatoexport) //print $code.'-'.$label.'-'.$entity; $tmparray = explode(':', $entityicon); - if (count($tmparray) >= 2) - { + if (count($tmparray) >= 2) { $entityicon = $tmparray[0]; $entitylang = $tmparray[1]; } @@ -595,27 +577,22 @@ if ($step == 2 && $datatoexport) $tablename = getablenamefromfield($code, $sqlmaxforexport); $htmltext = ''.$langs->trans("Name").": ".$text.'
    '; - if (!empty($objexport->array_export_special[0][$code])) - { + if (!empty($objexport->array_export_special[0][$code])) { $htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]."
    "; } else { $htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."
    "; } - if (!empty($objexport->array_export_examplevalues[0][$code])) - { + if (!empty($objexport->array_export_examplevalues[0][$code])) { $htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].'
    '; } - if (!empty($objexport->array_export_TypeFields[0][$code])) - { + if (!empty($objexport->array_export_TypeFields[0][$code])) { $htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].'
    '; } - if (!empty($objexport->array_export_help[0][$code])) - { + if (!empty($objexport->array_export_help[0][$code])) { $htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).'
    '; } - if (isset($array_selected[$code]) && $array_selected[$code]) - { + if (isset($array_selected[$code]) && $array_selected[$code]) { // Selected fields print ' '; print ''.img_left('default', 0, 'style="max-width: 20px"').''; @@ -642,15 +619,13 @@ if ($step == 2 && $datatoexport) print '
    '; /* - * Barre d'action - */ + * Barre d'action + */ print '
    '; - if (count($array_selected)) - { + if (count($array_selected)) { // If filters exist - if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) - { + if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { print ''.$langs->trans("NextStep").''; } else { print ''.$langs->trans("NextStep").''; @@ -662,10 +637,8 @@ if ($step == 2 && $datatoexport) print '
    '; } -if ($step == 3 && $datatoexport) -{ - if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired - { +if ($step == 3 && $datatoexport) { + if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired // Switch to step 2 header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport); exit; @@ -713,8 +686,7 @@ if ($step == 3 && $datatoexport) // Nbre champs exportes print ''.$langs->trans("ExportedFields").''; $list = ''; - foreach ($array_selected as $code=>$value) - { + foreach ($array_selected as $code => $value) { $list .= (!empty($list) ? ', ' : ''); $list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) : ''); } @@ -755,8 +727,7 @@ if ($step == 3 && $datatoexport) $i = 0; // on boucle sur les champs - foreach ($fieldsarray as $code => $label) - { + foreach ($fieldsarray as $code => $label) { print ''; $i++; @@ -767,8 +738,7 @@ if ($step == 3 && $datatoexport) print ''; // If value of entityicon=entitylang='icon:Label' $tmparray = explode(':', $entityicon); - if (count($tmparray) >= 2) - { + if (count($tmparray) >= 2) { $entityicon = $tmparray[0]; $entitylang = $tmparray[1]; } @@ -782,22 +752,18 @@ if ($step == 3 && $datatoexport) $tablename = getablenamefromfield($code, $sqlmaxforexport); $htmltext = ''.$langs->trans("Name").': '.$text.'
    '; - if (!empty($objexport->array_export_special[0][$code])) - { + if (!empty($objexport->array_export_special[0][$code])) { $htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]."
    "; } else { $htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."
    "; } - if (!empty($objexport->array_export_examplevalues[0][$code])) - { + if (!empty($objexport->array_export_examplevalues[0][$code])) { $htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].'
    '; } - if (!empty($objexport->array_export_TypeFields[0][$code])) - { + if (!empty($objexport->array_export_TypeFields[0][$code])) { $htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].'
    '; } - if (!empty($objexport->array_export_help[0][$code])) - { + if (!empty($objexport->array_export_help[0][$code])) { $htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).'
    '; } @@ -807,11 +773,9 @@ if ($step == 3 && $datatoexport) // Filter value print ''; - if (!empty($Typefieldsarray[$code])) // Example: Text, List:c_country:label:rowid, Number, Boolean - { + if (!empty($Typefieldsarray[$code])) { // Example: Text, List:c_country:label:rowid, Number, Boolean $szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]); - if ($szInfoFiltre) // Is there an info help for this filter ? - { + if ($szInfoFiltre) { // Is there an info help for this filter ? $tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter); print $form->textwithpicto($tmp, $szInfoFiltre); } else { @@ -837,10 +801,8 @@ if ($step == 3 && $datatoexport) print '
    '; } -if ($step == 4 && $datatoexport) -{ - if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired - { +if ($step == 4 && $datatoexport) { + if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired // Switch to step 2 header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport); exit; @@ -862,8 +824,7 @@ if ($step == 4 && $datatoexport) $h++; // If filters exist - if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) - { + if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; $head[$h][1] = $langs->trans("Step")." 3"; $h++; @@ -888,20 +849,19 @@ if ($step == 4 && $datatoexport) print $objexport->array_export_module[0]->getName(); print ''; - // Lot de donnees a exporter - print ''.$langs->trans("DatasetToExport").''; - print ''; + // Lot de donnees a exporter + print ''.$langs->trans("DatasetToExport").''; + print ''; $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]); $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); - print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; - print $objexport->array_export_label[0]; - print ''; + print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; + print $objexport->array_export_label[0]; + print ''; // List of exported fields print ''.$langs->trans("ExportedFields").''; $list = ''; - foreach ($array_selected as $code=>$value) - { + foreach ($array_selected as $code => $value) { $list .= (!empty($list) ? ', ' : ''); $list .= $langs->trans($objexport->array_export_fields[0][$code]); } @@ -909,19 +869,18 @@ if ($step == 4 && $datatoexport) print ''; // List of filtered fiels - if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) - { + if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { print ''.$langs->trans("FilteredFields").''; $list = ''; - if (!empty($array_filtervalue)) - { - foreach ($array_filtervalue as $code=>$value) - { - if (isset($objexport->array_export_fields[0][$code])) - { + if (!empty($array_filtervalue)) { + foreach ($array_filtervalue as $code => $value) { + if (isset($objexport->array_export_fields[0][$code])) { $list .= ($list ? ', ' : ''); - if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : ''); - else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) { + $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : ''); + } else { + $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'"; + } } } } @@ -949,8 +908,7 @@ if ($step == 4 && $datatoexport) //print ''.$langs->trans("FieldsTitle").''; print ''; - foreach ($array_selected as $code=>$value) - { + foreach ($array_selected as $code => $value) { print ''; $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]); @@ -960,8 +918,7 @@ if ($step == 4 && $datatoexport) print ''; // If value of entityicon=entitylang='icon:Label' $tmparray = explode(':', $entityicon); - if (count($tmparray) >= 2) - { + if (count($tmparray) >= 2) { $entityicon = $tmparray[0]; $entitylang = $tmparray[1]; } @@ -974,22 +931,18 @@ if ($step == 4 && $datatoexport) $tablename = getablenamefromfield($code, $sqlmaxforexport); $htmltext = ''.$langs->trans("Name").': '.$text.'
    '; - if (!empty($objexport->array_export_special[0][$code])) - { + if (!empty($objexport->array_export_special[0][$code])) { $htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]."
    "; } else { $htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."
    "; } - if (!empty($objexport->array_export_examplevalues[0][$code])) - { + if (!empty($objexport->array_export_examplevalues[0][$code])) { $htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].'
    '; } - if (!empty($objexport->array_export_TypeFields[0][$code])) - { + if (!empty($objexport->array_export_TypeFields[0][$code])) { $htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].'
    '; } - if (!empty($objexport->array_export_help[0][$code])) - { + if (!empty($objexport->array_export_help[0][$code])) { $htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).'
    '; } @@ -1001,8 +954,12 @@ if ($step == 4 && $datatoexport) print ''; print $value.' '; print ''; - if ($value < count($array_selected)) print ''.img_down().''; - if ($value > 1) print ''.img_up().''; + if ($value < count($array_selected)) { + print ''.img_down().''; + } + if ($value > 1) { + print ''.img_up().''; + } print ''; //print ' '; @@ -1017,13 +974,12 @@ if ($step == 4 && $datatoexport) print '
    '; /* - * Barre d'action - * - */ + * Barre d'action + * + */ print '
    '; - if (count($array_selected)) - { + if (count($array_selected)) { print ''.$langs->trans("NextStep").''; } @@ -1031,8 +987,7 @@ if ($step == 4 && $datatoexport) // Area for profils export - if (count($array_selected)) - { + if (count($array_selected)) { print '
    '; print '
    '; @@ -1062,15 +1017,15 @@ if ($step == 4 && $datatoexport) $sql = "SELECT rowid, label"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; $sql .= " WHERE type = '".$db->escape($datatoexport)."'"; - if (empty($conf->global->EXPORTS_SHARE_MODELS))$sql .= " AND fk_user=".$user->id; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { + $sql .= " AND fk_user=".$user->id; + } $sql .= " ORDER BY rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print $obj->label; @@ -1092,10 +1047,8 @@ if ($step == 4 && $datatoexport) } } -if ($step == 5 && $datatoexport) -{ - if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired - { +if ($step == 5 && $datatoexport) { + if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired // Switch to step 2 header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport); exit; @@ -1117,8 +1070,7 @@ if ($step == 5 && $datatoexport) $h++; // si le filtrage est parametre pour l'export ou pas - if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) - { + if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; $head[$h][1] = $langs->trans("Step")." 3"; $h++; @@ -1137,10 +1089,9 @@ if ($step == 5 && $datatoexport) print dol_get_fiche_head($head, $hselected, '', -2); /* - * Confirmation suppression fichier - */ - if ($action == 'remove_file') - { + * Confirmation suppression fichier + */ + if ($action == 'remove_file') { print $form->formconfirm($_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport.'&file='.urlencode(GETPOST("file")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } @@ -1156,39 +1107,37 @@ if ($step == 5 && $datatoexport) print $objexport->array_export_module[0]->getName(); print ''; - // Dataset to export - print ''.$langs->trans("DatasetToExport").''; - print ''; - $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]); - $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); - print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; - print $objexport->array_export_label[0]; - print ''; + // Dataset to export + print ''.$langs->trans("DatasetToExport").''; + print ''; + $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]); + $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); + print img_object($objexport->array_export_module[0]->getName(), $entityicon).' '; + print $objexport->array_export_label[0]; + print ''; // List of exported fields print ''.$langs->trans("ExportedFields").''; $list = ''; - foreach ($array_selected as $code=>$label) - { + foreach ($array_selected as $code => $label) { $list .= (!empty($list) ? ', ' : ''); $list .= $langs->trans($objexport->array_export_fields[0][$code]); } print ''.$list.''; // List of filtered fields - if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) - { + if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) { print ''.$langs->trans("FilteredFields").''; $list = ''; - if (!empty($array_filtervalue)) - { - foreach ($array_filtervalue as $code=>$value) - { - if (isset($objexport->array_export_fields[0][$code])) - { + if (!empty($array_filtervalue)) { + foreach ($array_filtervalue as $code => $value) { + if (isset($objexport->array_export_fields[0][$code])) { $list .= ($list ? ', ' : ''); - if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : ''); - else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) { + $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : ''); + } else { + $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'"; + } } } } @@ -1211,10 +1160,8 @@ if ($step == 5 && $datatoexport) $liste = $objmodelexport->liste_modeles($db); $listeall = $liste; - foreach ($listeall as $key => $val) - { - if (preg_match('/__\(Disabled\)__/', $listeall[$key])) - { + foreach ($listeall as $key => $val) { + if (preg_match('/__\(Disabled\)__/', $listeall[$key])) { $listeall[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $listeall[$key]); unset($liste[$key]); } @@ -1237,13 +1184,14 @@ if ($step == 5 && $datatoexport) print '
    '; - if ($sqlusedforexport && $user->admin) - { + if ($sqlusedforexport && $user->admin) { print info_admin($langs->trans("SQLUsedForExport").':
    '.$sqlusedforexport, 0, 0, 1, '', 'TechnicalInformation'); } - if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp); + if (!is_dir($conf->export->dir_temp)) { + dol_mkdir($conf->export->dir_temp); + } // Show existing generated documents // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste @@ -1273,8 +1221,9 @@ function getablenamefromfield($code, $sqlmaxforexport) $newsql = preg_replace('/^(.*) FROM /i', '', $newsql); // Remove part before the FROM $newsql = preg_replace('/WHERE (.*)$/i', '', $newsql); // Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE - if (preg_match($regexstring, $newsql, $reg)) - { + if (preg_match($regexstring, $newsql, $reg)) { return $reg[1]; // The tablename - } else return ''; + } else { + return ''; + } } diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index 79655a19b2f..3bff58453ab 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -48,8 +48,7 @@ print '
    '; print '
    '; -if (count($export->array_export_code)) -{ +if (count($export->array_export_code)) { print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', $user->rights->export->creer); } print '
    '; @@ -71,10 +70,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; $model = new ModeleExports($db); $liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties -foreach ($liste as $key => $val) -{ - if (preg_match('/__\(Disabled\)__/', $liste[$key])) - { +foreach ($liste as $key => $val) { + if (preg_match('/__\(Disabled\)__/', $liste[$key])) { $liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]); } diff --git a/htdocs/externalsite/admin/externalsite.php b/htdocs/externalsite/admin/externalsite.php index 66c6d265dec..47f0a3d57be 100644 --- a/htdocs/externalsite/admin/externalsite.php +++ b/htdocs/externalsite/admin/externalsite.php @@ -26,14 +26,17 @@ * \brief Page de configuration du module externalsite */ -if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test +if (!defined('NOSCANPOSTFORINJECTION')) { + define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'externalsite')); @@ -43,8 +46,7 @@ $def = array(); $action = GETPOST('action', 'aZ09'); // Sauvegardes parametres -if ($action == 'update') -{ +if ($action == 'update') { $i = 0; $db->begin(); @@ -55,8 +57,7 @@ if ($action == 'update') $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity); - if ($i >= 2) - { + if ($i >= 2) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { diff --git a/htdocs/externalsite/frames.php b/htdocs/externalsite/frames.php index 4827d832af4..04b48ba3cad 100644 --- a/htdocs/externalsite/frames.php +++ b/htdocs/externalsite/frames.php @@ -44,35 +44,29 @@ $keyforcontent = GETPOST('keyforcontent', 'aZ09'); * View */ -if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) -{ +if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) { llxHeader(); print '
    '.$langs->trans('ExternalSiteModuleNotComplete').'
    '; llxFooter(); exit; } -if (!empty($keyforcontent)) -{ +if (!empty($keyforcontent)) { llxHeader(); print '
    '; if (!preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent) - && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) - { + && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) { $langs->load("errors"); print $langs->trans("ErrorBadSyntaxForParamKeyForContent", 'EXTERNAL_SITE_CONTENT_', 'EXTERNAL_SITE_URL_'); - } elseif (empty($conf->global->$keyforcontent)) - { + } elseif (empty($conf->global->$keyforcontent)) { $langs->load("errors"); print $langs->trans("ErrorVariableKeyForContentMustBeSet", 'EXTERNAL_SITE_CONTENT_'.$keyforcontent, 'EXTERNAL_SITE_URL_'.$keyforcontent); } else { - if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) - { + if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) { print $conf->global->$keyforcontent; - } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) - { + } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) { /*print " @@ -80,17 +74,17 @@ if (!empty($keyforcontent)) global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0> - + "; print ''; print " - - <body> + <noframes> + <body> - </body> - + + @@ -111,8 +105,7 @@ if (!empty($keyforcontent)) print '<div>'; llxFooter(); } else { - if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) - { + if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) { print " <html> <head> From fb07484d3fe03b58af40dd758426532edd29c19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Thu, 25 Feb 2021 23:00:32 +0100 Subject: [PATCH 106/173] code syntax fichinter directory --- .../fichinter/admin/fichinter_extrafields.php | 17 +- .../admin/fichinterdet_extrafields.php | 17 +- htdocs/fichinter/card-rec.php | 89 ++- htdocs/fichinter/card.php | 695 ++++++++---------- .../class/api_interventions.class.php | 102 +-- htdocs/fichinter/class/fichinter.class.php | 406 +++++----- htdocs/fichinter/class/fichinterrec.class.php | 57 +- .../fichinter/class/fichinterstats.class.php | 34 +- htdocs/fichinter/contact.php | 57 +- htdocs/fichinter/document.php | 28 +- htdocs/fichinter/index.php | 154 ++-- htdocs/fichinter/info.php | 16 +- htdocs/fichinter/list.php | 405 ++++++---- htdocs/fichinter/note.php | 13 +- htdocs/fichinter/stats/index.php | 70 +- .../fichinter/tpl/linkedobjectblock.tpl.php | 16 +- 16 files changed, 1138 insertions(+), 1038 deletions(-) diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 0fa5a930f05..2fec51a0f5b 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -39,13 +39,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'fichinter'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -77,8 +81,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -104,8 +106,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index f648548c3b4..1cbdeb4cf0a 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -39,13 +39,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'fichinterdet'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +82,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +107,7 @@ if ($action == 'create') /* Edition d'un champ optionnel */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index bee9ac1c9fe..775f83ef500 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -52,22 +52,29 @@ $langs->loadLangs(array("interventions", "admin", "compta", "bills")); // Security check $id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int')); $action = GETPOST('action', 'aZ09'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $objecttype = 'fichinter_rec'; -if ($action == "create" || $action == "add") $objecttype = ''; +if ($action == "create" || $action == "add") { + $objecttype = ''; +} $result = restrictedArea($user, 'ficheinter', $id, $objecttype); -if ($page == -1) +if ($page == -1) { $page = 0; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -if ($sortorder == "") +if ($sortorder == "") { $sortorder = "DESC"; +} -if ($sortfield == "") +if ($sortfield == "") { $sortfield = "f.datec"; +} $object = new FichinterRec($db); $extrafields = new ExtraFields($db); @@ -212,7 +219,9 @@ if ($action == 'add') { // Set next date of execution $object->fetch($id); $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); - if (!empty($date)) $object->setNextDate($date); + if (!empty($date)) { + $object->setNextDate($date); + } } elseif ($action == 'setnb_gen_max' && $user->rights->ficheinter->creer) { // Set max period $object->fetch($id); @@ -261,8 +270,12 @@ if ($action == 'create') { print dol_get_fiche_head(); $rowspan = 4; - if (!empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++; - if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++; + if (!empty($conf->projet->enabled) && $object->fk_project > 0) { + $rowspan++; + } + if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) { + $rowspan++; + } print '<table class="border centpercent">'; @@ -595,9 +608,11 @@ if ($action == 'create') { print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '</tr></table></form>'; } else { - if ($object->frequency > 0) + if ($object->frequency > 0) { print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); - else print $langs->trans("NotARecurringInterventionalTemplate"); + } else { + print $langs->trans("NotARecurringInterventionalTemplate"); + } } print '</td></tr>'; @@ -619,12 +634,16 @@ if ($action == 'create') { print '<tr><td>'; if ($user->rights->ficheinter->creer && ($action == 'nb_gen_max' || $object->frequency > 0)) { print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); - } else print $langs->trans("MaxPeriodNumber"); + } else { + print $langs->trans("MaxPeriodNumber"); + } print '</td><td>'; if ($action == 'nb_gen_max' || $object->frequency > 0) { print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); - } else print ''; + } else { + print ''; + } print '</td>'; print '</tr>'; @@ -688,13 +707,19 @@ if ($action == 'create') { $i = 0; while ($i < $num) { // Show product and description - if (isset($object->lines[$i]->product_type)) + if (isset($object->lines[$i]->product_type)) { $type = $object->lines[$i]->product_type; - else $object->lines[$i]->fk_product_type; + } else { + $object->lines[$i]->fk_product_type; + } // Try to enhance type detection using date_start and date_end for free lines when type // was not saved. - if (!empty($objp->date_start)) $type = 1; - if (!empty($objp->date_end)) $type = 1; + if (!empty($objp->date_start)) { + $type = 1; + } + if (!empty($objp->date_end)) { + $type = 1; + } // Show line print '<tr class="oddeven">'; @@ -727,7 +752,9 @@ if ($action == 'create') { print $langs->trans('Delete').'</a></div>'; } print '</div>'; - } else print $langs->trans("ErrorRecordNotFound"); + } else { + print $langs->trans("ErrorRecordNotFound"); + } } else { /* * List mode @@ -743,14 +770,24 @@ if ($action == 'create') { } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($search_ref) $sql .= natural_search('f.titre', $search_ref); - if ($search_societe) $sql .= natural_search('s.nom', $search_societe); - if ($search_frequency == '1') $sql .= ' AND f.frequency > 0'; - if ($search_frequency == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; + if ($search_ref) { + $sql .= natural_search('f.titre', $search_ref); + } + if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); + } + if ($search_frequency == '1') { + $sql .= ' AND f.frequency > 0'; + } + if ($search_frequency == '0') { + $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; + } //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; @@ -855,8 +892,12 @@ if ($action == 'create') { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=createfrommodel'; print '&socid='.$objp->socid.'&id='.$objp->fich_rec.'">'; print $langs->trans("CreateFichInter").'</a>'; - } else print $langs->trans("DateIsNotEnough"); - } else print "&nbsp;"; + } else { + print $langs->trans("DateIsNotEnough"); + } + } else { + print "&nbsp;"; + } print "</td>"; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 6c1dd4ddeb2..d1507d52418 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -36,18 +36,15 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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'; } -if ($conf->contrat->enabled) -{ +if ($conf->contrat->enabled) { require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php"; require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"; } -if (!empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) -{ +if (!empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) { require_once DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php'; } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -75,7 +72,9 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -87,11 +86,14 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); - if ($ret > 0) $ret = $object->fetch_thirdparty(); - if ($ret < 0) dol_print_error('', $object->error); + if ($ret > 0) { + $ret = $object->fetch_thirdparty(); + } + if ($ret < 0) { + dol_print_error('', $object->error); + } } $permissionnote = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php @@ -106,14 +108,13 @@ $error = 0; $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -125,20 +126,16 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer) - { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer) { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - if ($object->id > 0) - { + if ($object->id > 0) { // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; $result = $object->createFromClone($user, $socid); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { @@ -150,21 +147,21 @@ if (empty($reshook)) } } - if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) - { + if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $result = $object->setValid($user); - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -178,15 +175,17 @@ if (empty($reshook)) } } elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $result = $object->setDraft($user); - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -212,16 +211,13 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); - if ($object->socid > 0) - { + if ($object->socid > 0) { // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $regs = array(); $element = $subelement = GETPOST('origin', 'alphanohtml'); - if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) - { + if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) { $element = $regs[1]; $subelement = $regs[2]; } @@ -242,8 +238,7 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) - { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } @@ -261,8 +256,7 @@ if (empty($reshook)) $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); @@ -270,12 +264,10 @@ if (empty($reshook)) dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { + if ($result > 0) { $srcobject->fetch_thirdparty(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } @@ -283,9 +275,10 @@ if (empty($reshook)) if (is_array($lines)) { $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) { + continue; // Skip unselected lines + } $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT); @@ -293,8 +286,7 @@ if (empty($reshook)) $duration = 3600; // Default to one hour // Predefined products & services - if ($lines[$i]->fk_product > 0) - { + if ($lines[$i]->fk_product > 0) { $prod = new Product($db); $prod->id = $lines[$i]->fk_product; @@ -305,8 +297,12 @@ if (empty($reshook)) $prod->fetch($lines[$i]->fk_product); $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $srcobject->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -367,12 +363,11 @@ if (empty($reshook)) $id, $desc, $date_intervention, - $duration, - $array_options + $duration, + $array_options ); - if ($result < 0) - { + if ($result < 0) { $error++; break; } @@ -395,16 +390,14 @@ if (empty($reshook)) $action = 'create'; } - if (!$error) - { + if (!$error) { // Extrafields $array_options = $extrafields->getOptionalsFromPost($object->table_element); $object->array_options = $array_options; $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { $id = $result; // Force raffraichissement sur fiche venant d'etre cree } else { $langs->load("errors"); @@ -429,22 +422,19 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Set into a project - elseif ($action == 'classin' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'classin' && $user->rights->ficheinter->creer) { + // Set into a project $result = $object->setProject(GETPOST('projectid', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - } - - // Set into a contract - elseif ($action == 'setcontract' && $user->rights->contrat->creer) - { + if ($result < 0) { + dol_print_error($db, $object->error); + } + } elseif ($action == 'setcontract' && $user->rights->contrat->creer) { + // Set into a contract $result = $object->set_contrat($user, GETPOST('contratid', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) - { + if ($result < 0) { + dol_print_error($db, $object->error); + } + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) { $result = $object->delete($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -452,32 +442,26 @@ if (empty($reshook)) header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1'); exit; - } elseif ($action == 'setdescription' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'setdescription' && $user->rights->ficheinter->creer) { $result = $object->set_description($user, GETPOST('description')); - if ($result < 0) dol_print_error($db, $object->error); - } - - // Add line - elseif ($action == "addline" && $user->rights->ficheinter->creer) - { - if (!GETPOST('np_desc', 'restricthtml') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) - { + if ($result < 0) { + dol_print_error($db, $object->error); + } + } elseif ($action == "addline" && $user->rights->ficheinter->creer) { + // Add line + if (!GETPOST('np_desc', 'restricthtml') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")); $error++; } - if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) - { + if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration")); $error++; } - if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour', 'int') >= 24 && GETPOST('durationmin', 'int') > 0) - { + if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour', 'int') >= 24 && GETPOST('durationmin', 'int') > 0) { $mesg = $langs->trans("ErrorValueTooHigh"); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $desc = GETPOST('np_desc', 'restricthtml'); @@ -500,19 +484,23 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if ($result >= 0) - { + if ($result >= 0) { $db->commit(); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + fichinter_create($db, $object, $object->model_pdf, $outputlangs); + } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { @@ -520,11 +508,8 @@ if (empty($reshook)) $db->rollback(); } } - } - - // Classify Billed - elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) { + // Classify Billed $result = $object->setStatut(2); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -532,61 +517,42 @@ if (empty($reshook)) } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Classify unbilled - elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) { + // Classify unbilled $result = $object->setStatut(1); - if ($result > 0) - { + if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; } - } - - // Classify Done - elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) { + // Classify Done $result = $object->setStatut(3); - if ($result > 0) - { + if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Reopen - elseif ($action == 'confirm_reopen' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'confirm_reopen' && $user->rights->ficheinter->creer) { + // Reopen $result = $object->setStatut(Fichinter::STATUS_VALIDATED); - if ($result > 0) - { + if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; - } - else { + } else { $mesg = $object->error; } - } - - /* - * Mise a jour d'une ligne d'intervention - */ - elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) { + } elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) { + // Mise a jour d'une ligne d'intervention $objectline = new FichinterLigne($db); - if ($objectline->fetch($lineid) <= 0) - { + if ($objectline->fetch($lineid) <= 0) { dol_print_error($db); exit; } - if ($object->fetch($objectline->fk_fichinter) <= 0) - { + if ($object->fetch($objectline->fk_fichinter) <= 0) { dol_print_error($db); exit; } @@ -606,8 +572,7 @@ if (empty($reshook)) $objectline->array_options = $array_options; $result = $objectline->update($user); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); exit; } @@ -615,34 +580,32 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + fichinter_create($db, $object, $object->model_pdf, $outputlangs); + } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; - } - - /* - * Supprime une ligne d'intervention AVEC confirmation - */ - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) { + // Supprime une ligne d'intervention AVEC confirmation $objectline = new FichinterLigne($db); - if ($objectline->fetch($lineid) <= 0) - { + if ($objectline->fetch($lineid) <= 0) { dol_print_error($db); exit; } $result = $objectline->deleteline($user); - if ($object->fetch($objectline->fk_fichinter) <= 0) - { + if ($object->fetch($objectline->fk_fichinter) <= 0) { dol_print_error($db); exit; } @@ -650,52 +613,61 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); - } - - /* - * Set position of lines - */ - elseif ($action == 'up' && $user->rights->ficheinter->creer) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + fichinter_create($db, $object, $object->model_pdf, $outputlangs); + } + } elseif ($action == 'up' && $user->rights->ficheinter->creer) { + // Set position of lines $object->line_up($lineid); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + fichinter_create($db, $object, $object->model_pdf, $outputlangs); + } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; - } elseif ($action == 'down' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'down' && $user->rights->ficheinter->creer) { $object->line_down($lineid); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + fichinter_create($db, $object, $object->model_pdf, $outputlangs); + } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; @@ -715,66 +687,55 @@ if (empty($reshook)) $permissiontoadd = $user->rights->ficheinter->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('INTERVENTION_MODIFY'); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) - { - if ($action == 'addcontact') - { - if ($result > 0 && $id > 0) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) { + if ($action == 'addcontact') { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); } else { $mesg = $object->error; } } - } - - // bascule du statut d'un contact - elseif ($action == 'swapstatut') - { + } elseif ($action == 'swapstatut') { + // bascule du statut d'un contact $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } - - // Efface un contact - elseif ($action == 'deletecontact') - { + } elseif ($action == 'deletecontact') { + // Efface un contact $result = $object->delete_contact(GETPOST('lineid', 'int')); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -791,13 +752,16 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); -if ($conf->contrat->enabled) $formcontract = new FormContract($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if ($conf->contrat->enabled) { + $formcontract = new FormContract($db); +} +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} llxHeader('', $langs->trans("Intervention")); -if ($action == 'create') -{ +if ($action == 'create') { // Create new intervention $soc = new Societe($db); @@ -810,21 +774,20 @@ if ($action == 'create') dol_htmloutput_mesg($mesg); } - if ($socid) $res = $soc->fetch($socid); + if ($socid) { + $res = $soc->fetch($socid); + } - if (GETPOST('origin', 'alphanohtml') && GETPOST('originid', 'int')) - { + if (GETPOST('origin', 'alphanohtml') && GETPOST('originid', 'int')) { // Parse element/subelement (ex: project_task) $regs = array(); $element = $subelement = GETPOST('origin', 'alphanohtml'); - if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) - { + if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) { $element = $regs[1]; $subelement = $regs[2]; } - if ($element == 'project') - { + if ($element == 'project') { $projectid = GETPOST('originid', 'int'); } else { // For compatibility @@ -843,8 +806,7 @@ if ($action == 'create') $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch(GETPOST('originid')); - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) - { + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); $lines = $objectsrc->lines; } @@ -864,8 +826,7 @@ if ($action == 'create') $projectid = GETPOST('projectid', 'int'); } - if (!$conf->global->FICHEINTER_ADDON) - { + if (!$conf->global->FICHEINTER_ADDON) { dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); exit; } @@ -878,8 +839,7 @@ if ($action == 'create') //$modFicheinter = new $obj; //$numpr = $modFicheinter->getNextValue($soc, $object); - if ($socid > 0) - { + if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); @@ -904,35 +864,31 @@ if ($action == 'create') print '</td></tr>'; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load("project"); print '<tr><td>'.$langs->trans("Project").'</td><td>'; /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty - if ($societe->fournisseur==1) - $numprojet=select_projects(-1,$_POST["projectid"],'projectid'); - else - $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); - */ + if ($societe->fournisseur==1) + $numprojet=select_projects(-1,$_POST["projectid"],'projectid'); + else + $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); + */ $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid'); - if ($numprojet == 0) - { + if ($numprojet == 0) { print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>'; } print '</td></tr>'; } // Contract - if ($conf->contrat->enabled) - { + if ($conf->contrat->enabled) { $langs->load("contracts"); print '<tr><td>'.$langs->trans("Contract").'</td><td>'; $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1, 1); - if ($numcontrat == 0) - { + if ($numcontrat == 0) { print ' &nbsp; <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddContract").'"></span></a>'; } print '</td></tr>'; @@ -956,8 +912,7 @@ if ($action == 'create') print '</td></tr>'; // Private note - if (empty($user->socid)) - { + if (empty($user->socid)) { print '<tr>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td>'; @@ -971,47 +926,46 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } // Show link to origin object - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) - { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $newclassname = $classname; - if ($newclassname == 'Propal') $newclassname = 'CommercialProposal'; + if ($newclassname == 'Propal') { + $newclassname = 'CommercialProposal'; + } print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; // Amount /* Hide amount because we only copy services so amount may differ than source - print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE - { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>"; - } + print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>'; + print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>"; + } - if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF - { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>"; - } + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>"; + } - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>"; + print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>"; - if (!empty($conf->multicurrency->enabled)) - { - print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>"; - print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; - } - */ + if (!empty($conf->multicurrency->enabled)) + { + print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; + print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>"; + print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; + } + */ } print '</table>'; - if (is_object($objectsrc)) - { + if (is_object($objectsrc)) { print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; } elseif ($origin == 'project' && !empty($projectid)) { @@ -1045,8 +999,7 @@ if ($action == 'create') print dol_get_fiche_head(''); - if (is_object($objectsrc)) - { + if (is_object($objectsrc)) { print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; } elseif ($origin == 'project' && !empty($projectid)) { @@ -1070,11 +1023,10 @@ if ($action == 'create') print '</form>'; } -} elseif ($id > 0 || !empty($ref)) -{ +} elseif ($id > 0 || !empty($ref)) { /* * Affichage en mode visu - */ + */ $object->fetch($id, $ref); $object->fetch_thirdparty(); @@ -1095,21 +1047,17 @@ if ($action == 'create') $formconfirm = ''; // Confirm deletion of intervention - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete', '', 0, 1); } // Confirm validation - if ($action == 'validate') - { + if ($action == 'validate') { // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') - { + if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); - if (empty($numref)) - { + if (empty($numref)) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } @@ -1122,20 +1070,17 @@ if ($action == 'create') } // Confirm back to draft - if ($action == 'modify') - { + if ($action == 'modify') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify', '', 0, 1); } // Confirm back to open - if ($action == 'reopen') - { + if ($action == 'reopen') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Reopen'), $langs->trans('ConfirmReopenIntervention', $object->ref), 'confirm_reopen', '', 0, 1); } // Confirm deletion of line - if ($action == 'ask_deleteline') - { + if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline', '', 0, 1); } @@ -1153,12 +1098,14 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (!$formconfirm) - { + if (!$formconfirm) { $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } } // Print form confirm @@ -1176,12 +1123,10 @@ if ($action == 'create') // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->ficheinter->creer) - { + if ($user->rights->ficheinter->creer) { if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; } @@ -1219,8 +1164,7 @@ if ($action == 'create') print '<table class="border tableforfield" width="100%">'; - if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) - { + if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) { // Date Start print '<tr><td class="titlefield">'.$langs->trans("Dateo").'</td>'; print '<td>'; @@ -1252,8 +1196,7 @@ if ($action == 'create') print '</tr>'; // Contract - if ($conf->contrat->enabled) - { + if ($conf->contrat->enabled) { $langs->load('contracts'); print '<tr>'; print '<td>'; @@ -1261,21 +1204,18 @@ if ($action == 'create') print '<table class="nobordernopadding centpercent"><tr><td>'; print $langs->trans('Contract'); print '</td>'; - if ($action != 'contrat') - { + if ($action != 'contrat') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=contrat&amp;id='.$object->id.'">'; print img_edit($langs->trans('SetContract'), 1); print '</a></td>'; } print '</tr></table>'; print '</td><td>'; - if ($action == 'contrat') - { + if ($action == 'contrat') { $formcontract = new Formcontract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); } else { - if ($object->fk_contrat) - { + if ($object->fk_contrat) { $contratstatic = new Contrat($db); $contratstatic->fetch($object->fk_contrat); //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>'; @@ -1301,8 +1241,7 @@ if ($action == 'create') print '<table class="border tableforfield centpercent">'; - if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) - { + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { // Duration print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>'; print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; @@ -1318,23 +1257,20 @@ if ($action == 'create') print '<div class="clearboth"></div><br>'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } // Line of interventions - if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) - { + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; @@ -1356,13 +1292,11 @@ if ($action == 'create') $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { + if ($num) { print '<br>'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; @@ -1404,8 +1338,7 @@ if ($action == 'create') print "</td>\n"; // Icon to edit and delete - if ($object->statut == 0 && $user->rights->ficheinter->creer) - { + if ($object->statut == 0 && $user->rights->ficheinter->creer) { print '<td class="center">'; print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;line_id='.$objp->rowid.'#'.$objp->rowid.'">'; print img_edit(); @@ -1414,16 +1347,13 @@ if ($action == 'create') print img_delete(); print '</a></td>'; print '<td class="center">'; - if ($num > 1) - { - if ($i > 0) - { + if ($num > 1) { + if ($i > 0) { print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=up&amp;line_id='.$objp->rowid.'">'; print img_up(); print '</a>'; } - if ($i < $num - 1) - { + if ($i < $num - 1) { print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=down&amp;line_id='.$objp->rowid.'">'; print img_down(); print '</a>'; @@ -1447,8 +1377,7 @@ if ($action == 'create') } // Line in update mode - if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id', 'int') == $objp->rowid) - { + if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id', 'int') == $objp->rowid) { print '<tr class="oddeven nohover">'; // No. @@ -1478,8 +1407,9 @@ if ($action == 'create') print '<td class="right">'; if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) { $selectmode = 'select'; - if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) + if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) { $selectmode = 'text'; + } $form->select_duration('duration', $objp->duree, 0, $selectmode); } print '</td>'; @@ -1504,10 +1434,8 @@ if ($action == 'create') $db->free($resql); // Add new line - if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) - { - if (!$num) - { + if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) { + if (!$num) { print '<br>'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; @@ -1522,7 +1450,7 @@ if ($action == 'create') print $langs->trans('Description').'</td>'; print '<td class="center">'.$langs->trans('Date').'</td>'; print '<td class="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').'</td>'; - print '<td colspan="3">&nbsp;</td>'; + print '<td colspan="3">&nbsp;</td>'; print "</tr>\n"; } @@ -1580,16 +1508,20 @@ if ($action == 'create') print $lineadd->showOptionals($extrafields, 'edit', array('colspan'=>5)); - if (!$num) print '</table>'; + if (!$num) { + print '</table>'; + } } - if ($num) print '</table>'; + if ($num) { + print '</table>'; + } } else { dol_print_error($db); } print '</form>'."\n"; - } + } print dol_get_fiche_end(); @@ -1605,10 +1537,8 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { - if ($user->socid == 0) - { + if (empty($reshook)) { + if ($user->socid == 0) { if ($action != 'editdescription' && ($action != 'presend')) { // Validate if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) { @@ -1619,31 +1549,33 @@ if ($action == 'create') } // Modify - if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) - { + if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">'; - if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify"); - else print $langs->trans("SetToDraft"); + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { + print $langs->trans("Modify"); + } else { + print $langs->trans("SetToDraft"); + } print '</a></div>'; } // Reopen - if ($object->statut >= Fichinter::STATUS_CLOSED) - { - if ($user->rights->ficheinter->creer) - { + if ($object->statut >= Fichinter::STATUS_CLOSED) { + if ($user->rights->ficheinter->creer) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans('Reopen').'</a></div>'; - } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Reopen').'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Reopen').'</a></div>'; + } } // Send if (empty($user->socid)) { - if ($object->statut > Fichinter::STATUS_DRAFT) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) - { + if ($object->statut > Fichinter::STATUS_DRAFT) { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; - } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; + } } } @@ -1655,30 +1587,30 @@ if ($action == 'create') } // Proposal - if ($conf->service->enabled && !empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) - { + if ($conf->service->enabled && !empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); - if ($object->statut < Fichinter::STATUS_BILLED) - { - if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>'; - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>'; + if ($object->statut < Fichinter::STATUS_BILLED) { + if ($user->rights->propal->creer) { + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>'; + } } } // Invoicing - if (!empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT) - { + if (!empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("bills"); - if ($object->statut < Fichinter::STATUS_BILLED) - { - if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>'; - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>'; + if ($object->statut < Fichinter::STATUS_BILLED) { + if ($user->rights->facture->creer) { + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>'; + } } - if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 - { - if ($object->statut != Fichinter::STATUS_BILLED) - { + if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + if ($object->statut != Fichinter::STATUS_BILLED) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyunbilled">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>'; @@ -1687,8 +1619,7 @@ if ($action == 'create') } // Done - if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) - { + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>'; } @@ -1698,8 +1629,7 @@ if ($action == 'create') } // Delete - if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) - { + if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'"'; print '>'.$langs->trans('Delete').'</a></div>'; } @@ -1709,8 +1639,7 @@ if ($action == 'create') print '</div>'; - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; /* diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 7046a61e2d5..a5ba127a54d 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -32,7 +32,7 @@ class Interventions extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'socid', 'fk_project', 'description', @@ -41,7 +41,7 @@ class Interventions extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDSLINE = array( + public static $FIELDSLINE = array( 'description', 'date', 'duree', @@ -117,27 +117,37 @@ class Interventions 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) + 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."fichinter 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('intervention').')'; - 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 + 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) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -146,8 +156,7 @@ class Interventions extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -158,13 +167,11 @@ class Interventions extends DolibarrApi dol_syslog("API Rest request"); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $fichinter_static = new Fichinter($this->db); if ($fichinter_static->fetch($obj->rowid)) { @@ -216,28 +223,28 @@ class Interventions extends DolibarrApi * @return int */ /* TODO - public function getLines($id) - { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + public function getLines($id) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->fichinter->getLinesArray(); - $result = array(); - foreach ($this->fichinter->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; - } - */ + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ /** * Add a line to given intervention @@ -270,11 +277,11 @@ class Interventions extends DolibarrApi } $updateRes = $this->fichinter->addLine( - DolibarrApiAccess::$user, - $id, - $this->fichinter->description, - $this->fichinter->date, - $this->fichinter->duree + DolibarrApiAccess::$user, + $id, + $this->fichinter->description, + $this->fichinter->date, + $this->fichinter->duree ); if ($updateRes > 0) { @@ -369,8 +376,7 @@ class Interventions extends DolibarrApi */ public function closeFichinter($id) { - if (!DolibarrApiAccess::$user->rights->ficheinter->creer) - { + if (!DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); } $result = $this->fichinter->fetch($id); @@ -408,8 +414,9 @@ class Interventions extends DolibarrApi { $fichinter = array(); foreach (Interventions::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $fichinter[$field] = $data[$field]; } return $fichinter; @@ -447,8 +454,9 @@ class Interventions extends DolibarrApi { $fichinter = array(); foreach (Interventions::$FIELDSLINE as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $fichinter[$field] = $data[$field]; } return $fichinter; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 39ac094132a..cea1b1ca48c 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -204,8 +204,7 @@ class Fichinter extends CommonObject $sql = "SELECT count(fi.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as fi"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -213,10 +212,8 @@ class Fichinter extends CommonObject $sql .= " ".$clause." fi.entity IN (".getEntity('intervention').")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["interventions"] = $obj->nb; } $this->db->free($resql); @@ -244,21 +241,20 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::create ref=".$this->ref); // Check parameters - if (!empty($this->ref)) // We check that ref is not already used - { + if (!empty($this->ref)) { // We check that ref is not already used $result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used - if ($result > 0) - { + if ($result > 0) { $this->error = 'ErrorRefAlreadyExists'; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); $this->db->rollback(); return -1; } } - if (!is_numeric($this->duration)) $this->duration = 0; + if (!is_numeric($this->duration)) { + $this->duration = 0; + } - if ($this->socid <= 0) - { + if ($this->socid <= 0) { $this->error = 'ErrorBadParameterForFunc'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; @@ -304,42 +300,42 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); - if ($this->id) - { + if ($this->id) { $this->ref = '(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } // Add linked object - if (!$error && $this->origin && $this->origin_id) - { + if (!$error && $this->origin && $this->origin_id) { $ret = $this->add_object_linked(); - if (!$ret) dol_print_error($this->db); + if (!$ret) { + dol_print_error($this->db); + } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('FICHINTER_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -370,14 +366,14 @@ class Fichinter extends CommonObject { global $conf; - if (!is_numeric($this->duration)) { - $this->duration = 0; - } - if (!dol_strlen($this->fk_project)) { - $this->fk_project = 0; - } + if (!is_numeric($this->duration)) { + $this->duration = 0; + } + if (!dol_strlen($this->fk_project)) { + $this->fk_project = 0; + } - $error = 0; + $error = 0; $this->db->begin(); @@ -391,22 +387,20 @@ class Fichinter extends CommonObject $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!$error) - { + if ($this->db->query($sql)) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('FICHINTER_MODIFY', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; $this->db->rollback(); return -1; + } // End call triggers } @@ -437,14 +431,14 @@ class Fichinter extends CommonObject if ($ref) { $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.ref='".$this->db->escape($ref)."'"; - } else $sql .= " WHERE f.rowid=".$rowid; + } else { + $sql .= " WHERE f.rowid=".$rowid; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -470,7 +464,9 @@ class Fichinter extends CommonObject $this->extraparams = (array) json_decode($obj->extraparams, true); - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == 0) { + $this->brouillon = 1; + } // Retrieve extrafields $this->fetch_optionals(); @@ -479,8 +475,7 @@ class Fichinter extends CommonObject * Lines */ $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { return -3; } $this->db->free($resql); @@ -505,8 +500,7 @@ class Fichinter extends CommonObject $error = 0; // Protection - if ($this->statut <= self::STATUS_DRAFT) - { + if ($this->statut <= self::STATUS_DRAFT) { return 0; } @@ -519,8 +513,7 @@ class Fichinter extends CommonObject $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { if (!$error) { $this->oldcopy = clone $this; } @@ -528,7 +521,9 @@ class Fichinter extends CommonObject if (!$error) { // Call trigger $result = $this->call_trigger('FICHINTER_UNVALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { @@ -560,15 +555,13 @@ class Fichinter extends CommonObject $error = 0; - if ($this->statut != 1) - { + if ($this->statut != 1) { $this->db->begin(); $now = dol_now(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef($this->thirdparty); } else { $num = $this->ref; @@ -586,51 +579,48 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::setValid", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('FICHINTER_VALIDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + if (preg_match('/^[\(]?PROV/i', $this->ref)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // 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 = 'ficheinter/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$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($num); $dirsource = $conf->ficheinter->dir_output.'/'.$oldref; $dirdest = $conf->ficheinter->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -643,8 +633,7 @@ class Fichinter extends CommonObject } // Set new ref and define current statut - if (!$error) - { + if (!$error) { $this->ref = $num; $this->statut = 1; $this->brouillon = 0; @@ -740,8 +729,7 @@ class Fichinter extends CommonObject { // phpcs:enable // Init/load array of translation of status - if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) - { + if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) { global $langs; $langs->load("fichinter"); @@ -785,19 +773,20 @@ class Fichinter extends CommonObject $url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id; - if ($option !== 'nolink') - { + 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'; - } + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowIntervention"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -817,16 +806,23 @@ class Fichinter extends CommonObject $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; global $action; $hookmanager->initHooks(array('interventiondao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -844,8 +840,7 @@ class Fichinter extends CommonObject global $conf, $db, $langs; $langs->load("interventions"); - if (!empty($conf->global->FICHEINTER_ADDON)) - { + if (!empty($conf->global->FICHEINTER_ADDON)) { $mybool = false; $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; @@ -870,8 +865,7 @@ class Fichinter extends CommonObject $numref = ""; $numref = $obj->getNextValue($soc, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { dol_print_error($db, "Fichinter::getNextNumRef ".$obj->error); @@ -905,10 +899,8 @@ class Fichinter extends CommonObject $sql .= " WHERE f.rowid = ".$id; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -921,14 +913,12 @@ class Fichinter extends CommonObject $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_modification) - { + if ($obj->fk_user_modification) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modification); $this->user_modification = $muser; @@ -956,27 +946,27 @@ class Fichinter extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('FICHINTER_DELETE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; $this->db->rollback(); return -1; + } // End call triggers } // Delete linked object - if (!$error) - { + if (!$error) { $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } // Delete linked contacts - if (!$error) - { + if (!$error) { $res = $this->delete_linked_contact(); - if ($res < 0) - { + if ($res < 0) { $this->error = 'ErrorFailToDeleteLinkedContact'; $error++; } @@ -988,62 +978,61 @@ class Fichinter extends CommonObject $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")"; $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet"; $sql .= " WHERE fk_fichinter = ".$this->id; $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } } - if (!$error) - { + if (!$error) { // Remove extrafields $res = $this->deleteExtraFields(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Delete object $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter"; $sql .= " WHERE rowid = ".$this->id; dol_syslog("Fichinter::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } } - if (!$error) - { + if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive $this->deleteEcmFiles(); // Remove directory with files $fichinterref = dol_sanitizeFileName($this->ref); - if ($conf->ficheinter->dir_output) - { + if ($conf->ficheinter->dir_output) { $dir = $conf->ficheinter->dir_output."/".$fichinterref; $file = $conf->ficheinter->dir_output."/".$fichinterref."/".$fichinterref.".pdf"; - if (file_exists($file)) - { + if (file_exists($file)) { dol_delete_preview($this); - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteFile", $file); return 0; } } - if (file_exists($dir)) - { - if (!dol_delete_dir_recursive($dir)) - { + if (file_exists($dir)) { + if (!dol_delete_dir_recursive($dir)) { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); return 0; @@ -1052,8 +1041,7 @@ class Fichinter extends CommonObject } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1075,15 +1063,13 @@ class Fichinter extends CommonObject // phpcs:enable global $conf; - if ($user->rights->ficheinter->creer) - { + if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET datei = '".$this->db->idate($date_delivery)."'"; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut = 0"; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->date_delivery = $date_delivery; return 1; } else { @@ -1107,15 +1093,13 @@ class Fichinter extends CommonObject // phpcs:enable global $conf; - if ($user->rights->ficheinter->creer) - { + if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET description = '".$this->db->escape($description)."',"; $sql .= " fk_user_modif = ".$user->id; $sql .= " WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->description = $description; return 1; } else { @@ -1140,14 +1124,12 @@ class Fichinter extends CommonObject // phpcs:enable global $conf; - if ($user->rights->ficheinter->creer) - { + if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET fk_contrat = ".((int) $contractid); $sql .= " WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->fk_contrat = $contractid; return 1; } else { @@ -1176,19 +1158,18 @@ class Fichinter extends CommonObject $this->db->begin(); // get extrafields so they will be clone - foreach ($this->lines as $line) + foreach ($this->lines as $line) { $line->fetch_optionals(); + } // Load source object $objFrom = clone $this; // Change socid if needed - if (!empty($socid) && $socid != $this->socid) - { + if (!empty($socid) && $socid != $this->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid) > 0) - { + if ($objsoc->fetch($socid) > 0) { $this->socid = $objsoc->id; //$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); //$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); @@ -1213,31 +1194,31 @@ class Fichinter extends CommonObject // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Add lines because it is not included into create function - foreach ($this->lines as $line) - { + foreach ($this->lines as $line) { $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration); } // Hook of thirdparty module - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('objFrom'=>$objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + if ($reshook < 0) { + $error++; + } } } unset($this->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -1262,8 +1243,7 @@ class Fichinter extends CommonObject { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); - if ($this->statut == 0) - { + if ($this->statut == 0) { $this->db->begin(); // Insertion ligne @@ -1280,8 +1260,7 @@ class Fichinter extends CommonObject $result = $line->insert($user); - if ($result >= 0) - { + if ($result >= 0) { $this->db->commit(); return 1; } else { @@ -1317,8 +1296,7 @@ class Fichinter extends CommonObject $this->duration = 0; $nbp = 25; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new FichinterLigne($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->datei = ($now - 3600 * (1 + $xnbp)); @@ -1348,12 +1326,10 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($resql); $line = new FichinterLigne($this->db); @@ -1466,8 +1442,7 @@ class FichinterLigne extends CommonObjectLine dol_syslog("FichinterLigne::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; $this->id = $objp->rowid; @@ -1503,14 +1478,12 @@ class FichinterLigne extends CommonObjectLine $this->db->begin(); $rangToUse = $this->rang; - if ($rangToUse == -1) - { + if ($rangToUse == -1) { // Recupere rang max de la ligne d'intervention dans $rangmax $sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet'; $sql .= ' WHERE fk_fichinter ='.$this->fk_fichinter; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $rangToUse = $obj->max + 1; } else { @@ -1532,16 +1505,13 @@ class FichinterLigne extends CommonObjectLine dol_syslog("FichinterLigne::insert", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet'); $this->rowid = $this->id; - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } @@ -1549,15 +1519,15 @@ class FichinterLigne extends CommonObjectLine $result = $this->update_total(); - if ($result > 0) - { + if ($result > 0) { $this->rang = $rangToUse; - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINEFICHINTER_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -1602,31 +1572,27 @@ class FichinterLigne extends CommonObjectLine dol_syslog("FichinterLigne::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { + if ($resql) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } $result = $this->update_total(); - if ($result > 0) - { - if (!$notrigger) - { + if ($result > 0) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINEFICHINTER_UPDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error) - { + if (!$error) { $this->db->commit(); return $result; } else { @@ -1660,11 +1626,12 @@ class FichinterLigne extends CommonObjectLine dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $total_duration = 0; - if (!empty($obj->total_duration)) $total_duration = $obj->total_duration; + if (!empty($obj->total_duration)) { + $total_duration = $obj->total_duration; + } $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql .= " SET duree = ".$total_duration; @@ -1674,8 +1641,7 @@ class FichinterLigne extends CommonObjectLine dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -1703,8 +1669,7 @@ class FichinterLigne extends CommonObjectLine $error = 0; - if ($this->statut == 0) - { + if ($this->statut == 0) { dol_syslog(get_class($this)."::deleteline lineid=".$this->id); $this->db->begin(); @@ -1718,16 +1683,15 @@ class FichinterLigne extends CommonObjectLine $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $result = $this->update_total(); - if ($result > 0) - { - if (!$notrigger) - { + if ($result > 0) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINEFICHINTER_DELETE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; $this->db->rollback(); return -1; + } // End call triggers } diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 418e1232bb8..8ed842a70c9 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -214,8 +214,8 @@ class FichinterRec extends Fichinter $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); /* - * Lines - */ + * Lines + */ $num = count($fichintsrc->lines); for ($i = 0; $i < $num; $i++) { //var_dump($fichintsrc->lines[$i]); @@ -239,13 +239,14 @@ class FichinterRec extends Fichinter $fichintsrc->lines[$i]->fk_unit ); - if ($result_insert < 0) + if ($result_insert < 0) { $error++; + } } - if ($error) + if ($error) { $this->db->rollback(); - else { + } else { $this->db->commit(); return $this->id; } @@ -277,8 +278,11 @@ class FichinterRec extends Fichinter $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate'; $sql .= ', f.note_private, f.note_public, f.fk_user_author'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f'; - if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid; - elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'"; + if ($rowid > 0) { + $sql .= ' WHERE f.rowid='.$rowid; + } elseif ($ref) { + $sql .= " WHERE f.titre='".$this->db->escape($ref)."'"; + } dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG); @@ -421,7 +425,9 @@ class FichinterRec extends Fichinter */ public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1) { - if (empty($rowid)) $rowid = $this->id; + if (empty($rowid)) { + $rowid = $this->id; + } dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); @@ -481,14 +487,20 @@ class FichinterRec extends Fichinter include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } if ($this->brouillon) { // Clean parameters $remise_percent = price2num($remise_percent); $qty = price2num($qty); - if (!$qty) $qty = 1; - if (!$info_bits) $info_bits = 0; + if (!$qty) { + $qty = 1; + } + if (!$info_bits) { + $info_bits = 0; + } $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); if (!preg_match('/\((.*)\)/', $txtva)) { @@ -623,7 +635,9 @@ class FichinterRec extends Fichinter $url = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$this->id; - if ($short) return $url; + if ($short) { + return $url; + } $picto = 'intervention'; @@ -709,7 +723,9 @@ class FichinterRec extends Fichinter dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; + if (!empty($unit)) { + $this->unit_frequency = $unit; + } return 1; } else { dol_print_error($this->db); @@ -732,13 +748,17 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + if ($increment_nb_gen_done > 0) { + $sql .= ', nb_gen_done = nb_gen_done + 1'; + } $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); if ($this->db->query($sql)) { $this->date_when = $date; - if ($increment_nb_gen_done > 0) $this->nb_gen_done++; + if ($increment_nb_gen_done > 0) { + $this->nb_gen_done++; + } return 1; } else { dol_print_error($this->db); @@ -759,7 +779,9 @@ class FichinterRec extends Fichinter return -1; } - if (empty($nb)) $nb = 0; + if (empty($nb)) { + $nb = 0; + } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET nb_gen_max = '.$nb; @@ -818,8 +840,9 @@ class FichinterRec extends Fichinter $sql .= ' SET nb_gen_done = nb_gen_done + 1'; $sql .= ' , date_last_gen = now()'; // si on et arrivé à la fin des génération - if ($this->nb_gen_max == $this->nb_gen_done + 1) + if ($this->nb_gen_max == $this->nb_gen_done + 1) { $sql .= ' , statut = 1'; + } $sql .= ' WHERE rowid = '.$this->id; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 5df841bf6f2..a0d22cf1e2a 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -64,8 +64,7 @@ class FichinterStats extends Stats $this->userid = $userid; $this->cachefilesuffix = $mode; - if ($mode == 'customer') - { + if ($mode == 'customer') { $object = new Fichinter($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; @@ -73,14 +72,17 @@ class FichinterStats extends Stats $this->field_line = '0'; //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled } - 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; + } $this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')'; - if ($this->socid) - { + if ($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; + } } /** @@ -96,7 +98,9 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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"; @@ -118,7 +122,9 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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'); @@ -139,7 +145,9 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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"; @@ -161,7 +169,9 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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"; @@ -181,7 +191,9 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; $sql .= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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'); diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index bace3d10231..7957479e611 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -39,13 +39,14 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); $result = $object->fetch($id, $ref); -if (!$result) -{ +if (!$result) { print 'Record not found'; exit; } @@ -54,17 +55,14 @@ if (!$result) * Adding a new contact */ -if ($action == 'addcontact' && $user->rights->ficheinter->creer) -{ - if ($result > 0 && $id > 0) - { +if ($action == 'addcontact' && $user->rights->ficheinter->creer) { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -77,21 +75,14 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer) setEventMessages($mesg, null, 'errors'); } -} - -// Toggle the status of a contact -elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) -{ +} elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) { + // Toggle the status of a contact $result = $object->swapContactStatus(GETPOST('ligne', 'int')); -} - -// Deletes a contact -elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) -{ +} elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) { + // Deletes a contact $result = $object->delete_contact(GETPOST('lineid', 'int')); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -114,8 +105,7 @@ llxHeader('', $langs->trans("Intervention")); // Mode vue et edition -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = fichinter_prepare_head($object); @@ -133,12 +123,10 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->ficheinter->creer) - { + if ($user->rights->ficheinter->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; @@ -174,15 +162,20 @@ if ($id > 0 || !empty($ref)) print '<br>'; - if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1; - if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1; + if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) { + $hideaddcontactforuser = 1; + } + if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) { + $hideaddcontactforthirdparty = 1; + } // 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) - { + foreach ($dirtpls as $reldir) { $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + if ($res) { + break; + } } } diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index aaab2072013..ba1f22c122b 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -47,7 +47,9 @@ $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, 'ficheinter', $id, 'fichinter'); @@ -56,12 +58,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Fichinter($db); @@ -86,8 +94,7 @@ $form = new Form($db); llxHeader('', $langs->trans("Intervention")); -if ($object->id) -{ +if ($object->id) { $object->fetch_thirdparty(); $head = fichinter_prepare_head($object); @@ -98,8 +105,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -115,12 +121,10 @@ if ($object->id) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { + if ($user->rights->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 3ea69f8d185..863463e8d0e 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (!$user->rights->ficheinter->lire) accessforbidden(); +if (!$user->rights->ficheinter->lire) { + accessforbidden(); +} $hookmanager = new HookManager($db); @@ -42,8 +44,7 @@ $langs->load("interventions"); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -66,8 +67,7 @@ print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention'); print '<div class="fichecenter"><div class="fichethirdleft">'; -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 // Search ficheinter $var = false; print '<form method="post" action="'.DOL_URL_ROOT.'/fichinter/list.php">'; @@ -88,15 +88,20 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles $sql = "SELECT count(f.rowid), f.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.fk_soc = s.rowid"; -if ($user->socid) $sql .= ' AND f.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND f.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY f.fk_statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -106,15 +111,15 @@ if ($resql) $vals = array(); $bool = false; // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); - if ($row) - { + if ($row) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { $bool = (!empty($row[2]) ?true:false); - if (!isset($vals[$row[1].$bool])) $vals[$row[1].$bool] = 0; + if (!isset($vals[$row[1].$bool])) { + $vals[$row[1].$bool] = 0; + } $vals[$row[1].$bool] += $row[0]; $totalinprocess += $row[0]; } @@ -131,19 +136,28 @@ if ($resql) print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n"; $listofstatus = array(0, 1, 3); $bool = false; - foreach ($listofstatus as $status) - { + foreach ($listofstatus as $status) { $dataseries[] = array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool]) ? (int) $vals[$status.$bool] : 0)); - if ($status == 3 && !$bool) $bool = true; - else $bool = false; + if ($status == 3 && !$bool) { + $bool = true; + } else { + $bool = false; + } - if ($status == Fichinter::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Fichinter::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Fichinter::STATUS_BILLED) $colorseries[$status] = $badgeStatus4; - if ($status == Fichinter::STATUS_CLOSED) $colorseries[$status] = $badgeStatus6; + if ($status == Fichinter::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Fichinter::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Fichinter::STATUS_BILLED) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Fichinter::STATUS_CLOSED) { + $colorseries[$status] = $badgeStatus6; + } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr class="impair"><td class="center" colspan="2">'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -160,10 +174,8 @@ if ($resql) print '</td></tr>'; } $bool = false; - foreach ($listofstatus as $status) - { - if (!$conf->use_javascript_ajax) - { + foreach ($listofstatus as $status) { + if (!$conf->use_javascript_ajax) { print '<tr class="oddeven">'; print '<td>'.$fichinterstatic->LibStatut($status, $bool, 0).'</td>'; print '<td class="right"><a href="list.php?search_status='.$status.'">'.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' '; @@ -171,8 +183,11 @@ if ($resql) print '</a>'; print '</td>'; print "</tr>\n"; - if ($status == 3 && !$bool) $bool = true; - else $bool = false; + if ($status == 3 && !$bool) { + $bool = true; + } else { + $bool = false; + } } } //if ($totalinprocess != $total) @@ -187,32 +202,34 @@ if ($resql) /* * Draft orders */ -if (!empty($conf->ficheinter->enabled)) -{ +if (!empty($conf->ficheinter->enabled)) { $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.fk_statut = 0"; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>'; $langs->load("fichinter"); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; print '<td class="nowrap">'; @@ -239,29 +256,32 @@ $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as date $sql .= " s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.fk_soc = s.rowid"; //$sql.= " AND c.fk_statut > 2"; -if ($socid) $sql .= " AND f.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) { + $sql .= " AND f.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 f.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="4">'.$langs->trans("LastModifiedInterventions", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -296,29 +316,35 @@ if ($resql) } } print "</table></div><br>"; -} else dol_print_error($db); +} else { + dol_print_error($db); +} /* * interventions to process */ -if (!empty($conf->ficheinter->enabled)) -{ +if (!empty($conf->ficheinter->enabled)) { $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.fk_statut = 1"; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.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 f.rowid DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '<div class="div-table-responsive-no-min">'; @@ -326,11 +352,9 @@ if (!empty($conf->ficheinter->enabled)) print '<tr class="liste_titre">'; print '<th colspan="3">'.$langs->trans("FichinterToProcess").' <a href="'.DOL_URL_ROOT.'/fichinter/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th></tr>'; - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; print '<td class="nowrap" width="20%">'; @@ -366,7 +390,9 @@ if (!empty($conf->ficheinter->enabled)) } print "</table></div><br>"; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } print '</div></div></div>'; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index a53c69b77bd..39ac695f84e 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -40,13 +40,14 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); -if (!$object->fetch($id, $ref) > 0) -{ +if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); exit; } @@ -77,15 +78,14 @@ $morehtmlref = '<div class="refidno">'; // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') + if ($user->rights->commande->creer) { + if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d054f5e5bcc..8f0ae8e626f 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -32,13 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} +if (!empty($conf->contrat->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'interventions')); -if (!empty($conf->projet->enabled)) $langs->load("projects"); -if (!empty($conf->contrat->enabled)) $langs->load("contracts"); +if (!empty($conf->projet->enabled)) { + $langs->load("projects"); +} +if (!empty($conf->contrat->enabled)) { + $langs->load("contracts"); +} $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); @@ -59,7 +67,9 @@ $socid = GETPOST('socid', 'int'); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id; @@ -68,14 +78,17 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "f.ref"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.ref"; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -97,8 +110,12 @@ $fieldstosearchall = array( 'f.note_public'=>'NotePublic', 'fd.description'=>'DescriptionOfLine', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; -if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['fd.description']); +if (empty($user->socid)) { + $fieldstosearchall["f.note_private"] = "NotePrivate"; +} +if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) { + unset($fieldstosearchall['fd.description']); +} // Definition of fields for list $arrayfields = array( @@ -127,21 +144,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_ref = ""; $search_company = ""; $search_projet_ref = ""; @@ -187,10 +208,8 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $atleastonefieldinlines = 0; -foreach ($arrayfields as $tmpkey => $tmpval) -{ - if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) - { +foreach ($arrayfields as $tmpkey => $tmpval) { + if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) { $atleastonefieldinlines++; break; } @@ -198,7 +217,9 @@ foreach ($arrayfields as $tmpkey => $tmpval) $sql = "SELECT"; $sql .= " f.ref, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) { + $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; +} $sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus"; if (!empty($conf->projet->enabled)) { $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title"; @@ -208,7 +229,9 @@ if (!empty($conf->contrat->enabled)) { } // 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 : ''); + 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(); @@ -221,9 +244,15 @@ if (!empty($conf->projet->enabled)) { if (!empty($conf->contrat->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid"; } -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 (f.rowid = ef.fk_object)"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; -if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +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 (f.rowid = ef.fk_object)"; +} +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; +} +if (!$user->rights->societe->client->voir && empty($socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.fk_soc = s.rowid"; @@ -240,16 +269,21 @@ if ($search_contrat_ref) { $sql .= natural_search('c.ref', $search_contrat_ref); } if ($search_desc) { - if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc); - else $sql .= natural_search(array('f.description'), $search_desc); + if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) { + $sql .= natural_search(array('f.description', 'fd.description'), $search_desc); + } else { + $sql .= natural_search(array('f.description'), $search_desc); + } } if ($search_status != '' && $search_status >= 0) { $sql .= ' AND f.fk_statut = '.urlencode($search_status); } -if (!$user->rights->societe->client->voir && empty($socid)) +if (!$user->rights->societe->client->voir && empty($socid)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($socid) +} +if ($socid) { $sql .= " AND s.rowid = ".$socid; +} if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -263,12 +297,10 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -278,30 +310,50 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($socid > 0) - { + if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - if (empty($search_company)) $search_company = $soc->name; + if (empty($search_company)) { + $search_company = $soc->name; + } } $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= "&sall=".urlencode($sall); - if ($socid) $param .= "&socid=".urlencode($socid); - if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); - if ($search_company) $param .= "&search_company=".urlencode($search_company); - if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); - if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } + if ($socid) { + $param .= "&socid=".urlencode($socid); + } + if ($search_ref) { + $param .= "&search_ref=".urlencode($search_ref); + } + if ($search_company) { + $param .= "&search_company=".urlencode($search_company); + } + if ($search_desc) { + $param .= "&search_desc=".urlencode($search_desc); + } + if ($search_status != '' && $search_status > -1) { + $param .= "&search_status=".urlencode($search_status); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -311,19 +363,27 @@ if ($resql) 'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->rights->ficheinter->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; $url = DOL_URL_ROOT.'/fichinter/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer); // Lines of title fields print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -339,9 +399,10 @@ if ($resql) $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -349,48 +410,47 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">'; print '</td>'; } - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">'; print '</td>'; } - if (!empty($arrayfields['pr.ref']['checked'])) - { + if (!empty($arrayfields['pr.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">'; print '</td>'; } - if (!empty($arrayfields['c.ref']['checked'])) - { + if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">'; print '</td>'; } - if (!empty($arrayfields['f.description']['checked'])) - { + if (!empty($arrayfields['f.description']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">'; print '</td>'; @@ -402,51 +462,45 @@ if ($resql) $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['f.note_public']['checked'])) - { + if (!empty($arrayfields['f.note_public']['checked'])) { // Note public print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['f.note_private']['checked'])) - { + if (!empty($arrayfields['f.note_private']['checked'])) { // Note private print '<td class="liste_titre">'; print '</td>'; } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="liste_titre right">'; $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus = $objectstatic->statuts_short; - if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { + unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + } print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print '</td>'; } // Fields of detail line - if (!empty($arrayfields['fd.description']['checked'])) - { + if (!empty($arrayfields['fd.description']['checked'])) { print '<td class="liste_titre">&nbsp;</td>'; } - if (!empty($arrayfields['fd.date']['checked'])) - { + if (!empty($arrayfields['fd.date']['checked'])) { print '<td class="liste_titre">&nbsp;</td>'; } - if (!empty($arrayfields['fd.duree']['checked'])) - { + if (!empty($arrayfields['fd.duree']['checked'])) { print '<td class="liste_titre">&nbsp;</td>'; } print '<td class="liste_titre maxwidthsearch">'; @@ -457,33 +511,58 @@ if ($resql) print "</tr>\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) { + print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['pr.ref']['checked'])) { + print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.description']['checked'])) { + print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.note_public']['checked'])) print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.note_private']['checked'])) print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); - if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.note_public']['checked'])) { + print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.note_private']['checked'])) { + print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['fd.description']['checked'])) { + print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); + } + if (!empty($arrayfields['fd.date']['checked'])) { + print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['fd.duree']['checked'])) { + print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; $total = 0; $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->rowid; @@ -500,8 +579,7 @@ if ($resql) print '<tr class="oddeven">'; - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print "<td>"; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; @@ -512,15 +590,13 @@ if ($resql) // Warning $warnornote = ''; //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (!empty($obj->note_private)) - { + if (!empty($obj->note_private)) { $warnornote .= ($warnornote ? ' ' : ''); $warnornote .= '<span class="note">'; $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; $warnornote .= '</span>'; } - if ($warnornote) - { + if ($warnornote) { print '<td style="min-width: 20px" class="nobordernopadding nowrap">'; print $warnornote; print '</td>'; @@ -535,17 +611,19 @@ if ($resql) print '</td></tr></table>'; print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td>'; print $companystatic->getNomUrl(1, '', 44); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['pr.ref']['checked'])) - { + if (!empty($arrayfields['pr.ref']['checked'])) { print '<td>'; $projetstatic->id = $obj->projet_id; $projetstatic->ref = $obj->projet_ref; @@ -554,10 +632,11 @@ if ($resql) print $projetstatic->getNomUrl(1, ''); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['c.ref']['checked'])) - { + if (!empty($arrayfields['c.ref']['checked'])) { print '<td>'; $contratstatic->id = $obj->contrat_id; $contratstatic->ref = $obj->contrat_ref; @@ -567,12 +646,15 @@ if ($resql) print $contratstatic->getNomUrl(1, ''); print '</td>'; } - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['f.description']['checked'])) - { + if (!empty($arrayfields['f.description']['checked'])) { print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description), 48).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -582,71 +664,84 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Note public - if (!empty($arrayfields['f.note_public']['checked'])) - { + if (!empty($arrayfields['f.note_public']['checked'])) { print '<td class="center">'; print dol_escape_htmltag($obj->note_public); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Note private - if (!empty($arrayfields['f.note_private']['checked'])) - { + if (!empty($arrayfields['f.note_private']['checked'])) { print '<td class="center">'; print dol_escape_htmltag($obj->note_private); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="right">'.$objectstatic->getLibStatut(5).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Fields of detail of line - if (!empty($arrayfields['fd.description']['checked'])) - { + if (!empty($arrayfields['fd.description']['checked'])) { print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['fd.date']['checked'])) - { + if (!empty($arrayfields['fd.date']['checked'])) { print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['fd.duree']['checked'])) - { + if (!empty($arrayfields['fd.duree']['checked'])) { print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } $totalarray['val']['fd.duree'] += $obj->duree; } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; @@ -669,7 +764,9 @@ if ($resql) print "</form>\n"; $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index dddbe79e33e..fcc790bf8c2 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -39,7 +39,9 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); @@ -62,8 +64,7 @@ llxHeader('', $langs->trans("Intervention")); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = fichinter_prepare_head($object); @@ -80,12 +81,10 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { + if ($user->rights->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 19e7f86d8a0..29a5f9976b0 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -30,13 +30,14 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mode = 'customer'; -if (!$user->rights->ficheinter->lire) accessforbidden(); +if (!$user->rights->ficheinter->lire) { + accessforbidden(); +} $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -70,15 +71,16 @@ print load_fiche_titre($title, '', 'intervention'); dol_mkdir($dir); $stats = new FichinterStats($db, $socid, $mode, ($userid > 0 ? $userid : 0)); -if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($object_status != '' && $object_status > -1) { + $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +} // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; } else { @@ -88,12 +90,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -115,8 +115,7 @@ if (!$mesg) $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; } else { @@ -126,12 +125,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px2->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -152,8 +149,7 @@ if (!$mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; } else { @@ -163,12 +159,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px3->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -196,7 +190,9 @@ foreach ($data as $val) { $arrayyears[$val['year']] = $val['year']; } } -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; +if (!count($arrayyears)) { + $arrayyears[$nowyear] = $nowyear; +} $h = 0; $head = array(); @@ -236,13 +232,19 @@ print '<div class="fichecenter"><div class="fichethirdleft">'; print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">'; $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus = $objectstatic->statuts_short; - if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 +if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { + unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 +} print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1); print '</td></tr>'; // Year print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; - 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 '</td></tr>'; @@ -265,11 +267,9 @@ print '<td class="right">%</td>'; print '</tr>'; $oldyear = 0; -foreach ($data as $val) -{ +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--; @@ -307,12 +307,14 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; // Show graphs print '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { print $px1->show(); /*print "<br>\n"; - print $px2->show(); - print "<br>\n"; - print $px3->show();*/ + print $px2->show(); + print "<br>\n"; + print $px3->show();*/ } print '</td></tr></table>'; diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php index b483e877e5e..ba754ec3321 100644 --- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php @@ -16,8 +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; } @@ -36,17 +35,18 @@ $langs->load("interventions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - <tr class="<?php echo $trclass; ?>"> + <tr class="<?php echo $trclass; ?>"> <td><?php echo $langs->trans("Intervention"); ?></td> - <td><?php echo $objectlink->getNomUrl(1); ?></td> - <td></td> + <td><?php echo $objectlink->getNomUrl(1); ?></td> + <td></td> <td class="center"><?php echo dol_print_date($objectlink->datev, 'day'); ?></td> <td></td> <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> From ed6d2376f14eeb456fe6c26a4c4ea38163cb4173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Thu, 25 Feb 2021 23:21:30 +0100 Subject: [PATCH 107/173] code syntax fourn directory --- htdocs/fourn/ajax/getSupplierPrices.php | 42 +- htdocs/fourn/card.php | 320 ++--- .../class/api_supplier_invoices.class.php | 57 +- .../fourn/class/api_supplier_orders.class.php | 108 +- htdocs/fourn/class/fournisseur.class.php | 35 +- .../class/fournisseur.commande.class.php | 1019 +++++++-------- .../fournisseur.commande.dispatch.class.php | 239 ++-- .../fourn/class/fournisseur.facture.class.php | 962 +++++++------- .../fourn/class/fournisseur.product.class.php | 205 +-- htdocs/fourn/class/paiementfourn.class.php | 178 ++- htdocs/fourn/commande/card.php | 998 +++++++-------- htdocs/fourn/commande/contact.php | 48 +- htdocs/fourn/commande/dispatch.php | 267 ++-- htdocs/fourn/commande/document.php | 31 +- htdocs/fourn/commande/index.php | 130 +- htdocs/fourn/commande/info.php | 71 +- htdocs/fourn/commande/list.php | 934 +++++++++----- htdocs/fourn/commande/note.php | 16 +- .../commande/tpl/linkedobjectblock.tpl.php | 51 +- htdocs/fourn/contact.php | 33 +- htdocs/fourn/facture/card.php | 1135 ++++++++--------- htdocs/fourn/facture/contact.php | 83 +- htdocs/fourn/facture/document.php | 73 +- htdocs/fourn/facture/impayees.php | 131 +- htdocs/fourn/facture/index.php | 116 +- htdocs/fourn/facture/info.php | 69 +- htdocs/fourn/facture/list.php | 1060 +++++++++------ htdocs/fourn/facture/note.php | 52 +- htdocs/fourn/facture/paiement.php | 266 ++-- htdocs/fourn/facture/rapport.php | 58 +- .../facture/tpl/linkedobjectblock.tpl.php | 60 +- htdocs/fourn/index.php | 93 +- htdocs/fourn/js/lib_dispatch.js.php | 35 +- htdocs/fourn/paiement/card.php | 92 +- htdocs/fourn/paiement/info.php | 4 +- htdocs/fourn/paiement/list.php | 220 +++- htdocs/fourn/product/list.php | 132 +- htdocs/fourn/recap-fourn.php | 31 +- 38 files changed, 5080 insertions(+), 4374 deletions(-) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 0c0d8f42c9e..e0cd9beff0c 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -22,10 +22,18 @@ * \brief File to return an Ajax response to get list of possible prices for margin calculation */ -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.'/fourn/class/fournisseur.product.class.php'; @@ -46,47 +54,45 @@ top_httphead(); //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; -if ($idprod > 0) -{ +if ($idprod > 0) { $producttmp = new ProductFournisseur($db); $producttmp->fetch($idprod); $sorttouse = 's.nom, pfp.quantity, pfp.price'; - if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; + if (GETPOST('bestpricefirst')) { + $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; + } $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. - if (is_array($productSupplierArray)) - { - foreach ($productSupplierArray as $productSupplier) - { + if (is_array($productSupplierArray)) { + foreach ($productSupplierArray as $productSupplier) { $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100); $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100); $title = $productSupplier->fourn_name.' - '.$productSupplier->fourn_ref.' - '; - if ($productSupplier->fourn_qty == 1) - { + if ($productSupplier->fourn_qty == 1) { $title .= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/"; } $title .= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); - if ($productSupplier->fourn_qty > 1) - { + if ($productSupplier->fourn_qty > 1) { $title .= " - "; $title .= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); $price = $unitprice; } $label = price($price, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); - if ($productSupplier->fourn_ref) $label .= ' ('.$productSupplier->fourn_ref.')'; + if ($productSupplier->fourn_ref) { + $label .= ' ('.$productSupplier->fourn_ref.')'; + } $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } // After best supplier prices and before costprice - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { // Add price for pmp $price = $producttmp->pmp; $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9794ea3cc11..d39cbf7ca0f 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -35,8 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->adherent->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +} +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by page $langs->loadLangs(array( @@ -53,7 +57,9 @@ $cancelbutton = GETPOST('cancel', 'alpha'); // Security check $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -if ($user->socid) $id = $user->socid; +if ($user->socid) { + $id = $user->socid; +} $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid'); $object = new Fournisseur($db); @@ -81,44 +87,48 @@ if ($object->id > 0) { $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancelbutton) - { +if (empty($reshook)) { + if ($cancelbutton) { $action = ""; } - if ($action == 'setsupplieraccountancycode') - { + if ($action == 'setsupplieraccountancycode') { $result = $object->fetch($id); - $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; $result = $object->update($object->id, $user, 1, 0, 1); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) - { + if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } } // mode de reglement - if ($action == 'setmode' && $user->rights->societe->creer) - { + if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } } // update supplier order min amount - if ($action == 'setsupplier_order_min_amount') - { + if ($action == 'setsupplier_order_min_amount') { $object->fetch($id); $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha')); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($action == 'update_extras') { @@ -129,15 +139,20 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; - - if (!$error) - { - $result = $object->insertExtraFields('COMPANY_MODIFY'); - if ($result < 0) $error++; + if ($ret < 0) { + $error++; } - if ($error) $action = 'edit_extras'; + if (!$error) { + $result = $object->insertExtraFields('COMPANY_MODIFY'); + if ($result < 0) { + $error++; + } + } + + if ($error) { + $action = 'edit_extras'; + } } } @@ -149,17 +164,19 @@ if (empty($reshook)) $contactstatic = new Contact($db); $form = new Form($db); -if ($id > 0 && empty($object->id)) -{ +if ($id > 0 && empty($object->id)) { // Load data of third party $res = $object->fetch($id); - if ($object->id <= 0) dol_print_error($db, $object->error); + if ($object->id <= 0) { + dol_print_error($db, $object->error); + } } -if ($object->id > 0) -{ +if ($object->id > 0) { $title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier'); - if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Supplier'); + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->name." - ".$langs->trans('Supplier'); + } $help_url = ''; llxHeader('', $title, $help_url); @@ -184,22 +201,20 @@ if ($object->id > 0) print $object->getTypeUrl(1); print '</td></tr>'; - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; } - if ($object->fournisseur) - { + if ($object->fournisseur) { print '<tr>'; - print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>'; - print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; - } - print '</td>'; - print '</tr>'; + print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>'; + print $object->code_fournisseur; + $tmpcheck = $object->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; + } + print '</td>'; + print '</tr>'; $langs->load('compta'); print '<tr>'; @@ -221,14 +236,12 @@ if ($object->id > 0) print '</tr>'; // Local Taxes - if ($mysoc->useLocalTax(1)) - { + if ($mysoc->useLocalTax(1)) { print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>'; print yn($object->localtax1_assuj); print '</td></tr>'; } - if ($mysoc->useLocalTax(2)) - { + if ($mysoc->useLocalTax(2)) { print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>'; print yn($object->localtax2_assuj); print '</td></tr>'; @@ -246,11 +259,12 @@ if ($object->id > 0) print '<table width="100%" class="nobordernopadding"><tr><td>'; print $langs->trans('PaymentConditions'); print '<td>'; - if (($action != 'editconditions') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; + if (($action != 'editconditions') && $user->rights->societe->creer) { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; - if ($action == 'editconditions') - { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', -1, 1); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'none'); @@ -263,11 +277,12 @@ if ($object->id > 0) print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans('PaymentMode'); print '<td>'; - if (($action != 'editmode') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; + if (($action != 'editmode') && $user->rights->societe->creer) { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'none'); @@ -280,8 +295,7 @@ if ($object->id > 0) print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans("CustomerRelativeDiscountShort"); print '<td><td class="right">'; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>'; } print '</td></tr></table>'; @@ -294,22 +308,24 @@ if ($object->id > 0) print '<tr><td class="nowrap">'; print $langs->trans("CustomerAbsoluteDiscountShort"); print '<td><td class="right">'; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>'; } print '</td></tr></table>'; print '</td>'; print '<td>'; $amount_discount = $object->getAvailableDiscounts('', '', 0, 1); - if ($amount_discount < 0) dol_print_error($db, $object->error); - if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>'; + if ($amount_discount < 0) { + dol_print_error($db, $object->error); + } + if ($amount_discount > 0) { + print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>'; + } //else print $langs->trans("DiscountNone"); print '</td>'; print '</tr>'; - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print '<tr class="nowrap">'; print '<td>'; print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer); @@ -321,8 +337,7 @@ if ($object->id > 0) } // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>'; print '<td>'; @@ -335,16 +350,14 @@ if ($object->id > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Module Adherent - if (!empty($conf->adherent->enabled)) - { + if (!empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("users"); print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<td>'; $adh = new Adherent($db); $result = $adh->fetch('', '', $object->id); - if ($result > 0) - { + if ($result > 0) { $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); } else { @@ -371,8 +384,7 @@ if ($object->id > 0) $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">'; $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">'; - if ($conf->supplier_proposal->enabled) - { + if ($conf->supplier_proposal->enabled) { // Box proposals $tmp = $object->getOutstandingProposals('supplier'); $outstandingOpened = $tmp['opened']; @@ -381,16 +393,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllSupplierProposals"); $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + if ($link) { + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + } $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; $boxstat .= '</div>'; - if ($link) $boxstat .= '</a>'; + if ($link) { + $boxstat .= '</a>'; + } } - 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)) { // Box proposals $tmp = $object->getOutstandingOrders('supplier'); $outstandingOpened = $tmp['opened']; @@ -399,16 +414,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllOrders"); $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + if ($link) { + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + } $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; $boxstat .= '</div>'; - if ($link) $boxstat .= '</a>'; + if ($link) { + $boxstat .= '</a>'; + } } - 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)) { $tmp = $object->getOutstandingBills('supplier'); $outstandingOpened = $tmp['opened']; $outstandingTotal = $tmp['total_ht']; @@ -417,23 +435,31 @@ if ($object->id > 0) $text = $langs->trans("OverAllInvoices"); $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + if ($link) { + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + } $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; $boxstat .= '</div>'; - if ($link) $boxstat .= '</a>'; + if ($link) { + $boxstat .= '</a>'; + } // Box outstanding bill $text = $langs->trans("CurrentOutstandingBill"); $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + if ($link) { + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + } $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>'; $boxstat .= '</div>'; - if ($link) $boxstat .= '</a>'; + if ($link) { + $boxstat .= '</a>'; + } $tmp = $object->getOutstandingBills('supplier', 1); $outstandingOpenedLate = $tmp['opened']; @@ -441,12 +467,16 @@ if ($object->id > 0) $text = $langs->trans("CurrentOutstandingBillLate"); $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + if ($link) { + $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">'; + } $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">'; $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>'; $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>'; $boxstat .= '</div>'; - if ($link) $boxstat .= '</a>'; + if ($link) { + $boxstat .= '</a>'; + } } } @@ -468,13 +498,12 @@ if ($object->id > 0) print '</tr>'; print '</table>'; print '<br>'; - */ + */ /* * List of products */ - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); //Query from product/liste.php $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,'; @@ -487,7 +516,9 @@ if ($object->id > 0) $sql .= $db->plimit($MAXLIST); $query = $db->query($sql); - if (!$query) dol_print_error($db); + if (!$query) { + dol_print_error($db); + } $num = $db->num_rows($query); @@ -498,12 +529,10 @@ if ($object->id > 0) print '</a></td></tr>'; $return = array(); - if ($num > 0) - { + if ($num > 0) { $productstatic = new Product($db); - while ($objp = $db->fetch_object($query)) - { + while ($objp = $db->fetch_object($query)) { $productstatic->id = $objp->rowid; $productstatic->ref = $objp->ref; $productstatic->label = $objp->label; @@ -523,11 +552,9 @@ if ($object->id > 0) //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>'; print '<td class="right">'; //print (isset($objp->unitprice) ? price($objp->unitprice) : ''); - if (isset($objp->price)) - { + if (isset($objp->price)) { print price($objp->price); - if ($objp->quantity > 1) - { + if ($objp->quantity > 1) { print ' / '; print $objp->quantity; } @@ -546,8 +573,7 @@ if ($object->id > 0) */ $proposalstatic = new SupplierProposal($db); - if ($user->rights->supplier_proposal->lire) - { + if ($user->rights->supplier_proposal->lire) { $langs->loadLangs(array("supplier_proposal")); $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; @@ -558,13 +584,11 @@ if ($object->id > 0) $sql .= " ".$db->plimit($MAXLIST); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '<table class="noborder centpercent lastrecordtable">'; print '<tr class="liste_titre">'; @@ -576,8 +600,7 @@ if ($object->id > 0) print '</td></tr>'; } - while ($i < $num && $i <= $MAXLIST) - { + while ($i < $num && $i <= $MAXLIST) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -590,8 +613,7 @@ if ($object->id > 0) print $proposalstatic->getNomUrl(1); print '</td>'; print '<td class="center" width="80">'; - if ($obj->dc) - { + if ($obj->dc) { print dol_print_date($db->jdate($obj->dc), 'day'); } else { print "-"; @@ -603,7 +625,9 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) print "</table>"; + if ($num > 0) { + print "</table>"; + } } else { dol_print_error($db); } @@ -614,8 +638,7 @@ if ($object->id > 0) */ $orderstatic = new CommandeFournisseur($db); - if ($user->rights->fournisseur->commande->lire) - { + if ($user->rights->fournisseur->commande->lire) { // TODO move to DAO class // Check if there are supplier orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,'; @@ -626,8 +649,7 @@ if ($object->id > 0) $sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2 .= ' AND s.rowid = '.$object->id; // Show orders we can bill - if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) - { + if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) { $sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php } else { // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY @@ -651,8 +673,7 @@ if ($object->id > 0) $sql .= " WHERE p.fk_soc =".$object->id; $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $object_count = $db->fetch_object($resql); $num = $object_count->total; } @@ -664,12 +685,10 @@ if ($object->id > 0) $sql .= " ORDER BY p.date_commande DESC"; $sql .= " ".$db->plimit($MAXLIST); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; - if ($num > 0) - { + if ($num > 0) { print '<table class="noborder centpercent lastrecordtable">'; print '<tr class="liste_titre">'; @@ -681,8 +700,7 @@ if ($object->id > 0) print '</td></tr>'; } - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -695,8 +713,7 @@ if ($object->id > 0) print $orderstatic->getNomUrl(1); print '</td>'; print '<td class="center" width="80">'; - if ($obj->dc) - { + if ($obj->dc) { print dol_print_date($db->jdate($obj->dc), 'day'); } else { print "-"; @@ -708,7 +725,9 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) print "</table>"; + if ($num > 0) { + print "</table>"; + } } else { dol_print_error($db); } @@ -721,8 +740,7 @@ if ($object->id > 0) $langs->load('bills'); $facturestatic = new FactureFournisseur($db); - if ($user->rights->fournisseur->facture->lire) - { + if ($user->rights->fournisseur->facture->lire) { // TODO move to DAO class $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,'; $sql .= ' SUM(pf.amount) as am'; @@ -733,12 +751,10 @@ if ($object->id > 0) $sql .= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye'; $sql .= ' ORDER BY f.datef DESC'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '<table class="noborder centpercent lastrecordtable">'; print '<tr class="liste_titre">'; @@ -749,8 +765,7 @@ if ($object->id > 0) print '</td></tr>'; } - while ($i < min($num, $MAXLIST)) - { + while ($i < min($num, $MAXLIST)) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -777,7 +792,9 @@ if ($object->id > 0) $i++; } $db->free($resql); - if ($num > 0) print '</table>'; + if ($num > 0) { + print '</table>'; + } } else { dol_print_error($db); } @@ -797,15 +814,12 @@ if ($object->id > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { - if ($object->status != 1) - { + if (empty($reshook)) { + if ($object->status != 1) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>'; } - if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) - { + if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); if ($object->status == 1) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddSupplierProposal").'</a>'; @@ -814,8 +828,7 @@ if ($object->id > 0) } } - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); if ($object->status == 1) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>'; @@ -824,21 +837,20 @@ if ($object->id > 0) } } - if ($user->rights->fournisseur->facture->creer) - { - if (!empty($orders2invoice) && $orders2invoice > 0) - { + if ($user->rights->fournisseur->facture->creer) { + if (!empty($orders2invoice) && $orders2invoice > 0) { if ($object->status == 1) { // Company is open print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisSupplier").'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; } - } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')').'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')').'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; + } } - if ($user->rights->fournisseur->facture->creer) - { + if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); if ($object->status == 1) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>'; @@ -848,10 +860,8 @@ if ($object->id > 0) } // Add action - if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) - { - if ($user->rights->agenda->myactions->create) - { + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { + if ($user->rights->agenda->myactions->create) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>'; } else { print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>'; @@ -862,15 +872,13 @@ if ($object->id > 0) print '</div>'; - if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) - { + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) { print '<br>'; // List of contacts show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); // List of todo actions diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 247434be7a8..953092120e4 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -34,7 +34,7 @@ class SupplierInvoices extends DolibarrApi * * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'socid', ); @@ -109,20 +109,32 @@ class SupplierInvoices 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) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir) { + $search_sale = DolibarrApiAccess::$user->id; + } $sql = "SELECT t.rowid"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; + if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; + } $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; // We need this table joined to the select in order to filter by sale - if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; - if (!DolibarrApiAccess::$user->rights->societe->client->voir || $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 + if (!DolibarrApiAccess::$user->rights->societe->client->voir || $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 + } // Filter by status if ($status == 'draft') { @@ -142,10 +154,8 @@ class SupplierInvoices extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -154,8 +164,7 @@ class SupplierInvoices extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -168,8 +177,7 @@ class SupplierInvoices extends DolibarrApi $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $invoice_static = new FactureFournisseur($this->db); if ($invoice_static->fetch($obj->rowid)) { @@ -244,12 +252,15 @@ class SupplierInvoices extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->invoice->$field = $value; } - if ($this->invoice->update($id, DolibarrApiAccess::$user)) + if ($this->invoice->update($id, DolibarrApiAccess::$user)) { return $this->get($id); + } return false; } @@ -279,8 +290,7 @@ class SupplierInvoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if ($this->invoice->delete(DolibarrApiAccess::$user) < 0) - { + if ($this->invoice->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500); } @@ -459,16 +469,14 @@ class SupplierInvoices extends DolibarrApi $paiement->note_public = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($paiement_id < 0) - { + if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } if (!empty($conf->banque->enabled)) { $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, $chqemetteur, $chqbank); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); throw new RestException(400, 'Add payment to bank error : '.$paiement->error); } @@ -706,8 +714,9 @@ class SupplierInvoices extends DolibarrApi { $invoice = array(); foreach (SupplierInvoices::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $invoice[$field] = $data[$field]; } return $invoice; diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 254e577f2f2..895902b13b2 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -32,7 +32,7 @@ class SupplierOrders extends DolibarrApi * * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'socid' ); @@ -108,41 +108,70 @@ class SupplierOrders 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) + 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_fournisseur 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 + } - if (!empty($product_ids)) $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; // We need this table joined to the select in order to filter by product + if (!empty($product_ids)) { + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; // We need this table joined to the select in order to filter by product + } $sql .= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if (!empty($product_ids)) $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$product_ids.")"; - 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 + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if (!empty($product_ids)) { + $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$product_ids.")"; + } + 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 + } // Filter by status - if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; - if ($status == 'validated') $sql .= " AND t.fk_statut IN (1)"; - if ($status == 'approved') $sql .= " AND t.fk_statut IN (2)"; - if ($status == 'running') $sql .= " AND t.fk_statut IN (3)"; - if ($status == 'received_start') $sql .= " AND t.fk_statut IN (4)"; - if ($status == 'received_end') $sql .= " AND t.fk_statut IN (5)"; - if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (6,7)"; - if ($status == 'refused') $sql .= " AND t.fk_statut IN (9)"; + if ($status == 'draft') { + $sql .= " AND t.fk_statut IN (0)"; + } + if ($status == 'validated') { + $sql .= " AND t.fk_statut IN (1)"; + } + if ($status == 'approved') { + $sql .= " AND t.fk_statut IN (2)"; + } + if ($status == 'running') { + $sql .= " AND t.fk_statut IN (3)"; + } + if ($status == 'received_start') { + $sql .= " AND t.fk_statut IN (4)"; + } + if ($status == 'received_end') { + $sql .= " AND t.fk_statut IN (5)"; + } + if ($status == 'cancelled') { + $sql .= " AND t.fk_statut IN (6,7)"; + } + if ($status == 'refused') { + $sql .= " AND t.fk_statut IN (9)"; + } // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -151,8 +180,7 @@ class SupplierOrders extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -161,13 +189,11 @@ class SupplierOrders extends DolibarrApi } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $order_static = new CommandeFournisseur($this->db); if ($order_static->fetch($obj->rowid)) { @@ -207,13 +233,13 @@ class SupplierOrders extends DolibarrApi $this->order->date = dol_now(); } /* We keep lines as an array - if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->order->lines = $lines; - }*/ + if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->order->lines = $lines; + }*/ if ($this->order->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors)); @@ -244,12 +270,15 @@ class SupplierOrders extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->order->$field = $value; } - if ($this->order->update($id, DolibarrApiAccess::$user)) + if ($this->order->update($id, DolibarrApiAccess::$user)) { return $this->get($id); + } return false; } @@ -368,8 +397,9 @@ class SupplierOrders extends DolibarrApi { $order = array(); foreach (SupplierOrders::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $order[$field] = $data[$field]; } return $order; diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 4ca073a38c7..57f6fa52d26 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -62,12 +62,10 @@ class Fournisseur extends Societe $sql .= " WHERE cf.fk_soc = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num == 1) - { + if ($num == 1) { $row = $this->db->fetch_row($resql); $this->single_open_commande = $row[0]; @@ -91,8 +89,7 @@ class Fournisseur extends Societe $sql .= " AND pfp.fk_soc = ".$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); return $obj->nb; } else { @@ -116,8 +113,7 @@ class Fournisseur extends Societe $sql = "SELECT count(s.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -126,10 +122,8 @@ class Fournisseur extends Societe $sql .= " AND s.entity IN (".getEntity('societe').")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["suppliers"] = $obj->nb; } $this->db->free($resql); @@ -158,8 +152,7 @@ class Fournisseur extends Societe dol_syslog("Fournisseur::CreateCategory", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { dol_syslog("Fournisseur::CreateCategory : Success"); return 0; } else { @@ -185,17 +178,19 @@ class Fournisseur extends Societe $sql = "SELECT s.rowid, s.nom as name"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.fournisseur = 1"; $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->rights->societe->client->voir && !$user->socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $arr[$obj->rowid] = $obj->name; } } else { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 52121d8c83d..d4e92fd8bf4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -34,7 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +if (!empty($conf->productbatch->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +} require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; /** @@ -303,7 +305,9 @@ class CommandeFournisseur extends CommonOrder global $conf; // Check parameters - if (empty($id) && empty($ref)) return -1; + if (empty($id) && empty($ref)) { + return -1; + } $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,"; $sql .= " c.localtax1, c.localtax2, "; @@ -324,18 +328,21 @@ class CommandeFournisseur extends CommonOrder $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; - if (empty($id)) $sql .= " WHERE c.entity IN (".getEntity('supplier_order').")"; - else $sql .= " WHERE c.rowid=".$id; + if (empty($id)) { + $sql .= " WHERE c.entity IN (".getEntity('supplier_order').")"; + } else { + $sql .= " WHERE c.rowid=".$id; + } - if ($ref) $sql .= " AND c.ref='".$this->db->escape($ref)."'"; + if ($ref) { + $sql .= " AND c.ref='".$this->db->escape($ref)."'"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if (!$obj) - { + if (!$obj) { $this->error = 'Bill with id '.$id.' not found'; dol_syslog(get_class($this).'::fetch '.$this->error); return 0; @@ -409,14 +416,15 @@ class CommandeFournisseur extends CommonOrder // fetch optionals attributes and labels $this->fetch_optionals(); - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == 0) { + $this->brouillon = 1; + } /* - * Lines - */ + * Lines + */ $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { return -1; } else { return 1; @@ -449,26 +457,28 @@ class CommandeFournisseur extends CommonOrder $sql .= " l.fk_unit,"; $sql .= " l.date_start, l.date_end,"; $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; + } $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn"; + } $sql .= " WHERE l.fk_commande = ".$this->id; - if ($only_product) $sql .= ' AND p.fk_product_type = 0'; + if ($only_product) { + $sql .= ' AND p.fk_product_type = 0'; + } $sql .= " ORDER BY l.rang, l.rowid"; //print $sql; dol_syslog(get_class($this)."::fetch get lines", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new CommandeFournisseurLigne($this->db); @@ -505,8 +515,7 @@ class CommandeFournisseur extends CommonOrder $line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - { + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $line->fk_fournprice = $objp->fk_pfp; $line->packaging = $objp->packaging; } @@ -563,8 +572,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::valid"); $result = 0; if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) - { + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) { $this->db->begin(); // Definition of supplier order numbering model name @@ -572,8 +580,7 @@ class CommandeFournisseur extends CommonOrder $soc->fetch($this->fourn_id); // Check if object has a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef($soc); } else { $num = $this->ref; @@ -589,49 +596,46 @@ class CommandeFournisseur extends CommonOrder $sql .= " AND fk_statut = ".self::STATUS_DRAFT; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'fournisseur/commande/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/commande/".$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($num); $dirsource = $conf->fournisseur->commande->dir_output.'/'.$oldref; $dirdest = $conf->fournisseur->commande->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -643,15 +647,13 @@ class CommandeFournisseur extends CommonOrder } } - if (!$error) - { + if (!$error) { $result = 1; $this->statut = self::STATUS_VALIDATED; $this->ref = $num; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -696,8 +698,11 @@ class CommandeFournisseur extends CommonOrder $this->statuts[0] = 'StatusSupplierOrderDraft'; $this->statuts[1] = 'StatusSupplierOrderValidated'; $this->statuts[2] = 'StatusSupplierOrderApproved'; - if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusSupplierOrderOnProcess'; - else $this->statuts[3] = 'StatusSupplierOrderOnProcessWithValidation'; + if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { + $this->statuts[3] = 'StatusSupplierOrderOnProcess'; + } else { + $this->statuts[3] = 'StatusSupplierOrderOnProcessWithValidation'; + } $this->statuts[4] = 'StatusSupplierOrderReceivedPartially'; $this->statuts[5] = 'StatusSupplierOrderReceivedAll'; $this->statuts[6] = 'StatusSupplierOrderCanceled'; // Approved->Canceled @@ -737,7 +742,9 @@ class CommandeFournisseur extends CommonOrder if ($billed) { $billedtext = ' - '.$langs->trans("Billed"); } - if ($status == 5 && $billed) $statusClass = 'status6'; + if ($status == 5 && $billed) { + $statusClass = 'status6'; + } $statusLong = $langs->transnoentitiesnoconv($this->statuts[$status]).$billedtext; $statusShort = $langs->transnoentitiesnoconv($this->statutshort[$status]); @@ -792,19 +799,20 @@ class CommandeFournisseur extends CommonOrder $picto = 'order'; $url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id; - if ($option !== 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowOrder"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -817,15 +825,17 @@ class CommandeFournisseur extends CommonOrder $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; - if ($addlinktonotes) - { + if ($addlinktonotes) { $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) - { + if ($txttoshow) { $notetoshow = $langs->trans("ViewPrivateNote").':<br>'.dol_string_nohtmltag($txttoshow, 1); $result .= ' <span class="note inline-block">'; $result .= '<a href="'.DOL_URL_ROOT.'/fourn/commande/note.php?id='.$this->id.'" class="classfortooltip" title="'.dol_escape_htmltag($notetoshow).'">'; @@ -853,8 +863,7 @@ class CommandeFournisseur extends CommonOrder global $db, $langs, $conf; $langs->load("orders"); - if (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) - { + if (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) { $mybool = false; $file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php'; @@ -878,8 +887,7 @@ class CommandeFournisseur extends CommonOrder $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -900,8 +908,7 @@ class CommandeFournisseur extends CommonOrder { $error = 0; - if ($this->billed) - { + if ($this->billed) { return 0; } @@ -910,18 +917,17 @@ class CommandeFournisseur extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; - if ($this->db->query($sql)) - { - if (!$error) - { + if ($this->db->query($sql)) { + if (!$error) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_CLASSIFY_BILLED', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->billed = 1; $this->db->commit(); @@ -955,8 +961,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::approve"); - if ($user->rights->fournisseur->commande->approuver) - { + if ($user->rights->fournisseur->commande->approuver) { $now = dol_now(); $this->db->begin(); @@ -966,8 +971,7 @@ class CommandeFournisseur extends CommonOrder $soc->fetch($this->fourn_id); // Check if object has a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef($soc); } else { $num = $this->ref; @@ -980,14 +984,11 @@ class CommandeFournisseur extends CommonOrder $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql .= " SET ref='".$this->db->escape($num)."',"; - if (empty($secondlevel)) // standard or first level approval - { + if (empty($secondlevel)) { // standard or first level approval $sql .= " date_approve='".$this->db->idate($now)."',"; $sql .= " fk_user_approve = ".$user->id; - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - if (empty($this->user_approve_id2)) - { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + if (empty($this->user_approve_id2)) { $movetoapprovestatus = false; // second level approval not done $comment = ' (first level)'; } @@ -996,67 +997,72 @@ class CommandeFournisseur extends CommonOrder { $sql .= " date_approve2='".$this->db->idate($now)."',"; $sql .= " fk_user_approve2 = ".$user->id; - if (empty($this->user_approve_id)) $movetoapprovestatus = false; // first level approval not done + if (empty($this->user_approve_id)) { + $movetoapprovestatus = false; // first level approval not done + } $comment = ' (second level)'; } // If double approval is required and first approval, we keep status to 1 = validated - if ($movetoapprovestatus) $sql .= ", fk_statut = ".self::STATUS_ACCEPTED; - else $sql .= ", fk_statut = ".self::STATUS_VALIDATED; + if ($movetoapprovestatus) { + $sql .= ", fk_statut = ".self::STATUS_ACCEPTED; + } else { + $sql .= ", fk_statut = ".self::STATUS_VALIDATED; + } $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; - if ($this->db->query($sql)) - { - if (!empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT)) - { + if ($this->db->query($sql)) { + if (!empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT)) { $result = $this->add_contact($user->id, 'SALESREPFOLL', 'internal', 1); - if ($result < 0 && $result != -2) // -2 means already exists - { + if ($result < 0 && $result != -2) { // -2 means already exists $error++; } } // If stock is incremented on validate order, we must increment it - if (!$error && $movetoapprovestatus && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) - { + if (!$error && $movetoapprovestatus && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { + for ($i = 0; $i < $cpt; $i++) { // Product with reference - if ($this->lines[$i]->fk_product > 0) - { + if ($this->lines[$i]->fk_product > 0) { $this->line = $this->lines[$i]; $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrement stock of product (and sub-products) $up_ht_disc = $this->lines[$i]->subprice; - if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); + if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { + $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); + } $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("OrderApprovedInDolibarr", $this->ref)); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } unset($this->line); } } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_APPROVE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->ref = $this->newref; - if ($movetoapprovestatus) $this->statut = self::STATUS_ACCEPTED; - else $this->statut = self::STATUS_VALIDATED; - if (empty($secondlevel)) // standard or first level approval - { + if ($movetoapprovestatus) { + $this->statut = self::STATUS_ACCEPTED; + } else { + $this->statut = self::STATUS_VALIDATED; + } + if (empty($secondlevel)) { // standard or first level approval $this->date_approve = $now; $this->user_approve_id = $user->id; } else // request a second level approval @@ -1096,26 +1102,24 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::refuse"); $result = 0; - if ($user->rights->fournisseur->commande->approuver) - { + if ($user->rights->fournisseur->commande->approuver) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".self::STATUS_REFUSED; $sql .= " WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $result = 0; - if ($error == 0) - { + if ($error == 0) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_REFUSE', $user); - if ($result < 0) - { + if ($result < 0) { $error++; $this->db->rollback(); - } else $this->db->commit(); + } else { + $this->db->commit(); + } // End call triggers } } else { @@ -1148,8 +1152,7 @@ class CommandeFournisseur extends CommonOrder //dol_syslog("CommandeFournisseur::Cancel"); $result = 0; - if ($user->rights->fournisseur->commande->commander) - { + if ($user->rights->fournisseur->commande->commander) { $statut = self::STATUS_CANCELED; $this->db->begin(); @@ -1157,17 +1160,17 @@ class CommandeFournisseur extends CommonOrder $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::cancel", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $result = 0; // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_CANCEL', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if ($error == 0) - { + if ($error == 0) { $this->db->commit(); return 1; } else { @@ -1200,12 +1203,13 @@ class CommandeFournisseur extends CommonOrder global $langs; dol_syslog(get_class($this)."::commande"); $error = 0; - if ($user->rights->fournisseur->commande->commander) - { + if ($user->rights->fournisseur->commande->commander) { $this->db->begin(); $newnoteprivate = $this->note_private; - if ($comment) $newnoteprivate = dol_concatdesc($newnoteprivate, $langs->trans("Comment").': '.$comment); + if ($comment) { + $newnoteprivate = dol_concatdesc($newnoteprivate, $langs->trans("Comment").': '.$comment); + } $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql .= " SET fk_statut=".self::STATUS_ORDERSENT.", fk_input_method=".$methode.", date_commande='".$this->db->idate($date)."', "; @@ -1213,8 +1217,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::commande", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->statut = self::STATUS_ORDERSENT; $this->methode_commande_id = $methode; $this->date_commande = $date; @@ -1222,7 +1225,9 @@ class CommandeFournisseur extends CommonOrder // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_SUBMIT', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; @@ -1230,8 +1235,7 @@ class CommandeFournisseur extends CommonOrder $this->errors[] = $this->db->lasterror(); } - if (!$error) - { + if (!$error) { $this->db->commit(); } else { $this->db->rollback(); @@ -1264,17 +1268,23 @@ class CommandeFournisseur extends CommonOrder // set tmp vars $date = ($this->date_commande ? $this->date_commande : $this->date); // in case of date is set - if (empty($date)) $date = $now; + if (empty($date)) { + $date = $now; + } $delivery_date = empty($this->delivery_date) ? $this->date_livraison : $this->delivery_date; // Clean parameters - if (empty($this->source)) $this->source = 0; + if (empty($this->source)) { + $this->source = 0; + } // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date); - else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; @@ -1330,16 +1340,14 @@ class CommandeFournisseur extends CommonOrder $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur"); if ($this->id) { $num = count($this->lines); // insert products details into database - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $this->special_code = $this->lines[$i]->special_code; // TODO : remove this in 9.0 and add special_code param to addline() // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set @@ -1364,8 +1372,7 @@ class CommandeFournisseur extends CommonOrder $this->lines[$i]->array_options, $this->lines[$i]->fk_unit ); - if ($result < 0) - { + if ($result < 0) { dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); // do not use dol_print_error here as it may be a functionnal error $this->db->rollback(); return -1; @@ -1376,30 +1383,22 @@ class CommandeFournisseur extends CommonOrder $sql .= " SET ref='(PROV".$this->id.")'"; $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { // Add link with price request and supplier order - if ($this->id) - { + if ($this->id) { $this->ref = "(PROV".$this->id.")"; - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { dol_print_error($this->db); $error++; } @@ -1408,8 +1407,7 @@ class CommandeFournisseur extends CommonOrder { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { dol_print_error($this->db); $error++; } @@ -1418,18 +1416,17 @@ class CommandeFournisseur extends CommonOrder } } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_CREATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -1467,19 +1464,18 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); // get extrafields so they will be clone - foreach ($this->lines as $line) + foreach ($this->lines as $line) { $line->fetch_optionals(); + } // Load source object $objFrom = clone $this; // Change socid if needed - if (!empty($socid) && $socid != $this->socid) - { + if (!empty($socid) && $socid != $this->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid) > 0) - { + if ($objsoc->fetch($socid) > 0) { $this->socid = $objsoc->id; $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); @@ -1507,25 +1503,26 @@ class CommandeFournisseur extends CommonOrder // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Hook of thirdparty module - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('objFrom'=>$objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; + if ($reshook < 0) { + $error++; + } } } unset($this->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -1568,17 +1565,28 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $info_bits, $notrigger, $date_start, $date_end, $fk_unit, $pu_ht_devise, $origin, $origin_id"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - if ($this->statut == self::STATUS_DRAFT) - { + if ($this->statut == self::STATUS_DRAFT) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($qty)) $qty = 0; - if (!$info_bits) $info_bits = 0; - if (empty($txtva)) $txtva = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($remise_percent)) $remise_percent = 0; + if (empty($qty)) { + $qty = 0; + } + if (!$info_bits) { + $info_bits = 0; + } + if (empty($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } + if (empty($remise_percent)) { + $remise_percent = 0; + } $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -1590,8 +1598,7 @@ class CommandeFournisseur extends CommonOrder } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if ($price_base_type == 'HT') - { + if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; @@ -1599,12 +1606,13 @@ class CommandeFournisseur extends CommonOrder $desc = trim($desc); // Check parameters - if ($qty < 0 && !$fk_product) - { + if ($qty < 0 && !$fk_product) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")); return -1; } - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error = $langs->trans('ErrorStartDateGreaterEnd'); @@ -1632,15 +1640,15 @@ class CommandeFournisseur extends CommonOrder // If supplier order created from customer order, we take best supplier price // If $pu (defined previously from pu_ht or pu_ttc) is not defined at all, we also take the best supplier price - if ($result > 0 && ($origin == 'commande' || $pu === '')) - { + if ($result > 0 && ($origin == 'commande' || $pu === '')) { $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent != 0) $remise_percent = $prod->remise_percent; + if ($remise_percent == 0 && $prod->remise_percent != 0) { + $remise_percent = $prod->remise_percent; + } } - if ($result == 0) // If result == 0, we failed to found the supplier reference price - { + if ($result == 0) { // If result == 0, we failed to found the supplier reference price $langs->load("errors"); $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); @@ -1649,16 +1657,14 @@ class CommandeFournisseur extends CommonOrder //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price return -1; } - if ($result == -1) - { + if ($result == -1) { $langs->load("errors"); $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); return -1; } - if ($result < -1) - { + if ($result < -1) { $this->error = $prod->error; $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); @@ -1695,8 +1701,7 @@ class CommandeFournisseur extends CommonOrder // Clean vat code $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -1783,15 +1788,15 @@ class CommandeFournisseur extends CommonOrder } $result = $this->line->insert($notrigger); - if ($result > 0) - { + if ($result > 0) { // Reorder if child line - if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) { + $this->line_order(true, 'DESC'); + } // Mise a jour informations denormalisees au niveau de la commande meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return $this->line->id; } else { @@ -1833,24 +1838,23 @@ class CommandeFournisseur extends CommonOrder require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; // Check parameters (if test are wrong here, there is bug into caller) - if ($entrepot <= 0) - { + if ($entrepot <= 0) { $this->error = 'ErrorBadValueForParameterWarehouse'; return -1; } - if ($qty == 0) - { + if ($qty == 0) { $this->error = 'ErrorBadValueForParameterQty'; return -1; } $dispatchstatus = 1; - if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $dispatchstatus = 0; // Setting dispatch status (a validation step after receiving products) will be done manually to 1 or 2 if this option is on + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { + $dispatchstatus = 0; // Setting dispatch status (a validation step after receiving products) will be done manually to 1 or 2 if this option is on + } $now = dol_now(); - if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) - { + if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; @@ -1861,15 +1865,12 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::dispatchProduct", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$notrigger) - { + if ($resql) { + if (!$notrigger) { global $conf, $langs, $user; // Call trigger $result = $this->call_trigger('LINEORDER_SUPPLIER_DISPATCH', $user); - if ($result < 0) - { + if ($result < 0) { $error++; } // End call triggers @@ -1880,16 +1881,13 @@ class CommandeFournisseur extends CommonOrder } // If module stock is enabled and the stock increase is done on purchase order dispatching - if (!$error && $entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) - { + if (!$error && $entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($this->db); - if ($product > 0) - { + if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); - if ($result < 0) - { + if ($result < 0) { $this->error = $mouv->error; $this->errors = $mouv->errors; dol_syslog(get_class($this)."::dispatchProduct ".$this->error." ".join(',', $this->errors), LOG_ERR); @@ -1898,8 +1896,7 @@ class CommandeFournisseur extends CommonOrder } } - if ($error == 0) - { + if ($error == 0) { $this->db->commit(); return 1; } else { @@ -1921,17 +1918,14 @@ class CommandeFournisseur extends CommonOrder */ public function deleteline($idline, $notrigger = 0) { - if ($this->statut == 0) - { + if ($this->statut == 0) { $line = new CommandeFournisseurLigne($this->db); - if ($line->fetch($idline) <= 0) - { + if ($line->fetch($idline) <= 0) { return 0; } - if ($line->delete($notrigger) > 0) - { + if ($line->delete($notrigger) > 0) { $this->update_price(); return 1; } else { @@ -1960,12 +1954,10 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); - if (empty($notrigger)) - { + if (empty($notrigger)) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->errors[] = 'ErrorWhenRunningTrigger'; dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); @@ -1978,8 +1970,7 @@ class CommandeFournisseur extends CommonOrder $ef = $main."_extrafields"; $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $this->errors[] = $this->db->lasterror(); $error++; @@ -1987,8 +1978,7 @@ class CommandeFournisseur extends CommonOrder $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $this->errors[] = $this->db->lasterror(); $error++; @@ -1996,10 +1986,8 @@ class CommandeFournisseur extends CommonOrder $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($resql = $this->db->query($sql)) - { - if ($this->db->affected_rows($resql) < 1) - { + if ($resql = $this->db->query($sql)) { + if ($this->db->affected_rows($resql) < 1) { $this->error = $this->db->lasterror(); $this->errors[] = $this->db->lasterror(); $error++; @@ -2011,11 +1999,9 @@ class CommandeFournisseur extends CommonOrder } // Remove extrafields - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->error = 'FailToDeleteExtraFields'; $this->errors[] = 'FailToDeleteExtraFields'; $error++; @@ -2031,31 +2017,25 @@ class CommandeFournisseur extends CommonOrder $error++; } - if (!$error) - { + if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive $this->deleteEcmFiles(); // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->fournisseur->commande->dir_output) - { + if ($conf->fournisseur->commande->dir_output) { $dir = $conf->fournisseur->commande->dir_output."/".$ref; $file = $dir."/".$ref.".pdf"; - if (file_exists($file)) - { - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (file_exists($file)) { + if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers $this->error = 'ErrorFailToDeleteFile'; $this->errors[] = 'ErrorFailToDeleteFile'; $error++; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { $res = @dol_delete_dir_recursive($dir); - if (!$res) - { + if (!$res) { $this->error = 'ErrorFailToDeleteDir'; $this->errors[] = 'ErrorFailToDeleteDir'; $error++; @@ -2064,8 +2044,7 @@ class CommandeFournisseur extends CommonOrder } } - if (!$error) - { + if (!$error) { dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); $this->db->commit(); return 1; @@ -2090,13 +2069,11 @@ class CommandeFournisseur extends CommonOrder $sql .= " WHERE active = 1"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $this->db->num_rows($resql); $this->methodes_commande = array(); - while ($i < $num) - { + while ($i < $num) { $row = $this->db->fetch_row($resql); $this->methodes_commande[$row[0]] = $row[1]; @@ -2130,20 +2107,19 @@ class CommandeFournisseur extends CommonOrder $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; $sql .= " WHERE cfd.fk_commande = ".$this->id; $sql .= " AND cfd.fk_product = p.rowid"; - if ($status >= 0) $sql .= " AND cfd.status = ".$status; + if ($status >= 0) { + $sql .= " AND cfd.status = ".$status; + } $sql .= " ORDER BY cfd.rowid ASC"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $this->db->fetch_object($resql); - if ($objp) - { + if ($objp) { $ret[] = array( 'id' => $objp->dispatchedlineid, 'productid' => $objp->fk_product, @@ -2154,7 +2130,9 @@ class CommandeFournisseur extends CommonOrder $i++; } - } else dol_print_error($this->db, 'Failed to execute request to get dispatched lines'); + } else { + dol_print_error($this->db, 'Failed to execute request to get dispatched lines'); + } return $ret; } @@ -2180,39 +2158,37 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::Livraison"); - if ($user->rights->fournisseur->commande->receptionner) - { + if ($user->rights->fournisseur->commande->receptionner) { // Define the new status - if ($type == 'par') $statut = self::STATUS_RECEIVED_PARTIALLY; - elseif ($type == 'tot') $statut = self::STATUS_RECEIVED_COMPLETELY; - elseif ($type == 'nev') $statut = self::STATUS_CANCELED_AFTER_ORDER; - elseif ($type == 'can') $statut = self::STATUS_CANCELED_AFTER_ORDER; - else { + if ($type == 'par') { + $statut = self::STATUS_RECEIVED_PARTIALLY; + } elseif ($type == 'tot') { + $statut = self::STATUS_RECEIVED_COMPLETELY; + } elseif ($type == 'nev') { + $statut = self::STATUS_CANCELED_AFTER_ORDER; + } elseif ($type == 'can') { + $statut = self::STATUS_CANCELED_AFTER_ORDER; + } else { $error++; dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR); return -2; } // Some checks to accept the record - if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) - { + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { // If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done" - if (!$error && ($type == 'tot')) - { + if (!$error && ($type == 'tot')) { $dispatchedlinearray = $this->getDispachedLines(0); - if (count($dispatchedlinearray) > 0) - { + if (count($dispatchedlinearray) > 0) { $result = -1; $error++; $this->errors[] = 'ErrorCantSetReceptionToTotalDoneWithReceptionToApprove'; dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG); } } - if (!$error && !empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to reception done, only if status of all line are ok (refuse denied) - { + if (!$error && !empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) { // Accept to move to reception done, only if status of all line are ok (refuse denied) $dispatcheddenied = $this->getDispachedLines(2); - if (count($dispatchedlinearray) > 0) - { + if (count($dispatchedlinearray) > 0) { $result = -1; $error++; $this->errors[] = 'ErrorCantSetReceptionToTotalDoneWithReceptionDenied'; @@ -2223,8 +2199,7 @@ class CommandeFournisseur extends CommonOrder // TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty). - if (empty($error)) - { + if (empty($error)) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; @@ -2234,8 +2209,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::Livraison", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $result = 1; $old_statut = $this->statut; $this->statut = $statut; @@ -2243,11 +2217,12 @@ class CommandeFournisseur extends CommonOrder // Call trigger $result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user); - if ($result_trigger < 0) $error++; + if ($result_trigger < 0) { + $error++; + } // End call triggers - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); } else { $this->statut = $old_statut; @@ -2296,8 +2271,7 @@ class CommandeFournisseur extends CommonOrder */ public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { $error = 0; $this->db->begin(); @@ -2308,34 +2282,31 @@ class CommandeFournisseur extends CommonOrder dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$error) - { + if (!$error) { $this->oldcopy = clone $this; $this->date_livraison = $delivery_date; $this->delivery_date = $delivery_date; } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -2359,8 +2330,7 @@ class CommandeFournisseur extends CommonOrder public function set_id_projet($user, $id_projet, $notrigger = 0) { // phpcs:enable - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { $error = 0; $this->db->begin(); @@ -2371,34 +2341,31 @@ class CommandeFournisseur extends CommonOrder dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->error(); $error++; } - if (!$error) - { + if (!$error) { $this->oldcopy = clone $this; $this->fk_projet = $id_projet; $this->fk_project = $id_projet; } - if (!$notrigger && empty($error)) - { + if (!$notrigger && empty($error)) { // Call trigger $result = $this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -2428,13 +2395,11 @@ class CommandeFournisseur extends CommonOrder $this->lines = array(); $num = count($comclient->lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $prod = new Product($this->db); $label = ''; $ref = ''; - if ($prod->fetch($comclient->lines[$i]->fk_product) > 0) - { + if ($prod->fetch($comclient->lines[$i]->fk_product) > 0) { $label = $prod->label; $ref = $prod->ref; } @@ -2445,8 +2410,7 @@ class CommandeFournisseur extends CommonOrder $sql .= ",".$comclient->lines[$i]->fk_product.", ".price2num($comclient->lines[$i]->price); $sql .= ", ".$comclient->lines[$i]->qty.", ".$comclient->lines[$i]->tva_tx.", ".$comclient->lines[$i]->localtax1_tx.", ".$comclient->lines[$i]->localtax2_tx.", ".$comclient->lines[$i]->remise_percent; $sql .= ", '".price2num($comclient->lines[$i]->subprice)."','0', '".$this->db->escape($ref)."');"; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->update_price(); } } @@ -2474,8 +2438,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::setStatus", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Trigger names for each status $triggerName = array(); $triggerName[0] = 'DRAFT'; @@ -2490,7 +2453,9 @@ class CommandeFournisseur extends CommonOrder // Call trigger $result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$triggerName[$status], $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; @@ -2498,8 +2463,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::setStatus ".$this->error); } - if (!$error) - { + if (!$error) { $this->statut = $status; $this->db->commit(); return 1; @@ -2540,30 +2504,47 @@ class CommandeFournisseur extends CommonOrder $error = 0; - if ($this->brouillon) - { + if ($this->brouillon) { // Clean parameters - if (empty($qty)) $qty = 0; - if (empty($info_bits)) $info_bits = 0; - if (empty($txtva)) $txtva = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($remise)) $remise = 0; - if (empty($remise_percent)) $remise_percent = 0; + if (empty($qty)) { + $qty = 0; + } + if (empty($info_bits)) { + $info_bits = 0; + } + if (empty($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } + if (empty($remise)) { + $remise = 0; + } + if (empty($remise_percent)) { + $remise_percent = 0; + } $remise_percent = price2num($remise_percent); $qty = price2num($qty); - if (!$qty) $qty = 1; + if (!$qty) { + $qty = 1; + } $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' - } + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error = $langs->trans('ErrorStartDateGreaterEnd'); @@ -2582,8 +2563,7 @@ class CommandeFournisseur extends CommonOrder // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -2621,14 +2601,11 @@ class CommandeFournisseur extends CommonOrder $this->line->desc = $desc; // redefine quantity according to packaging - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - { - if ($qty < $this->line->packaging) - { + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + if ($qty < $this->line->packaging) { $qty = $this->line->packaging; } else { - if (($qty % $this->line->packaging) > 0) - { + if (($qty % $this->line->packaging) > 0) { $coeff = intval($qty / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); @@ -2686,8 +2663,7 @@ class CommandeFournisseur extends CommonOrder // Mise a jour info denormalisees au niveau facture - if ($result >= 0) - { + if ($result >= 0) { $this->update_price('', 'auto'); $this->db->commit(); return $result; @@ -2730,8 +2706,7 @@ class CommandeFournisseur extends CommonOrder $sql .= $this->db->order("rowid", "ASC"); $sql .= $this->db->plimit(1); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $prodid = $obj->rowid; } @@ -2758,8 +2733,7 @@ class CommandeFournisseur extends CommonOrder // Lines $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new CommandeFournisseurLigne($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->qty = 1; @@ -2768,8 +2742,7 @@ class CommandeFournisseur extends CommonOrder $line->tva_tx = 19.6; $line->localtax1_tx = 0; $line->localtax2_tx = 0; - if ($xnbp == 2) - { + if ($xnbp == 2) { $line->total_ht = 50; $line->total_ttc = 59.8; $line->total_tva = 9.8; @@ -2806,17 +2779,25 @@ class CommandeFournisseur extends CommonOrder $sql .= ' WHERE c.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) $this->user_creation_id = $obj->fk_user_author; - if ($obj->fk_user_valid) $this->user_validation_id = $obj->fk_user_valid; - if ($obj->fk_user_modif) $this->user_modification_id = $obj->fk_user_modif; - if ($obj->fk_user_approve) $this->user_approve_id = $obj->fk_user_approve; - if ($obj->fk_user_approve2) $this->user_approve_id2 = $obj->fk_user_approve2; + if ($obj->fk_user_author) { + $this->user_creation_id = $obj->fk_user_author; + } + if ($obj->fk_user_valid) { + $this->user_validation_id = $obj->fk_user_valid; + } + if ($obj->fk_user_modif) { + $this->user_modification_id = $obj->fk_user_modif; + } + if ($obj->fk_user_approve) { + $this->user_approve_id = $obj->fk_user_approve; + } + if ($obj->fk_user_approve2) { + $this->user_approve_id2 = $obj->fk_user_approve2; + } $this->date_creation = $this->db->idate($obj->datec); $this->date_modification = $this->db->idate($obj->datem); @@ -2847,8 +2828,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT count(co.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -2856,10 +2836,8 @@ class CommandeFournisseur extends CommonOrder $sql .= " ".$clause." co.entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["supplier_orders"] = $obj->nb; } $this->db->free($resql); @@ -2888,8 +2866,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + if (!$user->rights->societe->client->voir && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; @@ -2900,11 +2877,12 @@ class CommandeFournisseur extends CommonOrder } else { $sql .= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")"; } - if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; + if ($user->socid) { + $sql .= " AND c.fk_soc = ".$user->socid; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $commandestatic = new CommandeFournisseur($this->db); $response = new WorkboardResponse(); @@ -2920,8 +2898,7 @@ class CommandeFournisseur extends CommonOrder $response->url = DOL_URL_ROOT.'/fourn/commande/list.php?statut=3,4&mainmenu=commercial&leftmenu=orders_suppliers'; } - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; $commandestatic->delivery_date = $this->db->jdate($obj->delivery_date); @@ -2950,27 +2927,25 @@ class CommandeFournisseur extends CommonOrder { global $db, $langs; - if ($this->methode_commande_id > 0) - { + if ($this->methode_commande_id > 0) { $sql = "SELECT rowid, code, libelle as label"; $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_method'; $sql .= " WHERE active=1 AND rowid = ".$this->db->escape($this->methode_commande_id); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $string = $langs->trans($obj->code); - if ($string == $obj->code) - { + if ($string == $obj->code) { $string = $obj->label != '-' ? $obj->label : ''; } return $string; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } } return ''; @@ -3017,26 +2992,30 @@ class CommandeFournisseur extends CommonOrder */ public function getMaxDeliveryTimeDay($langs) { - if (empty($this->lines)) return ''; + if (empty($this->lines)) { + return ''; + } $obj = new ProductFournisseur($this->db); $nb = 0; - foreach ($this->lines as $line) - { - if ($line->fk_product > 0) - { + foreach ($this->lines as $line) { + if ($line->fk_product > 0) { $idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty); - if ($idp) - { + if ($idp) { $obj->fetch($idp); - if ($obj->delivery_time_days > $nb) $nb = $obj->delivery_time_days; + if ($obj->delivery_time_days > $nb) { + $nb = $obj->delivery_time_days; + } } } } - if ($nb === 0) return ''; - else return $nb.' '.$langs->trans('Days'); + if ($nb === 0) { + return ''; + } else { + return $nb.' '.$langs->trans('Days'); + } } /** @@ -3079,7 +3058,9 @@ class CommandeFournisseur extends CommonOrder { global $conf; - if (empty($this->delivery_date) && !empty($this->date_livraison)) $this->delivery_date = $this->date_livraison; // For backward compatibility + if (empty($this->delivery_date) && !empty($this->date_livraison)) { + $this->delivery_date = $this->date_livraison; // For backward compatibility + } if ($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY) { $now = dol_now(); @@ -3110,7 +3091,9 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if (empty($this->delivery_date) && !empty($this->date_livraison)) $this->delivery_date = $this->date_livraison; // For backward compatibility + if (empty($this->delivery_date) && !empty($this->date_livraison)) { + $this->delivery_date = $this->date_livraison; // For backward compatibility + } $text = ''; @@ -3143,8 +3126,7 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) - { + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; $qtydelivered = array(); @@ -3171,7 +3153,9 @@ class CommandeFournisseur extends CommonOrder } foreach ($this->lines as $line) { // Exclude lines not qualified for shipment, similar code is found into interface_20_modWrokflow for customers - if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $line->product_type > 0) continue; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $line->product_type > 0) { + continue; + } $qtywished[$line->fk_product] += $line->qty; } @@ -3181,16 +3165,14 @@ class CommandeFournisseur extends CommonOrder $keysindeliverednotinwished = array_diff(array_keys($qtydelivered), array_keys($qtywished)); // To check we also have same number of keys /*var_dump(array_keys($qtydelivered)); - var_dump(array_keys($qtywished)); - var_dump($diff_array); - var_dump($keysinwishednotindelivered); - var_dump($keysindeliverednotinwished); - exit;*/ + var_dump(array_keys($qtywished)); + var_dump($diff_array); + var_dump($keysinwishednotindelivered); + var_dump($keysindeliverednotinwished); + exit;*/ - if (count($diff_array) == 0 && count($keysinwishednotindelivered) == 0 && count($keysindeliverednotinwished) == 0) //No diff => mean everythings is received - { - if ($closeopenorder) - { + if (count($diff_array) == 0 && count($keysinwishednotindelivered) == 0 && count($keysindeliverednotinwished) == 0) { //No diff => mean everythings is received + if ($closeopenorder) { //$ret=$this->setStatus($user,5); $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($ret < 0) { @@ -3211,16 +3193,13 @@ class CommandeFournisseur extends CommonOrder $close = 0; - if (count($diff_array) > 0) - { + if (count($diff_array) > 0) { //there are some difference between the two arrays //scan the array of results - foreach ($diff_array as $key => $value) - { + foreach ($diff_array as $key => $value) { //if the quantity delivered is greater or equal to wish quantity - if ($qtydelivered[$key] >= $qtywished[$key]) - { + if ($qtydelivered[$key] >= $qtywished[$key]) { $close++; } } @@ -3280,25 +3259,31 @@ class CommandeFournisseur extends CommonOrder $sql = 'SELECT cd.rowid, cd.fk_product,'; $sql .= ' sum(cfd.qty) as qty'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as cfd,'; - if ($filtre_statut >= 0) $sql .= ' '.MAIN_DB_PREFIX.'reception as e,'; + if ($filtre_statut >= 0) { + $sql .= ' '.MAIN_DB_PREFIX.'reception as e,'; + } $sql .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql .= ' WHERE'; - if ($filtre_statut >= 0) $sql .= ' cfd.fk_reception = e.rowid AND'; + if ($filtre_statut >= 0) { + $sql .= ' cfd.fk_reception = e.rowid AND'; + } $sql .= ' cfd.fk_commandefourndet = cd.rowid'; $sql .= ' AND cd.fk_commande ='.$this->id; - if ($this->fk_product > 0) $sql .= ' AND cd.fk_product = '.$this->fk_product; - if ($filtre_statut >= 0) $sql .= ' AND e.fk_statut >= '.$filtre_statut; + if ($this->fk_product > 0) { + $sql .= ' AND cd.fk_product = '.$this->fk_product; + } + if ($filtre_statut >= 0) { + $sql .= ' AND e.fk_statut >= '.$filtre_statut; + } $sql .= ' GROUP BY cd.rowid, cd.fk_product'; dol_syslog(get_class($this)."::loadReceptions", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); empty($this->receptions[$obj->rowid]) ? $this->receptions[$obj->rowid] = $obj->qty : $this->receptions[$obj->rowid] += $obj->qty; $i++; @@ -3399,20 +3384,20 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn"; + } $sql .= ' WHERE cd.rowid = '.$rowid; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $objp = $this->db->fetch_object($result); - if (!empty($objp)) - { + if (!empty($objp)) { $this->rowid = $objp->rowid; $this->id = $objp->rowid; $this->fk_commande = $objp->fk_commande; @@ -3443,8 +3428,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->product_ref = $objp->product_ref; $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - { + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->packaging = $objp->packaging; $this->fk_fournprice = $objp->fk_pfp; } @@ -3488,32 +3472,63 @@ class CommandeFournisseurLigne extends CommonOrderLine dol_syslog(get_class($this)."::insert rang=".$this->rang); // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) $this->localtax1_type = '0'; - if (empty($this->localtax2_type)) $this->localtax2_type = '0'; - if (empty($this->total_localtax1)) $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) $this->total_localtax2 = 0; - if (empty($this->rang)) $this->rang = 0; - if (empty($this->remise)) $this->remise = 0; - if (empty($this->remise_percent)) $this->remise_percent = 0; - if (empty($this->info_bits)) $this->info_bits = 0; - if (empty($this->special_code)) $this->special_code = 0; - if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->tva_tx)) { + $this->tva_tx = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } + if (empty($this->localtax1_type)) { + $this->localtax1_type = '0'; + } + if (empty($this->localtax2_type)) { + $this->localtax2_type = '0'; + } + if (empty($this->total_localtax1)) { + $this->total_localtax1 = 0; + } + if (empty($this->total_localtax2)) { + $this->total_localtax2 = 0; + } + if (empty($this->rang)) { + $this->rang = 0; + } + if (empty($this->remise)) { + $this->remise = 0; + } + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } + if (empty($this->info_bits)) { + $this->info_bits = 0; + } + if (empty($this->special_code)) { + $this->special_code = 0; + } + if (empty($this->fk_parent_line)) { + $this->fk_parent_line = 0; + } + if (empty($this->pa_ht)) { + $this->pa_ht = 0; + } // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { + if (!empty($this->multicurrency_code)) { + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; } // Check parameters - if ($this->product_type < 0) return -1; + if ($this->product_type < 0) { + return -1; + } $this->db->begin(); @@ -3528,7 +3543,11 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= " VALUES (".$this->fk_commande.", '".$this->db->escape($this->label)."','".$this->db->escape($this->desc)."',"; $sql .= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; - if ($this->fk_product) { $sql .= $this->fk_product.","; } else { $sql .= "null,"; } + if ($this->fk_product) { + $sql .= $this->fk_product.","; + } else { + $sql .= "null,"; + } $sql .= "'".$this->db->escape($this->product_type)."',"; $sql .= "'".$this->db->escape($this->special_code)."',"; $sql .= "'".$this->db->escape($this->rang)."',"; @@ -3556,25 +3575,23 @@ class CommandeFournisseurLigne extends CommonOrderLine dol_syslog(get_class($this)."::insert", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->rowid = $this->id; - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEORDER_SUPPLIER_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } @@ -3583,8 +3600,7 @@ class CommandeFournisseurLigne extends CommonOrderLine return 1; } - foreach ($this->errors as $errmsg) - { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->errors[] = ($this->errors ? ', '.$errmsg : $errmsg); } @@ -3647,32 +3663,26 @@ class CommandeFournisseurLigne extends CommonOrderLine dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); - if ($result > 0) - { - if (!$error) - { + if ($result > 0) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { global $user; // Call trigger $result = $this->call_trigger('LINEORDER_SUPPLIER_UPDATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -3702,8 +3712,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // extrafields $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -3712,24 +3721,22 @@ class CommandeFournisseurLigne extends CommonOrderLine dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if (!$notrigger) - { + if ($resql) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINEORDER_SUPPLIER_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } - 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); } diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index a7abed27369..c79a53297f2 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -140,16 +140,36 @@ class CommandeFournisseurDispatch extends CommonObject // Clean parameters - if (isset($this->fk_commande)) $this->fk_commande = trim($this->fk_commande); - if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); - if (isset($this->fk_commandefourndet)) $this->fk_commandefourndet = trim($this->fk_commandefourndet); - if (isset($this->qty)) $this->qty = trim($this->qty); - if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); - if (isset($this->fk_user)) $this->fk_user = trim($this->fk_user); - if (isset($this->comment)) $this->comment = trim($this->comment); - if (isset($this->status)) $this->status = trim($this->status); - if (isset($this->batch)) $this->batch = trim($this->batch); - if (empty($this->datec)) $this->datec = dol_now(); + if (isset($this->fk_commande)) { + $this->fk_commande = trim($this->fk_commande); + } + if (isset($this->fk_product)) { + $this->fk_product = trim($this->fk_product); + } + if (isset($this->fk_commandefourndet)) { + $this->fk_commandefourndet = trim($this->fk_commandefourndet); + } + if (isset($this->qty)) { + $this->qty = trim($this->qty); + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = trim($this->fk_entrepot); + } + if (isset($this->fk_user)) { + $this->fk_user = trim($this->fk_user); + } + if (isset($this->comment)) { + $this->comment = trim($this->comment); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + if (isset($this->batch)) { + $this->batch = trim($this->batch); + } + if (empty($this->datec)) { + $this->datec = dol_now(); + } // Check parameters @@ -190,16 +210,16 @@ class CommandeFournisseurDispatch extends CommonObject $this->db->begin(); - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - if (!$notrigger) - { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -211,17 +231,16 @@ class CommandeFournisseurDispatch extends CommonObject } // Create extrafields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -264,15 +283,16 @@ class CommandeFournisseurDispatch extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - if ($ref) $sql .= " WHERE t.ref = '".$ref."'"; - else $sql .= " WHERE t.rowid = ".$id; + if ($ref) { + $sql .= " WHERE t.ref = '".$ref."'"; + } else { + $sql .= " WHERE t.rowid = ".$id; + } dol_syslog(get_class($this)."::fetch"); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -318,15 +338,33 @@ class CommandeFournisseurDispatch extends CommonObject // Clean parameters - if (isset($this->fk_commande)) $this->fk_commande = trim($this->fk_commande); - if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); - if (isset($this->fk_commandefourndet)) $this->fk_commandefourndet = trim($this->fk_commandefourndet); - if (isset($this->qty)) $this->qty = trim($this->qty); - if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); - if (isset($this->fk_user)) $this->fk_user = trim($this->fk_user); - if (isset($this->comment)) $this->comment = trim($this->comment); - if (isset($this->status)) $this->status = trim($this->status); - if (isset($this->batch)) $this->batch = trim($this->batch); + if (isset($this->fk_commande)) { + $this->fk_commande = trim($this->fk_commande); + } + if (isset($this->fk_product)) { + $this->fk_product = trim($this->fk_product); + } + if (isset($this->fk_commandefourndet)) { + $this->fk_commandefourndet = trim($this->fk_commandefourndet); + } + if (isset($this->qty)) { + $this->qty = trim($this->qty); + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = trim($this->fk_entrepot); + } + if (isset($this->fk_user)) { + $this->fk_user = trim($this->fk_user); + } + if (isset($this->comment)) { + $this->comment = trim($this->comment); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + if (isset($this->batch)) { + $this->batch = trim($this->batch); + } @@ -357,34 +395,34 @@ class CommandeFournisseurDispatch extends CommonObject dol_syslog(__METHOD__); $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) - { - if (empty($this->id) && !empty($this->rowid))$this->id = $this->rowid; + if (!$error) { + if (!$error) { + if (empty($this->id) && !empty($this->rowid)) { + $this->id = $this->rowid; + } $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$notrigger) - { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you $result = $this->call_trigger('LINERECEPTION_UPDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } //// End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -397,13 +435,13 @@ class CommandeFournisseurDispatch extends CommonObject } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -411,10 +449,8 @@ class CommandeFournisseurDispatch extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -428,28 +464,26 @@ class CommandeFournisseurDispatch extends CommonObject // Remove extrafields if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE rowid=".$this->id; dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -491,21 +525,18 @@ class CommandeFournisseurDispatch extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $error++; } - if (!$error) - { + if (!$error) { } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -541,30 +572,36 @@ class CommandeFournisseurDispatch extends CommonObject global $langs; $langs->load('orders'); - if ($mode == 0) - { + if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } elseif ($mode == 1) - { + } elseif ($mode == 1) { return $langs->trans($this->statutshort[$status]); - } elseif ($mode == 2) - { + } elseif ($mode == 2) { return $langs->trans($this->statuts[$status]); - } elseif ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans($this->statuts[$status]), 'statut0'); - elseif ($status == 1) return img_picto($langs->trans($this->statuts[$status]), 'statut4'); - elseif ($status == 2) return img_picto($langs->trans($this->statuts[$status]), 'statut8'); - } elseif ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans($this->statuts[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 1) return img_picto($langs->trans($this->statuts[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 2) return img_picto($langs->trans($this->statuts[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); - } elseif ($mode == 5) - { - if ($status == 0) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut0'); - elseif ($status == 1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut4'); - elseif ($status == 2) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut8'); + } elseif ($mode == 3) { + if ($status == 0) { + return img_picto($langs->trans($this->statuts[$status]), 'statut0'); + } elseif ($status == 1) { + return img_picto($langs->trans($this->statuts[$status]), 'statut4'); + } elseif ($status == 2) { + return img_picto($langs->trans($this->statuts[$status]), 'statut8'); + } + } elseif ($mode == 4) { + if ($status == 0) { + return img_picto($langs->trans($this->statuts[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 1) { + return img_picto($langs->trans($this->statuts[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 2) { + return img_picto($langs->trans($this->statuts[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); + } + } elseif ($mode == 5) { + if ($status == 0) { + return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut0'); + } elseif ($status == 1) { + return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut4'); + } elseif ($status == 2) { + return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$status]).' </span>'.img_picto($langs->trans($this->statuts[$status]), 'statut8'); + } } } @@ -610,7 +647,7 @@ class CommandeFournisseurDispatch extends CommonObject { dol_syslog(__METHOD__, LOG_DEBUG); - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.fk_commande,"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0157dbd0eec..2336b22a366 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -38,8 +38,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.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'; +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'; +} /** * Class to manage suppliers invoices @@ -350,9 +354,15 @@ class FactureFournisseur extends CommonInvoice $now = dol_now(); // Clean parameters - if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); - if (empty($this->type)) $this->type = self::TYPE_STANDARD; - if (empty($this->date)) $this->date = $now; + if (isset($this->ref_supplier)) { + $this->ref_supplier = trim($this->ref_supplier); + } + if (empty($this->type)) { + $this->type = self::TYPE_STANDARD; + } + if (empty($this->date)) { + $this->date = $now; + } $socid = $this->socid; $ref_supplier = $this->ref_supplier; @@ -360,10 +370,12 @@ class FactureFournisseur extends CommonInvoice $remise = $this->remise; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); - else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; @@ -371,7 +383,9 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); - if (!$remise) $remise = 0; + if (!$remise) { + $remise = 0; + } $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn ("; $sql .= "ref"; @@ -423,8 +437,7 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn'); // Update ref with new one @@ -433,25 +446,21 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) $error++; + if (!$resql) { + $error++; + } - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) { // To use new linkedObjectsIds instead of old linked_objects $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { + if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { dol_print_error($this->db); $error++; } @@ -460,8 +469,7 @@ class FactureFournisseur extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { + if (!$ret) { dol_print_error($this->db); $error++; } @@ -469,17 +477,14 @@ class FactureFournisseur extends CommonInvoice } } - if (count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) - { + if (count($this->lines) && is_object($this->lines[0])) { // If this->lines is array of InvoiceLines (preferred mode) dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); - foreach ($this->lines as $i => $val) - { + foreach ($this->lines as $i => $val) { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn, special_code)'; $sql .= ' VALUES ('.$this->id.','.intval($this->lines[$i]->special_code).')'; $resql_insert = $this->db->query($sql); - if ($resql_insert) - { + if ($resql_insert) { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); $this->updateline( @@ -511,20 +516,20 @@ class FactureFournisseur extends CommonInvoice } else // If this->lines is an array of invoice line arrays { dol_syslog("There is ".count($this->lines)." lines that are array lines"); - foreach ($this->lines as $i => $val) - { + foreach ($this->lines as $i => $val) { $line = $this->lines[$i]; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (!is_object($line)) $line = (object) $line; + if (!is_object($line)) { + $line = (object) $line; + } $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn, special_code)'; $sql .= ' VALUES ('.$this->id.','.intval($this->lines[$i]->special_code).')'; $resql_insert = $this->db->query($sql); - if ($resql_insert) - { + if ($resql_insert) { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); $this->updateline( @@ -539,7 +544,7 @@ class FactureFournisseur extends CommonInvoice 'HT', (!empty($line->info_bits) ? $line->info_bits : ''), $line->product_type - ); + ); } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -550,28 +555,25 @@ class FactureFournisseur extends CommonInvoice // Update total price $result = $this->update_price(); - if ($result > 0) - { + if ($result > 0) { // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -584,8 +586,7 @@ class FactureFournisseur extends CommonInvoice return -3; } } else { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $langs->trans('ErrorRefAlreadyExists'); $this->db->rollback(); return -1; @@ -655,15 +656,17 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON t.fk_cond_reglement = cr.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; - if ($id) $sql .= " WHERE t.rowid=".$id; - if ($ref) $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; + if ($id) { + $sql .= " WHERE t.rowid=".$id; + } + if ($ref) { + $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -737,11 +740,12 @@ class FactureFournisseur extends CommonInvoice // fetch optionals attributes and labels $this->fetch_optionals(); - if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) { + $this->brouillon = 1; + } $result = $this->fetch_lines(); - if ($result < 0) - { + if ($result < 0) { $this->error = $this->db->lasterror(); return -3; } @@ -783,14 +787,11 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql_rows = $this->db->query($sql); - if ($resql_rows) - { + if ($resql_rows) { $num_rows = $this->db->num_rows($resql_rows); - if ($num_rows) - { + if ($num_rows) { $i = 0; - while ($i < $num_rows) - { + while ($i < $num_rows) { $obj = $this->db->fetch_object($resql_rows); $line = new SupplierInvoiceLine($this->db); @@ -877,37 +878,95 @@ class FactureFournisseur extends CommonInvoice $error = 0; // Clean parameters - if (empty($this->type)) $this->type = self::TYPE_STANDARD; - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); - if (isset($this->entity)) $this->entity = trim($this->entity); - if (isset($this->type)) $this->type = trim($this->type); - if (isset($this->fk_soc)) $this->fk_soc = trim($this->fk_soc); - if (isset($this->label)) $this->label = trim($this->label); - if (isset($this->libelle)) $this->libelle = trim($this->libelle); // deprecated - if (isset($this->paye)) $this->paye = trim($this->paye); - if (isset($this->amount)) $this->amount = trim($this->amount); - if (isset($this->remise)) $this->remise = trim($this->remise); - if (isset($this->close_code)) $this->close_code = trim($this->close_code); - if (isset($this->close_note)) $this->close_note = trim($this->close_note); - if (isset($this->tva)) $this->tva = trim($this->tva); - if (isset($this->localtax1)) $this->localtax1 = trim($this->localtax1); - if (isset($this->localtax2)) $this->localtax2 = trim($this->localtax2); - if (empty($this->total_ht)) $this->total_ht = 0; - if (empty($this->total_tva)) $this->total_tva = 0; + if (empty($this->type)) { + $this->type = self::TYPE_STANDARD; + } + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } + if (isset($this->ref_supplier)) { + $this->ref_supplier = trim($this->ref_supplier); + } + if (isset($this->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->type)) { + $this->type = trim($this->type); + } + if (isset($this->fk_soc)) { + $this->fk_soc = trim($this->fk_soc); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->libelle)) { + $this->libelle = trim($this->libelle); // deprecated + } + if (isset($this->paye)) { + $this->paye = trim($this->paye); + } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } + if (isset($this->remise)) { + $this->remise = trim($this->remise); + } + if (isset($this->close_code)) { + $this->close_code = trim($this->close_code); + } + if (isset($this->close_note)) { + $this->close_note = trim($this->close_note); + } + if (isset($this->tva)) { + $this->tva = trim($this->tva); + } + if (isset($this->localtax1)) { + $this->localtax1 = trim($this->localtax1); + } + if (isset($this->localtax2)) { + $this->localtax2 = trim($this->localtax2); + } + if (empty($this->total_ht)) { + $this->total_ht = 0; + } + if (empty($this->total_tva)) { + $this->total_tva = 0; + } // if (isset($this->total_localtax1)) $this->total_localtax1=trim($this->total_localtax1); // if (isset($this->total_localtax2)) $this->total_localtax2=trim($this->total_localtax2); - if (isset($this->total_ttc)) $this->total_ttc = trim($this->total_ttc); - if (isset($this->statut)) $this->statut = (int) $this->statut; - if (isset($this->author)) $this->author = trim($this->author); - if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid); - if (isset($this->fk_facture_source)) $this->fk_facture_source = trim($this->fk_facture_source); - if (isset($this->fk_project)) $this->fk_project = trim($this->fk_project); - if (isset($this->cond_reglement_id)) $this->cond_reglement_id = trim($this->cond_reglement_id); - if (isset($this->note_private)) $this->note = trim($this->note_private); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->total_ttc)) { + $this->total_ttc = trim($this->total_ttc); + } + if (isset($this->statut)) { + $this->statut = (int) $this->statut; + } + if (isset($this->author)) { + $this->author = trim($this->author); + } + if (isset($this->fk_user_valid)) { + $this->fk_user_valid = trim($this->fk_user_valid); + } + if (isset($this->fk_facture_source)) { + $this->fk_facture_source = trim($this->fk_facture_source); + } + if (isset($this->fk_project)) { + $this->fk_project = trim($this->fk_project); + } + if (isset($this->cond_reglement_id)) { + $this->cond_reglement_id = trim($this->cond_reglement_id); + } + if (isset($this->note_private)) { + $this->note = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note_public = trim($this->note_public); + } + if (isset($this->model_pdf)) { + $this->model_pdf = trim($this->model_pdf); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } // Check parameters @@ -922,7 +981,9 @@ class FactureFournisseur extends CommonInvoice $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " datef=".(dol_strlen($this->date) != 0 ? "'".$this->db->idate($this->date)."'" : 'null').","; - if (dol_strlen($this->tms) != 0) $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + if (dol_strlen($this->tms) != 0) { + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + } $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").","; $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; @@ -963,31 +1024,27 @@ class FactureFournisseur extends CommonInvoice } } - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_UPDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -1019,10 +1076,8 @@ class FactureFournisseur extends CommonInvoice $remise = new DiscountAbsolute($this->db); $result = $remise->fetch($idremise); - if ($result > 0) - { - if ($remise->fk_invoice_supplier) // Protection against multiple submission - { + if ($result > 0) { + if ($remise->fk_invoice_supplier) { // Protection against multiple submission $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; @@ -1043,8 +1098,7 @@ class FactureFournisseur extends CommonInvoice $facligne->info_bits = 2; // Get buy/cost price of invoice that is source of discount - if ($remise->fk_invoice_supplier_source > 0) - { + if ($remise->fk_invoice_supplier_source > 0) { $srcinvoice = new FactureFournisseur($this->db); $srcinvoice->fetch($remise->fk_invoice_supplier_source); $totalcostpriceofinvoice = 0; @@ -1064,15 +1118,12 @@ class FactureFournisseur extends CommonInvoice $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; $lineid = $facligne->insert(); - if ($lineid > 0) - { + if ($lineid > 0) { $result = $this->update_price(1); - if ($result > 0) - { + if ($result > 0) { // Create link between discount and invoice line $result = $remise->link_to_invoice($lineid, 0, 'supplier'); - if ($result < 0) - { + if ($result < 0) { $this->error = $remise->error; $this->db->rollback(); return -4; @@ -1117,12 +1168,10 @@ class FactureFournisseur extends CommonInvoice $error = 0; $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -1156,8 +1205,7 @@ class FactureFournisseur extends CommonInvoice } } - if (!$error) - { + if (!$error) { $main = MAIN_DB_PREFIX.'facture_fourn_det'; $ef = $main."_extrafields"; $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture_fourn = $rowid)"; @@ -1165,8 +1213,7 @@ class FactureFournisseur extends CommonInvoice $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resqlef && $resql) - { + if ($resqlef && $resql) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql2 = $this->db->query($sql); @@ -1178,47 +1225,43 @@ class FactureFournisseur extends CommonInvoice } } - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive $this->deleteEcmFiles(); // We remove directory - if ($conf->fournisseur->facture->dir_output) - { + if ($conf->fournisseur->facture->dir_output) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $ref = dol_sanitizeFileName($this->ref); $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoive_supplier').$ref; $file = $dir."/".$ref.".pdf"; - if (file_exists($file)) - { - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (file_exists($file)) { + if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers $this->error = 'ErrorFailToDeleteFile'; $error++; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { $res = @dol_delete_dir_recursive($dir); - if (!$res) - { + if (!$res) { $this->error = 'ErrorFailToDeleteDir'; $error++; } @@ -1227,18 +1270,15 @@ class FactureFournisseur extends CommonInvoice } // Remove extrafields - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); $this->db->commit(); return 1; @@ -1289,11 +1329,12 @@ class FactureFournisseur extends CommonInvoice dol_syslog("FactureFournisseur::set_paid", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_PAYED', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; @@ -1301,8 +1342,7 @@ class FactureFournisseur extends CommonInvoice dol_print_error($this->db); } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1350,11 +1390,12 @@ class FactureFournisseur extends CommonInvoice dol_syslog("FactureFournisseur::set_unpaid", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_UNPAYED', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } else { $error++; @@ -1362,8 +1403,7 @@ class FactureFournisseur extends CommonInvoice dol_syslog("FactureFournisseur::set_unpaid ".$this->error); } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1397,19 +1437,16 @@ class FactureFournisseur extends CommonInvoice $this->fetch_lines(); // Check parameters - if ($this->statut > self::STATUS_DRAFT) // This is to avoid to validate twice (avoid errors on logs and stock management) - { + if ($this->statut > self::STATUS_DRAFT) { // This is to avoid to validate twice (avoid errors on logs and stock management) dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; } - if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->ref_supplier)) - { + if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->ref_supplier)) { $langs->load("errors"); $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("RefSupplier")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); return -1; } - if (count($this->lines) <= 0) - { + if (count($this->lines) <= 0) { $langs->load("errors"); $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; @@ -1418,11 +1455,9 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); // Define new ref - if ($force_number) - { + if ($force_number) { $num = $force_number; - } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { + } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef($this->thirdparty); } else { $num = $this->ref; @@ -1435,71 +1470,72 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Si on incrémente le produit principal et ses composants à la validation de facture fournisseur - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) - { + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($this->lines[$i]->fk_product > 0) { $this->line = $this->lines[$i]; $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We increase stock for product $up_ht_disc = $this->lines[$i]->pu_ht; - if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); - if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num)); - else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num)); - if ($result < 0) { $error++; } + if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { + $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); + } + if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num)); + } else { + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num)); + } + if ($result < 0) { + $error++; + } unset($this->line); } } } // Triggers call - if (!$error && empty($notrigger)) - { + if (!$error && empty($notrigger)) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$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($num); $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$oldref; $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -1512,15 +1548,13 @@ class FactureFournisseur extends CommonInvoice } // Set new ref and define current statut - if (!$error) - { + if (!$error) { $this->ref = $num; $this->statut = self::STATUS_VALIDATED; //$this->date_validation=$now; this is stored into log table } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1548,8 +1582,7 @@ class FactureFournisseur extends CommonInvoice $error = 0; - if ($this->statut == self::STATUS_DRAFT) - { + if ($this->statut == self::STATUS_DRAFT) { dol_syslog(__METHOD__." already draft status", LOG_WARNING); return 0; } @@ -1563,42 +1596,40 @@ class FactureFournisseur extends CommonInvoice $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); - if ($result) - { - if (!$error) - { + if ($result) { + if (!$error) { $this->oldcopy = clone $this; } // Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente - if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) - { + if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We increase stock for product - if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); - else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + } else { + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + } } } } // Triggers call - if (!$error && empty($notrigger)) - { + if (!$error && empty($notrigger)) { // Call trigger $result = $this->call_trigger('BILL_SUPPLIER_UNVALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if ($error == 0) - { + if ($error == 0) { $this->db->commit(); return 1; } else { @@ -1652,17 +1683,32 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - if ($this->statut == self::STATUS_DRAFT) - { + if ($this->statut == self::STATUS_DRAFT) { // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; - if (empty($qty)) $qty = 0; - if (empty($info_bits)) $info_bits = 0; - if (empty($rang)) $rang = 0; - if (empty($ventil)) $ventil = 0; - if (empty($txtva)) $txtva = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($remise_percent)) { + $remise_percent = 0; + } + if (empty($qty)) { + $qty = 0; + } + if (empty($info_bits)) { + $info_bits = 0; + } + if (empty($rang)) { + $rang = 0; + } + if (empty($ventil)) { + $ventil = 0; + } + if (empty($txtva)) { + $txtva = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -1681,15 +1727,12 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); - if ($fk_product > 0) - { - if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) - { + if ($fk_product > 0) { + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." qty=".$qty." ref_supplier=".$ref_supplier); $prod = new Product($this->db, $fk_product); - if ($prod->fetch($fk_product) > 0) - { + if ($prod->fetch($fk_product) > 0) { $product_type = $prod->type; $label = $prod->label; $fk_prod_fourn_price = 0; @@ -1697,16 +1740,17 @@ class FactureFournisseur extends CommonInvoice // We use 'none' instead of $ref_supplier, because $ref_supplier may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc - if ($result > 0) - { - if (empty($pu)) $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + if ($result > 0) { + if (empty($pu)) { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + } $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent != 0) + if ($remise_percent == 0 && $prod->remise_percent != 0) { $remise_percent = $prod->remise_percent; + } } - if ($result == 0) // If result == 0, we failed to found the supplier reference price - { + if ($result == 0) { // If result == 0, we failed to found the supplier reference price $langs->load("errors"); $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); @@ -1715,16 +1759,14 @@ class FactureFournisseur extends CommonInvoice //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price return -1; } - if ($result == -1) - { + if ($result == -1) { $langs->load("errors"); $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); return -1; } - if ($result < -1) - { + if ($result < -1) { $this->error = $prod->error; $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); @@ -1749,8 +1791,7 @@ class FactureFournisseur extends CommonInvoice // Clean vat code $reg = array(); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } @@ -1775,10 +1816,11 @@ class FactureFournisseur extends CommonInvoice $pu_ht_devise = $tabprice[19]; // Check parameters - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } - if ($rang < 0) - { + if ($rang < 0) { $rangmax = $this->line_max(); $rang = $rangmax + 1; } @@ -1837,15 +1879,15 @@ class FactureFournisseur extends CommonInvoice } $result = $this->line->insert($notrigger); - if ($result > 0) - { + if ($result > 0) { // Reorder if child line - if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) { + $this->line_order(true, 'DESC'); + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. - if ($result > 0) - { + if ($result > 0) { $this->db->commit(); return $this->line->id; } else { @@ -1902,7 +1944,9 @@ class FactureFournisseur extends CommonInvoice // Check parameters //if (! is_numeric($pu) || ! is_numeric($qty)) return -1; - if ($type < 0) return -1; + if ($type < 0) { + return -1; + } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -1911,9 +1955,15 @@ class FactureFournisseur extends CommonInvoice } // Clean parameters - if (empty($vatrate)) $vatrate = 0; - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($vatrate)) { + $vatrate = 0; + } + if (empty($txlocaltax1)) { + $txlocaltax1 = 0; + } + if (empty($txlocaltax2)) { + $txlocaltax2 = 0; + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); @@ -1929,8 +1979,7 @@ class FactureFournisseur extends CommonInvoice // Clean vat code $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $vatrate, $reg)) - { + if (preg_match('/\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } @@ -1951,10 +2000,11 @@ class FactureFournisseur extends CommonInvoice $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - if (empty($info_bits)) $info_bits = 0; + if (empty($info_bits)) { + $info_bits = 0; + } - if ($idproduct) - { + if ($idproduct) { $product = new Product($this->db); $result = $product->fetch($idproduct); $product_type = $product->type; @@ -2046,8 +2096,7 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -2068,8 +2117,7 @@ class FactureFournisseur extends CommonInvoice } else { $res = $this->update_price(); - if ($res > 0) - { + if ($res > 0) { $this->db->commit(); return 1; } else { @@ -2095,26 +2143,21 @@ class FactureFournisseur extends CommonInvoice $sql .= ' WHERE c.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_modif) - { + if ($obj->fk_user_modif) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; @@ -2155,15 +2198,15 @@ class FactureFournisseur extends CommonInvoice $sql .= " AND f.paye = 0"; // Pas classee payee completement $sql .= " AND pf.fk_paiementfourn IS NULL"; // Aucun paiement deja fait $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($socid > 0) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_replacable_supplier_invoices", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $return[$obj->rowid] = array( 'id' => $obj->rowid, 'ref' => $obj->ref, @@ -2203,20 +2246,23 @@ class FactureFournisseur extends CommonInvoice $sql .= " AND NOT EXISTS (SELECT rowid from ".MAIN_DB_PREFIX."facture_fourn as ff WHERE f.rowid = ff.fk_facture_source"; $sql .= " AND ff.type=".self::TYPE_REPLACEMENT.")"; $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($socid > 0) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_qualified_avoir_supplier_invoices", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $qualified = 0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; - if ($qualified) - { + if ($obj->fk_statut == self::STATUS_VALIDATED) { + $qualified = 1; + } + if ($obj->fk_statut == self::STATUS_CLOSED) { + $qualified = 1; + } + if ($qualified) { $paymentornot = ($obj->fk_paiementfourn ? 1 : 0); $return[$obj->rowid] = array('ref'=>$obj->ref, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); } @@ -2243,16 +2289,21 @@ class FactureFournisseur extends CommonInvoice $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ' WHERE ff.paye=0'; $sql .= ' AND ff.fk_statut > 0'; $sql .= " AND ff.entity = ".$conf->entity; - if ($user->socid) $sql .= ' AND ff.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) { + $sql .= ' AND ff.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $langs->load("bills"); $now = dol_now(); @@ -2266,8 +2317,7 @@ class FactureFournisseur extends CommonInvoice $facturestatic = new FactureFournisseur($this->db); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; $facturestatic->date_echeance = $this->db->jdate($obj->datefin); @@ -2307,56 +2357,84 @@ class FactureFournisseur extends CommonInvoice $result = ''; - if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id.'&type=bank-transfer'; - elseif ($option == 'document') $url = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$this->id; - else $url = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$this->id; + if ($option == 'withdraw') { + $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id.'&type=bank-transfer'; + } elseif ($option == 'document') { + $url = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$this->id; + } else { + $url = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$this->id; + } - if ($short) return $url; + if ($short) { + return $url; + } - if ($option !== 'nolink') - { + 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'; + 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'; + } } $picto = $this->picto; - if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice + if ($this->type == self::TYPE_REPLACEMENT) { + $picto .= 'r'; // Replacement invoice + } + if ($this->type == self::TYPE_CREDIT_NOTE) { + $picto .= 'a'; // Credit note + } + if ($this->type == self::TYPE_DEPOSIT) { + $picto .= 'd'; // Deposit invoice + } $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("SupplierInvoice").'</u>'; - if ($this->type == self::TYPE_REPLACEMENT) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("InvoiceReplace").'</u>'; - elseif ($this->type == self::TYPE_CREDIT_NOTE) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("CreditNote").'</u>'; - elseif ($this->type == self::TYPE_DEPOSIT) $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("Deposit").'</u>'; - if (!empty($this->ref)) + if ($this->type == self::TYPE_REPLACEMENT) { + $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("InvoiceReplace").'</u>'; + } elseif ($this->type == self::TYPE_CREDIT_NOTE) { + $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("CreditNote").'</u>'; + } elseif ($this->type == self::TYPE_DEPOSIT) { + $label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("Deposit").'</u>'; + } + if (!empty($this->ref)) { $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; - if (!empty($this->ref_supplier)) + } + if (!empty($this->ref_supplier)) { $label .= '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier; - if (!empty($this->label)) + } + if (!empty($this->label)) { $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label; - if (!empty($this->date)) + } + if (!empty($this->date)) { $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day'); - if (!empty($this->total_ht)) + } + if (!empty($this->total_ht)) { $label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) + } + if (!empty($this->total_tva)) { $label .= '<br><b>'.$langs->trans('AmountVAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) + } + if (!empty($this->total_ttc)) { $label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label .= ' - '.$moretitle; + } + if ($moretitle) { + $label .= ' - '.$moretitle; + } if (isset($this->statut) && isset($this->alreadypaid)) { $label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5, $this->alreadypaid); } $ref = $this->ref; - if (empty($ref)) $ref = $this->id; + if (empty($ref)) { + $ref = $this->id; + } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowSupplierInvoice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -2369,15 +2447,17 @@ class FactureFournisseur extends CommonInvoice $linkend = '</a>'; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($max ?dol_trunc($ref, $max) : $ref); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($max ?dol_trunc($ref, $max) : $ref); + } $result .= $linkend; - if ($addlinktonotes) - { + if ($addlinktonotes) { $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) - { + if ($txttoshow) { $notetoshow = $langs->trans("ViewPrivateNote").':<br>'.dol_string_nohtmltag($txttoshow, 1); $result .= ' <span class="note inline-block">'; $result .= '<a href="'.DOL_URL_ROOT.'/fourn/facture/note.php?id='.$this->id.'" class="classfortooltip" title="'.dol_escape_htmltag($notetoshow).'">'; @@ -2406,7 +2486,9 @@ class FactureFournisseur extends CommonInvoice $langs->load("orders"); // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER = 'mod_facture_fournisseur_cactus'; + if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) { + $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER = 'mod_facture_fournisseur_cactus'; + } $mybool = false; @@ -2432,8 +2514,7 @@ class FactureFournisseur extends CommonInvoice $numref = ""; $numref = $obj->getNumRef($soc, $this, $mode); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -2467,12 +2548,10 @@ class FactureFournisseur extends CommonInvoice $sql .= $this->db->plimit(100); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_prods = $this->db->num_rows($resql); $i = 0; - while ($i < $num_prods) - { + while ($i < $num_prods) { $i++; $row = $this->db->fetch_row($resql); $prodids[$i] = $row[0]; @@ -2496,13 +2575,11 @@ class FactureFournisseur extends CommonInvoice $this->multicurrency_tx = 1; $this->multicurrency_code = $conf->currency; - if (empty($option) || $option != 'nolines') - { + if (empty($option) || $option != 'nolines') { // Lines $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line = new SupplierInvoiceLine($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->qty = 1; @@ -2512,8 +2589,7 @@ class FactureFournisseur extends CommonInvoice $line->tva_tx = 19.6; $line->localtax1_tx = 0; $line->localtax2_tx = 0; - if ($xnbp == 2) - { + if ($xnbp == 2) { $line->total_ht = 50; $line->total_ttc = 59.8; $line->total_tva = 9.8; @@ -2525,8 +2601,7 @@ class FactureFournisseur extends CommonInvoice $line->remise_percent = 0; } - if ($num_prods > 0) - { + if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; } @@ -2566,8 +2641,7 @@ class FactureFournisseur extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -2575,10 +2649,8 @@ class FactureFournisseur extends CommonInvoice $sql .= " ".$clause." f.entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["supplier_invoices"] = $obj->nb; } $this->db->free($resql); @@ -2629,10 +2701,8 @@ class FactureFournisseur extends CommonInvoice $object->close_note = ''; // Loop on each line of new invoice - foreach ($object->lines as $i => $line) - { - if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts - { + foreach ($object->lines as $i => $line) { + if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts unset($object->lines[$i]); } } @@ -2642,22 +2712,19 @@ class FactureFournisseur extends CommonInvoice $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $this->errors = $object->errors; $error++; } - if (!$error) - { + if (!$error) { } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -2685,18 +2752,15 @@ class FactureFournisseur extends CommonInvoice $outputlangs->load("products"); // Set the model on the model name to use - if (empty($modele)) - { - if (!empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) - { + if (empty($modele)) { + if (!empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { $modele = $conf->global->INVOICE_SUPPLIER_ADDON_PDF; } else { $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation } } - if (empty($modele)) - { + if (empty($modele)) { return 0; } else { $modelpath = "core/modules/supplier_invoice/doc/"; @@ -2764,7 +2828,9 @@ class FactureFournisseur extends CommonInvoice $resql = $this->db->query($sql); if (!empty($resql)) { $obj = $this->db->fetch_object($resql); - if (!empty($obj->fk_invoice_supplier)) $isUsed = true; + if (!empty($obj->fk_invoice_supplier)) { + $isUsed = true; + } } return $isUsed; @@ -3111,11 +3177,9 @@ class SupplierInvoiceLine extends CommonObjectLine $this->deleteObjectLinked(); // Remove extrafields - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } @@ -3133,8 +3197,7 @@ class SupplierInvoiceLine extends CommonObjectLine } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -3157,22 +3220,31 @@ class SupplierInvoiceLine extends CommonObjectLine $qty = price2num($this->qty); // Check parameters - if (empty($this->qty)) $this->qty = 0; + if (empty($this->qty)) { + $this->qty = 0; + } if ($this->product_type < 0) { return -1; } // Clean parameters - if (empty($this->remise_percent)) $this->remise_percent = 0; - if (empty($this->tva_tx)) $this->tva_tx = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } + if (empty($this->tva_tx)) { + $this->tva_tx = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } $this->db->begin(); - if (empty($this->fk_product)) - { + if (empty($this->fk_product)) { $fk_product = "null"; } else { $fk_product = $this->fk_product; @@ -3229,17 +3301,14 @@ class SupplierInvoiceLine extends CommonObjectLine $this->rowid = $this->id; $error = 0; - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { global $langs, $user; // Call trigger @@ -3275,41 +3344,78 @@ class SupplierInvoiceLine extends CommonObjectLine // Clean parameters $this->desc = trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx = 0; - if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; - if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - if (empty($this->localtax1_type)) $this->localtax1_type = '0'; - if (empty($this->localtax2_type)) $this->localtax2_type = '0'; - if (empty($this->total_tva)) $this->total_tva = 0; - if (empty($this->total_localtax1)) $this->total_localtax1 = 0; - if (empty($this->total_localtax2)) $this->total_localtax2 = 0; - if (empty($this->rang)) $this->rang = 0; - if (empty($this->remise_percent)) $this->remise_percent = 0; - if (empty($this->info_bits)) $this->info_bits = 0; - if (empty($this->subprice)) $this->subprice = 0; - if (empty($this->special_code)) $this->special_code = 0; - if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; - if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (empty($this->tva_tx)) { + $this->tva_tx = 0; + } + if (empty($this->localtax1_tx)) { + $this->localtax1_tx = 0; + } + if (empty($this->localtax2_tx)) { + $this->localtax2_tx = 0; + } + if (empty($this->localtax1_type)) { + $this->localtax1_type = '0'; + } + if (empty($this->localtax2_type)) { + $this->localtax2_type = '0'; + } + if (empty($this->total_tva)) { + $this->total_tva = 0; + } + if (empty($this->total_localtax1)) { + $this->total_localtax1 = 0; + } + if (empty($this->total_localtax2)) { + $this->total_localtax2 = 0; + } + if (empty($this->rang)) { + $this->rang = 0; + } + if (empty($this->remise_percent)) { + $this->remise_percent = 0; + } + if (empty($this->info_bits)) { + $this->info_bits = 0; + } + if (empty($this->subprice)) { + $this->subprice = 0; + } + if (empty($this->special_code)) { + $this->special_code = 0; + } + if (empty($this->fk_parent_line)) { + $this->fk_parent_line = 0; + } + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { + $this->situation_percent = 100; + } - if (empty($this->pa_ht)) $this->pa_ht = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->pa_ht)) { + $this->pa_ht = 0; + } + if (empty($this->multicurrency_subprice)) { + $this->multicurrency_subprice = 0; + } + if (empty($this->multicurrency_total_ht)) { + $this->multicurrency_total_ht = 0; + } + if (empty($this->multicurrency_total_tva)) { + $this->multicurrency_total_tva = 0; + } + if (empty($this->multicurrency_total_ttc)) { + $this->multicurrency_total_ttc = 0; + } // Check parameters - if ($this->product_type < 0) - { + if ($this->product_type < 0) { $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (!empty($this->fk_product)) - { + if (!empty($this->fk_product)) { // Check product exists $result = Product::isExistingObject('product', $this->fk_product); - if ($result <= 0) - { + if ($result <= 0) { $this->error = 'ErrorProductIdDoesNotExists'; return -1; } @@ -3365,26 +3471,21 @@ class SupplierInvoiceLine extends CommonObjectLine $sql .= ')'; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->rowid = $this->id; // backward compatibility - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } @@ -3423,8 +3524,7 @@ class SupplierInvoiceLine extends CommonObjectLine dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6ae9a3491ab..e0eea961b9e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -168,14 +168,12 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); $resql2 = $this->db->query($sql); - if (!$resql2) - { + if (!$resql2) { $this->error = $this->db->lasterror(); $ok = 0; } - if ($ok) - { + if ($ok) { $this->db->commit(); return 1; } else { @@ -203,18 +201,18 @@ class ProductFournisseur extends Product // Call trigger $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if (empty($error)) - { + if (empty($error)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = $this->db->lasterror(); $error++; } @@ -266,15 +264,28 @@ class ProductFournisseur extends Product //global $mysoc; // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { + if (empty($qty)) { + $qty = 0; + } + if (empty($buyprice)) { + $buyprice = 0; + } + if (empty($charges)) { + $charges = 0; + } + if (empty($availability)) { + $availability = 0; + } + if (empty($remise_percent)) { + $remise_percent = 0; + } + if (empty($supplier_reputation) || $supplier_reputation == -1) { + $supplier_reputation = ''; + } + if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) { + $delivery_time_days = ''; + } + if ($price_base_type == 'TTC') { $ttx = $tva_tx; $buyprice = $buyprice / (1 + ($ttx / 100)); } @@ -283,10 +294,13 @@ class ProductFournisseur extends Product $multicurrency_unitBuyPrice = null; $fk_multicurrency = null; if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { + if (empty($multicurrency_tx)) { + $multicurrency_tx = 1; + } + if (empty($multicurrency_buyprice)) { + $multicurrency_buyprice = 0; + } + if ($multicurrency_price_base_type == 'TTC') { $ttx = $tva_tx; $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); } @@ -309,8 +323,7 @@ class ProductFournisseur extends Product $newvat = $tva_tx; - if (count($localtaxes_array) > 0) - { + if (count($localtaxes_array) > 0) { $localtaxtype1 = $localtaxes_array['0']; $localtax1 = $localtaxes_array['1']; $localtaxtype2 = $localtaxes_array['2']; @@ -321,26 +334,26 @@ class ProductFournisseur extends Product $localtaxtype2 = '0'; $localtax2 = get_localtax($newvat, 2); } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 + if (empty($localtax1)) { + $localtax1 = 0; // If = '' then = 0 + } + if (empty($localtax2)) { + $localtax2 = 0; // If = '' then = 0 + } // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { + if ($buyprice != '' && !is_numeric($buyprice)) { } $this->db->begin(); - if ($this->product_fourn_price_id > 0) - { + if ($this->product_fourn_price_id > 0) { // check if price already logged, if not first log current price $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { + if (is_array($logPrices) && count($logPrices) == 0) { $currentPfp = new self($this->db); $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { + if ($result > 0 && $currentPfp->fourn_price != 0) { $currentPfpUser = new User($this->db); $result = $currentPfpUser->fetch($currentPfp->user_id); if ($result > 0) { @@ -387,27 +400,28 @@ class ProductFournisseur extends Product $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); + } $sql .= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { + if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); if ($result < 0) { $error++; } } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return $this->product_fourn_price_id; } else { @@ -431,7 +445,9 @@ class ProductFournisseur extends Product $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= ", packaging"; + } $sql .= " values("; $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; @@ -459,7 +475,9 @@ class ProductFournisseur extends Product $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); + } $sql .= ")"; $this->product_fourn_price_id = 0; @@ -483,8 +501,9 @@ class ProductFournisseur extends Product if (!$error) { // Call trigger $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) + if ($result < 0) { $error++; + } // End call triggers if (empty($error)) { @@ -532,11 +551,9 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->product_fourn_price_id = $rowid; $this->id = $obj->fk_product; @@ -578,18 +595,18 @@ class ProductFournisseur extends Product if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; + if ($this->packaging < $this->fourn_qty) { + $this->packaging = $this->fourn_qty; + } } - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { + if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) { $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProductSupplier($this); if ($price_result >= 0) { $this->fourn_price = $price_result; //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { + if ($this->fourn_qty != 0) { $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); } else { $this->fourn_unitprice = ""; @@ -629,24 +646,27 @@ class ProductFournisseur extends Product $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"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= ", pfp.packaging"; + } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; $sql .= " AND s.status=1"; // only enabled company selected $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); + if (empty($sortfield)) { + $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; + } else { + $sql .= $this->db->order($sortfield, $sortorder); + } $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { //define base attribute $prodfourn = new ProductFournisseur($this->db); @@ -683,7 +703,9 @@ class ProductFournisseur extends Product if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; + if ($prodfourn->packaging < $prodfourn->fourn_qty) { + $prodfourn->packaging = $prodfourn->fourn_qty; + } } if (!empty($conf->barcode->enabled)) { @@ -700,10 +722,8 @@ class ProductFournisseur extends Product } } - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { + if (!isset($prodfourn->fourn_unitprice)) { + if ($prodfourn->fourn_qty != 0) { $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); } else { $prodfourn->fourn_unitprice = ""; @@ -735,8 +755,7 @@ class ProductFournisseur extends Product // phpcs:enable global $conf; - if (empty($prodid)) - { + if (empty($prodid)) { dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); return 0; } @@ -771,30 +790,30 @@ class ProductFournisseur extends Product $sql .= " AND pfp.fk_product = ".$prodid; $sql .= " AND pfp.fk_soc = s.rowid"; $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; + if ($qty > 0) { + $sql .= " AND pfp.quantity <= ".$qty; + } + if ($socid > 0) { + $sql .= ' AND pfp.fk_soc = '.$socid; + } dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $record_array = array(); //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { $record_array[] = $record; } - if (count($record_array) == 0) - { + if (count($record_array) == 0) { $this->db->free($resql); return 0; } else { $min = -1; - foreach ($record_array as $record) - { + foreach ($record_array as $record) { $fourn_price = $record["price"]; // discount calculated buy price $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; @@ -809,16 +828,14 @@ class ProductFournisseur extends Product $price_result = $priceparser->parseProductSupplier($prod_supplier); if ($price_result >= 0) { $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { + if ($record["quantity"] != 0) { $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); } else { $fourn_unitprice = $fourn_price; } } } - if ($fourn_unitprice < $min || $min == -1) - { + if ($fourn_unitprice < $min || $min == -1) { $this->product_fourn_price_id = $record["product_fourn_price_id"]; $this->ref_supplier = $record["ref_fourn"]; $this->ref_fourn = $record["ref_fourn"]; // deprecated @@ -874,8 +891,7 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -982,18 +998,19 @@ class ProductFournisseur extends Product $sql .= " AND pfpl.fk_user = u.rowid"; $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); + if (empty($sortfield)) { + $sql .= " ORDER BY pfpl.datec"; + } else { + $sql .= $this->db->order($sortfield, $sortorder); + } $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $tmparray = array(); $tmparray['rowid'] = $obj->rowid; $tmparray['supplier_ref'] = $obj->supplier_ref; @@ -1126,7 +1143,9 @@ class ProductFournisseur extends Product if ($this->height) { $labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Height").'</b>: '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } - if ($labelsize) $label .= "<br>".$labelsize; + if ($labelsize) { + $label .= "<br>".$labelsize; + } $labelsurfacevolume = ""; if ($this->surface) { @@ -1135,7 +1154,9 @@ class ProductFournisseur extends Product if ($this->volume) { $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } - if ($labelsurfacevolume) $label .= "<br>".$labelsurfacevolume; + if ($labelsurfacevolume) { + $label .= "<br>".$labelsurfacevolume; + } } if (!empty($conf->accounting->enabled) && $this->status) { diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index cd172d08345..ceb7bb835ef 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -98,20 +98,19 @@ class PaiementFourn extends Paiement $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql .= ' WHERE p.entity IN ('.getEntity('facture_fourn').')'; - if ($id > 0) + if ($id > 0) { $sql .= ' AND p.rowid = '.$id; - elseif ($ref) + } elseif ($ref) { $sql .= ' AND p.rowid = '.$ref; - elseif ($fk_bank) + } elseif ($fk_bank) { $sql .= ' AND p.fk_bank = '.$fk_bank; + } //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -166,8 +165,7 @@ class PaiementFourn extends Paiement dol_syslog(get_class($this)."::create", LOG_DEBUG); - if ($way == 'dolibarr') - { + if ($way == 'dolibarr') { $amounts = &$this->amounts; $amounts_to_update = &$this->multicurrency_amounts; } else { @@ -175,8 +173,7 @@ class PaiementFourn extends Paiement $amounts_to_update = &$this->amounts; } - foreach ($amounts as $key => $value) - { + foreach ($amounts as $key => $value) { $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value ? $value : 0, $way, 'facture_fourn'); $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -190,13 +187,11 @@ class PaiementFourn extends Paiement $this->db->begin(); - if ($totalamount <> 0) // On accepte les montants negatifs - { + if ($totalamount <> 0) { // On accepte les montants negatifs $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); $now = dol_now(); - if ($way == 'dolibarr') - { + if ($way == 'dolibarr') { $total = $totalamount; $mtotal = $totalamount_converted; // Maybe use price2num with MT for the converted value } else { @@ -210,28 +205,23 @@ class PaiementFourn extends Paiement $sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', ".$user->id.", 0)"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiementfourn'); // Insere tableau des montants / factures - foreach ($this->amounts as $key => $amount) - { + foreach ($this->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { + if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount)'; $sql .= ' VALUES ('.$facid.','.$this->id.',\''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')'; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $invoice = new FactureFournisseur($this->db); $invoice->fetch($facid); // If we want to closed paid invoices - if ($closepaidinvoices) - { + if ($closepaidinvoices) { $paiement = $invoice->getSommePaiement(); //$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes = 0; @@ -239,18 +229,20 @@ class PaiementFourn extends Paiement $deposits = 0; $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); - if ($remaintopay == 0) - { + if ($remaintopay == 0) { $result = $invoice->setPaid($user, '', ''); - } else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); + } else { + dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); + } } // Regenerate documents of invoices - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $newlang = ''; $outputlangs = $langs; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $invoice->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -271,11 +263,12 @@ class PaiementFourn extends Paiement } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('PAYMENT_SUPPLIER_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } else { @@ -288,8 +281,7 @@ class PaiementFourn extends Paiement $error++; } - if ($totalamount <> 0 && $error == 0) // On accepte les montants negatifs - { + if ($totalamount <> 0 && $error == 0) { // On accepte les montants negatifs $this->amount = $total; $this->total = $total; $this->multicurrency_amount = $mtotal; @@ -322,10 +314,8 @@ class PaiementFourn extends Paiement // Verifier si paiement porte pas sur une facture a l'etat payee // Si c'est le cas, on refuse la suppression $billsarray = $this->getBillsArray('paye=1'); - if (is_array($billsarray)) - { - if (count($billsarray)) - { + if (is_array($billsarray)) { + if (count($billsarray)) { $this->error = "ErrorCantDeletePaymentSharedWithPayedInvoice"; $this->db->rollback(); return -1; @@ -337,12 +327,10 @@ class PaiementFourn extends Paiement // Verifier si paiement ne porte pas sur ecriture bancaire rapprochee // Si c'est le cas, on refuse le delete - if ($bank_line_id) - { + if ($bank_line_id) { $accline = new AccountLine($this->db); $accline->fetch($bank_line_id); - if ($accline->rappro) - { + if ($accline->rappro) { $this->error = "ErrorCantDeletePaymentReconciliated"; $this->db->rollback(); return -3; @@ -353,41 +341,34 @@ class PaiementFourn extends Paiement $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; $sql .= ' WHERE fk_paiementfourn = '.$this->id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn'; $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->error = $this->db->error(); $this->db->rollback(); return -3; } // Supprimer l'ecriture bancaire si paiement lie a ecriture - if ($bank_line_id) - { + if ($bank_line_id) { $accline = new AccountLine($this->db); $result = $accline->fetch($bank_line_id); - if ($result > 0) // If result = 0, record not found, we don't try to delete - { + if ($result > 0) { // If result = 0, record not found, we don't try to delete $result = $accline->delete($user); } - if ($result < 0) - { + if ($result < 0) { $this->error = $accline->error; $this->db->rollback(); return -4; } } - if (!$notrigger) - { + if (!$notrigger) { // Appel des triggers $result = $this->call_trigger('PAYMENT_SUPPLIER_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -416,22 +397,18 @@ class PaiementFourn extends Paiement $sql .= ' WHERE c.rowid = '.$id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num) - { + if ($num) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - if ($obj->fk_user_creat) - { + if ($obj->fk_user_creat) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creat); $this->user_creation = $cuser; } - if ($obj->fk_user_modif) - { + if ($obj->fk_user_modif) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; @@ -456,18 +433,18 @@ class PaiementFourn extends Paiement $sql = 'SELECT fk_facturefourn'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id; - if ($filter) $sql .= ' AND '.$filter; + if ($filter) { + $sql .= ' AND '.$filter; + } dol_syslog(get_class($this).'::getBillsArray', LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $this->db->num_rows($resql); $billsarray = array(); - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $billsarray[$i] = $obj->fk_facturefourn; $i++; @@ -564,20 +541,28 @@ class PaiementFourn extends Paiement $reg = array(); if (preg_match('/^\((.*)\)$/i', $text, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + if ($reg[1] == 'paiement') { + $reg[1] = 'Payment'; + } $text = $langs->trans($reg[1]); } $label = '<u>'.$langs->trans("Payment").'</u><br>'; $label .= '<strong>'.$langs->trans("Ref").':</strong> '.$text; - if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); + if ($this->datepaye ? $this->datepaye : $this->date) { + $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); + } $linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkend = '</a>'; $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; return $result; @@ -622,12 +607,15 @@ class PaiementFourn extends Paiement $langs->load("bills"); // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan'; - elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'brodator') $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_brodator'; - elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'bronan') $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan'; + if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) { + $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan'; + } elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'brodator') { + $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_brodator'; + } elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'bronan') { + $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan'; + } - if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON)) - { + if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON)) { $mybool = false; $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php"; @@ -640,8 +628,7 @@ class PaiementFourn extends Paiement $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) - { + if (is_file($dir.$file) && is_readable($dir.$file)) { $mybool |= include_once $dir.$file; } } @@ -706,18 +693,15 @@ class PaiementFourn extends Paiement $langs->load("suppliers"); // Set the model on the model name to use - if (empty($modele)) - { - if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)) - { + if (empty($modele)) { + if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)) { $modele = $conf->global->SUPPLIER_PAYMENT_ADDON_PDF; } else { $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation } } - if (empty($modele)) - { + if (empty($modele)) { return 0; } else { $modelpath = "core/modules/supplier_payment/doc/"; @@ -738,12 +722,9 @@ class PaiementFourn extends Paiement global $conf; $way = 'dolibarr'; - if (!empty($conf->multicurrency->enabled)) - { - foreach ($this->multicurrency_amounts as $value) - { - if (!empty($value)) // one value found then payment is in invoice currency - { + if (!empty($conf->multicurrency->enabled)) { + foreach ($this->multicurrency_amounts as $value) { + if (!empty($value)) { // one value found then payment is in invoice currency $way = 'customer'; break; } @@ -766,14 +747,11 @@ class PaiementFourn extends Paiement // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - if (empty($force_thirdparty_id)) - { + if (empty($force_thirdparty_id)) { $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him - if (!empty($billsarray)) - { + if (!empty($billsarray)) { $supplier_invoice = new FactureFournisseur($this->db); - if ($supplier_invoice->fetch($billsarray[0]) > 0) - { + if ($supplier_invoice->fetch($billsarray[0]) > 0) { $force_thirdparty_id = $supplier_invoice->fk_soc; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 0aea652de68..76ef5de8af0 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -41,10 +41,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -if (!empty($conf->supplier_proposal->enabled)) +if (!empty($conf->supplier_proposal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (!empty($conf->product->enabled)) +} +if (!empty($conf->product->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.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'; @@ -56,7 +58,9 @@ if (!empty($conf->variants->enabled)) { } $langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'receptions', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch')); -if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); +if (!empty($conf->incoterm->enabled)) { + $langs->load('incoterm'); +} $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -80,7 +84,9 @@ $datelivraison = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int' // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -93,20 +99,26 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); - if ($ret < 0) dol_print_error($db, $object->error); + if ($ret < 0) { + dol_print_error($db, $object->error); + } $ret = $object->fetch_thirdparty(); - if ($ret < 0) dol_print_error($db, $object->error); -} elseif (!empty($socid) && $socid > 0) -{ + if ($ret < 0) { + dol_print_error($db, $object->error); + } +} elseif (!empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); $ret = $fourn->fetch($socid); - if ($ret < 0) dol_print_error($db, $object->error); + if ($ret < 0) { + dol_print_error($db, $object->error); + } $object->socid = $fourn->id; $ret = $object->fetch_thirdparty(); - if ($ret < 0) dol_print_error($db, $object->error); + if ($ret < 0) { + dol_print_error($db, $object->error); + } } // Common permissions @@ -136,14 +148,13 @@ $permissiontoadd = $usercancreate; // Used by the include of actions_addupdated $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -156,67 +167,69 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'setref_supplier' && $usercancreate) - { + if ($action == 'setref_supplier' && $usercancreate) { $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Set incoterm - if ($action == 'set_incoterms' && $usercancreate) - { + if ($action == 'set_incoterms' && $usercancreate) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // payment conditions - if ($action == 'setconditions' && $usercancreate) - { + if ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // payment mode - if ($action == 'setmode' && $usercancreate) - { + if ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - } - - // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { + // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } // bank account - if ($action == 'setbankaccount' && $usercancreate) - { + if ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // date of delivery - if ($action == 'setdate_livraison' && $usercancreate) - { + if ($action == 'setdate_livraison' && $usercancreate) { $result = $object->setDeliveryDate($user, $datelivraison); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Set project - if ($action == 'classin' && $usercancreate) - { + if ($action == 'classin' && $usercancreate) { $result = $object->setProject($projectid); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Edit Thirdparty - if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $usercancreate && $object->statut == CommandeFournisseur::STATUS_DRAFT) - { + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $usercancreate && $object->statut == CommandeFournisseur::STATUS_DRAFT) { $new_socid = GETPOST('new_socid', 'int'); if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { $db->begin(); @@ -229,8 +242,9 @@ if (empty($reshook)) $res = $db->query($sql); - if (!$res) $db->rollback(); - else { + if (!$res) { + $db->rollback(); + } else { $db->commit(); // Replace prices for each lines by new supplier prices @@ -275,38 +289,44 @@ if (empty($reshook)) exit; } - if ($action == 'setremisepercent' && $usercancreate) - { + if ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise($user, $_POST['remise_percent']); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } - if ($action == 'reopen') // no test on permission here, permission to use will depends on status - { - if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) - { - if ($object->statut == 1) $newstatus = 0; // Validated->Draft - elseif ($object->statut == 2) $newstatus = 0; // Approved->Draft - elseif ($object->statut == 3) $newstatus = 2; // Ordered->Approved - elseif ($object->statut == 4) $newstatus = 3; - elseif ($object->statut == 5) - { + if ($action == 'reopen') { // no test on permission here, permission to use will depends on status + if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) { + if ($object->statut == 1) { + $newstatus = 0; // Validated->Draft + } elseif ($object->statut == 2) { + $newstatus = 0; // Approved->Draft + } elseif ($object->statut == 3) { + $newstatus = 2; // Ordered->Approved + } elseif ($object->statut == 4) { + $newstatus = 3; + } elseif ($object->statut == 5) { //$newstatus=2; // Ordered // TODO Can we set it to submited ? //$newstatus=3; // Submited // TODO If there is at least one reception, we can set to Received->Received partially $newstatus = 4; // Received partially - } elseif ($object->statut == 6) $newstatus = 2; // Canceled->Approved - elseif ($object->statut == 7) $newstatus = 3; // Canceled->Process running - elseif ($object->statut == 9) $newstatus = 1; // Refused->Validated - else $newstatus = 2; + } elseif ($object->statut == 6) { + $newstatus = 2; // Canceled->Approved + } elseif ($object->statut == 7) { + $newstatus = 3; // Canceled->Process running + } elseif ($object->statut == 9) { + $newstatus = 1; // Refused->Validated + } else { + $newstatus = 2; + } //print "old status = ".$object->statut.' new status = '.$newstatus; $db->begin(); $result = $object->setStatus($user, $newstatus); - if ($result > 0) - { + if ($result > 0) { // Currently the "Re-open" also remove the billed flag because there is no button "Set unpaid" yet. $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; $sql .= ' SET billed = 0'; @@ -314,8 +334,7 @@ if (empty($reshook)) $resql = $db->query($sql); - if ($newstatus == 0) - { + if ($newstatus == 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; $sql .= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; $sql .= ' WHERE rowid = '.$object->id; @@ -338,8 +357,7 @@ if (empty($reshook)) /* * Classify supplier order as billed */ - if ($action == 'classifybilled' && $usercancreate) - { + if ($action == 'classifybilled' && $usercancreate) { $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -347,8 +365,7 @@ if (empty($reshook)) } // Add a product line - if ($action == 'addline' && $usercancreate) - { + if ($action == 'addline' && $usercancreate) { $db->begin(); $langs->load('errors'); @@ -360,8 +377,7 @@ if (empty($reshook)) $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); - if ($prod_entry_mode == 'free') - { + if ($prod_entry_mode == 'free') { $idprod = 0; $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); @@ -386,28 +402,23 @@ if (empty($reshook)) } } - if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) - { + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) - { + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' - { + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not '' setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) - { + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (GETPOST('qty', 'int') == '') - { + if (GETPOST('qty', 'int') == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -426,51 +437,49 @@ if (empty($reshook)) } } - if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' - { + if ($prod_entry_mode != 'free' && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' $productsupplier = new ProductFournisseur($db); $idprod = 0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') { + $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } $reg = array(); - if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) - { + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) - { + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist - if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price - { + if ($productsupplier->fourn_socid != $socid) { // The price we found is for another supplier, so we clear supplier price $productsupplier->ref_supplier = ''; } } else { $fksoctosearch = $object->thirdparty->id; $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } - } elseif (GETPOST('idprodfournprice', 'alpha') > 0) - { + } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); $res = $productsupplier->fetch($idprod); } - if ($idprod > 0) - { + if ($idprod > 0) { $label = $productsupplier->label; // Define output language if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) + } + if (empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -489,8 +498,12 @@ if (empty($reshook)) $product_desc=''; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; - if (!empty($product_desc) && trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { + $desc = $product_desc; + } + if (!empty($product_desc) && trim($product_desc) != trim($desc)) { + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + } $type = $productsupplier->type; if ($price_ht != '' || $price_ht_devise != '') { @@ -514,11 +527,15 @@ if (empty($reshook)) $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) { + $pu = 0; // If pu is '' or null, we force to have a numeric value + } $result = $object->addline( $desc, @@ -545,22 +562,19 @@ if (empty($reshook)) 0 ); } - if ($idprod == -99 || $idprod == 0) - { + if ($idprod == -99 || $idprod == 0) { // Product not selected $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")), null, 'errors'); } - if ($idprod == -1) - { + if ($idprod == -1) { // Quantity too low $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } - } elseif (empty($error)) // $price_ht is already set - { + } elseif (empty($error)) { // $price_ht is already set $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); @@ -578,8 +592,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - if ($price_ht !== '') - { + if ($price_ht !== '') { $pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings } else { $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -592,19 +605,21 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (!$error && $result > 0) - { + if (!$error && $result > 0) { $db->commit(); $ret = $object->fetch($object->id); // Reload to get new records // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -613,7 +628,9 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } unset($_POST ['prod_entry_mode']); @@ -658,17 +675,17 @@ if (empty($reshook)) /* * Updating a line in the order */ - if ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) - { + if ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { $db->begin(); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - if ($lineid) - { + if ($lineid) { $line = new CommandeFournisseurLigne($db); $res = $line->fetch($lineid); - if (!$res) dol_print_error($db); + if (!$res) { + dol_print_error($db); + } } $productsupplier = new ProductFournisseur($db); @@ -692,14 +709,12 @@ if (empty($reshook)) $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht') != '') - { + if (GETPOST('price_ht') != '') { $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht')); } else { $vatratecleaned = $vat_rate; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" - { + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)" $vatratecleaned = trim($reg[1]); $vatratecode = $reg[2]; } @@ -769,15 +784,17 @@ if (empty($reshook)) unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -786,7 +803,9 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } $db->commit(); @@ -799,20 +818,20 @@ if (empty($reshook)) } // Remove a product line - if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) - { + if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $db->begin(); $result = $object->deleteline($lineid); - if ($result > 0) - { + if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -839,21 +858,22 @@ if (empty($reshook)) } // Validate - if ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) - { + if ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { $db->begin(); $object->date_commande = dol_now(); $result = $object->valid($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -873,8 +893,7 @@ if (empty($reshook)) } // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step - if (!$error && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $usercanapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) - { + if (!$error && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $usercanapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) { $action = 'confirm_approve'; // can make standard or first level approval also if permission is set } @@ -885,41 +904,39 @@ if (empty($reshook)) } } - if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $usercanapprove) - { + if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $usercanapprove) { $db->begin(); $idwarehouse = GETPOST('idwarehouse', 'int'); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change = $object->hasProductsOrServices(2); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER - { - if (!$idwarehouse || $idwarehouse == -1) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; } } - if (!$error) - { + if (!$error) { $result = $object->approve($user, $idwarehouse, ($action == 'confirm_approve2' ? 1 : 0)); - if ($result > 0) - { + if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -942,11 +959,9 @@ if (empty($reshook)) } } - if ($action == 'confirm_refuse' && $confirm == 'yes' && $usercanapprove) - { + if ($action == 'confirm_refuse' && $confirm == 'yes' && $usercanapprove) { $result = $object->refuse($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { @@ -964,19 +979,20 @@ if (empty($reshook)) } } - if ($action == 'confirm_commande' && $confirm == 'yes' && $usercanorder) - { + if ($action == 'confirm_commande' && $confirm == 'yes' && $usercanorder) { $db->begin(); $result = $object->commande($user, GETPOST("datecommande"), GETPOST("methode", 'int'), GETPOST('comment', 'alphanohtml')); - if ($result > 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if ($result > 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1000,11 +1016,9 @@ if (empty($reshook)) } - if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) - { + if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'); exit; } else { @@ -1013,19 +1027,15 @@ if (empty($reshook)) } // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) - { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - if ($object->id > 0) - { + if ($object->id > 0) { $orig = clone $object; $result = $object->createFromClone($user, $socid); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { @@ -1038,22 +1048,18 @@ if (empty($reshook)) } // Set status of reception (complete, partial, ...) - if ($action == 'livraison' && $usercanreceived) - { + if ($action == 'livraison' && $usercanreceived) { $db->begin(); - if (GETPOST("type") != '') - { + if (GETPOST("type") != '') { $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($result > 0) - { + if ($result > 0) { $langs->load("deliveries"); setEventMessages($langs->trans("DeliveryStateSaved"), null); $action = ''; - } elseif ($result == -3) - { + } elseif ($result == -3) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -1072,11 +1078,9 @@ if (empty($reshook)) } } - if ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanorder) - { + if ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanorder) { $result = $object->cancel($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { @@ -1099,48 +1103,44 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - if ($error) + if ($error) { $action = 'edit_extras'; + } } /* * Create an order */ - if ($action == 'add' && $usercancreate) - { - $error = 0; + if ($action == 'add' && $usercancreate) { + $error = 0; $selectedLines = GETPOST('toselect', 'array'); - if ($socid < 1) - { + if ($socid < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); $action = 'create'; $error++; } - if (!$error) - { + if (!$error) { $db->begin(); // Creation commande @@ -1160,23 +1160,20 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); // Fill array 'array_options' with data from add form - if (!$error) - { + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; - } + if ($ret < 0) { + $error++; + } + } - if (!$error) - { - // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) - { - if ($origin == 'propal' || $origin == 'proposal') - { + if (!$error) { + // If creation from another object of another module (Example: origin=propal, originid=1) + if (!empty($origin) && !empty($originid)) { + if ($origin == 'propal' || $origin == 'proposal') { $classname = 'Propal'; $element = 'comm/propal'; $subelement = 'propal'; - } elseif ($origin == 'order' || $origin == 'commande') - { + } elseif ($origin == 'order' || $origin == 'commande') { $classname = 'Commande'; $element = $subelement = 'commande'; } else { @@ -1196,23 +1193,20 @@ if (empty($reshook)) } $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $srcobject = new $classname($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { + if ($result > 0) { $tmpdate = ($srcobject->delivery_date ? $srcobject->delivery_date : $srcobject->date_livraison); $object->setDeliveryDate($user, $tmpdate); $object->set_id_projet($user, $srcobject->fk_project); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } @@ -1220,10 +1214,10 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0 || !in_array($lines[$i]->id, $selectedLines)) + for ($i = 0; $i < $num; $i++) { + if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0 || !in_array($lines[$i]->id, $selectedLines)) { continue; + } $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); @@ -1235,20 +1229,17 @@ if (empty($reshook)) } // Extrafields - if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if - { + if (method_exists($lines[$i], 'fetch_optionals')) { // For avoid conflicts if $lines[$i]->fetch_optionals(); $array_option = $lines[$i]->array_options; } $ref_supplier = ''; $product_fourn_price_id = 0; - if ($origin == "commande") - { + if ($origin == "commande") { $productsupplier = new ProductFournisseur($db); $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid); - if ($result > 0) - { + if ($result > 0) { $ref_supplier = $productsupplier->ref_supplier; $product_fourn_price_id = $productsupplier->product_fourn_price_id; } @@ -1259,8 +1250,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; - if ($origin == "commande") - { + if ($origin == "commande") { $soc = new societe($db); $soc->fetch($socid); $tva_tx = get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id); @@ -1309,8 +1299,9 @@ if (empty($reshook)) $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - if ($reshook < 0) + if ($reshook < 0) { $error++; + } } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error++; @@ -1320,17 +1311,15 @@ if (empty($reshook)) $error++; } } else { - $id = $object->create($user); - if ($id < 0) - { + $id = $object->create($user); + if ($id < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - if ($error) - { + if ($error) { $langs->load("errors"); $db->rollback(); $action = 'create'; @@ -1343,8 +1332,7 @@ if (empty($reshook)) } } - if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) - { + if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) { $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; $ws_user = GETPOST('ws_user', 'alpha'); @@ -1382,13 +1370,11 @@ if (empty($reshook)) //Prepare the order lines from order $order_lines = array(); - foreach ($object->lines as $line) - { + foreach ($object->lines as $line) { $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $line->ref_supplier); $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); - if ($result_product["result"]["result_code"] == "OK") - { + if ($result_product["result"]["result_code"] == "OK") { $order_lines[] = array( 'desc' => $line->product_desc, 'type' => $line->product_type, @@ -1419,11 +1405,9 @@ if (empty($reshook)) $ws_parameters = array('authentication'=>$ws_authentication, 'order' => $order); $result_order = $soapclient_order->call("createOrder", $ws_parameters, $ws_ns, ''); - if (empty($result_order["result"]["result_code"])) //No result, check error str - { + if (empty($result_order["result"]["result_code"])) { //No result, check error str setEventMessages($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", null, 'errors'); - } elseif ($result_order["result"]["result_code"] != "OK") //Something went wrong - { + } elseif ($result_order["result"]["result_code"] != "OK") { //Something went wrong setEventMessages($langs->trans("SOAPError")." '".$result_order["result"]["result_code"]."' - '".$result_order["result"]["result_label"]."'", null, 'errors'); } else { setEventMessages($langs->trans("RemoteOrderRef")." ".$result_order["ref"], null, 'mesgs'); @@ -1431,45 +1415,33 @@ if (empty($reshook)) } } - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) - { - if ($action == 'addcontact') - { - if ($object->id > 0) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { + if ($action == 'addcontact') { + if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // bascule du statut d'un contact - elseif ($action == 'swapstatut' && $object->id > 0) - { + } elseif ($action == 'swapstatut' && $object->id > 0) { + // bascule du statut d'un contact $result = $object->swapContactStatus(GETPOST('ligne')); - } - - // Efface un contact - elseif ($action == 'deletecontact' && $object->id > 0) - { + } elseif ($action == 'deletecontact' && $object->id > 0) { + // Efface un contact $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -1488,15 +1460,16 @@ $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $langs->trans("Order"), $help_url); $now = dol_now(); -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans('NewOrderSupplier'), '', 'supplier_order'); dol_htmloutput_events(); @@ -1504,14 +1477,12 @@ if ($action == 'create') $currency_code = $conf->currency; $societe = ''; - if ($socid > 0) - { + if ($socid > 0) { $societe = new Societe($db); $societe->fetch($socid); } - if (!empty($origin) && !empty($originid)) - { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; $regs = array(); @@ -1520,12 +1491,10 @@ if ($action == 'create') $subelement = $regs[2]; } - if ($origin == 'propal' || $origin == 'proposal') - { + if ($origin == 'propal' || $origin == 'proposal') { $classname = 'Propal'; $element = 'comm/propal'; $subelement = 'propal'; - } elseif ($origin == 'order' || $origin == 'commande') - { + } elseif ($origin == 'order' || $origin == 'commande') { $classname = 'Commande'; $element = $subelement = 'commande'; } else { @@ -1538,8 +1507,9 @@ if ($action == 'create') $objectsrc = new $classname($db); $objectsrc->fetch($originid); - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); + } $objectsrc->fetch_thirdparty(); // Replicate extrafields @@ -1562,10 +1532,13 @@ if ($action == 'create') $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : '')); - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($conf->multicurrency->enabled)) { + if (!empty($objectsrc->multicurrency_code)) { + $currency_code = $objectsrc->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) { + $currency_tx = $objectsrc->multicurrency_tx; + } } $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); @@ -1577,15 +1550,21 @@ if ($action == 'create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; - if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; + if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) { + $currency_code = $societe->multicurrency_code; + } $note_private = $object->getDefaultCreateValueFor('note_private'); $note_public = $object->getDefaultCreateValueFor('note_public'); } // If not defined, set default value from constant - if (empty($cond_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; - if (empty($mode_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; + if (empty($cond_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) { + $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; + } + if (empty($mode_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) { + $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; + } print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -1594,7 +1573,9 @@ if ($action == 'create') print '<input type="hidden" name="remise_percent" value="'.$soc->remise_supplier_percent.'">'; print '<input type="hidden" name="origin" value="'.$origin.'">'; print '<input type="hidden" name="originid" value="'.$originid.'">'; - if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; + if (!empty($currency_tx)) { + print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; + } print dol_get_fiche_head(''); @@ -1607,15 +1588,13 @@ if ($action == 'create') print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>'; print '<td>'; - if ($socid > 0) - { + if ($socid > 0) { print $societe->getNomUrl(1); print '<input type="hidden" name="socid" value="'.$socid.'">'; } else { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations - if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) - { + if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print '<script> $(document).ready(function() { $("#socid").change(function() { @@ -1630,8 +1609,7 @@ if ($action == 'create') } print '</td>'; - if ($societe->id > 0) - { + if ($societe->id > 0) { // Discounts for third party print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; @@ -1665,13 +1643,14 @@ if ($action == 'create') print '</td>'; print '<td>'; $usehourmin = 0; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 1; + } print $form->selectDate($datelivraison ? $datelivraison : -1, 'liv_', $usehourmin, $usehourmin, '', "set"); print '</td></tr>'; // Bank Account - if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) - { + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { $langs->load("bank"); print '<tr><td>'.$langs->trans('BankAccount').'</td><td>'; print img_picto('', 'bank_account', 'class="paddingrightonly"'); @@ -1680,8 +1659,7 @@ if ($action == 'create') } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); @@ -1692,8 +1670,7 @@ if ($action == 'create') } // Incoterms - if (!empty($conf->incoterm->enabled)) - { + if (!empty($conf->incoterm->enabled)) { $fkincoterms = (!empty($object->fk_incoterms) ? $object->fk_incoterms : ($socid > 0 ? $societe->fk_incoterms : '')); $locincoterms = (!empty($object->location_incoterms) ? $object->location_incoterms : ($socid > 0 ? $societe->location_incoterms : '')); print '<tr>'; @@ -1704,8 +1681,7 @@ if ($action == 'create') } // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; print '<td class="maxwidthonsmartphone">'; @@ -1742,20 +1718,17 @@ if ($action == 'create') print '<tr><td>'.$langs->trans($newclassname).'</td><td>'.$objectsrc->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($objectsrc->total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($objectsrc->total_tva)."</td></tr>"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE - { + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1 RE print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1)."</td></tr>"; } - if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF - { + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2 IRPF print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2)."</td></tr>"; } print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($objectsrc->total_ttc)."</td></tr>"; - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td>'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td>'.price($objectsrc->multicurrency_total_tva).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td>'.price($objectsrc->multicurrency_total_ttc).'</td></tr>'; @@ -1767,8 +1740,7 @@ if ($action == 'create') $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -1786,8 +1758,7 @@ if ($action == 'create') // Show origin lines - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) - { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1803,7 +1774,9 @@ if ($action == 'create') $societe = new Fournisseur($db); $result = $societe->fetch($object->socid); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } $author = new User($db); $author->fetch($object->user_author_id); @@ -1820,14 +1793,12 @@ if ($action == 'create') $formconfirm = ''; // Confirmation de la suppression de la commande - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); } // Clone confirmation - if ($action == 'clone') - { + if ($action == 'clone') { // Create an array for form $formquestion = array( array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) @@ -1837,24 +1808,22 @@ if ($action == 'create') } // Confirmation de la validation - if ($action == 'valid') - { + if ($action == 'valid') { $object->date_commande = dol_now(); // We check if number is temporary number - if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life - { + if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) { // empty should not happened, but when it occurs, the test save life $newref = $object->getNextNumRef($object->thirdparty); - } else $newref = $object->ref; + } else { + $newref = $object->ref; + } - if ($newref < 0) - { + if ($newref < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { $text = $langs->trans('ConfirmValidateOrder', $newref); - if (!empty($conf->notification->enabled)) - { + if (!empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '<br>'; @@ -1866,24 +1835,23 @@ if ($action == 'create') } // Confirm approval - if ($action == 'approve' || $action == 'approve2') - { + if ($action == 'approve' || $action == 'approve2') { $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } $formquestion = array(); - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $forcecombo = 0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } $formquestion = array( //'text' => $langs->trans("ConfirmClone"), //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), @@ -1892,8 +1860,7 @@ if ($action == 'create') ); } $text = $langs->trans("ConfirmApproveThisOrder", $object->ref); - if (!empty($conf->notification->enabled)) - { + if (!empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '<br>'; @@ -1904,34 +1871,33 @@ if ($action == 'create') } // Confirmation de la desapprobation - if ($action == 'refuse') - { + if ($action == 'refuse') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", '', 0, 1); } // Confirmation de l'annulation - if ($action == 'cancel') - { + if ($action == 'cancel') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", '', 0, 1); } // Confirmation de l'envoi de la commande - if ($action == 'commande') - { + if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); } // Confirmation to delete line - if ($action == 'ask_deleteline') - { + if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -1961,7 +1927,9 @@ if ($action == 'create') $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_thirdparty&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).'</a>'; } $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; + } } // Project @@ -1969,8 +1937,9 @@ if ($action == 'create') $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; if ($usercancreate) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -2007,8 +1976,7 @@ if ($action == 'create') print '<table class="border tableforfield centpercent">'; // Date - if ($object->methode_commande_id > 0) - { + if ($object->methode_commande_id > 0) { print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'; print $object->date_commande ? dol_print_date($object->date_commande, $usehourmin) : ''; if ($object->hasDelay() && !empty($object->date_delivery) && !empty($object->date_commande)) { @@ -2016,8 +1984,7 @@ if ($action == 'create') } print "</td></tr>"; - if ($object->methode_commande) - { + if ($object->methode_commande) { print '<tr><td>'.$langs->trans("Method").'</td><td>'.$object->getInputMethod().'</td></tr>'; } } @@ -2056,11 +2023,12 @@ if ($action == 'create') print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; print $langs->trans('PaymentConditions'); print '<td>'; - if ($action != 'editconditions') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; + if ($action != 'editconditions') { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; - if ($action == 'editconditions') - { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); @@ -2074,11 +2042,12 @@ if ($action == 'create') print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; print $langs->trans('PaymentMode'); print '</td>'; - if ($action != 'editmode') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; + if ($action != 'editmode') { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); @@ -2086,16 +2055,16 @@ if ($action == 'create') print '</td></tr>'; // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; print '<td>'; print '<table class="nobordernopadding centpercent"><tr><td>'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '</td>'; - if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; if ($action == 'editmulticurrencycode') { @@ -2106,16 +2075,16 @@ if ($action == 'create') print '</td></tr>'; // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) - { + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print '<tr>'; print '<td>'; print '<table class="nobordernopadding centpercent"><tr>'; print '<td>'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '</td>'; - if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -2136,14 +2105,14 @@ if ($action == 'create') } // Bank Account - if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) - { + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { print '<tr><td class="nowrap">'; print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; print $langs->trans('BankAccount'); print '<td>'; - if ($action != 'editbankaccount' && $usercancreate) + if ($action != 'editbankaccount' && $usercancreate) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; if ($action == 'editbankaccount') { @@ -2166,22 +2135,27 @@ if ($action == 'create') print '<table class="nobordernopadding centpercent"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; - if ($action != 'editdate_livraison') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>'; + if ($action != 'editdate_livraison') { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td>'; - if ($action == 'editdate_livraison') - { + if ($action == 'editdate_livraison') { print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="setdate_livraison">'; $usehourmin = 0; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 1; + } print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { $usehourmin = 'day'; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 'dayhour'; + } print $object->delivery_date ? dol_print_date($object->delivery_date, $usehourmin) : '&nbsp;'; if ($object->hasDelay() && !empty($object->delivery_date)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); @@ -2190,19 +2164,20 @@ if ($action == 'create') print '</td></tr>'; // Incoterms - if (!empty($conf->incoterm->enabled)) - { + if (!empty($conf->incoterm->enabled)) { print '<tr><td>'; print '<table class="nobordernopadding centpercent"><tr><td>'; print $langs->trans('IncotermLabel'); print '<td><td class="right">'; - if ($usercancreate) print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; - else print '&nbsp;'; + if ($usercancreate) { + print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; + } else { + print '&nbsp;'; + } print '</td></tr></table>'; print '</td>'; print '<td>'; - if ($action != 'editincoterm') - { + if ($action != 'editincoterm') { print $form->textwithpicto(dol_escape_htmltag($object->display_incoterms()), $object->label_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); @@ -2222,8 +2197,7 @@ if ($action == 'create') print '<table class="border tableforfield centpercent">'; - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) - { + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { // Multicurrency Amount HT print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; @@ -2254,14 +2228,12 @@ if ($action == 'create') print '</tr>'; // Amount Local Taxes - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 - { + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 - { + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency).'</td>'; print '</tr>'; @@ -2275,7 +2247,7 @@ if ($action == 'create') // Margin Infos /*if (! empty($conf->margin->enabled)) { - $formmargin->displayMarginInfos($object); + $formmargin->displayMarginInfos($object); }*/ @@ -2285,15 +2257,13 @@ if ($action == 'create') print '<div class="clearboth"></div><br>'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; @@ -2324,19 +2294,20 @@ if ($action == 'create') global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. - if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { + $senderissupplier = 1; + } // Show object lines - if (!empty($object->lines)) + if (!empty($object->lines)) { $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + } $num = count($object->lines); // Form to add new line - if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $usercancreate) - { - if ($action != 'editline') - { + if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $usercancreate) { + if ($action != 'editline') { // Add free products/services $object->formAddObjectLine(1, $societe, $mysoc); @@ -2354,24 +2325,22 @@ if ($action == 'create') * Boutons actions */ - if ($user->socid == 0 && $action != 'editline' && $action != 'delete') - { + if ($user->socid == 0 && $action != 'editline' && $action != 'delete') { print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. // Validate - if ($object->statut == 0 && $num > 0) - { - if ($usercanvalidate) - { + if ($object->statut == 0 && $num > 0) { + if ($usercanvalidate) { $tmpbuttonlabel = $langs->trans('Validate'); - if ($usercanapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + if ($usercanapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) { + $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + } print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'; print $tmpbuttonlabel; @@ -2385,21 +2354,16 @@ if ($action == 'create') }*/ // Modify - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) - { - if ($usercanorder) - { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanorder) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>'; } } // Approve - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) - { - if ($usercanapprove) - { - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) - { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprove) { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>'; } else { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>'; @@ -2410,14 +2374,10 @@ if ($action == 'create') } // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) - { - if ($usercanapprovesecond) - { - if (!empty($object->user_approve_id2)) - { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprovesecond) { + if (!empty($object->user_approve_id2)) { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>'; } else { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>'; @@ -2429,10 +2389,8 @@ if ($action == 'create') } // Refuse - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) - { - if ($usercanapprove || $usercanapprovesecond) - { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprove || $usercanapprovesecond) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("RefuseOrder").'</a>'; @@ -2441,51 +2399,43 @@ if ($action == 'create') // Send if (empty($user->socid)) { - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) - { - if ($usercanorder) - { + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) { + if ($usercanorder) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'; } } } // Reopen - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) - { + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { $buttonshown = 0; - if (!$buttonshown && $usercanapprove) - { + if (!$buttonshown && $usercanapprove) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) - || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) - { + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>'; $buttonshown++; } } - if (!$buttonshown && $usercanapprovesecond && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) - { + if (!$buttonshown && $usercanapprovesecond && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) - || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) - { + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>'; } } } - if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) - { - if ($usercanorder) - { + if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) { + if ($usercanorder) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; } } // Ship - 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))) { $labelofbutton = $langs->trans('ReceiveProducts'); - if ($conf->reception->enabled) $labelofbutton = $langs->trans("CreateReception"); + if ($conf->reception->enabled) { + $labelofbutton = $langs->trans("CreateReception"); + } if (in_array($object->statut, array(3, 4, 5))) { if ($conf->fournisseur->enabled && $usercanreceived) { @@ -2496,10 +2446,8 @@ if ($action == 'create') } } - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) - { - if ($usercanorder) - { + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { + if ($usercanorder) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=makeorder#makeorder">'.$langs->trans("MakeOrder").'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("MakeOrder").'</a></div>'; @@ -2507,10 +2455,8 @@ if ($action == 'create') } // Classify received (this does not record reception) - if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) - { - if ($usercanreceived) - { + if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { + if ($usercanreceived) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyreception#classifyreception">'.$langs->trans("ClassifyReception").'</a></div>'; } } @@ -2518,26 +2464,20 @@ if ($action == 'create') // Create bill //if (! empty($conf->facture->enabled)) //{ - if (!empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled - { - if ($user->rights->fournisseur->facture->creer) - { + if (!empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled + if ($user->rights->fournisseur->facture->creer) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; } } //} // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) - if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) // statut 2 means approved - { - if (empty($conf->facture->enabled)) - { + if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) { // statut 2 means approved + if (empty($conf->facture->enabled)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; } else { - if (!empty($object->linkedObjectsIds['invoice_supplier'])) - { - if ($user->rights->fournisseur->facture->creer) - { + if (!empty($object->linkedObjectsIds['invoice_supplier'])) { + if ($user->rights->fournisseur->facture->creer) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; } } else { @@ -2547,29 +2487,24 @@ if ($action == 'create') } // Create a remote order using WebService only if module is activated - if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted - { + if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) { // 2 means accepted print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=webservice&amp;mode=init">'.$langs->trans('CreateRemoteOrder').'</a>'; } // Clone - if ($usercancreate) - { + if ($usercancreate) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>'; } // Cancel - if ($object->statut == 2) - { - if ($usercanorder) - { + if ($object->statut == 2) { + if ($usercanorder) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>'; } } // Delete - if (!empty($usercandelete) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($usercancreate))) - { + if (!empty($usercandelete) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($usercancreate))) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans("Delete").'</a>'; } } @@ -2578,8 +2513,7 @@ if ($action == 'create') - if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') - { + if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') { // Set status to ordered (action=commande) print '<!-- form to record supplier order -->'."\n"; print '<form name="commande" id="makeorder" action="card.php?id='.$object->id.'&amp;action=commande" method="POST">'; @@ -2591,7 +2525,9 @@ if ($action == 'create') //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("OrderDate").'</td><td>'; $date_com = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($date_com)) $date_com = dol_now(); + if (empty($date_com)) { + $date_com = dol_now(); + } print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); print '</td></tr>'; @@ -2612,8 +2548,7 @@ if ($action == 'create') print "<br>"; } - if ($action != 'makeorder') - { + if ($action != 'makeorder') { print '<div class="fichecenter"><div class="fichehalfleft">'; // Generated documents @@ -2634,10 +2569,8 @@ if ($action == 'create') print '</div><div class="fichehalfright"><div class="ficheaddleft">'; - if ($action == 'classifyreception') - { - if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) - { + if ($action == 'classifyreception') { + if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print '<!-- form to record purchase order received -->'."\n"; print '<form id="classifyreception" action="card.php?id='.$object->id.'" method="post">'; @@ -2682,8 +2615,7 @@ if ($action == 'create') /* * Action webservice */ - if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) - { + if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) { $mode = GETPOST('mode', 'alpha'); $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; @@ -2712,8 +2644,7 @@ if ($action == 'create') $mode = "init"; } - if ($mode == "init") - { + if ($mode == "init") { //Table/form header print '<table class="border centpercent">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; @@ -2721,8 +2652,7 @@ if ($action == 'create') print '<input type="hidden" name="action" value="webservice">'; print '<input type="hidden" name="mode" value="check">'; - if ($error_occurred) - { + if ($error_occurred) { print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>"; print '<input class="button button-cancel" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; } else { @@ -2745,8 +2675,7 @@ if ($action == 'create') //End table/form print '</form>'; print '</table>'; - } elseif ($mode == "check") - { + } elseif ($mode == "check") { $ws_entity = ''; $ws_thirdparty = ''; $error_occurred = false; @@ -2761,14 +2690,12 @@ if ($action == 'create') $result_user = $soapclient_user->call("getUser", $ws_parameters, $ws_ns, ''); $user_status_code = $result_user["result"]["result_code"]; - if ($user_status_code == "OK") - { + if ($user_status_code == "OK") { //Fill the variables $ws_entity = $result_user["user"]["entity"]; $ws_authentication['entity'] = $ws_entity; $ws_thirdparty = $result_user["user"]["fk_thirdparty"]; - if (empty($ws_thirdparty)) - { + if (empty($ws_thirdparty)) { setEventMessages($langs->trans("RemoteUserMissingAssociatedSoc"), null, 'errors'); $error_occurred = true; } else { @@ -2788,8 +2715,7 @@ if ($action == 'create') } $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $ref_supplier); $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); - if (!$result_product) - { + if (!$result_product) { setEventMessages($line_id.$langs->trans("SOAPError")." ".$soapclient_product->error_str." - ".$soapclient_product->response, null, 'errors'); $error_occurred = true; break; @@ -2797,13 +2723,10 @@ if ($action == 'create') // Check the result code $status_code = $result_product["result"]["result_code"]; - if (empty($status_code)) //No result, check error str - { + if (empty($status_code)) { //No result, check error str setEventMessages($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", null, 'errors'); - } elseif ($status_code != "OK") //Something went wrong - { - if ($status_code == "NOT_FOUND") - { + } elseif ($status_code != "OK") { //Something went wrong + if ($status_code == "NOT_FOUND") { setEventMessages($line_id.$langs->trans("SupplierMissingRef")." '".$ref_supplier."'", null, 'warnings'); } else { setEventMessages($line_id.$langs->trans("ResponseNonOK")." '".$status_code."' - '".$result_product["result"]["result_label"]."'", null, 'errors'); @@ -2819,10 +2742,8 @@ if ($action == 'create') $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); - if (count($product_fourn_list) > 0) - { - foreach ($product_fourn_list as $product_fourn_line) - { + if (count($product_fourn_list) > 0) { + foreach ($product_fourn_list as $product_fourn_line) { //Only accept the line where the supplier is the same at this order and has the same ref if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { $local_price = price($product_fourn_line->fourn_price); @@ -2840,12 +2761,10 @@ if ($action == 'create') } } } - } elseif ($user_status_code == "PERMISSION_DENIED") - { + } elseif ($user_status_code == "PERMISSION_DENIED") { setEventMessages($langs->trans("RemoteUserNotPermission"), null, 'errors'); $error_occurred = true; - } elseif ($user_status_code == "BAD_CREDENTIALS") - { + } elseif ($user_status_code == "BAD_CREDENTIALS") { setEventMessages($langs->trans("RemoteUserBadCredentials"), null, 'errors'); $error_occurred = true; } else { @@ -2862,8 +2781,7 @@ if ($action == 'create') print '<input type="hidden" name="ws_password" value="'.$ws_password.'">'; print '<input type="hidden" name="ws_entity" value="'.$ws_entity.'">'; print '<input type="hidden" name="ws_thirdparty" value="'.$ws_thirdparty.'">'; - if ($error_occurred) - { + if ($error_occurred) { print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>"; } else { print '<input class="button" type="submit" id="ws_submit" name="ws_submit" value="'.$langs->trans("Confirm").'">'; diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 3e52f35d8bb..ae2e8bab481 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); @@ -51,51 +53,39 @@ $object = new CommandeFournisseur($db); * Add a new contact */ -if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) -{ +if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact -elseif ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer) -{ - if ($object->fetch($id)) - { +} elseif ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer) { + // Toggle the status of a contact + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } -} - -// Deleting a contact -elseif ($action == 'deletecontact' && $user->rights->fournisseur->commande->creer) -{ +} elseif ($action == 'deletecontact' && $user->rights->fournisseur->commande->creer) { + // Deleting a contact $object->fetch($id); $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -123,12 +113,10 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $langs->trans("OrderCard"); - if ($object->fetch($id, $ref) > 0) - { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $head = ordersupplier_prepare_head($object); @@ -145,12 +133,10 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index dbe0bd5d7af..ee8c86aa0b8 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -40,14 +40,16 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; -if (!empty($conf->projet->enabled)) +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("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks", "receptions")); -if (!empty($conf->productbatch->enabled)) +if (!empty($conf->productbatch->enabled)) { $langs->load('productbatch'); +} // Security check $id = GETPOST("id", 'int'); @@ -58,8 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -if ($user->socid) +if ($user->socid) { $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); if (empty($conf->stock->enabled)) { @@ -70,8 +73,9 @@ $hookmanager->initHooks(array('ordersupplierdispatch')); // Recuperation de l'id de projet $projectid = 0; -if ($_GET["projectid"]) +if ($_GET["projectid"]) { $projectid = GETPOST("projectid", 'int'); +} $object = new CommandeFournisseur($db); @@ -93,25 +97,24 @@ if ($id > 0 || !empty($ref)) { $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) -{ +if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) { $error = 0; $supplierorderdispatch = new CommandeFournisseurDispatch($db); $db->begin(); $result = $supplierorderdispatch->fetch($lineid); - if (!$result) - { + if (!$result) { $error++; setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); $action = ''; } - if (!$error) - { + if (!$error) { $result = $supplierorderdispatch->setStatut(1); if ($result < 0) { setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); @@ -120,8 +123,7 @@ if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_ } } - if (!$error) - { + if (!$error) { $result = $object->calcAndSetStatusDispatch($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -129,31 +131,27 @@ if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_ $action = ''; } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); } } -if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) -{ +if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) { $error = 0; $supplierorderdispatch = new CommandeFournisseurDispatch($db); $db->begin(); $result = $supplierorderdispatch->fetch($lineid); - if (!$result) - { + if (!$result) { $error++; setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); $action = ''; } - if (!$error) - { + if (!$error) { $result = $supplierorderdispatch->setStatut(0); if ($result < 0) { setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); @@ -161,8 +159,7 @@ if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCE $action = ''; } } - if (!$error) - { + if (!$error) { $result = $object->calcAndSetStatusDispatch($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -170,31 +167,27 @@ if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCE $action = ''; } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); } } -if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) -{ +if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) { $error = 0; $supplierorderdispatch = new CommandeFournisseurDispatch($db); $db->begin(); $result = $supplierorderdispatch->fetch($lineid); - if (!$result) - { + if (!$result) { $error++; setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); $action = ''; } - if (!$error) - { + if (!$error) { $result = $supplierorderdispatch->setStatut(2); if ($result < 0) { setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors'); @@ -202,8 +195,7 @@ if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_P $action = ''; } } - if (!$error) - { + if (!$error) { $result = $object->calcAndSetStatusDispatch($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -211,8 +203,7 @@ if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_P $action = ''; } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -225,12 +216,10 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $db->begin(); $pos = 0; - foreach ($_POST as $key => $value) - { + foreach ($_POST as $key => $value) { // without batch module enabled $reg = array(); - if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) - { + if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $pos++; // $numline=$reg[2] + 1; // line of product @@ -238,7 +227,9 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $prod = "product_".$reg[1].'_'.$reg[2]; $qty = "qty_".$reg[1].'_'.$reg[2]; $ent = "entrepot_".$reg[1].'_'.$reg[2]; - if (empty(GETPOST($ent))) $ent = $fk_default_warehouse; + if (empty(GETPOST($ent))) { + $ent = $fk_default_warehouse; + } $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; @@ -293,8 +284,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } } // with batch module enabled - if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) - { + if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $pos++; // eat-by date dispatch @@ -398,14 +388,12 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } // Remove a dispatched line -if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->receptionner) -{ +if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->receptionner) { $db->begin(); $supplierorderdispatch = new CommandeFournisseurDispatch($db); $result = $supplierorderdispatch->fetch($lineid); - if ($result > 0) - { + if ($result > 0) { $qty = $supplierorderdispatch->qty; $entrepot = $supplierorderdispatch->fk_entrepot; $product = $supplierorderdispatch->fk_product; @@ -417,48 +405,39 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fourn $result = $supplierorderdispatch->delete($user); } - if ($result < 0) - { + if ($result < 0) { $errors = $object->errors; $error++; - } - else { + } else { // If module stock is enabled and the stock increase is done on purchase order dispatching - if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) - { + if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); - if ($product > 0) - { + if ($product > 0) { $mouv->origin = &$object; $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); - if ($result < 0) - { + if ($result < 0) { $errors = $mouv->errors; $error++; } } } } - if ($error > 0) - { + if ($error > 0) { $db->rollback(); setEventMessages($error, $errors, 'errors'); - } - else { + } else { $db->commit(); } } // Update a dispatched line -if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionner) -{ +if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionner) { $db->begin(); $error = 0; $supplierorderdispatch = new CommandeFournisseurDispatch($db); $result = $supplierorderdispatch->fetch($lineid); - if ($result > 0) - { + if ($result > 0) { $qty = $supplierorderdispatch->qty; $entrepot = $supplierorderdispatch->fk_entrepot; $product = $supplierorderdispatch->fk_product; @@ -472,30 +451,23 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne $supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot'); $result = $supplierorderdispatch->update($user); } - if ($result < 0) - { + if ($result < 0) { $error++; $errors = $supplierorderdispatch->errors; - } - else { + } else { // If module stock is enabled and the stock increase is done on purchase order dispatching - if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) - { + if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); - if ($product > 0) - { + if ($product > 0) { $mouv->origin = &$object; $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); - if ($result < 0) - { + if ($result < 0) { $errors = $mouv->errors; $error++; - } - else { + } else { $mouv->origin = &$object; $result = $mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, $eatby, $sellby, $batch); - if ($result < 0) - { + if ($result < 0) { $errors = $mouv->errors; $error++; } @@ -503,12 +475,10 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne } } } - if ($error > 0) - { + if ($error > 0) { $db->rollback(); setEventMessages($error, $errors, 'errors'); - } - else { + } else { $db->commit(); } } @@ -544,8 +514,7 @@ if ($id > 0 || !empty($ref)) { $formconfirm = ''; // Confirmation to delete line - if ($action == 'ask_deleteline') - { + if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } @@ -553,8 +522,11 @@ if ($id > 0 || !empty($ref)) { $parameters = array('lineid' => $lineid); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -570,12 +542,10 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; @@ -643,8 +613,9 @@ if ($id > 0 || !empty($ref)) { print '<br>'; $disabled = 1; - if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $disabled = 0; + } // Line of orders if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) { @@ -653,8 +624,7 @@ if ($id > 0 || !empty($ref)) { if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY - || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) - { + || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $formproduct->loadWarehouses(); @@ -662,12 +632,18 @@ if ($id > 0 || !empty($ref)) { $listwarehouses = $entrepot->list_array(1); - if (empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id='.$object->id.'">'; - else print '<form method="post" action="'.dol_buildpath('/reception/card.php', 1).'?originid='.$object->id.'&origin=supplierorder">'; + if (empty($conf->reception->enabled)) { + print '<form method="POST" action="dispatch.php?id='.$object->id.'">'; + } else { + print '<form method="post" action="'.dol_buildpath('/reception/card.php', 1).'?originid='.$object->id.'&origin=supplierorder">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; - if (empty($conf->reception->enabled))print '<input type="hidden" name="action" value="dispatch">'; - else print '<input type="hidden" name="action" value="create">'; + if (empty($conf->reception->enabled)) { + print '<input type="hidden" name="action" value="dispatch">'; + } else { + print '<input type="hidden" name="action" value="create">'; + } print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; @@ -706,14 +682,17 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; $sql .= " WHERE l.fk_commande = ".$object->id; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= " AND l.product_type = 0"; + } // Enable hooks to alter the SQL query (WHERE) $parameters = array(); @@ -723,7 +702,9 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $sql .= $hookmanager->resPrint; $sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product @@ -785,7 +766,9 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print "</tr>\n"; @@ -803,8 +786,9 @@ if ($id > 0 || !empty($ref)) { $nbfreeproduct++; } else { $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched - if ($remaintodispatch < 0) + if ($remaintodispatch < 0) { $remaintodispatch = 0; + } if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { $nbproduct++; @@ -858,8 +842,9 @@ if ($id > 0 || !empty($ref)) { // Define unit price for PMP calculation $up_ht_disc = $objp->subprice; - if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) + if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU'); + } // Supplier ref print '<td class="right">'.$objp->sref.'</td>'; @@ -892,7 +877,9 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print '</tr>'; @@ -903,8 +890,7 @@ if ($id > 0 || !empty($ref)) { print '<input name="product_batch'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">'; print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->'; - if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! - { + if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { // Not tested ! print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price2num($up_ht_disc, 'MU').'">'; } else { print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price2num($up_ht_disc, 'MU').'">'; @@ -953,7 +939,9 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print '</tr>'; @@ -964,8 +952,7 @@ if ($id > 0 || !empty($ref)) { print '<input name="product'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">'; print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->'; - if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! - { + if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { // Not tested ! print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price2num($up_ht_disc, 'MU').'">'; } else { print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price2num($up_ht_disc, 'MU').'">'; @@ -1030,7 +1017,9 @@ if ($id > 0 || !empty($ref)) { $object, $action ); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print "</tr>\n"; @@ -1046,16 +1035,14 @@ if ($id > 0 || !empty($ref)) { print "</table>\n"; print '</div>'; - if ($nbproduct) - { + if ($nbproduct) { $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); print '<div class="center">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { if (empty($conf->reception->enabled)) { print $langs->trans("Comment").' : '; print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="'; @@ -1069,8 +1056,9 @@ if ($id > 0 || !empty($ref)) { $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); print '<br><input type="submit" class="button" name="dispatch" value="'.dol_escape_htmltag($dispatchBt).'"'; - if (count($listwarehouses) <= 0) + if (count($listwarehouses) <= 0) { print ' disabled'; + } print '>'; } print '</div>'; @@ -1079,9 +1067,11 @@ if ($id > 0 || !empty($ref)) { // Message if nothing to dispatch if (!$nbproduct) { print "<br>\n"; - if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) + if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all - else print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched. + } else { + print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched. + } } print '</form>'; @@ -1113,12 +1103,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " e.rowid as warehouse_id, e.ref as entrepot,"; $sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec"; $sql .= " ,cd.rowid, cd.subprice"; - if ($conf->reception->enabled)$sql .= " ,cfd.fk_reception, r.date_delivery"; + if ($conf->reception->enabled) { + $sql .= " ,cfd.fk_reception, r.date_delivery"; + } $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; - if ($conf->reception->enabled)$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid"; + if ($conf->reception->enabled) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid"; + } $sql .= " WHERE cfd.fk_commande = ".$object->id; $sql .= " AND cfd.fk_product = p.rowid"; $sql .= " ORDER BY cfd.rowid ASC"; @@ -1137,7 +1131,9 @@ if ($id > 0 || !empty($ref)) { print '<table id="dispatch_received_products" class="noborder centpercent">'; print '<tr class="liste_titre">'; - if ($conf->reception->enabled)print '<td>'.$langs->trans("Reception").'</td>'; + if ($conf->reception->enabled) { + print '<td>'.$langs->trans("Reception").'</td>'; + } print '<td>'.$langs->trans("Product").'</td>'; print '<td>'.$langs->trans("DateCreation").'</td>'; @@ -1169,8 +1165,7 @@ if ($id > 0 || !empty($ref)) { while ($i < $num) { $objp = $db->fetch_object($resql); - if ($action == 'editline' && $lineid == $objp->dispatchlineid) - { + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print '<form name="editdispatchedlines" id="editdispatchedlines" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#line_'.GETPOST('lineid').'" method="POST"> <input type="hidden" name="token" value="'.newToken().'"> <input type="hidden" name="action" value="updateline"> @@ -1219,11 +1214,9 @@ if ($id > 0 || !empty($ref)) { // Qty print '<td class="right">'; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) - { + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print '<input style="width: 50px;" type="number" min="1" name="qty" value="'.$objp->qty.'" />'; - } - else { + } else { print $objp->qty; } print '<input type="hidden" name="price" value="'.$objp->subprice.'" />'; @@ -1231,8 +1224,7 @@ if ($id > 0 || !empty($ref)) { // Warehouse print '<td>'; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) - { + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { if (count($listwarehouses) > 1) { print $formproduct->selectWarehouses(GETPOST("fk_entrepot") ?GETPOST("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''), "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, null, 'csswarehouse'); } elseif (count($listwarehouses) == 1) { @@ -1241,8 +1233,7 @@ if ($id > 0 || !empty($ref)) { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); } - } - else { + } else { $warehouse_static->id = $objp->warehouse_id; $warehouse_static->libelle = $objp->entrepot; print $warehouse_static->getNomUrl(1); @@ -1262,8 +1253,7 @@ if ($id > 0 || !empty($ref)) { // Add button to check/uncheck disaptching print '<td class="center">'; - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) - { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) { if (empty($objp->status)) { print '<a class="button buttonRefused" href="#">'.$langs->trans("Approve").'</a>'; print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>'; @@ -1273,8 +1263,9 @@ if ($id > 0 || !empty($ref)) { } } else { $disabled = ''; - if ($object->statut == 5) + if ($object->statut == 5) { $disabled = 1; + } if (empty($objp->status)) { print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>'; print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>'; @@ -1297,8 +1288,7 @@ if ($id > 0 || !empty($ref)) { print '</td>'; } - if ($action != 'editline' || $lineid != $objp->dispatchlineid) - { + if ($action != 'editline' || $lineid != $objp->dispatchlineid) { print '<td class="linecoledit center">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;lineid='.$objp->dispatchlineid.'#line_'.$objp->dispatchlineid.'">'; print img_edit(); @@ -1310,8 +1300,7 @@ if ($id > 0 || !empty($ref)) { print img_delete(); print '</a>'; print '</td>'; - } - else { + } else { print '<td class="center valignmiddle">'; print '<input type="submit" class="button button-save" id="savelinebutton" name="save" value="'.$langs->trans("Save").'" />'; print '</td>'; @@ -1322,7 +1311,9 @@ if ($id > 0 || !empty($ref)) { print "</tr>\n"; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) print '</form>'; + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { + print '</form>'; + } $i++; } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 293edb549ea..3bc2a799a5f 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -47,7 +47,9 @@ $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, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Get parameters @@ -55,17 +57,22 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new CommandeFournisseur($db); -if ($object->fetch($id, $ref) < 0) -{ +if ($object->fetch($id, $ref) < 0) { dol_print_error($db); exit; } @@ -87,8 +94,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $langs->trans("Order"), $help_url); @@ -105,8 +111,7 @@ if ($object->id > 0) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -121,12 +126,10 @@ if ($object->id > 0) // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 1e9e69fb8cd..d46456b52dc 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Security check $orderid = GETPOST('orderid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $hookmanager = new HookManager($db); @@ -59,8 +61,7 @@ print load_fiche_titre($langs->trans("SuppliersOrdersArea"), '', 'supplier_order print '<div class="fichecenter"><div class="fichethirdleft">'; -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 '<form method="post" action="list.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; @@ -79,16 +80,21 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles $sql = "SELECT count(cf.rowid) as nb, fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE cf.fk_soc = s.rowid"; $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; -if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND cf.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -98,11 +104,9 @@ if ($resql) // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially // -> 7=Canceled/Never received -> (reopen) 3=Process runing // -> 6=Canceled -> (reopen) 2=Approved - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $vals[($obj->status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER ? CommandeFournisseur::STATUS_CANCELED : $obj->status)] = $obj->nb; $total += $obj->nb; @@ -118,28 +122,41 @@ if ($resql) print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'</th></tr>'; print "</tr>\n"; $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9); - foreach ($listofstatus as $status) - { + foreach ($listofstatus as $status) { $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == CommandeFournisseur::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == CommandeFournisseur::STATUS_VALIDATED) $colorseries[$status] = '-'.$badgeStatus1; - if ($status == CommandeFournisseur::STATUS_ACCEPTED) $colorseries[$status] = $badgeStatus1; - if ($status == CommandeFournisseur::STATUS_REFUSED) $colorseries[$status] = $badgeStatus9; - if ($status == CommandeFournisseur::STATUS_ORDERSENT) $colorseries[$status] = $badgeStatus4; - if ($status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) $colorseries[$status] = '-'.$badgeStatus4; - if ($status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $colorseries[$status] = $badgeStatus6; - if ($status == CommandeFournisseur::STATUS_CANCELED || $status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER) $colorseries[$status] = $badgeStatus9; + if ($status == CommandeFournisseur::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == CommandeFournisseur::STATUS_VALIDATED) { + $colorseries[$status] = '-'.$badgeStatus1; + } + if ($status == CommandeFournisseur::STATUS_ACCEPTED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == CommandeFournisseur::STATUS_REFUSED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == CommandeFournisseur::STATUS_ORDERSENT) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { + $colorseries[$status] = '-'.$badgeStatus4; + } + if ($status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { + $colorseries[$status] = $badgeStatus6; + } + if ($status == CommandeFournisseur::STATUS_CANCELED || $status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER) { + $colorseries[$status] = $badgeStatus9; + } - if (!$conf->use_javascript_ajax) - { + if (!$conf->use_javascript_ajax) { print '<tr class="oddeven">'; print '<td>'.$commandestatic->LibStatut($status, 0).'</td>'; print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>'; print "</tr>\n"; } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr class="impair"><td class="center" colspan="2">'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -168,32 +185,34 @@ if ($resql) * Draft orders */ -if (!empty($conf->fournisseur->enabled)) -{ +if (!empty($conf->fournisseur->enabled)) { $sql = "SELECT c.rowid, c.ref, 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"; + 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").")"; // Thirdparty sharing is mandatory with supplier order sharing $sql .= " AND c.fk_statut = 0"; - if (!empty($socid)) $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; + if (!empty($socid)) { + $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; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="2">'.$langs->trans("DraftOrders").'</th></tr>'; $langs->load("orders"); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -218,8 +237,7 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_T } $sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; -if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) -{ +if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " WHERE ((ug.fk_user = u.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; @@ -230,8 +248,7 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_T $sql .= " AND u.fk_soc IS NULL"; // An external user can not approved $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -240,16 +257,14 @@ if ($resql) print '<tr class="liste_titre"><th>'.$langs->trans("UserWithApproveOrderGrant").'</th>'; print "</tr>\n"; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $userstatic = new User($db); $userstatic->id = $obj->rowid; $userstatic->getrights('fournisseur'); - if (!empty($userstatic->rights->fournisseur->commande->approuver)) - { + if (!empty($userstatic->rights->fournisseur->commande->approuver)) { print '<tr class="oddeven">'; print '<td>'; $userstatic->lastname = $obj->lastname; @@ -281,29 +296,32 @@ $max = 5; $sql = "SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.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"; +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 = ".$conf->entity; //$sql.= " AND c.fk_statut > 2"; -if (!empty($socid)) $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; +if (!empty($socid)) { + $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.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="4">'.$langs->trans("LastModifiedOrders", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -338,7 +356,9 @@ if ($resql) } } print "</table></div><br>"; -} else dol_print_error($db); +} else { + dol_print_error($db); +} /* diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index a50cbbdad39..60c67fdd0e8 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -44,17 +44,24 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS)); } @@ -62,10 +69,14 @@ $search_agenda_label = GETPOST('search_agenda_label'); // Security check $socid = 0; -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); -if (!$user->rights->fournisseur->commande->lire) accessforbidden(); +if (!$user->rights->fournisseur->commande->lire) { + accessforbidden(); +} @@ -76,11 +87,12 @@ if (!$user->rights->fournisseur->commande->lire) accessforbidden(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -94,15 +106,16 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $object = new CommandeFournisseur($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); $object->info($object->id); } $title = $langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +} $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $title, $help_url); @@ -125,12 +138,10 @@ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_ // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; @@ -181,18 +192,15 @@ print dol_get_fiche_end(); $out = ''; $permok = $user->rights->agenda->myactions->create; -if ($permok) -{ +if ($permok) { $out .= '&originid='.$object->id.'&origin=order_supplier'; } print '<div class="tabsAction">'; -if (!empty($conf->agenda->enabled)) -{ - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { +if (!empty($conf->agenda->enabled)) { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>'; @@ -202,18 +210,21 @@ if (!empty($conf->agenda->enabled)) print '</div>'; -if (!empty($object->id)) -{ +if (!empty($object->id)) { $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + 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("ActionsOnOrder"), '', ''); // List of actions on element /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object,'project',0);*/ + $formactions=new FormActions($db); + $somethingshown = $formactions->showactions($object,'project',0);*/ // List of todo actions //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 0918b316fb3..e35d9d84824 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -99,7 +99,9 @@ if (is_array(GETPOST('search_status', 'intcomma'))) { // Security check $orderid = GETPOST('orderid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id; @@ -108,14 +110,22 @@ $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 (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = 'cf.ref'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'cf.ref'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} -if ($search_status == '') $search_status = -1; +if ($search_status == '') { + $search_status = -1; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new CommandeFournisseur($db); @@ -138,7 +148,9 @@ $fieldstosearchall = array( 's.town'=>"Town", 'cf.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall["cf.note_private"] = "NotePrivate"; +} $checkedtypetiers = 0; $arrayfields = array( @@ -180,21 +192,25 @@ $error = 0; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_categ = ''; $search_user = ''; $search_sale = ''; @@ -231,8 +247,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -245,8 +260,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Mass action to generate vendor bills - if ($massaction == 'confirm_createsupplierbills') - { + if ($massaction == 'confirm_createsupplierbills') { $orders = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('validate_invoices', 'int'); @@ -262,7 +276,9 @@ if (empty($reshook)) foreach ($orders as $id_order) { $cmd = new CommandeFournisseur($db); - if ($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) { + continue; + } $objecttmp = new FactureFournisseur($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { @@ -274,11 +290,12 @@ if (empty($reshook)) $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + if (empty($createbills_onebythird)) { + $objecttmp->ref_client = $cmd->ref_client; + } $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) - { + if (empty($datefacture)) { $datefacture = dol_now(); } @@ -295,8 +312,7 @@ if (empty($reshook)) } } - if ($objecttmp->id > 0) - { + if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql .= "fk_source"; $sql .= ", sourcetype"; @@ -309,16 +325,13 @@ if (empty($reshook)) $sql .= ", '".$db->escape($objecttmp->element)."'"; $sql .= ")"; - if (!$db->query($sql)) - { + if (!$db->query($sql)) { $erorr++; } - if (!$error) - { + if (!$error) { $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) - { + if (empty($lines) && method_exists($cmd, 'fetch_lines')) { $cmd->fetch_lines(); $lines = $cmd->lines; } @@ -326,11 +339,9 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { + if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; @@ -341,8 +352,7 @@ if (empty($reshook)) $discount->fk_user = $user->id; $discount->description = $desc; $discountid = $discount->create($user); - if ($discountid > 0) - { + if ($discountid > 0) { $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else { @@ -355,17 +365,28 @@ if (empty($reshook)) $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start $date_start = false; - if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + if ($lines[$i]->date_debut_prevue) { + $date_start = $lines[$i]->date_debut_prevue; + } + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } //Date end $date_end = false; - if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; + if ($lines[$i]->date_fin_prevue) { + $date_end = $lines[$i]->date_fin_prevue; + } + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } $result = $objecttmp->addline( @@ -393,8 +414,7 @@ if (empty($reshook)) $lines[$i]->special_code, $fk_parent_line ); - if ($result > 0) - { + if ($result > 0) { $lineid = $result; } else { $lineid = 0; @@ -402,8 +422,7 @@ if (empty($reshook)) break; } // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { + if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } @@ -413,8 +432,11 @@ if (empty($reshook)) $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; - else $TFact[$objecttmp->id] = $objecttmp; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { + $TFactThird[$cmd->socid] = $objecttmp; + } else { + $TFact[$objecttmp->id] = $objecttmp; + } } // Build doc with all invoices @@ -424,11 +446,9 @@ if (empty($reshook)) if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach ($TAllFact as &$objecttmp) - { + foreach ($TAllFact as &$objecttmp) { $objecttmp->validate($user); - if ($result <= 0) - { + if ($result <= 0) { $error++; setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); break; @@ -446,8 +466,7 @@ if (empty($reshook)) $massaction = $action = 'confirm_createsupplierbills'; } - if (!$error) - { + if (!$error) { $db->commit(); if ($nb_bills_created == 1) { @@ -460,29 +479,73 @@ if (empty($reshook)) // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= '&sall='.urlencode($sall); - if ($socid > 0) $param .= '&socid='.urlencode($socid); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_company) $param .= '&search_company='.urlencode($search_company); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } //if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); - if ($search_total_tva != '') $param .= '&search_total_tva='.urlencode($search_total_tva); - if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($billed != '') $param .= '&billed='.urlencode($billed); + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_tva != '') { + $param .= '&search_total_tva='.urlencode($search_total_tva); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($billed != '') { + $param .= '&billed='.urlencode($billed); + } header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; @@ -513,8 +576,7 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $title = $langs->trans("ListOfSupplierOrders"); -if ($socid > 0) -{ +if ($socid > 0) { $fourn = new Fournisseur($db); $fourn->fetch($socid); $title .= ' - '.$fourn->name; @@ -528,14 +590,18 @@ if ($socid > 0) elseif ($search_status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled"); elseif (is_numeric($search_status) && $search_status >= 0) $title .= ' - '.$commandestatic->LibStatut($search_status); }*/ -if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed"); +if ($search_billed > 0) { + $title .= ' - '.$langs->trans("Billed"); +} //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; $help_url = ''; // llxHeader('',$title,$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT'; +if ($sall || $search_product_category > 0 || $search_user > 0) { + $sql = 'SELECT DISTINCT'; +} $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; @@ -547,7 +613,9 @@ $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title, $sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // 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 : ''); + 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(); @@ -558,15 +626,22 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -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 (cf.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; -if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +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 (cf.rowid = ef.fk_object)"; +} +if ($sall || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } @@ -575,39 +650,93 @@ $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object $sql .= $hookmanager->resPrint; $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; -if ($socid > 0) $sql .= " AND s.rowid = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); -if ($search_refsupp) $sql .= natural_search("cf.ref_supplier", $search_refsupp); -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_request_author) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); -if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed); -if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) { + $sql .= " AND s.rowid = ".$socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} +if ($search_ref) { + $sql .= natural_search('cf.ref', $search_ref); +} +if ($search_refsupp) { + $sql .= natural_search("cf.ref_supplier", $search_refsupp); +} +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_request_author) { + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); +} +if ($search_billed != '' && $search_billed >= 0) { + $sql .= " AND cf.billed = ".$db->escape($search_billed); +} +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".$search_product_category; +} //Required triple check because statut=0 means draft filter -if (GETPOST('statut', 'intcomma') !== '') +if (GETPOST('statut', 'intcomma') !== '') { $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")"; -if ($search_status != '' && $search_status != '-1') +} +if ($search_status != '' && $search_status != '-1') { $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; +} $sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); $sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); -if ($search_town) $sql .= natural_search('s.town', $search_town); -if ($search_zip) $sql .= natural_search("s.zip", $search_zip); -if ($search_state) $sql .= natural_search("state.nom", $search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); -if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); -if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1); -if ($search_total_tva != '') $sql .= natural_search('cf.total_tva', $search_total_tva, 1); -if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); -if ($search_multicurrency_code != '') $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; -if ($search_multicurrency_tx != '') $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1); -if ($search_multicurrency_montant_ht != '') $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); -if ($search_multicurrency_montant_tva != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1); -if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); +if ($search_town) { + $sql .= natural_search('s.town', $search_town); +} +if ($search_zip) { + $sql .= natural_search("s.zip", $search_zip); +} +if ($search_state) { + $sql .= natural_search("state.nom", $search_state); +} +if ($search_country) { + $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; +} +if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); +} +if ($search_user > 0) { + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); +} +if ($search_total_ht != '') { + $sql .= natural_search('cf.total_ht', $search_total_ht, 1); +} +if ($search_total_tva != '') { + $sql .= natural_search('cf.total_tva', $search_total_tva, 1); +} +if ($search_total_ttc != '') { + $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); +} +if ($search_multicurrency_code != '') { + $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +} +if ($search_multicurrency_tx != '') { + $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1); +} +if ($search_multicurrency_montant_ht != '') { + $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +} +if ($search_multicurrency_montant_tva != '') { + $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1); +} +if ($search_multicurrency_montant_ttc != '') { + $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +} +if ($search_project_ref != '') { + $sql .= natural_search("p.ref", $search_project_ref); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -619,12 +748,10 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -634,14 +761,12 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) - { + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/fourn/commande/card.php?id='.$id); @@ -651,36 +776,96 @@ if ($resql) llxHeader('', $title, $help_url); $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= '&sall='.urlencode($sall); - if ($socid > 0) $param .= '&socid='.urlencode($socid); - if ($sall) $param .= "&search_all=".urlencode($sall); - if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_company) $param .= '&search_company='.urlencode($search_company); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_request_author) $param .= '&search_request_author='.urlencode($search_request_author); - if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); - if ($search_total_ttc != '') $param .= "&search_total_ttc=".urlencode($search_total_ttc); - if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); - if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); - if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); - if ($search_multicurrency_montant_tva != '') $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva); - if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); - if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp); - if ($search_status != '' && $search_status != '-1') $param .= "&search_status=".urlencode($search_status); - if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); - if ($search_billed != '') $param .= "&search_billed=".urlencode($search_billed); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($sall) { + $param .= "&search_all=".urlencode($sall); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_request_author) { + $param .= '&search_request_author='.urlencode($search_request_author); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_ttc != '') { + $param .= "&search_total_ttc=".urlencode($search_total_ttc); + } + if ($search_multicurrency_code != '') { + $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + } + if ($search_multicurrency_tx != '') { + $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + } + if ($search_multicurrency_montant_ht != '') { + $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + } + if ($search_multicurrency_montant_tva != '') { + $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva); + } + if ($search_multicurrency_montant_ttc != '') { + $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + } + if ($search_refsupp) { + $param .= "&search_refsupp=".urlencode($search_refsupp); + } + if ($search_status != '' && $search_status != '-1') { + $param .= "&search_status=".urlencode($search_status); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($search_billed != '') { + $param .= "&search_billed=".urlencode($search_billed); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -695,18 +880,28 @@ if ($resql) 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); - if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + if ($user->rights->fournisseur->facture->creer) { + $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); + } + if ($user->rights->fournisseur->commande->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $user->rights->fournisseur->commande->creer); // Lines of title fields print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -723,8 +918,7 @@ if ($resql) $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($massaction == 'createbills') - { + if ($massaction == 'createbills') { //var_dump($_REQUEST); print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">'; @@ -763,17 +957,17 @@ if ($resql) print '<br>'; } - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { + if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; @@ -781,16 +975,14 @@ if ($resql) $moreforfilter .= '</div>'; } // If the user can view other users - if ($user->rights->user->user->lire) - { + if ($user->rights->user->user->lire) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; } // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) - { + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -800,11 +992,13 @@ if ($resql) } $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -829,126 +1023,116 @@ if ($resql) print '<tr class="liste_titre_filter">'; // Ref - if (!empty($arrayfields['cf.ref']['checked'])) - { + if (!empty($arrayfields['cf.ref']['checked'])) { print '<td class="liste_titre"><input size="8" type="text" class="flat maxwidth75" name="search_ref" value="'.$search_ref.'"></td>'; } // Ref customer - if (!empty($arrayfields['cf.ref_supplier']['checked'])) - { + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_refsupp" value="'.$search_refsupp.'"></td>'; } // Project ref - if (!empty($arrayfields['p.project_ref']['checked'])) - { + if (!empty($arrayfields['p.project_ref']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_project_ref" value="'.$search_project_ref.'"></td>'; } // Request author - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.'">'; print '</td>'; } // Thirpdarty - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.'"></td>'; } // Town - if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>'; + } // Zip - if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>'; + } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); print '</td>'; } // Date order - if (!empty($arrayfields['cf.date_commande']['checked'])) - { + if (!empty($arrayfields['cf.date_commande']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; + } print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.'">'; $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); print '</td>'; } // Date delivery - if (!empty($arrayfields['cf.date_livraison']['checked'])) - { + if (!empty($arrayfields['cf.date_livraison']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; + } print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.'">'; $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); print '</td>'; } - if (!empty($arrayfields['cf.total_ht']['checked'])) - { + if (!empty($arrayfields['cf.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">'; print '</td>'; } - if (!empty($arrayfields['cf.total_tva']['checked'])) - { + if (!empty($arrayfields['cf.total_tva']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.'">'; print '</td>'; } - if (!empty($arrayfields['cf.total_ttc']['checked'])) - { + if (!empty($arrayfields['cf.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">'; print '</td>'; } - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { // Currency print '<td class="liste_titre">'; print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); print '</td>'; } - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { // Currency rate print '<td class="liste_titre">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">'; print '</td>'; } - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">'; print '</td>'; } - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).'">'; print '</td>'; } - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">'; @@ -962,27 +1146,23 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['cf.datec']['checked'])) - { + if (!empty($arrayfields['cf.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['cf.tms']['checked'])) - { + if (!empty($arrayfields['cf.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (!empty($arrayfields['cf.fk_statut']['checked'])) - { + if (!empty($arrayfields['cf.fk_statut']['checked'])) { print '<td class="liste_titre right">'; $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status'); print '</td>'; } // Status billed - if (!empty($arrayfields['cf.billed']['checked'])) - { + if (!empty($arrayfields['cf.billed']['checked'])) { print '<td class="liste_titre center">'; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print '</td>'; @@ -997,37 +1177,87 @@ if ($resql) // Fields title print '<tr class="liste_titre">'; - if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp '); - if (!empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cf.date_livraison']['checked'])) print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['cf.total_tva']['checked'])) print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['cf.ref']['checked'])) { + print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { + print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp '); + } + if (!empty($arrayfields['p.project_ref']['checked'])) { + print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cf.fk_author']['checked'])) { + print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.date_commande']['checked'])) { + print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cf.date_livraison']['checked'])) { + print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cf.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cf.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cf.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { + print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.datec']['checked'])) { + print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['cf.tms']['checked'])) { + print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['cf.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cf.billed']['checked'])) { + print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; @@ -1042,8 +1272,7 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $notshippable = 0; @@ -1067,8 +1296,7 @@ if ($resql) print '<tr class="oddeven">'; // Ref - if (!empty($arrayfields['cf.ref']['checked'])) - { + if (!empty($arrayfields['cf.ref']['checked'])) { print '<td class="nowrap">'; // Picto + Ref @@ -1079,24 +1307,30 @@ if ($resql) print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref Supplier - if (!empty($arrayfields['cf.ref_supplier']['checked'])) - { + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print '<td>'.$obj->ref_supplier.'</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project - if (!empty($arrayfields['p.project_ref']['checked'])) - { + if (!empty($arrayfields['p.project_ref']['checked'])) { $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_title; print '<td>'; - if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Author $userstatic->id = $obj->fk_user_author; @@ -1105,68 +1339,78 @@ if ($resql) $userstatic->login = $obj->login; $userstatic->photo = $obj->photo; $userstatic->email = $obj->user_email; - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { print '<td class="tdoverflowmax150">'; - if ($userstatic->id) print $userstatic->getNomUrl(1); + if ($userstatic->id) { + print $userstatic->getNomUrl(1); + } print "</td>"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax150">'; $thirdpartytmp->id = $obj->socid; $thirdpartytmp->name = $obj->name; $thirdpartytmp->email = $obj->email; print $thirdpartytmp->getNomUrl(1, 'supplier'); print '</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Town - if (!empty($arrayfields['s.town']['checked'])) - { + if (!empty($arrayfields['s.town']['checked'])) { print '<td>'; print $obj->town; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip - if (!empty($arrayfields['s.zip']['checked'])) - { + if (!empty($arrayfields['s.zip']['checked'])) { print '<td>'; print $obj->zip; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type ent - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="center">'; - if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } print $typenArray[$obj->typent_code]; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Order date - if (!empty($arrayfields['cf.date_commande']['checked'])) - { + if (!empty($arrayfields['cf.date_commande']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_commande), 'day'); if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { @@ -1175,11 +1419,12 @@ if ($resql) } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Plannned date of delivery - if (!empty($arrayfields['cf.date_livraison']['checked'])) - { + if (!empty($arrayfields['cf.date_livraison']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_livraison), 'day'); if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { @@ -1188,65 +1433,81 @@ if ($resql) } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['cf.total_ht']['checked'])) - { + if (!empty($arrayfields['cf.total_ht']['checked'])) { print '<td class="right">'.price($obj->total_ht)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; + } $totalarray['val']['cf.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['cf.total_tva']['checked'])) - { + if (!empty($arrayfields['cf.total_tva']['checked'])) { print '<td class="right">'.price($obj->total_tva)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; + } $totalarray['val']['cf.total_tva'] += $obj->total_tva; } // Amount TTC - if (!empty($arrayfields['cf.total_ttc']['checked'])) - { + if (!empty($arrayfields['cf.total_ttc']['checked'])) { print '<td class="right">'.price($obj->total_ttc)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; + } $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; } // Currency - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Currency rate - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { print '<td class="nowrap">'; $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount VAT - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_tva)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount TTC - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -1256,44 +1517,51 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['cf.datec']['checked'])) - { + if (!empty($arrayfields['cf.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['cf.tms']['checked'])) - { + if (!empty($arrayfields['cf.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['cf.fk_statut']['checked'])) - { + if (!empty($arrayfields['cf.fk_statut']['checked'])) { print '<td class="right nowrap">'.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Billed - if (!empty($arrayfields['cf.billed']['checked'])) - { + if (!empty($arrayfields['cf.billed']['checked'])) { print '<td class="center">'.yn($obj->billed).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; @@ -1317,7 +1585,9 @@ if ($resql) print '</form>'."\n"; $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index dea5ad69afa..9f8c192752c 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -40,7 +40,9 @@ $ref = GETPOST('ref'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); @@ -72,10 +74,8 @@ $form = new Form($db); $now = dol_now(); -if ($id > 0 || !empty($ref)) -{ - if ($result >= 0) - { +if ($id > 0 || !empty($ref)) { + if ($result >= 0) { $object->fetch_thirdparty(); $author = new User($db); @@ -97,12 +97,10 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 57dfb90e3fd..a152ca26ff1 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -17,8 +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; } @@ -37,41 +36,41 @@ $langs->load("orders"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - <tr class="<?php echo $trclass; ?>"> - <td><?php echo $langs->trans("SupplierOrder"); ?></td> - <td><a href="<?php echo DOL_URL_ROOT.'/fourn/commande/card.php?id='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowOrder"), "order").' '.$objectlink->ref; ?></a></td> - <td class="left"><?php echo $objectlink->ref_supplier; ?></td> - <td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> - <td class="right"><?php + <tr class="<?php echo $trclass; ?>"> + <td><?php echo $langs->trans("SupplierOrder"); ?></td> + <td><a href="<?php echo DOL_URL_ROOT.'/fourn/commande/card.php?id='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowOrder"), "order").' '.$objectlink->ref; ?></a></td> + <td class="left"><?php echo $objectlink->ref_supplier; ?></td> + <td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> + <td class="right"><?php if ($user->rights->fournisseur->commande->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?></td> - <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> - <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> - </tr> + <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> + <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> + </tr> <?php } -if (count($linkedObjectBlock) > 1) -{ +if (count($linkedObjectBlock) > 1) { ?> - <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> - <td><?php echo $langs->trans("Total"); ?></td> - <td></td> - <td class="center"></td> - <td class="center"></td> - <td class="right"><?php echo price($total); ?></td> - <td class="right"></td> - <td class="right"></td> - </tr> - <?php + <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> + <td><?php echo $langs->trans("Total"); ?></td> + <td></td> + <td class="center"></td> + <td class="center"></td> + <td class="right"><?php echo price($total); ?></td> + <td class="right"></td> + <td class="right"></td> + </tr> + <?php } print "<!-- END PHP TEMPLATE -->\n"; diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index 781fd4b6e9a..82c8df6ac66 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -35,8 +35,7 @@ $langs->load("companies"); llxHeader(); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -45,12 +44,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "p.name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "p.name"; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -59,14 +64,20 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; */ $sql = "SELECT s.rowid as socid, s.nom as name, st.libelle as stcomm, p.rowid as cidp, p.lastname, p.firstname, p.email, p.phone"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; +} $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = st.id"; $sql .= " AND s.fournisseur = 1"; $sql .= " AND s.rowid = p.fk_soc"; $sql .= " AND s.entity IN (".getEntity('societe').")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} if (dol_strlen($stcomm)) { $sql .= " AND s.fk_stcomm=$stcomm"; @@ -90,8 +101,7 @@ $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit($limit, $offset); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); @@ -107,8 +117,7 @@ if ($result) print "</tr>\n"; $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); print '<tr class="oddeven">'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1e88aaf74c4..761e1bb9577 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -54,11 +54,15 @@ if (!empty($conf->projet->enabled)) { if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.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'; +} $langs->loadLangs(array('bills', 'compta', 'suppliers', 'companies', 'products', 'banks', 'admin')); -if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); +if (!empty($conf->incoterm->enabled)) { + $langs->load('incoterm'); +} $id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); $socid = GETPOST('socid', 'int'); @@ -86,17 +90,22 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); - if ($ret < 0) dol_print_error($db, $object->error); + if ($ret < 0) { + dol_print_error($db, $object->error); + } $ret = $object->fetch_thirdparty(); - if ($ret < 0) dol_print_error($db, $object->error); + if ($ret < 0) { + dol_print_error($db, $object->error); + } } // Security check $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); @@ -124,14 +133,13 @@ $error = 0; $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -145,24 +153,23 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Link invoice to order - if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) - { + if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) { $object->fetch($id); $object->fetch_thirdparty(); $result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder')); } // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) - { + if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. - if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml'); + if (GETPOST('newsupplierref', 'alphanohtml')) { + $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml'); + } $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); $result = $objectutil->createFromClone($user, $id); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { @@ -170,15 +177,14 @@ if (empty($reshook)) setEventMessages($objectutil->error, $objectutil->errors, 'errors'); $action = ''; } - } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse'); $object->fetch($id); $object->fetch_thirdparty(); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -187,8 +193,7 @@ if (empty($reshook)) // Check parameters if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (!$idwarehouse || $idwarehouse == -1) - { + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -201,12 +206,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } else { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -215,7 +223,9 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } } } @@ -225,25 +235,19 @@ if (empty($reshook)) $isErasable = $object->is_erasable(); - if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) - { + if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { header('Location: list.php?restore_lastsearch_values=1'); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Remove a product line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) - { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + // Remove a product line $result = $object->deleteline($lineid); - if ($result > 0) - { + if ($result > 0) { // Define output language /*$outputlangs = $langs; $newlang = ''; @@ -267,11 +271,8 @@ if (empty($reshook)) /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ $action = ''; } - } - - // Delete link of credit note to invoice - elseif ($action == 'unlinkdiscount' && $usercancreate) - { + } elseif ($action == 'unlinkdiscount' && $usercancreate) { + // Delete link of credit note to invoice $discount = new DiscountAbsolute($db); $result = $discount->fetch(GETPOST("discountid")); $discount->unlink_invoice(); @@ -331,8 +332,12 @@ if (empty($reshook)) if (!$error) { $old_date_echeance = $object->date_echeance; $new_date_echeance = $object->calculate_date_lim_reglement(); - if ($new_date_echeance > $old_date_echeance) $object->date_echeance = $new_date_echeance; - if ($object->date_echeance < $object->date) $object->date_echeance = $object->date; + if ($new_date_echeance > $old_date_echeance) { + $object->date_echeance = $new_date_echeance; + } + if ($object->date_echeance < $object->date) { + $object->date_echeance = $object->date; + } $result = $object->update($user); if ($result < 0) { $error++; @@ -345,83 +350,72 @@ if (empty($reshook)) } else { $db->commit(); } - } - - // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) - { + } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { + // Set incoterm $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // payment mode - elseif ($action == 'setmode' && $usercancreate) - { + } elseif ($action == 'setmode' && $usercancreate) { + // payment mode $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } - - // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { + // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha'))); - } - - // bank account - elseif ($action == 'setbankaccount' && $usercancreate) { + } elseif ($action == 'setbankaccount' && $usercancreate) { + // bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } - // transport mode - if ($action == 'settransportmode' && $user->rights->fournisseur->facture->creer) - { - $result = $object->setTransportMode(GETPOST('transport_mode_id', 'int')); - } - // Set label - elseif ($action == 'setlabel' && $usercancreate) - { + if ($action == 'settransportmode' && $user->rights->fournisseur->facture->creer) { + // transport mode + $result = $object->setTransportMode(GETPOST('transport_mode_id', 'int')); + } elseif ($action == 'setlabel' && $usercancreate) { + // Set label $object->fetch($id); $object->label = GETPOST('label'); $result = $object->update($user); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } } elseif ($action == 'setdatef' && $usercancreate) { $newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); - if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) - { - if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings'); - else setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings'); + if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) { + if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) { + setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings'); + } else { + setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings'); + } } $object->fetch($id); $object->date = $newdate; $date_echence_calc = $object->calculate_date_lim_reglement(); - if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) - { + if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) { $object->date_echeance = $date_echence_calc; } - if ($object->date_echeance && $object->date_echeance < $object->date) - { + if ($object->date_echeance && $object->date_echeance < $object->date) { $object->date_echeance = $object->date; } $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } } elseif ($action == 'setdate_lim_reglement' && $usercancreate) { $object->fetch($id); $object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); - if (!empty($object->date_echeance) && $object->date_echeance < $object->date) - { + if (!empty($object->date_echeance) && $object->date_echeance < $object->date) { $object->date_echeance = $object->date; setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings'); } $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == "setabsolutediscount" && $usercancreate) - { + if ($result < 0) { + dol_print_error($db, $object->error); + } + } elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice @@ -437,23 +431,20 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (!empty($_POST["remise_id_for_payment"])) - { + if (!empty($_POST["remise_id_for_payment"])) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); //var_dump($object->getRemainToPay(0)); //var_dump($discount->amount_ttc);exit; - if (price2num($discount->amount_ttc) > price2num($object->getRemainToPay(0))) - { + if (price2num($discount->amount_ttc) > price2num($object->getRemainToPay(0))) { // TODO Split the discount in 2 automatically $error++; setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { setEventMessages($discount->error, $discount->errors, 'errors'); @@ -461,12 +452,15 @@ if (empty($reshook)) } } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -474,12 +468,12 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } - } - // Convertir en reduc - elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) - { + } elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { + // Convertir en reduc $object->fetch($id); $object->fetch_thirdparty(); //$object->fetch_lines(); // Already done into fetch @@ -489,10 +483,13 @@ if (empty($reshook)) $result = $discountcheck->fetch(0, 0, $object->id); $canconvert = 0; - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is paid (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc) - if ($canconvert) - { + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) { + $canconvert = 1; // we can convert deposit into discount if deposit is paid (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + } + if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) { + $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc) + } + if ($canconvert) { $db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); @@ -500,10 +497,9 @@ if (empty($reshook)) // Loop on each vat rate $i = 0; - foreach ($object->lines as $line) - { - if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 - { // no need to create discount if amount is null + foreach ($object->lines as $line) { + if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 + // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; @@ -527,13 +523,13 @@ if (empty($reshook)) // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $discount->description = '(CREDIT_NOTE)'; - elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) + } elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) { $discount->description = '(DEPOSIT)'; - elseif ($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT || $object->type == FactureFournisseur::TYPE_SITUATION) + } elseif ($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT || $object->type == FactureFournisseur::TYPE_SITUATION) { $discount->description = '(EXCESS PAID)'; - else { + } else { setEventMessages($langs->trans('CantConvertToReducAnInvoiceOfThisType'), null, 'errors'); } $discount->discount_type = 1; // Supplier discount @@ -542,8 +538,7 @@ if (empty($reshook)) $error = 0; - if ($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT || $object->type == FactureFournisseur::TYPE_SITUATION) - { + if ($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT || $object->type == FactureFournisseur::TYPE_SITUATION) { // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT // Total payments @@ -555,7 +550,9 @@ if (empty($reshook)) $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -571,43 +568,39 @@ if (empty($reshook)) while ($obj = $db->fetch_object($resql)) { $total_creditnote_and_deposit += $obj->amount_ttc; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; $result = $discount->create($user); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) - { - foreach ($amount_ht as $tva_tx => $xxx) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); $result = $discount->create($user); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } } - if (empty($error)) - { + if (empty($error)) { if ($object->type != FactureFournisseur::TYPE_DEPOSIT) { // Classe facture $result = $object->setPaid($user); - if ($result >= 0) - { + if ($result >= 0) { $db->commit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -621,15 +614,10 @@ if (empty($reshook)) $db->rollback(); } } - } - - - // Delete payment - elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) - { - $object->fetch($id); - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) - { + } elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) { + // Delete payment + $object->fetch($id); + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) { $paiementfourn = new PaiementFourn($db); $result = $paiementfourn->fetch(GETPOST('paiement_id')); if ($result > 0) { @@ -640,12 +628,11 @@ if (empty($reshook)) setEventMessages($paiementfourn->error, $paiementfourn->errors, 'errors'); } } - } - - // Create - elseif ($action == 'add' && $usercancreate) - { - if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + } elseif ($action == 'add' && $usercancreate) { + // Create + if ($socid > 0) { + $object->socid = GETPOST('socid', 'int'); + } $db->begin(); @@ -653,14 +640,15 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $datedue = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); // Replacement invoice - if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT) - { + if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT) { if (empty($dateinvoice)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); $action = 'create'; @@ -713,16 +701,13 @@ if (empty($reshook)) } // Credit note invoice - if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir', 'int'); - if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) - { + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); } - if (GETPOST('socid', 'int') < 1) - { + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); $action = 'create'; $error++; @@ -739,16 +724,14 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST('ref_supplier')) - { + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); $action = 'create'; $_GET['socid'] = $_POST['socid']; $error++; } - if (!$error) - { + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); // Creation facture @@ -781,15 +764,12 @@ if (empty($reshook)) $error++; } - if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) - { + if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source) > 0) - { + if ($facture_source->fetch($object->fk_facture_source) > 0) { $fk_parent_line = 0; - foreach ($facture_source->lines as $line) - { + foreach ($facture_source->lines as $line) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; @@ -820,11 +800,9 @@ if (empty($reshook)) } } - if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) - { + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined - if ($facture_source->fetch($object->fk_facture_source) > 0) - { + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); $totaldeposits = $facture_source->getSumDepositsUsed(); @@ -837,10 +815,8 @@ if (empty($reshook)) } // Standard or deposit - if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) - { - if (GETPOST('socid', 'int') < 1) - { + if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) { + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); $action = 'create'; $error++; @@ -857,16 +833,14 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST('ref_supplier')) - { + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); $action = 'create'; $_GET['socid'] = $_POST['socid']; $error++; } - if (!$error) - { + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); // Creation invoice @@ -890,13 +864,14 @@ if (empty($reshook)) $object->transport_mode_id = GETPOST('transport_mode_id'); // Auto calculation of date due if not filled by user - if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + if (empty($object->date_echeance)) { + $object->date_echeance = $object->calculate_date_lim_reglement(); + } $object->fetch_thirdparty(); // If creation from another object of another module - if (!$error && GETPOST('origin', 'alpha') && GETPOST('originid')) - { + if (!$error && GETPOST('origin', 'alpha') && GETPOST('originid')) { // Parse element/subelement (ex: project_task) $element = $subelement = GETPOST('origin', 'alpha'); /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) @@ -918,8 +893,7 @@ if (empty($reshook)) if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } - if ($element == 'project') - { + if ($element == 'project') { $element = 'projet'; } $object->origin = GETPOST('origin', 'alpha'); @@ -928,25 +902,23 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') { + $classname = 'CommandeFournisseur'; + } $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); - if (!empty($object->origin) && !empty($object->origin_id)) - { + if (!empty($object->origin) && !empty($object->origin_id)) { $object->linkedObjectsIds[$object->origin] = $object->origin_id; } // Add also link with order if object is reception - if ($object->origin == 'reception') - { + if ($object->origin == 'reception') { $objectsrc->fetchObjectLinked(); - if (count($objectsrc->linkedObjectsIds['order_supplier']) > 0) - { - foreach ($objectsrc->linkedObjectsIds['order_supplier'] as $key => $value) - { + if (count($objectsrc->linkedObjectsIds['order_supplier']) > 0) { + foreach ($objectsrc->linkedObjectsIds['order_supplier'] as $key => $value) { $object->linkedObjectsIds['order_supplier'] = $value; } } @@ -955,26 +927,24 @@ if (empty($reshook)) $id = $object->create($user); // Add lines - if ($id > 0) - { + if ($id > 0) { require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') { + $classname = 'CommandeFournisseur'; + } $srcobject = new $classname($db); $result = $srcobject->fetch(GETPOST('originid', 'int')); - if ($result > 0) - { + if ($result > 0) { $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } $num = count($lines); - for ($i = 0; $i < $num; $i++) // TODO handle subprice < 0 - { + for ($i = 0; $i < $num; $i++) { // TODO handle subprice < 0 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); @@ -986,18 +956,25 @@ if (empty($reshook)) // Dates // TODO mutualiser $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } // FIXME Missing special_code into addline and updateline methods $object->special_code = $lines[$i]->special_code; // FIXME If currency different from main currency, take multicurrency price - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) - { + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { $pu = 0; $pu_currency = $lines[$i]->multicurrency_subprice; } else { @@ -1031,8 +1008,7 @@ if (empty($reshook)) $lines[$i]->special_code ); - if ($result < 0) - { + if ($result < 0) { $error++; break; } @@ -1046,19 +1022,16 @@ if (empty($reshook)) } else { $error++; } - } elseif (!$error) - { + } elseif (!$error) { $id = $object->create($user); - if ($id < 0) - { + if ($id < 0) { $error++; } } } } - if ($error) - { + if ($error) { $langs->load("errors"); $db->rollback(); @@ -1071,8 +1044,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db, $object->error, $object->errors); exit; } @@ -1081,11 +1053,8 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } - - // Edit line - elseif ($action == 'updateline' && $usercancreate) - { + } elseif ($action == 'updateline' && $usercancreate) { + // Edit line $db->begin(); $object->fetch($id); @@ -1093,8 +1062,7 @@ if (empty($reshook)) $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') - { + if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') { $up = price2num(GETPOST('price_ht')); $price_base_type = 'HT'; } else { @@ -1102,13 +1070,10 @@ if (empty($reshook)) $price_base_type = 'TTC'; } - if (GETPOST('productid') > 0) - { + if (GETPOST('productid') > 0) { $productsupplier = new ProductFournisseur($db); - if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) - { - if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty')), GETPOST('productid', 'int'), 'restricthtml', GETPOST('socid', 'int')) < 0) - { + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty')), GETPOST('productid', 'int'), 'restricthtml', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } @@ -1116,7 +1081,9 @@ if (empty($reshook)) $prod = new Product($db); $prod->fetch(GETPOST('productid')); $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) $label = $_POST['product_desc']; + if (trim($_POST['product_desc']) != trim($label)) { + $label = $_POST['product_desc']; + } $type = $prod->type; } else { @@ -1129,8 +1096,9 @@ if (empty($reshook)) // Define info_bits $info_bits = 0; - if (preg_match('/\*/', $tva_tx)) + if (preg_match('/\*/', $tva_tx)) { $info_bits |= 0x01; + } // Define vat_rate $tva_tx = str_replace('*', '', $tva_tx); @@ -1151,8 +1119,7 @@ if (empty($reshook)) } $result = $object->updateline(GETPOST('lineid', 'int'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, price2num(GETPOST('qty'), 'MS'), GETPOST('productid', 'int'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, GETPOST('units'), $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); - if ($result >= 0) - { + if ($result >= 0) { unset($_POST['label']); unset($_POST['fourn_ref']); unset($_POST['date_starthour']); @@ -1177,8 +1144,7 @@ if (empty($reshook)) $db->begin(); $ret = $object->fetch($id); - if ($ret < 0) - { + if ($ret < 0) { dol_print_error($db, $object->error); exit; } @@ -1194,8 +1160,7 @@ if (empty($reshook)) $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); - if ($prod_entry_mode == 'free') - { + if ($prod_entry_mode == 'free') { $idprod = 0; $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); @@ -1220,28 +1185,23 @@ if (empty($reshook)) } } - if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) - { + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) - { + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' - { + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not '' setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) - { + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (!GETPOST('qty')) - { + if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -1260,55 +1220,57 @@ if (empty($reshook)) } } - if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' - { + if ($prod_entry_mode != 'free' && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' $productsupplier = new ProductFournisseur($db); $idprod = 0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') { + $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } $reg = array(); - if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) - { + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) - { + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist - if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price - { + if ($productsupplier->fourn_socid != $socid) { // The price we found is for another supplier, so we clear supplier price $productsupplier->ref_supplier = ''; } } else { $fksoctosearch = $object->thirdparty->id; $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } - } elseif (GETPOST('idprodfournprice', 'alpha') > 0) - { + } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); $res = $productsupplier->fetch($idprod); } - if ($idprod > 0) - { + if ($idprod > 0) { $label = $productsupplier->label; // if we use supplier description of the products if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; - } else $desc = $productsupplier->description; + } else { + $desc = $productsupplier->description; + } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; - if (!empty($product_desc) && trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { + $desc = $product_desc; + } + if (!empty($product_desc) && trim($product_desc) != trim($desc)) { + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + } $type = $productsupplier->type; if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { @@ -1330,11 +1292,15 @@ if (empty($reshook)) $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) { + $pu = 0; // If pu is '' or null, we force to have a numeric value + } $result = $object->addline( $desc, @@ -1361,22 +1327,19 @@ if (empty($reshook)) '' ); } - if ($idprod == -99 || $idprod == 0) - { + if ($idprod == -99 || $idprod == 0) { // Product not selected $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")), null, 'errors'); } - if ($idprod == -1) - { + if ($idprod == -1) { // Quantity too low $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } - } elseif (empty($error)) // $price_ht is already set - { + } elseif (empty($error)) { // $price_ht is already set $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); @@ -1407,17 +1370,19 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (!$error && $result > 0) - { + if (!$error && $result > 0) { $db->commit(); // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1426,7 +1391,9 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } unset($_POST ['prod_entry_mode']); @@ -1470,12 +1437,8 @@ if (empty($reshook)) } elseif ($action == 'classin' && $usercancreate) { $object->fetch($id); $result = $object->setProject($projectid); - } - - - // Set invoice to draft status - elseif ($action == 'confirm_edit' && $confirm == 'yes' && $usercancreate) - { + } elseif ($action == 'confirm_edit' && $confirm == 'yes' && $usercancreate) { + // Set invoice to draft status $object->fetch($id); $totalpaye = $object->getSommePaiement(); @@ -1484,29 +1447,24 @@ if (empty($reshook)) // We check that lines of invoices are exported in accountancy $ventilExportCompta = $object->getVentilExportCompta(); - if (!$ventilExportCompta) - { + if (!$ventilExportCompta) { // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED) - { + if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED) { $idwarehouse = GETPOST('idwarehouse'); $object->fetch_thirdparty(); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (!$idwarehouse || $idwarehouse == -1) - { + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -1516,12 +1474,15 @@ if (empty($reshook)) $object->setDraft($user, $idwarehouse); // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1530,24 +1491,21 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } $action = ''; } } - } - - // Set invoice to validated/unpaid status - elseif ($action == 'reopen' && $usercancreate) - { + } elseif ($action == 'reopen' && $usercancreate) { + // Set invoice to validated/unpaid status $result = $object->fetch($id); if ($object->statut == FactureFournisseur::STATUS_CLOSED - || ($object->statut == FactureFournisseur::STATUS_ABANDONED && $object->close_code != 'replaced')) - { + || ($object->statut == FactureFournisseur::STATUS_ABANDONED && $object->close_code != 'replaced')) { $result = $object->setUnpaid($user); - if ($result > 0) - { + if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } else { @@ -1572,91 +1530,75 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Make calculation according to calculationrule - if ($action == 'calculate') - { + if ($action == 'calculate') { $calculationrule = GETPOST('calculationrule'); $object->fetch($id); $object->fetch_thirdparty(); $result = $object->update_price(0, (($calculationrule == 'totalofround') ? '0' : '1'), 0, $object->thirdparty); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db, $result); exit; } } - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $object->insertExtraFields('BILL_SUPPLIER_MODIFY'); - if ($result < 0) - { + if ($result < 0) { $error++; } } } - if ($error) + if ($error) { $action = 'edit_extras'; + } } - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) - { - if ($action == 'addcontact') - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { + if ($action == 'addcontact') { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // bascule du statut d'un contact - elseif ($action == 'swapstatut') - { - if ($object->fetch($id)) - { + } elseif ($action == 'swapstatut') { + // bascule du statut d'un contact + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } - - // Efface un contact - elseif ($action == 'deletecontact') - { + } elseif ($action == 'deletecontact') { + // Efface un contact $object->fetch($id); $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -1675,7 +1617,9 @@ $form = new Form($db); $formfile = new FormFile($db); $bankaccountstatic = new Account($db); $paymentstatic = new PaiementFourn($db); -if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $now = dol_now(); @@ -1684,8 +1628,7 @@ $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Mód llxHeader('', $title, $helpurl); // Mode creation -if ($action == 'create') -{ +if ($action == 'create') { $facturestatic = new FactureFournisseur($db); print load_fiche_titre($langs->trans('NewBill'), '', 'supplier_invoice'); @@ -1698,7 +1641,9 @@ if ($action == 'create') if (GETPOST('socid') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); - if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; + if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) { + $currency_code = $societe->multicurrency_code; + } } if (!empty($origin) && !empty($originid)) { @@ -1726,7 +1671,9 @@ if ($action == 'create') require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') { + $classname = 'CommandeFournisseur'; + } $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); @@ -1743,10 +1690,13 @@ if ($action == 'create') $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0)); - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($conf->multicurrency->enabled)) { + if (!empty($objectsrc->multicurrency_code)) { + $currency_code = $objectsrc->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) { + $currency_tx = $objectsrc->multicurrency_tx; + } } $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -1767,7 +1717,9 @@ if ($action == 'create') $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); $datedue = ($datetmp == '' ?-1 : $datetmp); - if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) { + $currency_code = $soc->multicurrency_code; + } } // when payment condition is empty (means not override by payment condition form a other object, like third-party), try to use default value @@ -1786,10 +1738,14 @@ if ($action == 'create') print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - if ($societe->id > 0) print '<input type="hidden" name="socid" value="'.$societe->id.'">'."\n"; + if ($societe->id > 0) { + print '<input type="hidden" name="socid" value="'.$societe->id.'">'."\n"; + } print '<input type="hidden" name="origin" value="'.$origin.'">'; print '<input type="hidden" name="originid" value="'.$originid.'">'; - if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; + if (!empty($currency_tx)) { + print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; + } print dol_get_fiche_head(); @@ -1802,16 +1758,14 @@ if ($action == 'create') print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>'; print '<td>'; - if ($societe->id > 0) - { + if ($societe->id > 0) { $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); print $societe->getNomUrl(1); print '<input type="hidden" name="socid" value="'.$societe->id.'">'; } else { print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve supplier informations - if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) - { + if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print '<script type="text/javascript"> $(document).ready(function() { $("#socid").change(function() { @@ -1828,7 +1782,9 @@ if ($action == 'create') // Ref supplier print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier']) ? $_POST['ref_supplier'] : $objectsrc->ref_supplier).'" type="text"'; - if ($societe->id > 0) print ' autofocus'; + if ($societe->id > 0) { + print ' autofocus'; + } print '></td>'; print '</tr>'; @@ -1876,7 +1832,7 @@ if ($action == 'create') print '</div></div>'; } } - */ + */ /* Not yet supported for supplier if ($societe->id > 0) @@ -1942,24 +1898,19 @@ if ($action == 'create') } */ - if (empty($origin)) - { - if ($societe->id > 0) - { + if (empty($origin)) { + if ($societe->id > 0) { // Credit note - if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) - { + if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id); - if ($facids < 0) - { + if ($facids < 0) { dol_print_error($db, $facturestatic); exit; } $optionsav = ""; $newinvoice_static = new FactureFournisseur($db); - foreach ($facids as $key => $valarray) - { + foreach ($facids as $key => $valarray) { $newinvoice_static->id = $key; $newinvoice_static->ref = $valarray ['ref']; $newinvoice_static->statut = $valarray ['status']; @@ -1967,8 +1918,9 @@ if ($action == 'create') $newinvoice_static->paye = $valarray ['paye']; $optionsav .= '<option value="'.$key.'"'; - if ($key == GETPOST('fac_avoir', 'int')) + if ($key == GETPOST('fac_avoir', 'int')) { $optionsav .= ' selected'; + } $optionsav .= '>'; $optionsav .= $newinvoice_static->ref; $optionsav .= ' ('.$newinvoice_static->getLibStatut(1, $valarray ['paymentornot']).')'; @@ -1977,7 +1929,9 @@ if ($action == 'create') print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">'; $tmp = '<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST('type') == 2 ? ' checked' : ''); - if (!$optionsav) $tmp .= ' disabled'; + if (!$optionsav) { + $tmp .= ' disabled'; + } $tmp .= '> '; // Show credit note options only if we checked credit note print '<script type="text/javascript" language="javascript"> @@ -1997,8 +1951,9 @@ if ($action == 'create') $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk").' '; // $text.='<input type="text" value="">'; $text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"'; - if (!$optionsav) + if (!$optionsav) { $text .= ' disabled'; + } $text .= '>'; if ($optionsav) { $text .= '<option value="-1"></option>'; @@ -2034,8 +1989,7 @@ if ($action == 'create') print '</td></tr>'; - if ($societe->id > 0) - { + if ($societe->id > 0) { // Discounts for third party print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; @@ -2071,16 +2025,14 @@ if ($action == 'create') print '</td></tr>'; // Bank Account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print '<tr><td>'.$langs->trans('BankAccount').'</td><td>'; print img_picto('', 'bank_account').$form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1, '', 0, '', 1); print '</td></tr>'; } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); @@ -2090,8 +2042,7 @@ if ($action == 'create') } // Incoterms - if (!empty($conf->incoterm->enabled)) - { + if (!empty($conf->incoterm->enabled)) { print '<tr>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).'</label></td>'; print '<td colspan="3" class="maxwidthonsmartphone">'; @@ -2100,8 +2051,7 @@ if ($action == 'create') } // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; print '<td class="maxwidthonsmartphone">'; @@ -2110,8 +2060,7 @@ if ($action == 'create') } // Intracomm report - if (!empty($conf->intracommreport->enabled)) - { + if (!empty($conf->intracommreport->enabled)) { $langs->loadLangs(array("intracommreport")); print '<tr><td>'.$langs->trans('IntracommReportTransportMode').'</td><td>'; $form->selectTransportMode(isset($_POST['transport_mode_id']) ? $_POST['transport_mode_id'] : $transport_mode_id, 'transport_mode_id'); @@ -2136,13 +2085,11 @@ if ($action == 'create') // print '<td><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; print '</tr>'; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } - if (is_object($objectsrc)) - { + if (is_object($objectsrc)) { print "\n<!-- ".$classname." info -->"; print "\n"; print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; @@ -2163,12 +2110,10 @@ if ($action == 'create') $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; // count function need a array as argument (Note: the array must implement Countable too) - if (is_array($invoice_supplier)) - { + if (is_array($invoice_supplier)) { $cntinvoice = count($invoice_supplier); - if ($cntinvoice >= 1) - { + if ($cntinvoice >= 1) { setEventMessages('WarningBillExist', null, 'warnings'); echo ' ('.$langs->trans('LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).')'; } @@ -2177,19 +2122,16 @@ if ($action == 'create') print '</td></tr>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($objectsrc->total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($objectsrc->total_tva)."</td></tr>"; - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 - { + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1)."</td></tr>"; } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 - { + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2)."</td></tr>"; } print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($objectsrc->total_ttc)."</td></tr>"; - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td>'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td>'.price($objectsrc->multicurrency_total_tva)."</td></tr>"; print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td>'.price($objectsrc->multicurrency_total_ttc)."</td></tr>"; @@ -2240,11 +2182,15 @@ if ($action == 'create') $object->fetch($id, $ref); $result = $object->fetch_thirdparty(); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } $societe = new Fournisseur($db); $result = $societe->fetch($object->socid); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); @@ -2258,8 +2204,7 @@ if ($action == 'create') // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if ($object->paye) - { + if ($object->paye) { $resteapayer = 0; } $resteapayeraffiche = $resteapayer; @@ -2278,8 +2223,8 @@ if ($action == 'create') $absolute_creditnote = price2num($absolute_creditnote, 'MT'); /* - * View card - */ + * View card + */ $head = facturefourn_prepare_head($object); $titre = $langs->trans('SupplierInvoice'); @@ -2289,17 +2234,20 @@ if ($action == 'create') // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if ($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; - elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; - elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; + if ($object->type == FactureFournisseur::TYPE_STANDARD) { + $type_fac = 'ExcessPaid'; + } elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $type_fac = 'CreditNote'; + } elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) { + $type_fac = 'Deposit'; + } $text = $langs->trans('ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac))); $text .= '<br>'.$langs->trans('ConfirmConvertToReducSupplier2'); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } // Clone confirmation - if ($action == 'clone') - { + if ($action == 'clone') { // Create an array for form $formquestion = array( array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier), @@ -2310,8 +2258,7 @@ if ($action == 'create') } // Confirmation of validation - if ($action == 'valid') - { + if ($action == 'valid') { // We check if number is temporary number if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) { // empty should not happened, but when it occurs, the test save life @@ -2341,8 +2288,7 @@ if ($action == 'create') $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -2365,19 +2311,16 @@ if ($action == 'create') } // Confirmation edit (back to draft) - if ($action == 'edit') - { + if ($action == 'edit') { $formquestion = array(); $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -2398,34 +2341,32 @@ if ($action == 'create') } // Confirmation set paid - if ($action == 'paid') - { + if ($action == 'paid') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); } // Confirmation de la suppression de la facture fournisseur - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); } - if ($action == 'deletepayment') - { + if ($action == 'deletepayment') { $payment_id = GETPOST('paiement_id'); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&paiement_id='.$payment_id, $langs->trans('DeletePayment'), $langs->trans('ConfirmDeletePayment'), 'confirm_delete_paiement', '', 0, 1); } - // Confirmation to delete line - if ($action == 'ask_deleteline') - { + // Confirmation to delete line + if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } - if (!$formconfirm) - { + if (!$formconfirm) { $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } } // Print form confirm @@ -2441,14 +2382,14 @@ if ($action == 'create') $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($usercancreate) - { + if ($usercancreate) { if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; } @@ -2492,36 +2433,34 @@ if ($action == 'create') print '<span class="badgeneutral">'; print $object->getLibType(); print '</span>'; - if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) - { + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { + if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $id) - { - if ($i == 0) print ' '; - else print ','; + foreach ($facidavoir as $id) { + if ($i == 0) { + print ' '; + } else { + print ','; + } $facavoir = new FactureFournisseur($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); } print ')'; } - if (isset($facidnext) && $facidnext > 0) - { + if (isset($facidnext) && $facidnext > 0) { $facthatreplace = new FactureFournisseur($db); $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; @@ -2576,8 +2515,7 @@ if ($action == 'create') } print '</tr></table>'; print '</td><td colspan="2">'; - if ($action == 'editconditions') - { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); @@ -2604,8 +2542,7 @@ if ($action == 'create') } print '</tr></table>'; print '</td><td colspan="2">'; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); @@ -2613,16 +2550,16 @@ if ($action == 'create') print '</td></tr>'; // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; print '<td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '</td>'; - if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editmulticurrencycode') { @@ -2633,15 +2570,15 @@ if ($action == 'create') print '</td></tr>'; // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) - { + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print '<tr>'; print '<td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '</td>'; - if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -2662,14 +2599,14 @@ if ($action == 'create') } // Bank Account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print '<tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans('BankAccount'); print '<td>'; - if ($action != 'editbankaccount' && $usercancreate) + if ($action != 'editbankaccount' && $usercancreate) { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editbankaccount') { @@ -2682,19 +2619,20 @@ if ($action == 'create') } // Incoterms - if (!empty($conf->incoterm->enabled)) - { + if (!empty($conf->incoterm->enabled)) { print '<tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>'; print $langs->trans('IncotermLabel'); print '<td><td class="right">'; - if ($usercancreate) print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; - else print '&nbsp;'; + if ($usercancreate) { + print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; + } else { + print '&nbsp;'; + } print '</td></tr></table>'; print '</td>'; print '<td colspan="3">'; - if ($action != 'editincoterm') - { + if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); @@ -2716,11 +2654,9 @@ if ($action == 'create') print '</td>'; print '<td>'; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1); - } - else { + } else { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none'); } print '</td></tr>'; @@ -2739,8 +2675,7 @@ if ($action == 'create') print '<table class="border tableforfield centpercent">'; - if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) - { + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; @@ -2760,10 +2695,16 @@ if ($action == 'create') // Amount print '<tr><td class="titlefield">'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).'<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; '; - if (GETPOST('calculationrule')) $calculationrule = GETPOST('calculationrule', 'alpha'); - else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); - if ($calculationrule == 'totalofround') $calculationrulenum = 1; - else $calculationrulenum = 2; + if (GETPOST('calculationrule')) { + $calculationrule = GETPOST('calculationrule', 'alpha'); + } else { + $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); + } + if ($calculationrule == 'totalofround') { + $calculationrulenum = 1; + } else { + $calculationrulenum = 2; + } // Show link for "recalculate" if ($object->getVentilExportCompta() == 0) { $s = $langs->trans("ReCalculate").' '; @@ -2776,14 +2717,12 @@ if ($action == 'create') // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj == "1") //Localtax1 - { + if ($societe->localtax1_assuj == "1") { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($societe->localtax2_assuj == "1") //Localtax2 - { + if ($societe->localtax2_assuj == "1") { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; @@ -2793,23 +2732,37 @@ if ($action == 'create') print '</table>'; /* - * List of payments - */ + * List of payments + */ $totalpaye = 0; $sign = 1; - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = - 1; + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $sign = - 1; + } $nbrows = 9; $nbcols = 3; - if (!empty($conf->projet->enabled)) $nbrows++; - if (!empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } - if (!empty($conf->incoterm->enabled)) $nbrows++; - if (!empty($conf->multicurrency->enabled)) $nbrows += 5; + if (!empty($conf->projet->enabled)) { + $nbrows++; + } + if (!empty($conf->banque->enabled)) { + $nbrows++; $nbcols++; + } + if (!empty($conf->incoterm->enabled)) { + $nbrows++; + } + if (!empty($conf->multicurrency->enabled)) { + $nbrows += 5; + } // Local taxes - if ($societe->localtax1_assuj == "1") $nbrows++; - if ($societe->localtax2_assuj == "1") $nbrows++; + if ($societe->localtax1_assuj == "1") { + $nbrows++; + } + if ($societe->localtax2_assuj == "1") { + $nbrows++; + } $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,'; $sql .= ' c.id as paiement_type,'; @@ -2824,8 +2777,7 @@ if ($action == 'create') $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; @@ -2835,15 +2787,15 @@ if ($action == 'create') print '<td class="liste_titre">'.($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>'; print '<td>'.$langs->trans('Date').'</td>'; print '<td>'.$langs->trans('Type').'</td>'; - if (!empty($conf->banque->enabled)) print '<td class="right">'.$langs->trans('BankAccount').'</td>'; + if (!empty($conf->banque->enabled)) { + print '<td class="right">'.$langs->trans('BankAccount').'</td>'; + } print '<td class="right">'.$langs->trans('Amount').'</td>'; print '<td width="18">&nbsp;</td>'; print '</tr>'; - if ($num > 0) - { - while ($i < $num) - { + if ($num > 0) { + while ($i < $num) { $objp = $db->fetch_object($result); $paymentstatic->id = $objp->rowid; @@ -2860,8 +2812,7 @@ if ($action == 'create') print '<td>'; print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_payment; print '</td>'; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; $bankaccountstatic->label = $objp->baref; @@ -2876,13 +2827,14 @@ if ($action == 'create') } print '<td class="right">'; - if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1, 'transactions'); + if ($objp->baid > 0) { + print $bankaccountstatic->getNomUrl(1, 'transactions'); + } print '</td>'; } print '<td class="right">'.price($sign * $objp->amount).'</td>'; print '<td class="center">'; - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) - { + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepayment&token='.newToken().'&paiement_id='.$objp->rowid.'">'; print img_delete(); print '</a>'; @@ -2897,16 +2849,16 @@ if ($action == 'create') } /* - if ($object->paye == 0) - { - print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans('AlreadyPaid').' :</td><td class="right">'.price($totalpaye).'</td><td></td></tr>'; - print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("Billed").' :</td><td class="right">'.price($object->total_ttc).'</td><td></td></tr>'; + if ($object->paye == 0) + { + print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans('AlreadyPaid').' :</td><td class="right">'.price($totalpaye).'</td><td></td></tr>'; + print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("Billed").' :</td><td class="right">'.price($object->total_ttc).'</td><td></td></tr>'; - $resteapayer = $object->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaye; - print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans('RemainderToPay').' :</td>'; - print '<td class="right'.($resteapayer?' amountremaintopay':'').'">'.price($resteapayer).'</td><td></td></tr>'; - } + print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans('RemainderToPay').' :</td>'; + print '<td class="right'.($resteapayer?' amountremaintopay':'').'">'.price($resteapayer).'</td><td></td></tr>'; + } */ $db->free($result); @@ -2914,14 +2866,15 @@ if ($action == 'create') dol_print_error($db); } - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) { // Total already paid print '<tr><td colspan="'.$nbcols.'" class="right">'; print '<span class="opacitymedium">'; - if ($object->type != FactureFournisseur::TYPE_DEPOSIT) + if ($object->type != FactureFournisseur::TYPE_DEPOSIT) { print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else print $langs->trans('AlreadyPaid'); + } else { + print $langs->trans('AlreadyPaid'); + } print '</span>'; print '</td><td class="right"'.(($totalpaye > 0) ? ' class="amountalreadypaid"' : '').'>'.price($totalpaye).'</td><td>&nbsp;</td></tr>'; @@ -2948,10 +2901,12 @@ if ($action == 'create') $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_invoice_supplier_source); print '<tr><td colspan="'.$nbcols.'" class="right">'; - if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) + if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) { print $langs->trans("CreditNote").' '; - if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) + } + if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) { print $langs->trans("Deposit").' '; + } print $invoice->getNomUrl(0); print ' :</td>'; print '<td class="right">'.price($obj->amount_ttc).'</td>'; @@ -2959,10 +2914,12 @@ if ($action == 'create') print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'</a>'; print '</td></tr>'; $i++; - if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) + if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $creditnoteamount += $obj->amount_ttc; - if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) + } + if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) { $depositamount += $obj->amount_ttc; + } } } else { dol_print_error($db); @@ -3002,8 +2959,9 @@ if ($action == 'create') if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'abandon') { print '<tr><td colspan="'.$nbcols.'" class="right nowrap">'; $text = $langs->trans("HelpAbandonOther"); - if ($object->close_note) + if ($object->close_note) { $text .= '<br><br><b>'.$langs->trans("Reason").'</b>:'.$object->close_note; + } print '<span class="opacitymedium">'; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print '</span>'; @@ -3022,9 +2980,11 @@ if ($action == 'create') // Remainder to pay print '<tr><td colspan="'.$nbcols.'" class="right">'; print '<span class="opacitymedium">'; - if ($resteapayeraffiche >= 0) + if ($resteapayeraffiche >= 0) { print $langs->trans('RemainderToPay'); - else print $langs->trans('ExcessPaid'); + } else { + print $langs->trans('ExcessPaid'); + } print '</span>'; print '</td>'; print '<td class="right'.($resteapayeraffiche ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayeraffiche).'</td>'; @@ -3044,9 +3004,11 @@ if ($action == 'create') // Remainder to pay back print '<tr><td colspan="'.$nbcols.'" class="right">'; print '<span class="opacitymedium">'; - if ($resteapayeraffiche <= 0) + if ($resteapayeraffiche <= 0) { print $langs->trans('RemainderToPayBack'); - else print $langs->trans('ExcessPaid'); + } else { + print $langs->trans('ExcessPaid'); + } print '</td>'; print '</span>'; print '<td class="right'.($resteapayeraffiche ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($sign * $resteapayeraffiche).'</td>'; @@ -3067,15 +3029,13 @@ if ($action == 'create') print '<div class="clearboth"></div><br>'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $colwidth = 20; $blocname = 'notes'; $title = $langs->trans('Notes'); @@ -3084,8 +3044,8 @@ if ($action == 'create') /* - * Lines - */ + * Lines + */ print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid')).'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="'.(($action != 'editline') ? 'addline' : 'updateline').'">'; @@ -3104,7 +3064,9 @@ if ($action == 'create') $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. //if (! empty($conf->global->SUPPLIER_INVOICE_WITH_NOPRICEDEFINED)) $senderissupplier=2; - if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { + $senderissupplier = 1; + } // Show object lines if (!empty($object->lines)) { @@ -3114,10 +3076,8 @@ if ($action == 'create') $num = count($object->lines); // Form to add new line - if ($object->statut == FactureFournisseur::STATUS_DRAFT && $usercancreate) - { - if ($action != 'editline') - { + if ($object->statut == FactureFournisseur::STATUS_DRAFT && $usercancreate) { + if ($action != 'editline') { // Add free products/services $object->formAddObjectLine(1, $societe, $mysoc); @@ -3133,27 +3093,23 @@ if ($action == 'create') print dol_get_fiche_end(); - if ($action != 'presend') - { + if ($action != 'presend') { /* - * Buttons actions - */ + * Buttons actions + */ print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { // Modify a validated invoice with no payments - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $usercancreate) - { + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $usercancreate) { // We check if lines of invoice are not already transfered into accountancy $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. - if ($ventilExportCompta == 0) - { + if ($ventilExportCompta == 0) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans('Modify').'</a></div>'; } else { print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Modify').'</span></div>'; @@ -3163,13 +3119,11 @@ if ($action == 'create') $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, 0, $object->id); - // Reopen a standard paid invoice + // Reopen a standard paid invoice if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) - && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely) - { - if (!$facidnext && $object->close_code != 'replaced' && $usercancreate) // Not replaced by another invoice - { + && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) { // A paid invoice (partially or completely) + if (!$facidnext && $object->close_code != 'replaced' && $usercancreate) { // Not replaced by another invoice print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans('ReOpen').'</a></div>'; } else { if ($usercancreate) { @@ -3182,24 +3136,22 @@ if ($action == 'create') // Send by mail if (empty($user->socid)) { - if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) - { - if ($usercansend) - { + if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) { + if ($usercansend) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; - } else print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans('SendMail').'</a></div>'; + } else { + print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans('SendMail').'</a></div>'; + } } } // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) - { + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account > 0 ? '&amp;accountid='.$object->fk_account : '').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice } // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) - { + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"'; print '>'.$langs->trans('ClassifyPaid').'</a></div>'; @@ -3209,10 +3161,8 @@ if ($action == 'create') // Reverse back money or convert to reduction if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD) { // For credit note only - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0) - { - if ($resteapayer == 0) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0) { + if ($resteapayer == 0) { print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPaymentBack').'</span></div>'; } else { print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create&amp;accountid='.$object->fk_account.'">'.$langs->trans('DoPaymentBack').'</a></div>'; @@ -3220,8 +3170,7 @@ if ($action == 'create') } // For standard invoice with excess paid - if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) - { + if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessPaidToReduc').'</a></div>'; } // For credit note @@ -3231,19 +3180,15 @@ if ($action == 'create') print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReducSupplier2")).'">'.$langs->trans('ConvertToReduc').'</a></div>'; } // For deposit invoice - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $usercancreate && empty($discount->id)) - { + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $usercancreate && empty($discount->id)) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>'; } } // Validate - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) - { - if (count($object->lines)) - { - if ($usercanvalidate) - { + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { + if (count($object->lines)) { + if ($usercanvalidate) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"'; print '>'.$langs->trans('Validate').'</a></div>'; } else { @@ -3260,24 +3205,20 @@ if ($action == 'create') }*/ // Clone - if ($action != 'edit' && $usercancreate) - { + if ($action != 'edit' && $usercancreate) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=clone&amp;socid='.$object->socid.'">'.$langs->trans('ToClone').'</a></div>'; } // Create a credit note - if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $usercancreate) - { - if (!$objectidnext) - { + if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $usercancreate) { + if (!$objectidnext) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->socid.'&amp;fac_avoir='.$object->id.'&amp;action=create&amp;type=2'.($object->fk_project > 0 ? '&amp;projectid='.$object->fk_project : '').'">'.$langs->trans("CreateCreditNote").'</a></div>'; } } // Delete $isErasable = $object->is_erasable(); - if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) - { + if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); if ($isErasable == -4) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecausePayments").'">'.$langs->trans('Delete').'</a></div>'; @@ -3287,8 +3228,7 @@ if ($action == 'create') print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastInvoice").'">'.$langs->trans('Delete').'</a></div>'; } elseif ($isErasable == -1) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Delete').'</a></div>'; - } elseif ($isErasable <= 0) // Any other cases - { + } elseif ($isErasable <= 0) { // Any other cases print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotErasable").'">'.$langs->trans('Delete').'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'; @@ -3296,13 +3236,12 @@ if ($action == 'create') } print '</div>'; - if ($action != 'confirm_edit') - { + if ($action != 'confirm_edit') { print '<div class="fichecenter"><div class="fichehalfleft">'; /* - * Documents generes - */ + * Documents generes + */ $ref = dol_sanitizeFileName($object->ref); $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref; $filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index d655b97c74f..4f450bca3c4 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); @@ -51,51 +53,39 @@ $object = new FactureFournisseur($db); * Ajout d'un nouveau contact */ -if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) -{ +if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) { $result = $object->fetch($id, $ref); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// bascule du statut d'un contact -elseif ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) -{ - if ($object->fetch($id)) - { +} elseif ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) { + // bascule du statut d'un contact + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } -} - -// Efface un contact -elseif ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) -{ +} elseif ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) { + // Efface un contact $object->fetch($id); $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -124,10 +114,8 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $alreadypaid = $object->getSommePaiement(); @@ -144,17 +132,18 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') + if ($user->rights->facture->creer) { + if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -192,36 +181,34 @@ if ($id > 0 || !empty($ref)) // Type print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td colspan="4">'; print $object->getLibType(); - if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) - { + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { + if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $fid) - { - if ($i == 0) print ' '; - else print ','; + foreach ($facidavoir as $fid) { + if ($i == 0) { + print ' '; + } else { + print ','; + } $facavoir = new FactureFournisseur($db); $facavoir->fetch($fid); print $facavoir->getNomUrl(1); } print ')'; } - if ($facidnext > 0) - { + if ($facidnext > 0) { $facthatreplace = new FactureFournisseur($db); $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; @@ -239,14 +226,12 @@ if ($id > 0 || !empty($ref)) // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj == "1") //Localtax1 - { + if ($societe->localtax1_assuj == "1") { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($societe->localtax2_assuj == "1") //Localtax2 - { + if ($societe->localtax2_assuj == "1") { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 4b2b45c7226..24009d35dbc 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -46,7 +46,9 @@ $confirm = GETPOST('confirm', 'alpha'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Get parameters @@ -54,16 +56,21 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new FactureFournisseur($db); -if ($object->fetch($id, $ref)) -{ +if ($object->fetch($id, $ref)) { $object->fetch_thirdparty(); $ref = dol_sanitizeFileName($object->ref); $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref; @@ -87,8 +94,7 @@ $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Documents'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); -if ($object->id > 0) -{ +if ($object->id > 0) { $head = facturefourn_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice'); @@ -102,17 +108,18 @@ if ($object->id > 0) $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') + if ($user->rights->facture->creer) { + if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -148,16 +155,14 @@ if ($object->id > 0) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } /* * Confirm delete file */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } @@ -166,28 +171,27 @@ if ($object->id > 0) // Type print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>'; print $object->getLibType(); - if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) - { + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { + if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $id) - { - if ($i == 0) print ' '; - else print ','; + foreach ($facidavoir as $id) { + if ($i == 0) { + print ' '; + } else { + print ','; + } $facavoir = new FactureFournisseur($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); @@ -215,14 +219,12 @@ if ($object->id > 0) // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($mysoc->localtax1_assuj == "1") //Localtax1 - { + if ($mysoc->localtax1_assuj == "1") { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($mysoc->localtax2_assuj == "1") //Localtax2 - { + if ($mysoc->localtax2_assuj == "1") { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; @@ -255,8 +257,7 @@ if ($object->id > 0) $defaulttpldir = '/core/tpl'; $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); - foreach ($dirtpls as $module => $reldir) - { + foreach ($dirtpls as $module => $reldir) { if (!empty($module)) { $tpl = dol_buildpath($reldir.'/document_actions_post_headers.tpl.php'); } else { @@ -268,7 +269,9 @@ if ($object->id > 0) } else { $res = include $tpl; // for debug } - if ($res) break; + if ($res) { + break; + } } } else { print $langs->trans('ErrorUnknown'); diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 18c4bff9036..7019b90b868 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -if (!$user->rights->fournisseur->facture->lire) accessforbidden(); +if (!$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} $langs->loadLangs(array("companies", "bills")); @@ -39,8 +41,7 @@ $socid = GETPOST('socid', 'int'); $option = GETPOST('option'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -56,15 +57,20 @@ $search_amount_all_tax = GETPOST('search_amount_all_tax', 'alpha'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "f.date_lim_reglement"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "f.date_lim_reglement"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers $search_ref = ""; $search_ref_supplier = ""; $search_company = ""; @@ -85,101 +91,124 @@ $title = $langs->trans("BillsSuppliersUnpaid"); $facturestatic = new FactureFournisseur($db); $companystatic = new Societe($db); -if ($user->rights->fournisseur->facture->lire) -{ +if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql .= " f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc,"; $sql .= " f.datef as df, f.date_lim_reglement as datelimite, "; $sql .= " f.paye as paye, f.rowid as facid, f.fk_statut"; $sql .= " ,sum(pf.amount) as am"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn "; $sql .= " WHERE f.entity = ".$conf->entity; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.paye = 0 AND f.fk_statut = 1"; - if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; - 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; + if ($option == 'late') { + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; + } + 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; + } - if (GETPOST('filtre')) - { + if (GETPOST('filtre')) { $filtrearr = explode(",", GETPOST('filtre')); - foreach ($filtrearr as $fil) - { + foreach ($filtrearr as $fil) { $filt = explode(":", $fil); $sql .= " AND ".$filt[0]." = ".$filt[1]; } } - if ($search_ref) - { + if ($search_ref) { $sql .= " AND f.ref LIKE '%".$db->escape($search_ref)."%'"; } - if ($search_ref_supplier) - { + if ($search_ref_supplier) { $sql .= " AND f.ref_supplier LIKE '%".$db->escape($search_ref_supplier)."%'"; } - if ($search_company) - { + if ($search_company) { $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } - if ($search_amount_no_tax) - { + if ($search_amount_no_tax) { $sql .= " AND f.total_ht = '".$db->escape($search_amount_no_tax)."'"; } - if ($search_amount_all_tax) - { + if ($search_amount_all_tax) { $sql .= " AND f.total_ttc = '".$db->escape($search_amount_all_tax)."'"; } - if (dol_strlen(GETPOST('sf_re')) > 0) - { + if (dol_strlen(GETPOST('sf_re')) > 0) { $sql .= " AND f.ref_supplier LIKE '%".$db->escape(GETPOST('sf_re'))."%'"; } $sql .= " GROUP BY s.rowid, s.nom, f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= $db->order($sortfield, $sortorder); - if (!in_array("f.ref_supplier", explode(',', $sortfield))) $sql .= ", f.ref_supplier DESC"; + if (!in_array("f.ref_supplier", explode(',', $sortfield))) { + $sql .= ", f.ref_supplier DESC"; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($socid) - { + if ($socid) { $soc = new Societe($db); $soc->fetch($socid); } $param = ''; - if ($socid) $param .= "&socid=".$socid; + if ($socid) { + $param .= "&socid=".$socid; + } - if ($search_ref) $param .= '&amp;search_ref='.urlencode($search_ref); - if ($search_ref_supplier) $param .= '&amp;search_ref_supplier='.urlencode($search_ref_supplier); - if ($search_company) $param .= '&amp;search_company='.urlencode($search_company); - if ($search_amount_no_tax) $param .= '&amp;search_amount_no_tax='.urlencode($search_amount_no_tax); - if ($search_amount_all_tax) $param .= '&amp;search_amount_all_tax='.urlencode($search_amount_all_tax); + if ($search_ref) { + $param .= '&amp;search_ref='.urlencode($search_ref); + } + if ($search_ref_supplier) { + $param .= '&amp;search_ref_supplier='.urlencode($search_ref_supplier); + } + if ($search_company) { + $param .= '&amp;search_company='.urlencode($search_company); + } + if ($search_amount_no_tax) { + $param .= '&amp;search_amount_no_tax='.urlencode($search_amount_no_tax); + } + if ($search_amount_all_tax) { + $param .= '&amp;search_amount_all_tax='.urlencode($search_amount_all_tax); + } $param .= ($option ? "&option=".$option : ""); - if (!empty($late)) $param .= '&late='.urlencode($late); + if (!empty($late)) { + $param .= '&late='.urlencode($late); + } $urlsource = str_replace('&amp;', '&', $param); $titre = ($socid ? $langs->trans("BillsSuppliersUnpaidForCompany", $soc->name) : $langs->trans("BillsSuppliersUnpaid")); - if ($option == 'late') $titre .= ' ('.$langs->trans("Late").')'; - else $titre .= ' ('.$langs->trans("All").')'; + if ($option == 'late') { + $titre .= ' ('.$langs->trans("Late").')'; + } else { + $titre .= ' ('.$langs->trans("All").')'; + } $link = ''; - if (empty($option)) $link = '<a href="'.$_SERVER["PHP_SELF"].'?option=late'.($socid ? '&socid='.$socid : '').'">'.$langs->trans("ShowUnpaidLateOnly").'</a>'; - elseif ($option == 'late') $link = '<a href="'.$_SERVER["PHP_SELF"].'?'.($socid ? '&socid='.$socid : '').'">'.$langs->trans("ShowUnpaidAll").'</a>'; + if (empty($option)) { + $link = '<a href="'.$_SERVER["PHP_SELF"].'?option=late'.($socid ? '&socid='.$socid : '').'">'.$langs->trans("ShowUnpaidLateOnly").'</a>'; + } elseif ($option == 'late') { + $link = '<a href="'.$_SERVER["PHP_SELF"].'?'.($socid ? '&socid='.$socid : '').'">'.$langs->trans("ShowUnpaidAll").'</a>'; + } print load_fiche_titre($titre, $link); print_barre_liste('', '', $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0); // We don't want pagination on this page @@ -220,14 +249,12 @@ if ($user->rights->fournisseur->facture->lire) print '</td>'; print "</tr>\n"; - if ($num > 0) - { + if ($num > 0) { $total_ht = 0; $total_ttc = 0; $total_paid = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $facturestatic->statut = $objp->fk_statut; diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 131b34bbe39..8904310bf3e 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -34,8 +34,7 @@ $langs->loadLangs(['bills', 'boxes']); // Filter to show only result of one supplier $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -58,8 +57,7 @@ print '<div class="fichecenter">'; print '<div class="fichethirdleft">'; // This is useless due to the global search combo -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) -{ +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print getAreaSearchFrom(); print '<br>'; } @@ -129,16 +127,21 @@ function getPieChart($socid = 0) $sql = "SELECT count(f.rowid), f.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($user->socid) $sql .= ' AND f.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) { + $sql .= ' AND f.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $sql .= " GROUP BY f.fk_statut"; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -149,11 +152,9 @@ function getPieChart($socid = 0) $total = 0; $vals = []; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); - if ($row) - { + if ($row) { $vals[$row[1]] = $row[0]; $total += $row[0]; } @@ -174,14 +175,12 @@ function getPieChart($socid = 0) $array = [FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED]; $dataseries = []; - foreach ($array as $status) - { + foreach ($array as $status) { $objectstatic->statut = $status; $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0; $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)]; - if (!$conf->use_javascript_ajax) - { + if (!$conf->use_javascript_ajax) { $result .= '<tr class="oddeven">'; $result .= '<td>'.$objectstatic->getLibStatut(0).'</td>'; $result .= '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>'; @@ -189,8 +188,7 @@ function getPieChart($socid = 0) } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); $dolgraph->setShowLegend(2); @@ -229,17 +227,22 @@ function getDraftTable($maxCount = 500, $socid = 0) $sql = "SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -258,8 +261,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $result .= '</td>'; $result .= '</tr>'; - if ($num < 1) - { + if ($num < 1) { $result .= '</table>'; $result .= '</div>'; return $result; @@ -271,8 +273,7 @@ function getDraftTable($maxCount = 500, $socid = 0) $total = 0; $i = 0; - while ($i < $nbofloop) - { + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->rowid; @@ -293,14 +294,11 @@ function getDraftTable($maxCount = 500, $socid = 0) $total += $obj->total_ttc; } - if ($num > $nbofloop) - { + if ($num > $nbofloop) { $result .= '<tr class="liste_total">'; $result .= '<td colspan="3" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop)).'</td>'; $result .= '</tr>'; - } - elseif ($total > 0) - { + } elseif ($total > 0) { $result .= '<tr class="liste_total">'; $result .= '<td colspan="2" class="right">'.$langs->trans("Total").'</td>'; $result .= '<td class="right">'.price($total).'</td>'; @@ -327,17 +325,22 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $sql .= " f.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) { + $sql .= " AND f.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 f.tms DESC"; $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -350,8 +353,7 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $result .= '<td colspan="4">'.$langs->trans("BoxTitleLastSupplierBills", $maxCount).'</td>'; $result .= '</tr>'; - if ($num < 1) - { + if ($num < 1) { $result .= '</table>'; $result .= '</div>'; return $result; @@ -362,8 +364,7 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $formfile = new FormFile($db); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->rowid; @@ -423,18 +424,23 @@ function getOpenTable($maxCount = 500, $socid = 0) $sql .= ", f.datef as df, f.date_lim_reglement as datelimite"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; - 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; + 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 f.rowid DESC"; $sql .= $db->plimit($maxCount, 0); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); return ''; } @@ -452,8 +458,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $result .= '</td>'; $result .= '</tr>'; - if ($num < 1) - { + if ($num < 1) { $result .= '</table>'; $result .= '</div>'; return $result; @@ -467,8 +472,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $total = 0; $i = 0; - while ($i < $nbofloop) - { + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); $objectstatic->id = $obj->id; @@ -491,8 +495,7 @@ function getOpenTable($maxCount = 500, $socid = 0) $result .= '<td class="nobordernopadding nowrap">'.$objectstatic->getNomUrl(1).'</td>'; $result .= '<td width="18" class="nobordernopadding nowrap">'; - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) - { + if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { $result .= img_warning($langs->trans("Late")); } @@ -514,14 +517,11 @@ function getOpenTable($maxCount = 500, $socid = 0) $total += $obj->total_ttc; } - if ($num > $nbofloop) - { + if ($num > $nbofloop) { $result .= '<tr class="liste_total">'; $result .= '<td colspan="4" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop)).'</td>'; $result .= '</tr>'; - } - elseif ($total > 0) - { + } elseif ($total > 0) { $result .= '<tr class="liste_total">'; $result .= '<td colspan="2" class="right">'.$langs->trans("Total").'</td>'; $result .= '<td align="right">'.price($total).'</td>'; diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 69ea8839cfb..efe91880a56 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -40,7 +40,9 @@ $id = GETPOST("facid", 'int') ?GETPOST("facid", 'int') : GETPOST("id", 'int'); $ref = GETPOST("ref", 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); @@ -75,39 +77,40 @@ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); -if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; +if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; +} // Project -if (!empty($conf->projet->enabled)) -{ - $langs->load("projects"); - $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') - //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref .= '<input type="hidden" name="action" value="classin">'; - $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref .= '</form>'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; - $morehtmlref .= $proj->ref; - $morehtmlref .= '</a>'; - } else { - $morehtmlref .= ''; - } - } +if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '<br>'.$langs->trans('Project').' '; + if ($user->rights->facture->creer) { + if ($action != 'classify') { + //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + $morehtmlref .= $proj->ref; + $morehtmlref .= '</a>'; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '</div>'; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 99ab93ca973..7c6ed0c5e16 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -44,7 +44,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (!$user->rights->fournisseur->facture->lire) accessforbidden(); +if (!$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('products', 'bills', 'companies', 'projects')); @@ -120,12 +122,18 @@ $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 ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } +if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { + $page = 0; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "f.datef,f.rowid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef,f.rowid"; +} $diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id; @@ -149,7 +157,9 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall["f.note_private"] = "NotePrivate"; +} $checkedtypetiers = 0; $arrayfields = array( @@ -198,19 +208,23 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) // All tests must be present to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) { // All tests must be present to be compatible with all browsers $search_all = ""; $search_user = ''; $search_sale = ''; @@ -266,12 +280,10 @@ if (empty($reshook)) $uploaddir = $conf->fournisseur->facture->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($massaction == 'banktransfertrequest') - { + if ($massaction == 'banktransfertrequest') { $langs->load("withdrawals"); - if (!$user->rights->paymentbybanktransfer->create) - { + if (!$user->rights->paymentbybanktransfer->create) { $error++; setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); } else { @@ -280,12 +292,10 @@ if (empty($reshook)) $arrayofselected = is_array($toselect) ? $toselect : array(); $listofbills = array(); - foreach ($arrayofselected as $toselectid) - { + foreach ($arrayofselected as $toselectid) { $objecttmp = new FactureFournisseur($db); $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $totalpaye = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); @@ -314,8 +324,7 @@ if (empty($reshook)) $rsql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($rsql); - if ($result_sql) - { + if ($result_sql) { $numprlv = $db->num_rows($result_sql); } @@ -332,15 +341,12 @@ if (empty($reshook)) } //Massive withdraw request for request with no errors - if (!empty($listofbills)) - { + if (!empty($listofbills)) { $nbwithdrawrequestok = 0; - foreach ($listofbills as $aBill) - { + foreach ($listofbills as $aBill) { $db->begin(); $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice'); - if ($result > 0) - { + if ($result > 0) { $db->commit(); $nbwithdrawrequestok++; } else { @@ -348,8 +354,7 @@ if (empty($reshook)) setEventMessages($aBill->error, $aBill->errors, 'errors'); } } - if ($nbwithdrawrequestok > 0) - { + if ($nbwithdrawrequestok > 0) { setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs'); } } @@ -358,8 +363,7 @@ if (empty($reshook)) } -if ($massaction == 'transfer_request') -{ +if ($massaction == 'transfer_request') { $langs->load("withdrawals"); if (!$user->rights->paymentbybanktransfer->create) { @@ -371,12 +375,10 @@ if ($massaction == 'transfer_request') $arrayofselected = is_array($toselect) ? $toselect : array(); $listofbills = array(); - foreach ($arrayofselected as $toselectid) - { + foreach ($arrayofselected as $toselectid) { $objecttmp = new FactureFournisseur($db); $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $totalpaye = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); @@ -405,16 +407,14 @@ if ($massaction == 'transfer_request') $rsql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($rsql); - if ($result_sql) - { + if ($result_sql) { $numprlv = $db->num_rows($result_sql); } if ($numprlv > 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings'); - } - elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') { + } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); } else { @@ -460,7 +460,9 @@ $thirdparty = new Societe($db); // llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); $sql = "SELECT"; -if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($search_all || $search_product_category > 0) { + $sql = 'SELECT DISTINCT'; +} $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,"; $sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; $sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; @@ -475,11 +477,17 @@ $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label, $sql .= " u.login"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (!$search_all) $sql .= ', SUM(pf.amount) as dynamount_payed'; -if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; +if (!$search_all) { + $sql .= ', SUM(pf.amount) as dynamount_payed'; +} +if ($search_categ_sup) { + $sql .= ", cs.fk_categorie, cs.fk_soc"; +} // 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 : ''); + 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(); @@ -489,86 +497,164 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; +if (!empty($search_categ_sup)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; +} $sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; -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 (f.rowid = ef.fk_object)"; -if (!$search_all) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; -if ($search_all || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; -if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +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 (f.rowid = ef.fk_object)"; +} +if (!$search_all) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; +} +if ($search_all || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; -if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; -if ($search_ref) -{ - if (is_numeric($search_ref)) $sql .= natural_search(array('f.ref'), $search_ref); - else $sql .= natural_search('f.ref', $search_ref); +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_ref) $sql .= natural_search('f.ref', $search_ref); -if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); -if ($search_type != '' && $search_type >= 0) -{ - if ($search_type == '0') $sql .= " AND f.type = 0"; // standard - if ($search_type == '1') $sql .= " AND f.type = 1"; // replacement - if ($search_type == '2') $sql .= " AND f.type = 2"; // credit note - if ($search_type == '3') $sql .= " AND f.type = 3"; // deposit +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".$search_product_category; +} +if ($socid > 0) { + $sql .= ' AND s.rowid = '.$socid; +} +if ($search_ref) { + if (is_numeric($search_ref)) { + $sql .= natural_search(array('f.ref'), $search_ref); + } else { + $sql .= natural_search('f.ref', $search_ref); + } +} +if ($search_ref) { + $sql .= natural_search('f.ref', $search_ref); +} +if ($search_refsupplier) { + $sql .= natural_search('f.ref_supplier', $search_refsupplier); +} +if ($search_type != '' && $search_type >= 0) { + if ($search_type == '0') { + $sql .= " AND f.type = 0"; // standard + } + if ($search_type == '1') { + $sql .= " AND f.type = 1"; // replacement + } + if ($search_type == '2') { + $sql .= " AND f.type = 2"; // credit note + } + if ($search_type == '3') { + $sql .= " AND f.type = 3"; // deposit + } //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation } -if ($search_project) $sql .= natural_search('p.ref', $search_project); -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_town) $sql .= natural_search('s.town', $search_town); -if ($search_zip) $sql .= natural_search("s.zip", $search_zip); -if ($search_state) $sql .= natural_search("state.nom", $search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); -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_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); -if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); -if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); -if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode); -if ($search_paymentcond > 0) $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond); +if ($search_project) { + $sql .= natural_search('p.ref', $search_project); +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_town) { + $sql .= natural_search('s.town', $search_town); +} +if ($search_zip) { + $sql .= natural_search("s.zip", $search_zip); +} +if ($search_state) { + $sql .= natural_search("state.nom", $search_state); +} +if ($search_country) { + $sql .= " AND s.fk_pays IN (".$search_country.')'; +} +if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) { + $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +} +if ($search_montant_ht != '') { + $sql .= natural_search('f.total_ht', $search_montant_ht, 1); +} +if ($search_montant_vat != '') { + $sql .= natural_search('f.total_tva', $search_montant_vat, 1); +} +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_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); +} +if ($search_multicurrency_montant_ttc != '') { + $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +} +if ($search_login) { + $sql .= natural_search('u.login', $search_login); +} +if ($search_status != '' && $search_status >= 0) { + $sql .= " AND f.fk_statut = ".$db->escape($search_status); +} +if ($search_paymentmode > 0) { + $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode); +} +if ($search_paymentcond > 0) { + $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond); +} $sql .= dolSqlDateFilter("f.datef", $day, $month, $year); $sql .= dolSqlDateFilter("f.date_lim_reglement", $day_lim, $month_lim, $year_lim); -if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; -if ($search_label) $sql .= natural_search('f.libelle', $search_label); -if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); -if ($search_categ_sup == -2) $sql .= " AND cs.fk_categorie IS NULL"; -if ($search_status != '' && $search_status >= 0) -{ +if ($option == 'late') { + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; +} +if ($search_label) { + $sql .= natural_search('f.libelle', $search_label); +} +if ($search_categ_sup > 0) { + $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); +} +if ($search_categ_sup == -2) { + $sql .= " AND cs.fk_categorie IS NULL"; +} +if ($search_status != '' && $search_status >= 0) { $sql .= " AND f.fk_statut = ".$search_status; } -if ($filter && $filter != -1) -{ +if ($filter && $filter != -1) { $aFilter = explode(',', $filter); - foreach ($aFilter as $fil) - { + foreach ($aFilter as $fil) { $filt = explode(':', $fil); $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } -if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); -if ($search_user > 0) -{ +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); +} +if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields @@ -578,8 +664,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if (!$search_all) -{ +if (!$search_all) { $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement, f.fk_cond_reglement,"; $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql .= " f.localtax1, f.localtax2,"; @@ -605,12 +690,10 @@ if (!$search_all) $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -620,14 +703,12 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) - { + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->facid; @@ -637,47 +718,114 @@ if ($resql) llxHeader('', $langs->trans("SuppliersInvoices"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); - if ($socid) - { + if ($socid) { $soc = new Societe($db); $soc->fetch($socid); - if (empty($search_company)) $search_company = $soc->name; + if (empty($search_company)) { + $search_company = $soc->name; + } } $param = '&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_all) $param .= '&search_all='.urlencode($search_all); - if ($day) $param .= '&day='.urlencode($day); - if ($month) $param .= '&month='.urlencode($month); - if ($year) $param .= '&year='.urlencode($year); - if ($day_lim) $param .= '&day_lim='.urlencode($day_lim); - if ($month_lim) $param .= '&month_lim='.urlencode($month_lim); - if ($year_lim) $param .= '&year_lim='.urlencode($year_lim); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_refsupplier) $param .= '&search_refsupplier='.urlencode($search_refsupplier); - if ($search_type != '') $param .= '&search_type='.urlencode($search_type); - if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_company) $param .= '&search_company='.urlencode($search_company); - if ($search_login) $param .= '&search_login='.urlencode($search_login); - if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); - if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); - if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); - if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); - if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); - if ($search_amount_no_tax) $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); - if ($search_amount_all_tax) $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); - if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($option) $param .= "&option=".urlencode($option); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup); - if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($search_all) { + $param .= '&search_all='.urlencode($search_all); + } + if ($day) { + $param .= '&day='.urlencode($day); + } + if ($month) { + $param .= '&month='.urlencode($month); + } + if ($year) { + $param .= '&year='.urlencode($year); + } + if ($day_lim) { + $param .= '&day_lim='.urlencode($day_lim); + } + if ($month_lim) { + $param .= '&month_lim='.urlencode($month_lim); + } + if ($year_lim) { + $param .= '&year_lim='.urlencode($year_lim); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_refsupplier) { + $param .= '&search_refsupplier='.urlencode($search_refsupplier); + } + if ($search_type != '') { + $param .= '&search_type='.urlencode($search_type); + } + if ($search_label) { + $param .= '&search_label='.urlencode($search_label); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } + if ($search_montant_ht != '') { + $param .= '&search_montant_ht='.urlencode($search_montant_ht); + } + if ($search_montant_vat != '') { + $param .= '&search_montant_vat='.urlencode($search_montant_vat); + } + if ($search_montant_localtax1 != '') { + $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + } + if ($search_montant_localtax2 != '') { + $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + } + if ($search_montant_ttc != '') { + $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + } + if ($search_multicurrency_code != '') { + $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + } + if ($search_multicurrency_tx != '') { + $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + } + if ($search_multicurrency_montant_ht != '') { + $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + } + if ($search_multicurrency_montant_vat != '') { + $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + } + if ($search_multicurrency_montant_ttc != '') { + $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + } + if ($search_amount_no_tax) { + $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); + } + if ($search_amount_all_tax) { + $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); + } + if ($search_status >= 0) { + $param .= "&search_status=".urlencode($search_status); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($option) { + $param .= "&option=".urlencode($option); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_categ_sup > 0) { + $param .= '&search_categ_sup='.urlencode($search_categ_sup); + } + if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -690,25 +838,33 @@ if ($resql) //'presend'=>$langs->trans("SendByMail"), ); if ($conf->paymentbybanktransfer->enabled) { - $langs->load("withdrawals"); - $arrayofmassactions['transfer_request'] = $langs->trans("MakeBankTransferOrder"); + $langs->load("withdrawals"); + $arrayofmassactions['transfer_request'] = $langs->trans("MakeBankTransferOrder"); } //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) { $langs->load('withdrawals'); $arrayofmassactions['banktransfertrequest'] = $langs->trans("MakeBankTransferOrder"); } - if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + if ($user->rights->fournisseur->facture->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->rights->fournisseur->facture->creer); $i = 0; print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -724,8 +880,7 @@ if ($resql) $trackid = 'sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($massaction == 'createbills') - { + if ($massaction == 'createbills') { //var_dump($_REQUEST); print '<input type="hidden" name="massaction" value="confirm_createbills">'; @@ -764,33 +919,31 @@ if ($resql) print '<br>'; } - if ($search_all) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } - // If the user can view prospects other than his' - $moreforfilter = ''; - if ($user->rights->societe->client->voir || $socid) - { - $langs->load("commercial"); - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter .= '</div>'; - } // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { + $moreforfilter = ''; + if ($user->rights->societe->client->voir || $socid) { + $langs->load("commercial"); + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; + } + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter .= '</div>'; + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) - { + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -799,8 +952,7 @@ if ($resql) $moreforfilter .= '</div>'; } - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; @@ -809,19 +961,23 @@ if ($resql) } $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if ($moreforfilter) - { - print '<div class="liste_titre liste_titre_bydiv centpercent">'; + if ($moreforfilter) { + print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; @@ -829,22 +985,19 @@ if ($resql) // Line for filters print '<tr class="liste_titre_filter">'; // Ref - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.$search_ref.'">'; print '</td>'; } // Ref supplier - if (!empty($arrayfields['f.ref_supplier']['checked'])) - { + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_refsupplier" value="'.$search_refsupplier.'">'; print '</td>'; } // Type - if (!empty($arrayfields['f.type']['checked'])) - { + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone">'; $listtype = array( FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), @@ -857,180 +1010,163 @@ if ($resql) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } - */ + */ //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print '</td>'; } // Label - if (!empty($arrayfields['f.label']['checked'])) - { + if (!empty($arrayfields['f.label']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth75" type="text" name="search_label" value="'.$search_label.'">'; print '</td>'; } // Date invoice - if (!empty($arrayfields['f.datef']['checked'])) - { + if (!empty($arrayfields['f.datef']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; + } print '<input class="flat width25 valignmiddle" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); print '</td>'; } // Date due - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) - { + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; + } print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month_lim" value="'.$month_lim.'">'; $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); print '<br><input type="checkbox" name="option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Late"); print '</td>'; } // Project - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.$search_project.'"></td>'; } // Thirpdarty - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.$search_company.'"></td>'; } // Town - if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; + } // Zip - if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) { + print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; + } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); print '</td>'; } // Condition of payment - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print '<td class="liste_titre left">'; $form->select_conditions_paiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100'); print '</td>'; } // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print '<td class="liste_titre left">'; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 20, 1, 'maxwidth100'); print '</td>'; } - if (!empty($arrayfields['f.total_ht']['checked'])) - { + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount without tax print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; print '</td>'; } - if (!empty($arrayfields['f.total_vat']['checked'])) - { + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount vat print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; print '</td>'; } - if (!empty($arrayfields['f.total_localtax1']['checked'])) - { + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Amount tax 1 print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; print '</td>'; } - if (!empty($arrayfields['f.total_localtax2']['checked'])) - { + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Amount tax 2 - print '<td class="liste_titre right">'; + print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; print '</td>'; } - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount inc tac print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '</td>'; } - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { // Author print '<td class="liste_titre" align="center">'; print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">'; print '</td>'; } - if (!empty($arrayfields['dynamount_payed']['checked'])) - { + if (!empty($arrayfields['dynamount_payed']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } - if (!empty($arrayfields['rtp']['checked'])) - { + if (!empty($arrayfields['rtp']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['f.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { // Currency print '<td class="liste_titre">'; print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); print '</td>'; } - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { // Currency rate print '<td class="liste_titre">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">'; print '</td>'; } - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">'; print '</td>'; } - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">'; print '</td>'; } - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">'; print '</td>'; } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) - { + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['multicurrency_rtp']['checked'])) - { + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } @@ -1042,20 +1178,17 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); @@ -1070,45 +1203,111 @@ if ($resql) print "</tr>\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['f.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['multicurrency_rtp']['checked'])) print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) { + print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.ref_supplier']['checked'])) { + print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.type']['checked'])) { + print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.label']['checked'])) { + print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.datef']['checked'])) { + print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['f.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['f.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['rtp']['checked'])) { + print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { + print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { + print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) { + print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.tms']['checked'])) { + print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; @@ -1117,12 +1316,10 @@ if ($resql) $projectstatic = new Project($db); $userstatic = new User($db); - if ($num > 0) - { + if ($num > 0) { $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $datelimit = $db->jdate($obj->datelimite); @@ -1176,8 +1373,7 @@ if ($resql) } print '<tr class="oddeven">'; - if (!empty($arrayfields['f.ref']['checked'])) - { + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="nowrap">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; @@ -1192,253 +1388,301 @@ if ($resql) print '</td></tr></table>'; print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Supplier ref - if (!empty($arrayfields['f.ref_supplier']['checked'])) - { + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print '<td class="nowrap tdoverflowmax200">'; print $obj->ref_supplier; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type - if (!empty($arrayfields['f.type']['checked'])) - { + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="nowrap">'; print $facturestatic->getLibType(); print "</td>"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Label - if (!empty($arrayfields['f.label']['checked'])) - { + if (!empty($arrayfields['f.label']['checked'])) { print '<td class="nowrap">'; print $obj->label; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date - if (!empty($arrayfields['f.datef']['checked'])) - { + if (!empty($arrayfields['f.datef']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->datef), 'day'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) - { + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td class="center nowrap">'.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) - { + if ($facturestatic->hasDelay()) { print img_warning($langs->trans('Late')); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; - if ($obj->project_id > 0) - { + if ($obj->project_id > 0) { $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; print $projectstatic->getNomUrl(1); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Third party - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax200">'; print $thirdparty->getNomUrl(1, 'supplier'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Town - if (!empty($arrayfields['s.town']['checked'])) - { + if (!empty($arrayfields['s.town']['checked'])) { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip - if (!empty($arrayfields['s.zip']['checked'])) - { + if (!empty($arrayfields['s.zip']['checked'])) { print '<td class="nocellnopadd center">'; print $obj->zip; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State - if (!empty($arrayfields['state.nom']['checked'])) - { + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type ent - if (!empty($arrayfields['typent.code']['checked'])) - { + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="center">'; - if (empty($typenArray)) $typenArray = $formcompany->typent_array(1); + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } print $typenArray[$obj->typent_code]; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Payment condition - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print '<td>'; $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) - { + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print '<td>'; $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) - { + if (!empty($arrayfields['f.total_ht']['checked'])) { print '<td class="right nowrap">'.price($obj->total_ht)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } $totalarray['val']['f.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['f.total_vat']['checked'])) - { + if (!empty($arrayfields['f.total_vat']['checked'])) { print '<td class="right nowrap">'.price($obj->total_vat)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + } $totalarray['val']['f.total_vat'] += $obj->total_vat; } // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) - { + if (!empty($arrayfields['f.total_localtax1']['checked'])) { print '<td class="right nowrap">'.price($obj->total_localtax1)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; } // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) - { + if (!empty($arrayfields['f.total_localtax2']['checked'])) { print '<td class="right nowrap">'.price($obj->total_localtax2)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; } // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) - { + if (!empty($arrayfields['f.total_ttc']['checked'])) { print '<td class="right nowrap">'.price($obj->total_ttc)."</td>\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } // Author - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { $userstatic->id = $obj->fk_user_author; $userstatic->login = $obj->login; print '<td align="center">'; - if ($userstatic->id) print $userstatic->getLoginUrl(1); - else print '&nbsp;'; + if ($userstatic->id) { + print $userstatic->getLoginUrl(1); + } else { + print '&nbsp;'; + } print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['dynamount_payed']['checked'])) - { + if (!empty($arrayfields['dynamount_payed']['checked'])) { print '<td class="right nowrap">'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } $totalarray['val']['totalam'] += $totalpay; } - if (!empty($arrayfields['rtp']['checked'])) - { + if (!empty($arrayfields['rtp']['checked'])) { print '<td class="right nowrap">'.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } $totalarray['val']['rtp'] += $remaintopay; } // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Currency rate - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { print '<td class="nowrap">'; $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount HT - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_ht)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount VAT - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount TTC - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) - { + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { print '<td class="right nowrap">'.price($obj->multicurrency_total_ttc)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) - { + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { print '<td class="right nowrap">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Pending amount - if (!empty($arrayfields['multicurrency_rtp']['checked'])) - { + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { print '<td class="right nowrap">'; print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '&nbsp;'); print '</td>'; // TODO Use a denormalized field - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } @@ -1449,40 +1693,46 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['f.datec']['checked'])) - { + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['f.tms']['checked'])) - { + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) - { + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="right nowrap">'; print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); print "</td>"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->facid, $arrayofselected)) $selected = 1; + if (in_array($obj->facid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; @@ -1505,7 +1755,9 @@ if ($resql) print "</form>\n"; $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } // Show list of available documents $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index c98ad3ba1d8..541121031ee 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -40,7 +40,9 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); @@ -56,11 +58,12 @@ $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the inc include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once // Set label -if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) -{ +if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) { $object->label = $_POST['label']; $result = $object->update($user); - if ($result < 0) dol_print_error($db); + if ($result < 0) { + dol_print_error($db); + } } @@ -74,8 +77,7 @@ $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Notes'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); -if ($object->id > 0) -{ +if ($object->id > 0) { $object->fetch_thirdparty(); $alreadypaid = $object->getSommePaiement(); @@ -94,14 +96,14 @@ if ($object->id > 0) $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; + } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->fournisseur->commande->creer) - { + if ($user->rights->fournisseur->commande->creer) { if ($action != 'classify') { // $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= ' : '; @@ -143,36 +145,34 @@ if ($object->id > 0) // Type print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>'; print $object->getLibType(); - if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) - { + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { + if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $fid) - { - if ($i == 0) print ' '; - else print ','; + foreach ($facidavoir as $fid) { + if ($i == 0) { + print ' '; + } else { + print ','; + } $facavoir = new FactureFournisseur($db); $facavoir->fetch($fid); print $facavoir->getNomUrl(1); } print ')'; } - if ($facidnext > 0) - { + if ($facidnext > 0) { $facthatreplace = new FactureFournisseur($db); $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; @@ -190,14 +190,12 @@ if ($object->id > 0) // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj == "1") //Localtax1 - { + if ($societe->localtax1_assuj == "1") { //Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($societe->localtax2_assuj == "1") //Localtax2 - { + if ($societe->localtax2_assuj == "1") { //Localtax2 print '<tr><td>'.$langs->transcountry("AmountLT2", $societe->country_code).'</td>'; print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'</td>'; print '</tr>'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 0592084f042..104e0e7efd2 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -64,12 +64,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "p.rowid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "p.rowid"; +} $amounts = array(); $amountsresttopay = array(); @@ -79,8 +85,7 @@ $multicurrency_amounts = array(); $multicurrency_amountsresttopay = array(); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } @@ -103,8 +108,7 @@ $arrayfields = array(); * Actions */ -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_ref = ""; $search_account = ""; $search_amount = ""; @@ -119,12 +123,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) - { +if (empty($reshook)) { + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); @@ -135,10 +139,8 @@ if (empty($reshook)) // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new FactureFournisseur($db); - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_') - { + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_') { $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(GETPOST($key)); if (!empty($amounts[$cursorfacid])) { @@ -150,19 +152,18 @@ if (empty($reshook)) } } $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); + if ($result <= 0) { + dol_print_error($db); + } $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) - { + if ($amounts[$cursorfacid]) { // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); } // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { + if ($datepaye && ($datepaye < $tmpinvoice->date)) { $langs->load("errors"); //$error++; setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); @@ -170,26 +171,26 @@ if (empty($reshook)) } $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); - } elseif (substr($key, 0, 21) == 'multicurrency_amount_') - { + } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = (GETPOST($key) ? price2num(GETPOST($key)) : 0); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + if (!empty($multicurrency_amounts[$cursorfacid])) { + $atleastonepaymentnotnull++; + } $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); + if ($result <= 0) { + dol_print_error($db); + } $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1)); - if ($multicurrency_amounts[$cursorfacid]) - { + if ($multicurrency_amounts[$cursorfacid]) { // Check amount - if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) - { + if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); } // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { + if ($datepaye && ($datepaye < $tmpinvoice->date)) { $langs->load("errors"); //$error++; setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); @@ -201,37 +202,31 @@ if (empty($reshook)) } // Check parameters - if ($_POST['paiementid'] <= 0) - { + if ($_POST['paiementid'] <= 0) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { + if (GETPOST('accountid') <= 0) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); $error++; } } - if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) - { + if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); $error++; } - if (empty($datepaye)) - { + if (empty($datepaye)) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); $error++; } // Check if payments in both currency - if ($totalpayment > 0 && $multicurrency_totalpayment > 0) - { + if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); $error++; } @@ -240,10 +235,8 @@ if (empty($reshook)) /* * Action add_paiement */ - if ($action == 'add_paiement') - { - if ($error) - { + if ($action == 'add_paiement') { + if ($error) { $action = 'create'; } // All the next of this action is displayed at the page's bottom. @@ -253,30 +246,25 @@ if (empty($reshook)) /* * Action confirm_paiement */ - if ($action == 'confirm_paiement' && $confirm == 'yes') - { + if ($action == 'confirm_paiement' && $confirm == 'yes') { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); // Clean parameters amount if payment is for a credit note - foreach ($amounts as $key => $value) // How payment is dispatched - { + foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new FactureFournisseur($db); $tmpinvoice->fetch($key); - if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } } - foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched - { + foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new FactureFournisseur($db); $tmpinvoice->fetch($key); - if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } @@ -286,12 +274,13 @@ if (empty($reshook)) //var_dump($multicurrency_amounts); //exit; - if (!$error) - { + if (!$error) { $db->begin(); $thirdparty = new Societe($db); - if ($socid > 0) $thirdparty->fetch($socid); + if ($socid > 0) { + $thirdparty->fetch($socid); + } // Creation of payment line $paiement = new PaiementFourn($db); @@ -305,43 +294,42 @@ if (empty($reshook)) $paiement->num_payment = $paiement->num_payment; $paiement->note_private = $paiement->note_private; - if (!$error) - { + if (!$error) { $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); - if ($paiement_id < 0) - { + if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', ''); - if ($result < 0) - { + if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card $invoiceid = 0; - foreach ($paiement->amounts as $key => $amount) - { + foreach ($paiement->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment - else $invoiceid = $facid; + if (is_numeric($amount) && $amount <> 0) { + if ($invoiceid != 0) { + $invoiceid = -1; // There is more than one invoice payed by this payment + } else { + $invoiceid = $facid; + } } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id; + if ($invoiceid > 0) { + $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid; + } else { + $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id; + } header('Location: '.$loc); exit; } else { @@ -364,8 +352,7 @@ $invoicesupplierstatic = new FactureFournisseur($db); llxHeader('', $langs->trans('ListPayment')); -if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') -{ +if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $object = new FactureFournisseur($db); $result = $object->fetch($facid); @@ -374,26 +361,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql = 'SELECT s.nom as name, s.rowid as socid,'; $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.rowid = '.$facid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $obj = $db->fetch_object($resql); $total = $obj->total; print load_fiche_titre($langs->trans('DoPayment')); // Add realtime total information - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".'<script type="text/javascript" language="javascript">'; print '$(document).ready(function () { @@ -491,8 +481,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>'; $form->select_types_paiements(empty($_POST['paiementid']) ? $obj->fk_mode_reglement : $_POST['paiementid'], 'paiementid'); print '</td>'; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>'; $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid, 'accountid', 0, '', 2); print '</td></tr>'; @@ -510,11 +499,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $parameters = array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook = $hookmanager->executeHooks('paymentsupplierinvoices', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { + if (empty($reshook)) { /* - * All unpaid supplier invoices - */ + * All unpaid supplier invoices + */ $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,'; $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,'; $sql .= ' f.datef as df, f.date_lim_reglement as dlr,'; @@ -525,8 +513,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql .= ' AND f.fk_soc = '.$object->socid; $sql .= ' AND f.paye = 0'; $sql .= ' AND f.fk_statut = 1'; // Status=0 => unvalidated, Status=2 => canceled - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) - { + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) { $sql .= ' AND f.type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation } else { $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes @@ -537,11 +524,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { $i = 0; print '<br>'; @@ -582,12 +567,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $total = 0; $total_ttc = 0; $totalrecu = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $sign = 1; - if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; + if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $sign = -1; + } $invoice = new FactureFournisseur($db); $invoice->fetch($objp->facid); @@ -629,13 +615,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Date Max Payment - if ($objp->dlr > 0) - { + if ($objp->dlr > 0) { print '<td class="center nowraponall">'; print dol_print_date($db->jdate($objp->dlr), 'day'); - if ($invoice->hasDelay()) - { + if ($invoice->hasDelay()) { print img_warning($langs->trans('Late')); } @@ -645,28 +629,24 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { // Currency print '<td class="center">'.$objp->multicurrency_code."</td>\n"; print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($objp->multicurrency_total_ttc); } print '</td>'; print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($objp->multicurrency_am); } print '</td>'; print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($objp->multicurrency_total_ttc - $objp->multicurrency_am); } print '</td>'; @@ -675,8 +655,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '<td class="right">'.price($sign * $objp->total_ttc).'</td>'; print '<td class="right">'.price($sign * $objp->am); - if ($creditnotes) print '+'.price($creditnotes); - if ($deposits) print '+'.price($deposits); + if ($creditnotes) { + print '+'.price($creditnotes); + } + if ($deposits) { + print '+'.price($deposits); + } print '</td>'; print '<td class="right">'.price($sign * $remaintopay).'</td>'; @@ -687,10 +671,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $namef = 'amount_'.$objp->facid; $nameRemain = 'remain_'.$objp->facid; - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) + if ($action != 'add_paiement') { + if (!empty($conf->use_javascript_ajax)) { print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + } print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">'; print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is requied to be used by javascript callForResult(); } else { @@ -700,20 +684,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "</td>"; // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { print '<td class="right">'; // Add remind multicurrency amount $namef = 'multicurrency_amount_'.$objp->facid; $nameRemain = 'multicurrency_remain_'.$objp->facid; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { + if ($action != 'add_paiement') { + if (!empty($conf->use_javascript_ajax)) { print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + } print '<input type=hidden class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">'; print '<input type="text" size="8" class="multicurrency_amount" name="'.$namef.'" value="'.$_POST[$namef].'">'; } else { @@ -744,8 +726,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>'; print '<td class="right"><b>'.price($sign * $totalrecu); - if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); - if ($totalrecudeposits) print '+'.price($totalrecudeposits); + if ($totalrecucreditnote) { + print '+'.price($totalrecucreditnote); + } + if ($totalrecudeposits) { + print '+'.price($totalrecudeposits); + } print '</b></td>'; print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>'; print '<td class="center" id="result" style="font-weight: bold;"></td>'; // Autofilled @@ -765,25 +751,23 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Save Button - if ($action != 'add_paiement') - { + if ($action != 'add_paiement') { print '<br><div class="center"><input type="checkbox" checked name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically"); print '<br><input type="submit" class="button" value="'.$langs->trans('ToMakePayment').'"></div>'; } // Form to confirm payment - if ($action == 'add_paiement') - { + if ($action == 'add_paiement') { $preselectedchoice = $addwarning ? 'no' : 'yes'; print '<br>'; - if (!empty($totalpayment)) $text = $langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) - { + if (!empty($totalpayment)) { + $text = $langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->trans("Currency".$conf->currency)); + } + if (!empty($multicurrency_totalpayment)) { $text .= '<br>'.$langs->trans('ConfirmSupplierPayment', price($multicurrency_totalpayment), $langs->trans("paymentInInvoiceCurrency")); } - if (GETPOST('closepaidinvoices')) - { + if (GETPOST('closepaidinvoices')) { $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">'; } diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php index 9ae7970d7db..fe2bb78008d 100644 --- a/htdocs/fourn/facture/rapport.php +++ b/htdocs/fourn/facture/rapport.php @@ -32,36 +32,39 @@ $langs->loadLangs(array('bills')); // Security check $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $action = GETPOST('action', 'aZ09'); $socid = 0; -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } $dir = $conf->fournisseur->facture->dir_output.'/payments'; -if (!$user->rights->societe->client->voir || $socid) $dir .= '/private/'.$user->id; // If user has no permission to see all, output dir is specific to user +if (!$user->rights->societe->client->voir || $socid) { + $dir .= '/private/'.$user->id; // If user has no permission to see all, output dir is specific to user +} $year = GETPOST("year", 'int'); -if (!$year) { $year = date("Y"); } +if (!$year) { + $year = date("Y"); +} /* * Actions */ -if ($action == 'builddoc') -{ +if ($action == 'builddoc') { $rap = new pdf_paiement_fourn($db); $outputlangs = $langs; - if (GETPOST('lang_id', 'aZ09')) - { + if (GETPOST('lang_id', 'aZ09')) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } @@ -69,8 +72,7 @@ if ($action == 'builddoc') // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output = $outputlangs->charset_output; - if ($rap->write_file($dir, GETPOST("remonth", 'int'), GETPOST("reyear", 'int'), $outputlangs) > 0) - { + if ($rap->write_file($dir, GETPOST("remonth", 'int'), GETPOST("reyear", 'int'), $outputlangs) > 0) { $outputlangs->charset_output = $sav_charset_output; } else { $outputlangs->charset_output = $sav_charset_output; @@ -114,15 +116,11 @@ clearstatcache(); // Show link on other years $linkforyear = array(); $found = 0; -if (is_dir($dir)) -{ +if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) { $found = 1; $linkforyear[] = $file; } @@ -130,18 +128,17 @@ if (is_dir($dir)) } } asort($linkforyear); -foreach ($linkforyear as $cursoryear) -{ +foreach ($linkforyear as $cursoryear) { print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$cursoryear.'">'.$cursoryear.'</a> &nbsp;'; } -if ($year) -{ - if (is_dir($dir.'/'.$year)) - { +if ($year) { + if (is_dir($dir.'/'.$year)) { $handle = opendir($dir.'/'.$year); - if ($found) print '<br>'; + if ($found) { + print '<br>'; + } print '<br>'; print '<table width="100%" class="noborder">'; print '<tr class="liste_titre">'; @@ -150,12 +147,9 @@ if ($year) print '<td class="right">'.$langs->trans("Date").'</td>'; print '</tr>'; - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^supplier_payment/i', $file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^supplier_payment/i', $file)) { $tfile = $dir.'/'.$year.'/'.$file; $relativepath = $year.'/'.$file; print '<tr class="oddeven"><td><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart=facture_fournisseur&amp;file=payments/'.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a>'.$formfile->showPreview($file, 'facture_fournisseur', 'payments/'.$relativepath, 0).'</td>'; diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index 4456d27c539..c3ca301ed45 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -19,8 +19,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; } @@ -38,24 +37,26 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("bills"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - <tr class="<?php echo $trclass; ?>"> - <td><?php echo $langs->trans("SupplierInvoice"); ?></td> - <td><a href="<?php echo DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowBill"), "bill").' '.$objectlink->ref; ?></a></td> - <td class="left"><?php echo $objectlink->ref_supplier; ?></td> - <td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> - <td class="right"><?php + <tr class="<?php echo $trclass; ?>"> + <td><?php echo $langs->trans("SupplierInvoice"); ?></td> + <td><a href="<?php echo DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowBill"), "bill").' '.$objectlink->ref; ?></a></td> + <td class="left"><?php echo $objectlink->ref_supplier; ?></td> + <td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> + <td class="right"><?php if ($user->rights->fournisseur->facture->lire) { $sign = 1; - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) - { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + $sign = -1; + } + if ($objectlink->statut != 3) { // If not abandonned $total = $total + $sign * $objectlink->total_ht; echo price($objectlink->total_ht); @@ -63,24 +64,23 @@ foreach ($linkedObjectBlock as $key => $objectlink) echo '<strike>'.price($objectlink->total_ht).'</strike>'; } } ?></td> - <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> - <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> - </tr> - <?php + <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> + <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> + </tr> + <?php } -if (count($linkedObjectBlock) > 1) -{ +if (count($linkedObjectBlock) > 1) { ?> - <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> - <td><?php echo $langs->trans("Total"); ?></td> - <td></td> - <td class="center"></td> - <td class="center"></td> - <td class="right"><?php echo price($total); ?></td> - <td class="right"></td> - <td class="right"></td> - </tr> - <?php + <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> + <td><?php echo $langs->trans("Total"); ?></td> + <td></td> + <td class="center"></td> + <td class="center"></td> + <td class="right"><?php echo price($total); ?></td> + <td class="right"></td> + <td class="right"></td> + </tr> + <?php } print "<!-- END PHP TEMPLATE -->\n"; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 5d82021bf3c..54ed40e37b0 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -32,7 +32,9 @@ $langs->loadLangs(array("suppliers", "orders", "companies")); // Security check $socid = GETPOST("socid", 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'societe', $socid, ''); @@ -58,15 +60,18 @@ print '<div class="fichecenter"><div class="fichethirdleft">'; $sql = "SELECT count(cf.rowid), cf.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +} $sql .= " WHERE cf.fk_soc = s.rowid "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND sc.fk_user = ".$user->id; +} $sql .= " AND cf.entity = ".$conf->entity; $sql .= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -74,8 +79,7 @@ if ($resql) print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td class="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>'; print "</tr>\n"; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); print '<tr class="oddeven">'; @@ -95,35 +99,37 @@ if ($resql) // Draft orders -if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) -{ +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; $sql .= " s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + } $sql .= " WHERE cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND sc.fk_user = ".$user->id; + } $sql .= " AND cf.entity = ".$conf->entity; $sql .= " AND cf.fk_statut = 0"; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + if ($socid) { + $sql .= " AND cf.fk_soc = ".$socid; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<td colspan="3">'.$langs->trans("DraftOrders").'<span class="badge marginleftonlyshort">'.$num.'</span></td></tr>'; $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven"><td class="nowrap">'; @@ -141,8 +147,7 @@ if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUP $i++; $total += $obj->total_ttc; } - if ($total > 0) - { + if ($total > 0) { print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>"; } print "</table>"; @@ -152,34 +157,36 @@ if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUP } // Draft invoices -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) -{ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; $sql .= ", s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + } $sql .= " WHERE s.rowid = ff.fk_soc"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND sc.fk_user = ".$user->id; + } $sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.fk_statut = 0"; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<td colspan="3">'.$langs->trans("DraftBills").'<span class="badge marginleftonlyshort">'.$num.'</span></td></tr>'; $i = 0; $tot_ttc = 0; - while ($i < $num && $i < 20) - { + while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); print '<tr class="oddeven"><td class="nowrap">'; @@ -226,18 +233,23 @@ $sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix $sql .= ", st.libelle as stcomm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = st.id"; $sql .= " AND s.fournisseur = 1"; $sql .= " AND s.entity IN (".getEntity('societe').")"; -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; +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 s.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $langs->load("boxes"); $num = $db->num_rows($resql); $i = 0; @@ -248,8 +260,7 @@ if ($resql) print '<td class="right">'.$langs->trans("DateModification")."</td>\n"; print "</tr>\n"; - while ($obj = $db->fetch_object($resql)) - { + while ($obj = $db->fetch_object($resql)) { print '<tr class="oddeven">'; print '<td><a href="card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"), "company").'</a>'; print "&nbsp;<a href=\"card.php?socid=".$obj->socid."\">".$obj->name."</a></td>\n"; @@ -271,8 +282,7 @@ if ($resql) $companystatic->LoadSupplierCateg(); $categstatic = new Categorie($db); -if (count($companystatic->SupplierCategories)) -{ +if (count($companystatic->SupplierCategories)) { print '<br>'; print '<table class="liste centpercent">'; @@ -280,8 +290,7 @@ if (count($companystatic->SupplierCategories)) print $langs->trans("Category"); print "</td></tr>\n"; - foreach ($companystatic->SupplierCategories as $rowid => $label) - { + foreach ($companystatic->SupplierCategories as $rowid => $label) { print '<tr class="oddeven">'."\n"; print '<td>'; $categstatic->id = $rowid; diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index b4090e8a34d..254fac29f28 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -21,13 +21,27 @@ * \brief File that include javascript functions used for dispatching qty/stock/lot */ -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'); @@ -36,8 +50,11 @@ require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} ?> /** diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 5dea09eaf09..66981436d7a 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -48,7 +48,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $result = restrictedArea($user, $object->element, $object->id, 'paiementfourn', ''); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} // Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice. // It should be enough because all payments are done on invoices of the same thirdparty. if ($socid && $socid != $object->thirdparty->id) { @@ -60,14 +62,12 @@ if ($socid && $socid != $object->thirdparty->id) { * Actions */ -if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) -{ +if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) { $db->begin(); $object->fetch($id); $result = $object->update_note(GETPOST('note', 'restricthtml')); - if ($result > 0) - { + if ($result > 0) { $db->commit(); $action = ''; } else { @@ -76,14 +76,12 @@ if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) { $db->begin(); $object->fetch($id); $result = $object->delete(); - if ($result > 0) - { + if ($result > 0) { $db->commit(); header('Location: '.DOL_URL_ROOT.'/fourn/paiement/list.php'); exit; @@ -96,13 +94,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse if ($action == 'confirm_validate' && $confirm == 'yes' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) -) -{ +) { $db->begin(); $object->fetch($id); - if ($object->validate() >= 0) - { + if ($object->validate() >= 0) { $db->commit(); header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; @@ -112,25 +108,21 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && } } -if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) -{ +if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) { $object->fetch($id); $res = $object->update_num($_POST['num_paiement']); - if ($res === 0) - { + if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); } else { setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors'); } } -if ($action == 'setdatep' && !empty($_POST['datepday'])) -{ +if ($action == 'setdatep' && !empty($_POST['datepday'])) { $object->fetch($id); $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); - if ($res === 0) - { + if ($res === 0) { setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); } else { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); @@ -159,21 +151,18 @@ $head = payment_supplier_prepare_head($object); print dol_get_fiche_head($head, 'payment', $langs->trans('SupplierPayment'), -1, 'payment'); -if ($result > 0) -{ +if ($result > 0) { /* * Confirmation of payment's delete */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete'); } /* * Confirmation of payment's validation */ - if ($action == 'validate') - { + if ($action == 'validate') { print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate'); } @@ -189,7 +178,7 @@ if ($result > 0) /*print '<tr>'; print '<td width="20%">'.$langs->trans('Ref').'</td><td>'; - print $form->showrefnav($object,'id','',1,'rowid','ref'); + print $form->showrefnav($object,'id','',1,'rowid','ref'); print '</td></tr>';*/ // Date of payment @@ -211,28 +200,24 @@ if ($result > 0) print '<td>'; print $form->editfieldval("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded')); print '</td></tr>'; - */ + */ // Amount print '<tr><td>'.$langs->trans('Amount').'</td>'; print '<td>'.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>'; - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { print '<tr><td>'.$langs->trans('Status').'</td>'; print '<td>'.$object->getLibStatut(4).'</td></tr>'; } $allow_delete = 1; // Bank account - if (!empty($conf->banque->enabled)) - { - if ($object->fk_account) - { + if (!empty($conf->banque->enabled)) { + if ($object->fk_account) { $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); - if ($bankline->rappro) - { + if ($bankline->rappro) { $allow_delete = 0; $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); } @@ -276,8 +261,7 @@ if ($result > 0) $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; $sql .= ' AND pf.fk_paiementfourn = '.$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -293,12 +277,10 @@ if ($result > 0) print '<td class="right">'.$langs->trans('Status').'</td>'; print "</tr>\n"; - if ($num > 0) - { + if ($num > 0) { $facturestatic = new FactureFournisseur($db); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $facturestatic->id = $objp->facid; @@ -328,8 +310,7 @@ if ($result > 0) print '<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).'</td>'; print "</tr>\n"; - if ($objp->paye == 1) - { + if ($objp->paye == 1) { $allow_delete = 0; $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid")); } @@ -353,23 +334,17 @@ if ($result > 0) */ print '<div class="tabsAction">'; - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { - if ($user->socid == 0 && $object->statut == 0 && $action == '') - { + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { + if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) - { + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Valid').'</a>'; } } } - if ($user->socid == 0 && $action == '') - { - if ($user->rights->fournisseur->facture->supprimer) - { - if ($allow_delete) - { + if ($user->socid == 0 && $action == '') { + if ($user->rights->fournisseur->facture->supprimer) { + if ($allow_delete) { print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$title_button.'">'.$langs->trans('Delete').'</a>'; @@ -385,8 +360,7 @@ if ($result > 0) include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; $modellist = ModelePDFSuppliersPayments::liste_modeles($db); - if (is_array($modellist)) - { + if (is_array($modellist)) { $ref = dol_sanitizeFileName($object->ref); $filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; diff --git a/htdocs/fourn/paiement/info.php b/htdocs/fourn/paiement/info.php index 9ff0a86931e..8032b2b418f 100644 --- a/htdocs/fourn/paiement/info.php +++ b/htdocs/fourn/paiement/info.php @@ -40,7 +40,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $result = restrictedArea($user, $object->element, $object->id, 'paiementfourn', ''); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} // Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice. // It should be enough because all payments are done on invoices of the same thirdparty. if ($socid && $socid != $object->thirdparty->id) { diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 1bf8984a6ee..02adee36149 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -35,7 +35,9 @@ require '../../main.inc.php'; // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} // doesn't work :-( // restrictedArea($user, 'fournisseur'); @@ -78,13 +80,19 @@ $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +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 = "p.datep"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "p.datep"; +} $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall')); @@ -117,7 +125,9 @@ $object = new PaiementFourn($db); $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -150,7 +160,9 @@ $sql = 'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement'; $sql .= ', s.rowid as socid, s.nom as name, s.email'; $sql .= ', c.code as paiement_type, c.libelle as paiement_libelle'; $sql .= ', ba.rowid as bid, ba.label'; -if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user'; +if (!$user->rights->societe->client->voir) { + $sql .= ', sc.fk_soc, sc.fk_user'; +} $sql .= ', SUM(pf.amount)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; @@ -160,26 +172,48 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; -if (!$user->rights->societe->client->voir) $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; +if (!$user->rights->societe->client->voir) { + $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; +} $sql .= ' WHERE f.entity = '.$conf->entity; -if (!$user->rights->societe->client->voir) $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; -if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid; -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); +if (!$user->rights->societe->client->voir) { + $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; +} +if ($socid > 0) { + $sql .= ' AND f.fk_soc = '.$socid; +} +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} $sql .= dolSqlDateFilter('p.datep', $search_day, $search_month, $search_year); -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; -if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num); -if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); -if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account."'"; +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_payment_type != '') { + $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; +} +if ($search_cheque_num != '') { + $sql .= natural_search('p.num_paiement', $search_cheque_num); +} +if ($search_amount) { + $sql .= natural_search('p.amount', $search_amount, 1); +} +if ($search_bank_account > 0) { + $sql .= ' AND b.fk_account='.$search_bank_account."'"; +} -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle, ba.rowid, ba.label'; -if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user'; +if (!$user->rights->societe->client->voir) { + $sql .= ', sc.fk_soc, sc.fk_user'; +} $sql .= $db->order($sortfield, $sortorder); @@ -207,24 +241,48 @@ $num = $db->num_rows($resql); $i = 0; $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} -if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); -if ($saerch_day) $param .= '&search_day='.urlencode($search_day); -if ($saerch_month) $param .= '&search_month='.urlencode($search_month); -if ($search_year) $param .= '&search_year='.urlencode($search_year); -if ($search_company) $param .= '&search_company='.urlencode($search_company); -if ($search_payment_type) $param .= '&search_company='.urlencode($search_payment_type); -if ($search_cheque_num) $param .= '&search_cheque_num='.urlencode($search_cheque_num); -if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($saerch_day) { + $param .= '&search_day='.urlencode($search_day); +} +if ($saerch_month) { + $param .= '&search_month='.urlencode($search_month); +} +if ($search_year) { + $param .= '&search_year='.urlencode($search_year); +} +if ($search_company) { + $param .= '&search_company='.urlencode($search_company); +} +if ($search_payment_type) { + $param .= '&search_company='.urlencode($search_payment_type); +} +if ($search_cheque_num) { + $param .= '&search_cheque_num='.urlencode($search_cheque_num); +} +if ($search_amount) { + $param .= '&search_amount='.urlencode($search_amount); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; @@ -234,9 +292,10 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1); -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -244,8 +303,11 @@ $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; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} if ($moreforfilter) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; @@ -255,7 +317,9 @@ if ($moreforfilter) { $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} print '<div class="div-table-responsive">'; print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'; @@ -272,7 +336,9 @@ if (!empty($arrayfields['p.ref']['checked'])) { // Filter: Date if (!empty($arrayfields['p.datep']['checked'])) { print '<td class="liste_titre center">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; + } print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5); print '</td>'; @@ -326,14 +392,30 @@ print '</td>'; print '</tr>'; print '<tr class="liste_titre">'; -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.datep']['checked'])) print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.num_paiement']['checked'])) print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']); -if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.amount']['checked'])) print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.datep']['checked'])) { + print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.libelle']['checked'])) { + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.num_paiement']['checked'])) { + print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']); +} +if (!empty($arrayfields['ba.label']['checked'])) { + print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['p.amount']['checked'])) { + print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right '); +} // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -368,21 +450,29 @@ while ($i < min($num, $limit)) { // No if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print '<td>'.(($offset * $limit) + $i).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'.$paymentfournstatic->getNomUrl(1).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date if (!empty($arrayfields['p.datep']['checked'])) { $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; + if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) { + $dateformatforpayment = 'dayhour'; + } print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Thirdparty @@ -392,43 +482,57 @@ while ($i < min($num, $limit)) { print $companystatic->getNomUrl(1, '', 24); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Pyament type if (!empty($arrayfields['c.libelle']['checked'])) { $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Cheque number (fund transfer) if (!empty($arrayfields['p.num_paiement']['checked'])) { print '<td>'.$objp->num_paiement.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Account - if (!empty($arrayfields['ba.label']['checked'])) - { + if (!empty($arrayfields['ba.label']['checked'])) { print '<td>'; - if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).'</a>'; - else print '&nbsp;'; + if ($objp->bid) { + print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).'</a>'; + } else { + print '&nbsp;'; + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount if (!empty($arrayfields['p.amount']['checked'])) { print '<td class="right">'.price($objp->pamount).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } $totalarray['pos'][$checkedCount] = 'amount'; $totalarray['val']['amount'] += $objp->pamount; } // Buttons print '<td></td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'; $i++; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 468352c72fe..32ddf769ce2 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $langs->loadLangs(array("products", "suppliers")); -if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden(); +if (!$user->rights->produit->lire && !$user->rights->service->lire) { + accessforbidden(); +} $sref = GETPOST('sref', 'alphanohtml'); $sRefSupplier = GETPOST('srefsupplier'); @@ -46,15 +48,23 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "p.ref"; // Set here default search field -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "p.ref"; // Set here default search field +} +if (!$sortorder) { + $sortorder = "ASC"; +} $fourn_id = GETPOST('fourn_id', 'intcomma'); -if ($user->socid) $fourn_id = $user->socid; +if ($user->socid) { + $fourn_id = $user->socid; +} $catid = GETPOST('catid', 'intcomma'); @@ -71,22 +81,26 @@ $extrafields = new ExtraFields($db); * Put here all code to do according to value of "action" parameter */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 $sref = ''; $sRefSupplier = ''; $snom = ''; @@ -109,8 +123,7 @@ $companystatic = new Societe($db); $title = $langs->trans("ProductsAndServices"); -if ($fourn_id) -{ +if ($fourn_id) { $supplier = new Fournisseur($db); $supplier->fetch($fourn_id); } @@ -122,8 +135,12 @@ $arrayofmassactions = array( 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->mymodule->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -133,54 +150,52 @@ $sql .= " s.rowid as socid, s.nom as name"; // Add fields to SELECT from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -if ($catid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; +if ($catid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($sRefSupplier) -{ +if ($sRefSupplier) { $sql .= natural_search('ppf.ref_fourn', $sRefSupplier); } -if (GETPOST('type')) -{ +if (GETPOST('type')) { $sql .= " AND p.fk_product_type = ".GETPOST('type', 'int'); } -if ($sref) -{ +if ($sref) { $sql .= natural_search('p.ref', $sref); } -if ($snom) -{ +if ($snom) { $sql .= natural_search('p.label', $snom); } -if ($catid) -{ +if ($catid) { $sql .= " AND cp.fk_categorie = ".$catid; } -if ($fourn_id > 0) -{ +if ($fourn_id > 0) { $sql .= " AND ppf.fk_soc = ".$fourn_id; } // Add WHERE filters from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records without orderby and limit $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -190,30 +205,32 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("fourn/product/list.php:", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num == 1 && (GETPOST("mode") == 'search')) - { + if ($num == 1 && (GETPOST("mode") == 'search')) { $objp = $db->fetch_object($resql); header("Location: ".DOL_URL_ROOT."/product/card.php?id=".$objp->rowid); exit; } - if (!empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); - else $texte = $langs->trans("List"); + if (!empty($supplier->id)) { + $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); + } else { + $texte = $langs->trans("List"); + } llxHeader("", "", $texte); $param = "&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type) ? "&amp;type=".$type : "").(empty($sRefSupplier) ? "" : "&amp;srefsupplier=".$sRefSupplier); - if ($optioncss != '') $param .= '&optioncss='.$optioncss; + if ($optioncss != '') { + $param .= '&optioncss='.$optioncss; + } print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - if (!empty($catid)) - { + if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); $ways = $c->print_all_ways(' &gt; ', 'fourn/product/list.php'); @@ -222,9 +239,13 @@ if ($resql) } print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; - if ($fourn_id > 0) print '<input type="hidden" name="fourn_id" value="'.$fourn_id.'">'; + if ($fourn_id > 0) { + print '<input type="hidden" name="fourn_id" value="'.$fourn_id.'">'; + } print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; @@ -256,7 +277,9 @@ if ($resql) // add filters from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print '<td class="liste_titre maxwidthsearch">'; $searchpicto = $form->showFilterButtons(); @@ -276,13 +299,14 @@ if ($resql) // add header cells from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print_liste_field_titre('', $_SERVER["PHP_SELF"]); print "</tr>\n"; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); $productstatic->id = $objp->rowid; @@ -307,7 +331,9 @@ if ($resql) $companystatic->name = $objp->name; $companystatic->id = $objp->socid; print '<td>'; - if ($companystatic->id > 0) print $companystatic->getNomUrl(1, 'supplier'); + if ($companystatic->id > 0) { + print $companystatic->getNomUrl(1, 'supplier'); + } print '</td>'; print '<td class="right">'.(isset($objp->price) ? price($objp->price) : '').'</td>'; @@ -319,7 +345,9 @@ if ($resql) // add additional columns from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print $hookmanager->resPrint; print '<td class="right"></td>'; diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 736a7bf4f90..06ad90ec858 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -32,8 +32,7 @@ $langs->loadLangs(array('bills', 'companies')); // Security check $socid = GETPOST("socid", 'int'); -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -51,22 +50,20 @@ $userstatic = new User($db); llxHeader(); -if ($socid > 0) -{ +if ($socid > 0) { $societe = new Societe($db); $societe->fetch($socid); /* - * Affichage onglets - */ + * Affichage onglets + */ $head = societe_prepare_head($societe); print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($societe, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print dol_get_fiche_end(); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->facture->lire) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->facture->lire) { // Invoice list print load_fiche_titre($langs->trans("SupplierPreview")); @@ -82,8 +79,7 @@ if ($socid > 0) $sql .= " ORDER BY f.datef DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '<tr class="liste_titre">'; @@ -96,22 +92,19 @@ if ($socid > 0) print '<td>&nbsp;</td>'; print '</tr>'; - if (!$num > 0) - { + if (!$num > 0) { print '<tr><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>'; } $solde = 0; // Boucle sur chaque facture - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $objf = $db->fetch_object($resql); $fac = new FactureFournisseur($db); $ret = $fac->fetch($objf->facid); - if ($ret < 0) - { + if ($ret < 0) { print $fac->error."<br>"; continue; } @@ -144,13 +137,11 @@ if ($socid > 0) $sql .= " AND pf.fk_facturefourn = ".$fac->id; $resqlp = $db->query($sql); - if ($resqlp) - { + if ($resqlp) { $nump = $db->num_rows($resqlp); $j = 0; - while ($j < $nump) - { + while ($j < $nump) { $objp = $db->fetch_object($resqlp); // print '<tr class="oddeven">'; From 5d31a93bf0b4215e4b8009b63bf87bdf83915dbc Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 08:20:51 +0100 Subject: [PATCH 108/173] Fix #16420 - undefined $model_mail_selected_id Set $model_mail_selected_id to 0 when it is undefined --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 2b551ed14d1..729be941d51 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -455,7 +455,7 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { - $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : $arraydefaultmessage->id; + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ( ($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0 ); // If list of template is filled $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; From e079ceb9c3d2e47ff4d00129ad37aa79fb9f421e Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 08:51:01 +0100 Subject: [PATCH 109/173] Fix #16420 undefined $model_mail_selected_id Set $model_mail_selected_id to 0 when it is undefined --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e8b291ebfca..9c98a69d14a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -488,7 +488,7 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { - $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : $arraydefaultmessage->id; + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ( ($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0 ); // If list of template is filled $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; From 8e8efce7d173346fe52c8374500b49190a83da6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:23:53 +0100 Subject: [PATCH 110/173] Fix sql syntax --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 030d2417853..e0239da6142 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1686,7 +1686,7 @@ class Contact extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".intval($this->socid)." AND fk_socpeople=".$this->id; ; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".((int) $this->socid)." AND fk_socpeople=".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); From 99a17cadb7377f82ecb409ee0304785c0fcc4675 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:25:08 +0100 Subject: [PATCH 111/173] Fix sql syntax --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e0239da6142..06b436fc0c8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1704,7 +1704,7 @@ class Contact extends CommonObject $sql .= "fk_socpeople) "; $sql .= " VALUES (".$conf->entity.","; $sql .= "'".$this->db->idate(dol_now())."',"; - $sql .= $this->socid.", "; + $sql .= ((int) $this->socid).", "; $sql .= $valRoles." , "; $sql .= $this->id; $sql .= ")"; From 549136efebebdb1e33fbfe224c53b19a15afe6ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:25:30 +0100 Subject: [PATCH 112/173] Removed useless log --- htdocs/contact/class/contact.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 06b436fc0c8..ac415afce6c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1708,7 +1708,6 @@ class Contact extends CommonObject $sql .= $valRoles." , "; $sql .= $this->id; $sql .= ")"; - dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if (!$result) From 69c974800cf9b20e88a9ff0f175f4e52c4d9d543 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:30:30 +0100 Subject: [PATCH 113/173] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 729be941d51..d505bd1fada 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -455,7 +455,7 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { - $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ( ($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0 ); + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : (($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0); // If list of template is filled $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; From e0785ac5ef316cf737c6d5d7fcf200059646d52c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:31:02 +0100 Subject: [PATCH 114/173] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d505bd1fada..46fcd5e331b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -455,7 +455,7 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { - $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : (($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0); + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ($arraydefaultmessage->id > 0 ? $arraydefaultmessage->id : 0); // If list of template is filled $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; From e7ae2e65d7790afcf547da58bffc73dd14c57480 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:33:49 +0100 Subject: [PATCH 115/173] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 9c98a69d14a..4898e8d5872 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -488,7 +488,7 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { - $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ( ($arraydefaultmessage->id) ? $arraydefaultmessage->id : 0 ); + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : ($arraydefaultmessage->id > 0 ? $arraydefaultmessage->id : 0); // If list of template is filled $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; From aba43b3e3560eecc333c705f29943a7deda367f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 10:44:52 +0100 Subject: [PATCH 116/173] Fix init before --- htdocs/core/ajax/objectonoff.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index af8529cde28..05843abed9d 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -47,9 +47,19 @@ $id = GETPOST('id', 'int'); $value = GETPOST('value', 'int'); $field = GETPOST('field', 'alpha'); $element = GETPOST('element', 'alpha'); +$format = 'int'; $object = new GenericObject($db); +$tablename = $element; +if ($tablename == 'websitepage') { + $tablename = 'website_page'; +} + +$object->table_element = $tablename; +$object->id = $id; +$object->fields[$field] = array('type' => $format, 'enabled' => 1); + // Security check if (!empty($user->socid)) { $socid = $user->socid; @@ -69,9 +79,9 @@ top_httphead(); print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; if (in_array($field, array('status'))) { - $result = restrictedArea($user, $element, $id); + restrictedArea($user, $element, $id); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products - $result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); + restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); } else { accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1); exit; @@ -85,16 +95,5 @@ if (($action == 'set') && !empty($id)) { $triggerkey = 'COMPANY_UPDATE'; } - $tablename = $element; - if ($tablename == 'websitepage') { - $tablename = 'website_page'; - } - - $format = 'int'; - - $object->table_element = $tablename; - $object->id = $id; - $object->fields[$field] = array('type' => $format, 'enabled' => 1); - $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); } From 2670d4fc17c70416074d190675fcaac30976eb9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 11:00:58 +0100 Subject: [PATCH 117/173] Look and feel v14 --- htdocs/core/class/html.form.class.php | 7 +++++++ htdocs/product/card.php | 1 - htdocs/product/list.php | 9 +-------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 78342100fa3..483d356891c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -316,6 +316,13 @@ class Form $arraylist[$tmp[0]] = $tmp[1]; } $ret .= $arraylist[$value]; + if ($htmlname == 'fk_product_type') { + if ($value == 0) { + $ret = img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"').$ret; + } else { + $ret = img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"').$ret; + } + } } elseif (preg_match('/^ckeditor/', $typeofdata)) { $tmpcontent = dol_htmlentitiesbr($value); if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 55c29aa1381..abf99c1b921 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1813,7 +1813,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Type if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { - // TODO change for compatibility with edit in place $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print '<tr><td class="titlefield">'; print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f7999860185..ff035dcdb9c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1113,17 +1113,10 @@ if ($resql) { print '<td class="center">'; $s = ''; - if ($obj->fk_product_type == 0) - { - //$s .= '<a class="product-type-back" title="'.$langs->trans("Product").'">'; + if ($obj->fk_product_type == 0) { $s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"'); - //$s .= dol_substr($langs->trans("Product"), 0, 1); - //$s .= '</a>'; } else { - //$s .= '<span class="service-type-back" title="'.$langs->trans("Service").'">'; $s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"'); - //$s .= dol_substr($langs->trans("Service"), 0, 1); - //$s .= '</a>'; } print $s; print '</td>'; From adc03135437dc19f6ed3c71f3c3a059990c65ebf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 11:09:15 +0100 Subject: [PATCH 118/173] Fix lang --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 9ce8d84d7e3..21ed3790418 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -381,7 +381,7 @@ function show_stats_for_company($product, $socid) $nblines++; $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) dol_print_error($db); - $langs->load("propal"); + $langs->load("supplier_proposal"); print '<tr><td>'; print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('', 'supplier_proposal').' '.$langs->trans("SupplierProposals").'</a>'; print '</td><td class="right">'; From 0f44bdb90fabecf66220ca9c2f41d0de2396b99c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 11:27:03 +0100 Subject: [PATCH 119/173] Fix sql error --- htdocs/core/lib/product.lib.php | 24 ++++++++++++------------ htdocs/product/class/product.class.php | 2 +- htdocs/product/stats/bom.php | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 21ed3790418..7012b6bff07 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -365,7 +365,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("propal"); print '<tr><td>'; - print '<a href="propal.php?id='.$product->id.'">'.img_object('', 'propal').' '.$langs->trans("Proposals").'</a>'; + print '<a href="propal.php?id='.$product->id.'">'.img_object('', 'propal', 'class="paddingright"').$langs->trans("Proposals").'</a>'; print '</td><td class="right">'; print $product->stats_propale['customers']; print '</td><td class="right">'; @@ -383,7 +383,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("supplier_proposal"); print '<tr><td>'; - print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('', 'supplier_proposal').' '.$langs->trans("SupplierProposals").'</a>'; + print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('', 'supplier_proposal', 'class="paddingright"').$langs->trans("SupplierProposals").'</a>'; print '</td><td class="right">'; print $product->stats_proposal_supplier['suppliers']; print '</td><td class="right">'; @@ -401,7 +401,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("orders"); print '<tr><td>'; - print '<a href="commande.php?id='.$product->id.'">'.img_object('', 'order').' '.$langs->trans("CustomersOrders").'</a>'; + print '<a href="commande.php?id='.$product->id.'">'.img_object('', 'order', 'class="paddingright"').$langs->trans("CustomersOrders").'</a>'; print '</td><td class="right">'; print $product->stats_commande['customers']; print '</td><td class="right">'; @@ -419,7 +419,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("orders"); print '<tr><td>'; - print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('', 'supplier_order').' '.$langs->trans("SuppliersOrders").'</a>'; + print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('', 'supplier_order', 'class="paddingright"').$langs->trans("SuppliersOrders").'</a>'; print '</td><td class="right">'; print $product->stats_commande_fournisseur['suppliers']; print '</td><td class="right">'; @@ -455,7 +455,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("bills"); print '<tr><td>'; - print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('', 'supplier_invoice').' '.$langs->trans("SuppliersInvoices").'</a>'; + print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('', 'supplier_invoice', 'class="paddingright"').$langs->trans("SuppliersInvoices").'</a>'; print '</td><td class="right">'; print $product->stats_facture_fournisseur['suppliers']; print '</td><td class="right">'; @@ -474,7 +474,7 @@ function show_stats_for_company($product, $socid) if ($ret < 0) dol_print_error($db); $langs->load("contracts"); print '<tr><td>'; - print '<a href="contrat.php?id='.$product->id.'">'.img_object('', 'contract').' '.$langs->trans("Contracts").'</a>'; + print '<a href="contrat.php?id='.$product->id.'">'.img_object('', 'contract', 'class="paddingright"').$langs->trans("Contracts").'</a>'; print '</td><td class="right">'; print $product->stats_contrat['customers']; print '</td><td class="right">'; @@ -496,15 +496,15 @@ function show_stats_for_company($product, $socid) $langs->load("mrp"); print '<tr><td>'; - print '<a href="bom.php?id='.$product->id.'">'.img_object('', 'mrp').' '.$langs->trans("BOM").'</a>'; + print '<a href="bom.php?id='.$product->id.'">'.img_object('', 'bom', 'class="paddingright"').$langs->trans("BOM").'</a>'; print '</td><td class="right">'; print '</td><td class="right">'; - print $form->textwithpicto($product->stats_bom['nb_toproduce'], $langs->trans("QtyToProduce")); - print $form->textwithpicto($product->stats_bom['nb_toconsume'], $langs->trans("ToConsume")); + print $form->textwithpicto($product->stats_bom['nb_toconsume'], $langs->trans("RowMaterial")); + print $form->textwithpicto($product->stats_bom['nb_toproduce'], $langs->trans("Finished")); print '</td><td class="right">'; - print $form->textwithpicto($product->stats_bom['qty_toproduce'], $langs->trans("QtyToProduce")); - print $form->textwithpicto($product->stats_bom['qty_toconsume'], $langs->trans("ToConsume")); + print $form->textwithpicto($product->stats_bom['qty_toconsume'], $langs->trans("RowMaterial")); + print $form->textwithpicto($product->stats_bom['qty_toproduce'], $langs->trans("Finished")); print '</td>'; print '</tr>'; } @@ -519,7 +519,7 @@ function show_stats_for_company($product, $socid) } $langs->load("mrp"); print '<tr><td>'; - print '<a href="mo.php?id='.$product->id.'">'.img_object('', 'mrp').' '.$langs->trans("MO").'</a>'; + print '<a href="mo.php?id='.$product->id.'">'.img_object('', 'mrp', 'class="paddingright"').$langs->trans("MO").'</a>'; print '</td><td class="right">'; print $form->textwithpicto($product->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); print $form->textwithpicto($product->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f8286216e57..3be810a2e8e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2464,7 +2464,7 @@ class Product extends CommonObject $this->stats_bom['qty_toconsume'] = 0; $sql = "SELECT COUNT(DISTINCT b.rowid) as nb_toproduce,"; - $sql .= " b.qty as qty_toproduce"; + $sql .= " SUM(b.qty) as qty_toproduce"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid"; $sql .= " WHERE "; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index 1582646cd8a..d1254a65b1e 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -244,8 +244,8 @@ if ($id > 0 || !empty($ref)) print '<tr class="liste_titre">'; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "b.rowid", "", "&amp;id=".$product->id, '', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "b.date_valid", "", "&amp;id=".$product->id, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$product->id, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$product->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("RowMaterial", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$product->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Finished", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$product->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "b.status", "", "&amp;id=".$product->id, '', $sortfield, $sortorder, 'center '); print "</tr>\n"; From 60016cc3f3c50944708f3c01d3418e49063a11ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 11:29:16 +0100 Subject: [PATCH 120/173] Fix phpcs --- htdocs/main.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 740323a644b..f72a933c688 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -425,7 +425,7 @@ if (!defined('NOTOKENRENEWAL')) { // Check token if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) || defined('CSRFCHECK_WITH_TOKEN')) { // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set into page -// Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) + // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deletefilter', 'deleteoperation', 'deleteprof', 'deletepayment', 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_reject_check'))) { @@ -712,7 +712,7 @@ if (!defined('NOLOGIN')) { // End test login / passwords if (!$login || (in_array('ldap', $authmode) && empty($passwordtotest))) { // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success. - // No data to test login, so we show the login page. + // No data to test login, so we show the login page. dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09')." - actionlogin=".GETPOST('actionlogin', 'aZ09')." - showing the login form and exit"); if (defined('NOREDIRECTBYMAINTOLOGIN')) { return 'ERROR_NOT_LOGGED'; @@ -1051,7 +1051,7 @@ if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea' if (!defined('NOREQUIRETRAN')) { if (!GETPOST('lang', 'aZ09')) { // If language was not forced on URL - // If user has chosen its own language + // If user has chosen its own language if (!empty($user->conf->MAIN_LANG_DEFAULT)) { // If different than current language //print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT; @@ -3073,7 +3073,7 @@ if (!function_exists("llxFooter")) { if (strpos('alpha', DOL_VERSION) > 0 && !$forceping) { print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It is an alpha version -->\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 + // 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) { print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. An error already occured this month, we will try later. -->\n"; From 4aaf9e133aeab56df2eb812205634b16e86063c9 Mon Sep 17 00:00:00 2001 From: Christophe Battarel <christophe@altairis.fr> Date: Fri, 26 Feb 2021 11:51:23 +0100 Subject: [PATCH 121/173] change translation --- htdocs/langs/en_US/productbatch.lang | 2 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index b4f3408ecf0..a05a6190fc4 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,7 +1,7 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Use lot/serial number ProductStatusOnBatch=Lot (required) -ProductStatusOnSerial=Serial number (required) +ProductStatusOnSerial=Serial number (must be unique for each equipment) ProductStatusNotOnBatch=No (lot/serial not used) ProductStatusOnBatchShort=Lot ProductStatusOnSerialShort=Serial diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index b4b5a56c5cd..76cba909e2c 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -1,7 +1,7 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Utiliser les numéros de lots/série ProductStatusOnBatch=Lot (requis) -ProductStatusOnSerial=Numéro de série (requis) +ProductStatusOnSerial=Numéro de série (doit être unique pour chaque équipement) ProductStatusNotOnBatch=Non (Lot/Série non utilisé) ProductStatusOnBatchShort=Lot ProductStatusOnSerialShort=N°série From badd46e2897b49ac777695e3dbf43a842c964781 Mon Sep 17 00:00:00 2001 From: Juanjo Menent <jmenent@2byte.es> Date: Fri, 26 Feb 2021 11:53:23 +0100 Subject: [PATCH 122/173] FIX: Bad project filter in ticket list --- htdocs/ticket/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 565d1279037..1a276c75f5f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -352,7 +352,7 @@ foreach ($search as $key => $val) if (count($newarrayofstatus)) $sql .= natural_search($key, join(',', $newarrayofstatus), 2); continue; } - if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key = 'fk_project') + if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') { if ($search[$key] > 0) $sql .= natural_search($key, $search[$key], 2); continue; From 7d97d16eebc32a09c2961fa69e0c302811c300ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 11:59:13 +0100 Subject: [PATCH 123/173] code syntax zapier directory --- htdocs/zapier/admin/about.php | 4 +- htdocs/zapier/admin/setup.php | 4 +- htdocs/zapier/class/api_zapier.class.php | 52 +++++----- htdocs/zapier/class/hook.class.php | 36 +++---- htdocs/zapier/hook_agenda.php | 90 +++++++++------- htdocs/zapier/hook_card.php | 120 ++++++++++++---------- htdocs/zapier/hook_document.php | 16 ++- htdocs/zapier/hook_list.php | 124 +++++++++++++++++------ htdocs/zapier/hook_note.php | 62 ++++++------ htdocs/zapier/lib/zapier_hook.lib.php | 16 ++- htdocs/zapier/zapierindex.php | 4 +- 11 files changed, 324 insertions(+), 204 deletions(-) diff --git a/htdocs/zapier/admin/about.php b/htdocs/zapier/admin/about.php index e67ba8861a2..b24fe42ed22 100644 --- a/htdocs/zapier/admin/about.php +++ b/htdocs/zapier/admin/about.php @@ -34,7 +34,9 @@ require_once '../lib/zapier.lib.php'; $langs->loadLangs(array("errors", "admin", "zapier@zapier")); // Access control -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Parameters $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/zapier/admin/setup.php b/htdocs/zapier/admin/setup.php index 0d10ac95231..606da5509e3 100644 --- a/htdocs/zapier/admin/setup.php +++ b/htdocs/zapier/admin/setup.php @@ -33,7 +33,9 @@ require_once '../lib/zapier.lib.php'; $langs->loadLangs(array("admin", "zapier@zapier")); // Access control -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Parameters $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 945a6a69a8f..f5447bfa804 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -37,7 +37,7 @@ class ZapierApi extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'url', ); @@ -163,7 +163,9 @@ class ZapierApi extends DolibarrApi } $sql .= " FROM ".MAIN_DB_PREFIX."hook_mytable 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 + 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 @@ -270,33 +272,33 @@ class ZapierApi extends DolibarrApi // * @url PUT /hooks/{id} // */ /*public function put($id, $request_data = null) - { - if (! DolibarrApiAccess::$user->rights->zapier->write) { - throw new RestException(401); - } + { + if (! DolibarrApiAccess::$user->rights->zapier->write) { + throw new RestException(401); + } - $result = $this->hook->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Hook not found'); - } + $result = $this->hook->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Hook not found'); + } - if( ! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach($request_data as $field => $value) { - if ($field == 'id') { - continue; - } - $this->hook->$field = $value; - } + foreach($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->hook->$field = $value; + } - if ($this->hook->update($id, DolibarrApiAccess::$user) > 0) { - return $this->get($id); - } else { - throw new RestException(500, $this->hook->error); - } - }*/ + if ($this->hook->update($id, DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->hook->error); + } + }*/ /** * Delete hook diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index b71c5aec1d7..412a9d602fa 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -385,13 +385,13 @@ class Hook extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ /*public function fetchLines() - { - $this->lines=array(); + { + $this->lines=array(); - // Load lines with object MyObjectLine + // Load lines with object MyObjectLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + }*/ /** * Load list of objects in memory from the database. @@ -542,11 +542,11 @@ class Hook extends CommonObject $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* - $hookmanager->initHooks(array('hookdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ + $hookmanager->initHooks(array('hookdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -621,7 +621,9 @@ class Hook extends CommonObject } $statusType = 'status5'; - if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status4'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -720,11 +722,11 @@ class Hook extends CommonObject /* class MyObjectLine { - // @var int ID - public $id; - // @var mixed Sample line property 1 - public $prop1; - // @var mixed Sample line property 2 - public $prop2; + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; } */ diff --git a/htdocs/zapier/hook_agenda.php b/htdocs/zapier/hook_agenda.php index 6ae9d7d57aa..14f1aeda682 100644 --- a/htdocs/zapier/hook_agenda.php +++ b/htdocs/zapier/hook_agenda.php @@ -43,7 +43,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -58,12 +60,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Initialize technical objects $object = new MyObject($db); @@ -76,7 +84,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; +} @@ -86,7 +96,9 @@ if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$obj $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { // Cancel @@ -118,7 +130,9 @@ if ($object->id > 0) { $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = myobjectPrepareHead($object); @@ -143,31 +157,31 @@ if ($object->id > 0) { if ($user->rights->mymodule->creer) { if ($action != 'classify') - //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - $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.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; - } else { - $morehtmlref.=''; - } - } - }*/ + //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $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.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref.='<input type="hidden" name="action" value="classin">'; + $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref.='</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; + $morehtmlref.=$proj->ref; + $morehtmlref.='</a>'; + } else { + $morehtmlref.=''; + } + } + }*/ $morehtmlref .= '</div>'; @@ -194,7 +208,9 @@ if ($object->id > 0) { $permok = $user->rights->agenda->myactions->create; if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; - if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id; + if (get_class($objthirdparty) == 'Societe') { + $out .= '&amp;socid='.$objthirdparty->id; + } $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); @@ -216,8 +232,12 @@ if ($object->id > 0) { if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + 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("ActionsOnMyObject"), '', ''); diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index 43706c0c533..455efc95cc9 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -56,10 +56,14 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -79,7 +83,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { $error = 0; @@ -88,8 +94,11 @@ if (empty($reshook)) { $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__'); + if (empty($id)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__'); + } } $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record @@ -223,21 +232,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* $forcecombo=0; if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -257,32 +269,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->write) - { - if ($action != 'classify') - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($user->rights->mymodule->write) + { + if ($action != 'classify') + $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref.='<input type="hidden" name="action" value="classin">'; + $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref.='</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } } */ $morehtmlref .= '</div>'; @@ -317,7 +329,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } if (empty($reshook)) { // Modify @@ -333,18 +347,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } /* - if ($user->rights->mymodule->write) - { - if ($object->status == 1) - { - print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a>'."\n"; - } - else - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a>'."\n"; - } - } - */ + if ($user->rights->mymodule->write) + { + if ($object->status == 1) + { + print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a>'."\n"; + } + else + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a>'."\n"; + } + } + */ if ($user->rights->mymodule->delete) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n"; diff --git a/htdocs/zapier/hook_document.php b/htdocs/zapier/hook_document.php index 5b1af8080de..b78ad4d7bac 100644 --- a/htdocs/zapier/hook_document.php +++ b/htdocs/zapier/hook_document.php @@ -50,12 +50,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects @@ -71,7 +77,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/myobject/" . dol_sanitizeFileName($object->id); -if ($id > 0 || !empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity]."/myobject/".dol_sanitizeFileName($object->ref); +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity]."/myobject/".dol_sanitizeFileName($object->ref); +} /* diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index 93461517107..3894ca3f0a3 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -96,20 +96,26 @@ if ($user->socid > 0) { $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of fields for list $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -133,7 +139,9 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { // Selection of new fields @@ -195,7 +203,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/, $/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; +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 (t.rowid = ef.fk_object)"; +} if ($object->ismultientitymanaged == 1) { $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { @@ -224,11 +234,11 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY " foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql.='t.'.$key.', '; } // 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.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook @@ -296,8 +306,12 @@ llxHeader('', $title, $help_url); $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); +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) { @@ -307,7 +321,9 @@ foreach ($search as $key => $val) { $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'; @@ -316,12 +332,18 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->zapier->delete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -354,7 +376,9 @@ $trackid = 'zapier'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -365,8 +389,11 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; @@ -423,9 +450,15 @@ print '</tr>'."\n"; print '<tr class="liste_titre">'; foreach ($object->fields as $key => $val) { $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } @@ -474,7 +507,9 @@ while ($i < min($num, $limit)) { // Store properties in $object $object->id = $obj->rowid; foreach ($object->fields as $key => $val) { - if (isset($obj->$key)) $object->$key = $obj->$key; + if (isset($obj->$key)) { + $object->$key = $obj->$key; + } } // Show here line of result @@ -487,26 +522,45 @@ while ($i < min($num, $limit)) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; - if ($cssforfield || $val['css']) print ' class="'; + if ($cssforfield || $val['css']) { + print ' class="'; + } print $cssforfield; - if ($cssforfield && $val['css']) print ' '; + if ($cssforfield && $val['css']) { + print ' '; + } print $val['css']; - if ($cssforfield || $val['css']) print '"'; + if ($cssforfield || $val['css']) { + print '"'; + } print '>'; - if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); - else print $object->showOutputField($val, $key, $obj->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + } else { + print $object->showOutputField($val, $key, $obj->$key, ''); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } if (!empty($val['isameasure'])) { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -522,11 +576,15 @@ while ($i < min($num, $limit)) { if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'; diff --git a/htdocs/zapier/hook_note.php b/htdocs/zapier/hook_note.php index da0484160a3..ce613da2989 100644 --- a/htdocs/zapier/hook_note.php +++ b/htdocs/zapier/hook_note.php @@ -53,7 +53,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; +} $permissionnote = 1; //$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php @@ -98,35 +100,35 @@ if ($id > 0 || !empty($ref)) { // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) - { - if ($action != 'classify') - //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - $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.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($user->rights->mymodule->creer) + { + if ($action != 'classify') + //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $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.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref.='<input type="hidden" name="action" value="classin">'; + $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref.='</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; + $morehtmlref.=$proj->ref; + $morehtmlref.='</a>'; + } else { + $morehtmlref.=''; + } + } }*/ $morehtmlref .= '</div>'; diff --git a/htdocs/zapier/lib/zapier_hook.lib.php b/htdocs/zapier/lib/zapier_hook.lib.php index 114e7753512..3d4228325e2 100644 --- a/htdocs/zapier/lib/zapier_hook.lib.php +++ b/htdocs/zapier/lib/zapier_hook.lib.php @@ -43,11 +43,17 @@ function myobjectPrepareHead($object) if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $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_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; + if ($nbNote > 0) { + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; + } $head[$h][2] = 'note'; $h++; } @@ -59,7 +65,9 @@ function myobjectPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + } $head[$h][2] = 'document'; $h++; diff --git a/htdocs/zapier/zapierindex.php b/htdocs/zapier/zapierindex.php index 5ecdf24e6cd..357777000f6 100644 --- a/htdocs/zapier/zapierindex.php +++ b/htdocs/zapier/zapierindex.php @@ -35,7 +35,9 @@ $action = GETPOST('action', 'aZ09'); // Securite acces client -if (!$user->rights->zapier->read) accessforbidden(); +if (!$user->rights->zapier->read) { + accessforbidden(); +} $socid = GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { $action = ''; From 256001ebd6522b6780dc5737d769739bb3d099bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 12:03:07 +0100 Subject: [PATCH 124/173] code syntax website directory --- htdocs/website/class/website.class.php | 228 ++- htdocs/website/class/websitepage.class.php | 98 +- htdocs/website/index.php | 1753 +++++++++----------- htdocs/website/samples/wrapper.php | 148 +- htdocs/website/websiteaccount_card.php | 162 +- 5 files changed, 1161 insertions(+), 1228 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index d0ffc3ccc03..fe2e6aab4cf 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -244,7 +244,9 @@ class Website extends CommonObject if (is_array($tmplangarray)) { dol_mkdir($conf->website->dir_output.'/'.$this->ref); foreach ($tmplangarray as $val) { - if (trim($val) == $this->lang) continue; + if (trim($val) == $this->lang) { + continue; + } dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val)); } } @@ -540,7 +542,9 @@ class Website extends CommonObject if (is_array($tmplangarray)) { dol_mkdir($conf->website->dir_output.'/'.$this->ref); foreach ($tmplangarray as $val) { - if (trim($val) == $this->lang) continue; + if (trim($val) == $this->lang) { + continue; + } dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val)); } } @@ -603,8 +607,7 @@ class Website extends CommonObject } } - if (!$error && !empty($this->ref)) - { + if (!$error && !empty($this->ref)) { $pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref; dol_delete_dir_recursive($pathofwebsite); @@ -645,8 +648,7 @@ class Website extends CommonObject $object = new self($this->db); // Check no site with ref exists - if ($object->fetch(0, $newref) > 0) - { + if ($object->fetch(0, $newref) > 0) { $this->error = 'ErrorNewRefIsAlreadyUsed'; return -1; } @@ -678,7 +680,9 @@ class Website extends CommonObject $object->fk_user_creat = $user->id; $object->position = ((int) $object->position) + 1; $object->status = self::STATUS_DRAFT; - if (empty($object->lang)) $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages + if (empty($object->lang)) { + $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages + } // Create clone $object->context['createfromclone'] = 'createfromclone'; @@ -690,15 +694,13 @@ class Website extends CommonObject dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - if (!$error) - { + if (!$error) { dolCopyDir($pathofwebsiteold, $pathofwebsitenew, $conf->global->MAIN_UMASK, 0, null, 2); // Check symlink to medias and restore it if ko $pathtomedias = DOL_DATA_ROOT.'/medias'; // Target $pathtomediasinwebsite = $pathofwebsitenew.'/medias'; // Source / Link name - if (!is_link(dol_osencode($pathtomediasinwebsite))) - { + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); @@ -718,8 +720,7 @@ class Website extends CommonObject // Duplicate pages $objectpages = new WebsitePage($this->db); $listofpages = $objectpages->fetchAll($fromid); - foreach ($listofpages as $pageid => $objectpageold) - { + foreach ($listofpages as $pageid => $objectpageold) { // Delete old file $filetplold = $pathofwebsitenew.'/page'.$pageid.'.tpl.php'; dol_delete_file($filetplold); @@ -728,43 +729,41 @@ class Website extends CommonObject $objectpagenew = $objectpageold->createFromClone($user, $pageid, $objectpageold->pageurl, '', 0, $object->id, 1); //print $pageid.' = '.$objectpageold->pageurl.' -> '.$objectpagenew->id.' = '.$objectpagenew->pageurl.'<br>'; - if (is_object($objectpagenew) && $objectpagenew->pageurl) - { + if (is_object($objectpagenew) && $objectpagenew->pageurl) { $filealias = $pathofwebsitenew.'/'.$objectpagenew->pageurl.'.php'; $filetplnew = $pathofwebsitenew.'/page'.$objectpagenew->id.'.tpl.php'; // Save page alias $result = dolSavePageAlias($filealias, $object, $objectpagenew); - if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + if (!$result) { + setEventMessages('Failed to write file '.$filealias, null, 'errors'); + } $result = dolSavePageContent($filetplnew, $object, $objectpagenew); - if (!$result) setEventMessages('Failed to write file '.$filetplnew, null, 'errors'); + if (!$result) { + setEventMessages('Failed to write file '.$filetplnew, null, 'errors'); + } - if ($pageid == $oldidforhome) - { + if ($pageid == $oldidforhome) { $newidforhome = $objectpagenew->id; } - } - else { + } else { setEventMessages($objectpageold->error, $objectpageold->errors, 'errors'); $error++; } } } - if (!$error) - { + if (!$error) { // Restore id of home page $object->fk_default_home = $newidforhome; $res = $object->update($user); - if (!($res > 0)) - { + if (!($res > 0)) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } - if (!$error) - { + if (!$error) { $filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php'; $filewrapper = $pathofwebsitenew.'/wrapper.php'; @@ -821,10 +820,11 @@ class Website extends CommonObject $linkstart = $linkend = ''; - if ($withpicto) - { + if ($withpicto) { $result .= ($linkstart.img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? '' : 'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result .= ' '; + if ($withpicto != 2) { + $result .= ' '; + } } $result .= $linkstart.$this->ref.$linkend; return $result; @@ -854,8 +854,7 @@ class Website extends CommonObject // phpcs:enable global $langs; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); @@ -865,7 +864,9 @@ class Website extends CommonObject } $statusType = 'status5'; - if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status4'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -909,16 +910,14 @@ class Website extends CommonObject $website = $this; - if (empty($website->id) || empty($website->ref)) - { + if (empty($website->id) || empty($website->ref)) { setEventMessages("Website id or ref is not defined", null, 'errors'); return ''; } dol_syslog("Create temp dir ".$conf->website->dir_temp); dol_mkdir($conf->website->dir_temp); - if (!is_writable($conf->website->dir_temp)) - { + if (!is_writable($conf->website->dir_temp)) { setEventMessages("Temporary dir ".$conf->website->dir_temp." is not writable", null, 'errors'); return ''; } @@ -928,8 +927,7 @@ class Website extends CommonObject dol_syslog("Clear temp dir ".$destdir); $count = 0; $countreallydeleted = 0; $counttodelete = dol_delete_dir_recursive($destdir, $count, 1, 0, $countreallydeleted); - if ($counttodelete != $countreallydeleted) - { + if ($counttodelete != $countreallydeleted) { setEventMessages("Failed to clean temp directory ".$destdir, null, 'errors'); return ''; } @@ -987,8 +985,7 @@ class Website extends CommonObject // Build sql file $filesql = $conf->website->dir_temp.'/'.$website->ref.'/website_pages.sql'; $fp = fopen($filesql, "w"); - if (empty($fp)) - { + if (empty($fp)) { setEventMessages("Failed to create file ".$filesql, null, 'errors'); return ''; } @@ -998,20 +995,16 @@ class Website extends CommonObject // Assign ->newid and ->newfk_page $i = 1; - foreach ($listofpages as $pageid => $objectpageold) - { + foreach ($listofpages as $pageid => $objectpageold) { $objectpageold->newid = $i; $i++; } $i = 1; - foreach ($listofpages as $pageid => $objectpageold) - { + foreach ($listofpages as $pageid => $objectpageold) { // Search newid $newfk_page = 0; - foreach ($listofpages as $pageid2 => $objectpageold2) - { - if ($pageid2 == $objectpageold->fk_page) - { + foreach ($listofpages as $pageid2 => $objectpageold2) { + if ($pageid2 == $objectpageold->fk_page) { $newfk_page = $objectpageold2->newid; break; } @@ -1019,8 +1012,7 @@ class Website extends CommonObject $objectpageold->newfk_page = $newfk_page; $i++; } - foreach ($listofpages as $pageid => $objectpageold) - { + foreach ($listofpages as $pageid => $objectpageold) { $allaliases = $objectpageold->pageurl; $allaliases .= ($objectpageold->aliasalt ? ','.$objectpageold->aliasalt : ''); @@ -1081,8 +1073,7 @@ class Website extends CommonObject // Add line to update home page id during import //var_dump($this->fk_default_home.' - '.$objectpageold->id.' - '.$objectpageold->newid);exit; - if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) // This is the record with home page - { + if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) { // This is the record with home page // Warning: We must keep llx_ here. It is a generic SQL. $line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;"; $line .= "\n"; @@ -1091,8 +1082,9 @@ class Website extends CommonObject } fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($filesql, octdec($conf->global->MAIN_UMASK)); + } // Build zip file $filedir = $conf->website->dir_temp.'/'.$website->ref.'/.'; @@ -1102,11 +1094,9 @@ class Website extends CommonObject dol_delete_file($fileglob, 0); $result = dol_compress_file($filedir, $filename, 'zip'); - if ($result > 0) - { + if ($result > 0) { return $filename; - } - else { + } else { global $errormsg; $this->error = $errormsg; return ''; @@ -1127,8 +1117,7 @@ class Website extends CommonObject $error = 0; $object = $this; - if (empty($object->ref)) - { + if (empty($object->ref)) { $this->error = 'Function importWebSite called on object not loaded (object->ref is empty)'; return -1; } @@ -1137,16 +1126,14 @@ class Website extends CommonObject dol_mkdir($conf->website->dir_temp.'/'.$object->ref); $filename = basename($pathtofile); - if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) - { + if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) { $this->errors[] = 'Bad format for filename '.$filename.'. Must be website_XXX-VERSION.'; return -1; } $result = dol_uncompress($pathtofile, $conf->website->dir_temp.'/'.$object->ref); - if (!empty($result['error'])) - { + if (!empty($result['error'])) { $this->errors[] = 'Failed to unzip file '.$pathtofile.'.'; return -1; } @@ -1172,8 +1159,7 @@ class Website extends CommonObject // Now generate the master.inc.php page $filemaster = $conf->website->dir_output.'/'.$object->ref.'/master.inc.php'; $result = dolSaveMasterFile($filemaster); - if (!$result) - { + if (!$result) { $this->errors[] = 'Failed to write file '.$filemaster; $error++; } @@ -1190,16 +1176,14 @@ class Website extends CommonObject // Search the $maxrowid because we need it later $sqlgetrowid = 'SELECT MAX(rowid) as max from '.MAIN_DB_PREFIX.'website_page'; $resql = $this->db->query($sqlgetrowid); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $maxrowid = $obj->max; } // Load sql record $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); // The maxrowid of table is searched into this function two - if ($runsql <= 0) - { + if ($runsql <= 0) { $this->errors[] = 'Failed to load sql file '.$sqlfile; $error++; } @@ -1208,16 +1192,13 @@ class Website extends CommonObject // Make replacement of IDs $fp = fopen($sqlfile, "r"); - if ($fp) - { - while (!feof($fp)) - { + if ($fp) { + while (!feof($fp)) { $reg = array(); // Warning fgets with second parameter that is null or 0 hang. $buf = fgets($fp, 65000); - if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) - { + if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) { $oldid = $reg[1]; $newid = ($reg[2] + $maxrowid); $aliasesarray = explode(',', $reg[3]); @@ -1237,12 +1218,9 @@ class Website extends CommonObject } // Regenerate alternative aliases pages - if (is_array($aliasesarray)) - { - foreach ($aliasesarray as $aliasshortcuttocreate) - { - if (trim($aliasshortcuttocreate)) - { + if (is_array($aliasesarray)) { + foreach ($aliasesarray as $aliasshortcuttocreate) { + if (trim($aliasshortcuttocreate)) { $filealias = $conf->website->dir_output.'/'.$object->ref.'/'.trim($aliasshortcuttocreate).'.php'; $result = dolSavePageAlias($filealias, $object, $objectpagestatic); if (!$result) { @@ -1274,12 +1252,10 @@ class Website extends CommonObject $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php'); - if ($error) - { + if ($error) { $this->db->rollback(); return -1; - } - else { + } else { $this->db->commit(); return $object->id; } @@ -1298,8 +1274,7 @@ class Website extends CommonObject $error = 0; $object = $this; - if (empty($object->ref)) - { + if (empty($object->ref)) { $this->error = 'Function rebuildWebSiteFiles called on object not loaded (object->ref is empty)'; return -1; } @@ -1386,7 +1361,9 @@ class Website extends CommonObject { global $websitepagefile, $website; - if (!is_object($weblangs)) return 'ERROR componentSelectLang called with parameter $weblangs not defined'; + if (!is_object($weblangs)) { + return 'ERROR componentSelectLang called with parameter $weblangs not defined'; + } $arrayofspecialmainlanguages = array( 'en'=>'en_US', @@ -1419,51 +1396,55 @@ class Website extends CommonObject $tmppage = new WebsitePage($this->db); $pageid = 0; - if (!empty($websitepagefile)) - { + if (!empty($websitepagefile)) { $websitepagefileshort = basename($websitepagefile); - if ($websitepagefileshort == 'index.php') $pageid = $website->fk_default_home; - else $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort); - if ($pageid > 0) - { + if ($websitepagefileshort == 'index.php') { + $pageid = $website->fk_default_home; + } else { + $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort); + } + if ($pageid > 0) { $tmppage->fetch($pageid); } } // Fill $languagecodes array with existing translation, nothing if none - if (!is_array($languagecodes) && $pageid > 0) - { + if (!is_array($languagecodes) && $pageid > 0) { $languagecodes = array(); $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; $sql .= " WHERE wp.fk_website = ".$website->id; $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; - if ($tmppage->fk_page > 0) $sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page; + if ($tmppage->fk_page > 0) { + $sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page; + } $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $newlang = $obj->lang; - if ($obj->rowid == $pageid) $newlang = $obj->lang; - if (!in_array($newlang, $languagecodes)) $languagecodes[] = $newlang; + if ($obj->rowid == $pageid) { + $newlang = $obj->lang; + } + if (!in_array($newlang, $languagecodes)) { + $languagecodes[] = $newlang; + } } } } // Now $languagecodes is always an array. Example array('en', 'fr', 'es'); $languagecodeselected = substr($weblangs->defaultlang, 0, 2); // Because we must init with a value, but real value is the lang of main parent container - if (!empty($websitepagefile)) - { + if (!empty($websitepagefile)) { $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); - if ($pageid > 0) - { + if ($pageid > 0) { $pagelang = substr($tmppage->lang, 0, 2); $languagecodeselected = substr($pagelang, 0, 2); - if (!in_array($pagelang, $languagecodes)) $languagecodes[] = $pagelang; // We add language code of page into combo list + if (!in_array($pagelang, $languagecodes)) { + $languagecodes[] = $pagelang; // We add language code of page into combo list + } } } @@ -1474,7 +1455,9 @@ class Website extends CommonObject $url = preg_replace('/(\?|&)l=([a-zA-Z_]*)/', '', $url); // We remove param l from url //$url = preg_replace('/(\?|&)lang=([a-zA-Z_]*)/', '', $url); // We remove param lang from url $url .= (preg_match('/\?/', $url) ? '&' : '?').'l='; - if (!preg_match('/^\//', $url)) $url = '/'.$url; + if (!preg_match('/^\//', $url)) { + $url = '/'.$url; + } $HEIGHTOPTION = 40; $MAXHEIGHT = 4 * $HEIGHTOPTION; @@ -1504,8 +1487,7 @@ class Website extends CommonObject $out .= '</style>'; $out .= '<ul class="componentSelectLang'.$htmlname.($morecss ? ' '.$morecss : '').'">'; - if ($languagecodeselected) - { + if ($languagecodeselected) { // Convert $languagecodeselected into a long language code if (strlen($languagecodeselected) == 2) { $languagecodeselected = (empty($arrayofspecialmainlanguages[$languagecodeselected]) ? $languagecodeselected.'_'.strtoupper($languagecodeselected) : $arrayofspecialmainlanguages[$languagecodeselected]); @@ -1513,28 +1495,34 @@ class Website extends CommonObject $countrycode = strtolower(substr($languagecodeselected, -2)); $label = $weblangs->trans("Language_".$languagecodeselected); - if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); + if ($countrycode == 'us') { + $label = preg_replace('/\s*\(.*\)/', '', $label); + } $out .= '<a href="'.$url.substr($languagecodeselected, 0, 2).'"><li><img height="12px" src="/medias/image/common/flags/'.$countrycode.'.png" style="margin-right: 5px;"/><span class="websitecomponentlilang">'.$label.'</span>'; $out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />'; $out .= '</li></a>'; } $i = 0; - if (is_array($languagecodes)) - { - foreach ($languagecodes as $languagecode) - { + if (is_array($languagecodes)) { + foreach ($languagecodes as $languagecode) { // Convert $languagecode into a long language code if (strlen($languagecode) == 2) { $languagecode = (empty($arrayofspecialmainlanguages[$languagecode]) ? $languagecode.'_'.strtoupper($languagecode) : $arrayofspecialmainlanguages[$languagecode]); } - if ($languagecode == $languagecodeselected) continue; // Already output + if ($languagecode == $languagecodeselected) { + continue; // Already output + } $countrycode = strtolower(substr($languagecode, -2)); $label = $weblangs->trans("Language_".$languagecode); - if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); + if ($countrycode == 'us') { + $label = preg_replace('/\s*\(.*\)/', '', $label); + } $out .= '<a href="'.$url.substr($languagecode, 0, 2).'"><li><img height="12px" src="/medias/image/common/flags/'.$countrycode.'.png" style="margin-right: 5px;"/><span class="websitecomponentlilang">'.$label.'</span>'; - if (empty($i) && empty($languagecodeselected)) $out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />'; + if (empty($i) && empty($languagecodeselected)) { + $out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />'; + } $out .= '</li></a>'; $i++; } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index bacc4664791..c6c4d81d04e 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -106,9 +106,9 @@ class WebsitePage extends CommonObject */ public $author_alias; - /** - * @var string path of external object - */ + /** + * @var string path of external object + */ public $object_type; /** @@ -229,7 +229,9 @@ class WebsitePage extends CommonObject { $this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1); $this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1); - if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,' + if ($this->aliasalt) { + $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,' + } // Remove spaces and be sure we have main language only $this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en @@ -281,12 +283,12 @@ class WebsitePage extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level $sql .= ' WHERE 1 = 1'; - if ($id > 0) - { + if ($id > 0) { $sql .= ' AND t.rowid = '.$id; - } - else { - if ($id < 0) $sql .= ' AND t.rowid <> '.abs($id); + } else { + if ($id < 0) { + $sql .= ' AND t.rowid <> '.abs($id); + } if (null !== $website_id) { $sql .= " AND t.fk_website = '".$this->db->escape($website_id)."'"; if ($page) { @@ -295,12 +297,18 @@ class WebsitePage extends CommonObject $tmppage = explode('/', $page); if (!empty($tmppage[1])) { $pagetouse = $tmppage[1]; - if (strlen($tmppage[0])) $langtouse = $tmppage[0]; + if (strlen($tmppage[0])) { + $langtouse = $tmppage[0]; + } } $sql .= " AND t.pageurl = '".$this->db->escape($pagetouse)."'"; - if ($langtouse) $sql .= " AND t.lang = '".$this->db->escape($langtouse)."'"; + if ($langtouse) { + $sql .= " AND t.lang = '".$this->db->escape($langtouse)."'"; + } + } + if ($aliasalt) { + $sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')"; } - if ($aliasalt) $sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')"; } } $sql .= $this->db->plimit(1); @@ -419,7 +427,9 @@ class WebsitePage extends CommonObject $listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'"; } $stringtouse = $key." IN (".join(',', $listoflang).")"; - if ($foundnull) $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)'; + if ($foundnull) { + $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)'; + } $sqlwhere[] = $stringtouse; } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -441,8 +451,7 @@ class WebsitePage extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $record = new self($this->db); $record->id = $obj->rowid; @@ -520,7 +529,9 @@ class WebsitePage extends CommonObject $listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'"; } $stringtouse = $key." IN (".join(',', $listoflang).")"; - if ($foundnull) $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)'; + if ($foundnull) { + $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)'; + } $sqlwhere[] = $stringtouse; } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -561,7 +572,9 @@ class WebsitePage extends CommonObject { $this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1); $this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1); - if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,' + if ($this->aliasalt) { + $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,' + } // Remove spaces and be sure we have main language only $this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en @@ -595,8 +608,7 @@ class WebsitePage extends CommonObject // Delete all child tables if (!$error) { - foreach ($this->childtablesoncascade as $table) - { + foreach ($this->childtablesoncascade as $table) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE fk_website_page = ".(int) $this->id; @@ -611,19 +623,16 @@ class WebsitePage extends CommonObject if (!$error) { $result = $this->deleteCommon($user, $trigger); - if ($result <= 0) - { + if ($result <= 0) { $error++; } } - if (!$error) - { + if (!$error) { $websiteobj = new Website($this->db); $result = $websiteobj->fetch($this->fk_website); - if ($result > 0) - { + if ($result > 0) { global $dolibarr_main_data_root; $pathofwebsite = $dolibarr_main_data_root.'/website/'.$websiteobj->ref; @@ -696,10 +705,17 @@ class WebsitePage extends CommonObject $object->date_creation = $now; $object->title = ($newtitle == '1' ? $object->title : ($newtitle ? $newtitle : $object->title)); $object->description = $object->title; - if (!empty($newlang)) $object->lang = $newlang; - if ($istranslation) $object->fk_page = $fromid; - else $object->fk_page = 0; - if (!empty($newwebsite)) $object->fk_website = $newwebsite; + if (!empty($newlang)) { + $object->lang = $newlang; + } + if ($istranslation) { + $object->fk_page = $fromid; + } else { + $object->fk_page = 0; + } + if (!empty($newwebsite)) { + $object->fk_website = $newwebsite; + } $object->import_key = ''; // Create clone @@ -755,17 +771,16 @@ class WebsitePage extends CommonObject $url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id; $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; @@ -774,8 +789,12 @@ class WebsitePage extends CommonObject //$linkstart = $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_picto(($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_picto(($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; return $result; @@ -805,8 +824,7 @@ class WebsitePage extends CommonObject // phpcs:enable global $langs; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); @@ -816,7 +834,9 @@ class WebsitePage extends CommonObject } $statusType = 'status5'; - if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status4'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 46dfd49ed0a..425af726c24 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -44,7 +44,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $langs->loadLangs(array("admin", "other", "website", "errors")); -if (!$user->rights->website->read) accessforbidden(); +if (!$user->rights->website->read) { + accessforbidden(); +} $conf->dol_hide_leftmenu = 1; // Force hide of left menu. @@ -70,38 +72,78 @@ $section_dir = GETPOST('section_dir', 'alpha'); $file_manager = GETPOST('file_manager', 'alpha'); $replacesite = GETPOST('replacesite', 'alpha'); -if (GETPOST('deletesite', 'alpha')) { $action = 'deletesite'; } -if (GETPOST('delete', 'alpha')) { $action = 'delete'; } -if (GETPOST('preview', 'alpha')) $action = 'preview'; -if (GETPOST('createsite', 'alpha')) { $action = 'createsite'; } -if (GETPOST('createcontainer', 'alpha')) { $action = 'createcontainer'; } -if (GETPOST('editcss', 'alpha')) { $action = 'editcss'; } -if (GETPOST('editmenu', 'alpha')) { $action = 'editmenu'; } -if (GETPOST('setashome', 'alpha')) { $action = 'setashome'; } -if (GETPOST('editmeta', 'alpha')) { $action = 'editmeta'; } -if (GETPOST('editsource', 'alpha')) { $action = 'editsource'; } -if (GETPOST('editcontent', 'alpha')) { $action = 'editcontent'; } -if (GETPOST('exportsite', 'alpha')) { $action = 'exportsite'; } -if (GETPOST('importsite', 'alpha')) { $action = 'importsite'; } -if (GETPOST('createfromclone', 'alpha')) { $action = 'createfromclone'; } -if (GETPOST('createpagefromclone', 'alpha')) { $action = 'createpagefromclone'; } -if (empty($action) && $file_manager) $action = 'file_manager'; -if (empty($action) && $replacesite) $action = 'replacesite'; -if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0; +if (GETPOST('deletesite', 'alpha')) { + $action = 'deletesite'; +} +if (GETPOST('delete', 'alpha')) { + $action = 'delete'; +} +if (GETPOST('preview', 'alpha')) { + $action = 'preview'; +} +if (GETPOST('createsite', 'alpha')) { + $action = 'createsite'; +} +if (GETPOST('createcontainer', 'alpha')) { + $action = 'createcontainer'; +} +if (GETPOST('editcss', 'alpha')) { + $action = 'editcss'; +} +if (GETPOST('editmenu', 'alpha')) { + $action = 'editmenu'; +} +if (GETPOST('setashome', 'alpha')) { + $action = 'setashome'; +} +if (GETPOST('editmeta', 'alpha')) { + $action = 'editmeta'; +} +if (GETPOST('editsource', 'alpha')) { + $action = 'editsource'; +} +if (GETPOST('editcontent', 'alpha')) { + $action = 'editcontent'; +} +if (GETPOST('exportsite', 'alpha')) { + $action = 'exportsite'; +} +if (GETPOST('importsite', 'alpha')) { + $action = 'importsite'; +} +if (GETPOST('createfromclone', 'alpha')) { + $action = 'createfromclone'; +} +if (GETPOST('createpagefromclone', 'alpha')) { + $action = 'createpagefromclone'; +} +if (empty($action) && $file_manager) { + $action = 'file_manager'; +} +if (empty($action) && $replacesite) { + $action = 'replacesite'; +} +if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) { + $pageid = 0; +} // Load variable for pagination $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (! $sortfield) $sortfield='name'; //if (! $sortorder) $sortorder='ASC'; -if (empty($action)) $action = 'preview'; +if (empty($action)) { + $action = 'preview'; +} $object = new Website($db); $objectpage = new WebsitePage($db); @@ -109,16 +151,13 @@ $objectpage = new WebsitePage($db); $object->fetchAll('ASC', 'position'); // Init $object->records with list of websites // If website not defined, we take first found -if (!($websiteid > 0) && empty($websitekey) && $action != 'createsite') -{ - foreach ($object->records as $key => $valwebsite) - { +if (!($websiteid > 0) && empty($websitekey) && $action != 'createsite') { + foreach ($object->records as $key => $valwebsite) { $websitekey = $valwebsite->ref; break; } } -if ($websiteid > 0 || $websitekey) -{ +if ($websiteid > 0 || $websitekey) { $res = $object->fetch($websiteid, $websitekey); $websitekey = $object->ref; } @@ -126,38 +165,33 @@ if ($websiteid > 0 || $websitekey) $website = $object; // Check pageid received as parameter -if ($pageid < 0) $pageid = 0; -if (($pageid > 0 || $pageref) && $action != 'addcontainer') -{ +if ($pageid < 0) { + $pageid = 0; +} +if (($pageid > 0 || $pageref) && $action != 'addcontainer') { $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); - if ($res == 0) - { + if ($res == 0) { $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref); } // Check if pageid is inside the new website, if not we reset param pageid - if ($res >= 0 && $object->id > 0) - { - if ($objectpage->fk_website != $object->id) // We have a bad page that does not belong to web site - { - if ($object->fk_default_home > 0) - { + if ($res >= 0 && $object->id > 0) { + if ($objectpage->fk_website != $object->id) { // We have a bad page that does not belong to web site + if ($object->fk_default_home > 0) { $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site - if ($res > 0) $pageid = $object->fk_default_home; - } - else { - $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site - if ($res == 0) // Page was not found, we reset it - { - $objectpage = new WebsitePage($db); + if ($res > 0) { + $pageid = $object->fk_default_home; } - else // We found a page, we set pageid to it. + } else { + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site + if ($res == 0) { // Page was not found, we reset it + $objectpage = new WebsitePage($db); + } else // We found a page, we set pageid to it. { $pageid = $objectpage->id; } } - } - else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. + } else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. { $pageid = $objectpage->id; } @@ -165,20 +199,23 @@ if (($pageid > 0 || $pageref) && $action != 'addcontainer') } // Define pageid if pageid and pageref not received as parameter or was wrong -if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createcontainer') -{ +if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createcontainer') { $pageid = $object->fk_default_home; - if (empty($pageid)) - { + if (empty($pageid)) { $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); - if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + if (!is_array($array) && $array < 0) { + dol_print_error('', $objectpage->error, $objectpage->errors); + } $atleastonepage = (is_array($array) && count($array) > 0); $firstpageid = 0; $homepageid = 0; - foreach ($array as $key => $valpage) - { - if (empty($firstpageid)) $firstpageid = $valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; + foreach ($array as $key => $valpage) { + if (empty($firstpageid)) { + $firstpageid = $valpage->id; + } + if ($object->fk_default_home && $key == $object->fk_default_home) { + $homepageid = $valpage->id; + } } $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page } @@ -267,9 +304,15 @@ $manifestjsoncontentdefault .= '{ $listofpages = array(); $algo = ''; -if (GETPOST('optionmeta')) $algo .= 'meta'; -if (GETPOST('optioncontent')) $algo .= 'content'; -if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; +if (GETPOST('optionmeta')) { + $algo .= 'meta'; +} +if (GETPOST('optioncontent')) { + $algo .= 'content'; +} +if (GETPOST('optionsitefiles')) { + $algo .= 'sitefiles'; +} if (empty($sortfield)) { if ($action == 'file_manager') { @@ -301,43 +344,49 @@ $permissiontodelete = $user->rights->website->delete; */ // Protections -if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) -{ +if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) { $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. } -if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. -{ - if ($action == 'addsite') $action = 'preview'; - if ($action == 'updatesource') $action = 'preview'; +if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) { // If we change the site, we reset the pageid and cancel addsite action. + if ($action == 'addsite') { + $action = 'preview'; + } + if ($action == 'updatesource') { + $action = 'preview'; + } $pageid = $object->fk_default_home; - if (empty($pageid)) - { + if (empty($pageid)) { $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); - if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + if (!is_array($array) && $array < 0) { + dol_print_error('', $objectpage->error, $objectpage->errors); + } $atleastonepage = (is_array($array) && count($array) > 0); $firstpageid = 0; $homepageid = 0; - foreach ($array as $key => $valpage) - { - if (empty($firstpageid)) $firstpageid = $valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; + foreach ($array as $key => $valpage) { + if (empty($firstpageid)) { + $firstpageid = $valpage->id; + } + if ($object->fk_default_home && $key == $object->fk_default_home) { + $homepageid = $valpage->id; + } } $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page } } -if (GETPOST('refreshpage', 'alpha') && !in_array($action, array('updatecss'))) $action = 'preview'; +if (GETPOST('refreshpage', 'alpha') && !in_array($action, array('updatecss'))) { + $action = 'preview'; +} if ($cancel && $action == 'renamefile') { $cancel = ''; } // Cancel -if ($cancel) -{ +if ($cancel) { $action = 'preview'; - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } @@ -345,8 +394,12 @@ if ($cancel) $savbacktopage = $backtopage; $backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha') ? '&section_dir='.urlencode(GETPOST('section_dir', 'alpha')) : ''); // used after a confirm_deletefile into actions_linkedfiles.inc.php -if ($sortfield) $backtopage .= '&sortfield='.$sortfield; -if ($sortorder) $backtopage .= '&sortorder='.$sortorder; +if ($sortfield) { + $backtopage .= '&sortfield='.$sortfield; +} +if ($sortorder) { + $backtopage .= '&sortorder='.$sortorder; +} include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $backtopage = $savbacktopage; @@ -354,43 +407,37 @@ if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core $action = 'file_manager'; } -if ($action == 'seteditinline') -{ +if ($action == 'seteditinline') { dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); //dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } -if ($action == 'unseteditinline') -{ +if ($action == 'unseteditinline') { dolibarr_del_const($db, 'WEBSITE_EDITINLINE'); header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } -if ($action == 'setshowsubcontainers') -{ +if ($action == 'setshowsubcontainers') { dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); //dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } -if ($action == 'unsetshowsubcontainers') -{ +if ($action == 'unsetshowsubcontainers') { dolibarr_del_const($db, 'WEBSITE_SUBCONTAINERSINLINE'); header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } -if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && !$searchkey) -{ +if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && !$searchkey) { $action = 'replacesite'; $massaction = ''; } // Set category -if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) -{ +if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) { $error = 0; $nbupdate = 0; @@ -429,17 +476,14 @@ if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $us } // Replacement of string into pages -if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha')) -{ +if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha')) { $replacestring = GETPOST('replacestring', 'none'); if (empty($user->rights->website->writephp)) { setEventMessages("NotAllowedToAddDynamicContent", null, 'errors'); - } - elseif (!$replacestring) { + } elseif (!$replacestring) { setEventMessages("ErrorReplaceStringEmpty", null, 'errors'); - } - else { + } else { $nbreplacement = 0; foreach ($toselect as $keyselected) { @@ -461,15 +505,13 @@ if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha')) // Save page alias $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) - { + if (!$result) { setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); } // Save page of content $result = dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { + if ($result) { $nbreplacement++; //var_dump($objectpage->content);exit; $objectpage->update($user); @@ -524,31 +566,26 @@ if ($action == 'adddir' && $permtouploadfile) */ // Add site -if ($action == 'addsite') -{ +if ($action == 'addsite') { $db->begin(); - if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) - { + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); } - if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) - { + if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (!$error && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) - { + if (!$error && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); } - if (!$error) - { + if (!$error) { $arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml')); foreach ($arrayotherlang as $key => $val) { $arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only @@ -562,75 +599,64 @@ if ($action == 'addsite') $tmpobject->virtualhost = GETPOST('virtualhost', 'alpha'); $result = $tmpobject->create($user); - if ($result <= 0) - { + if ($result <= 0) { $error++; setEventMessages($tmpobject->error, $tmpobject->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs'); $action = ''; header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); exit; - } - else { + } else { $db->rollback(); $action = 'createsite'; } - if (!$error) - { + if (!$error) { $action = 'preview'; $id = $object->id; } } // Add page/container -if ($action == 'addcontainer') -{ +if ($action == 'addcontainer') { dol_mkdir($pathofwebsite); $db->begin(); $objectpage->fk_website = $object->id; - if (GETPOSTISSET('fetchexternalurl')) // Fetch from external url - { + if (GETPOSTISSET('fetchexternalurl')) { // Fetch from external url $urltograb = GETPOST('externalurl', 'alpha'); $grabimages = GETPOST('grabimages', 'alpha'); $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - if (empty($urltograb)) - { + if (empty($urltograb)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'createcontainer'; - } - elseif (!preg_match('/^http/', $urltograb)) - { + } elseif (!preg_match('/^http/', $urltograb)) { $error++; $langs->load("errors"); setEventMessages('Error URL must start with http:// or https://', null, 'errors'); $action = 'createcontainer'; } - if (!$error) - { + if (!$error) { // Clean url to grab, so url can be // http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa $urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb); //$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb); $urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam); - if (empty($urltograbwithoutdomainandparam) && !preg_match('/\/$/', $urltograb)) - { + if (empty($urltograbwithoutdomainandparam) && !preg_match('/\/$/', $urltograb)) { $urltograb .= '/'; } $pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/', '-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); @@ -642,34 +668,27 @@ if ($action == 'addcontainer') } // Check pageurl is not already used - if ($pageurl) - { + if ($pageurl) { $tmpwebsitepage = new WebsitePage($db); $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); $error++; $action = 'createcontainer'; } } - if (!$error) - { + if (!$error) { $tmp = getURLContent($urltograb); - if ($tmp['curl_error_no']) - { + if ($tmp['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); $action = 'createcontainer'; - } - elseif ($tmp['http_code'] != '200') - { + } elseif ($tmp['http_code'] != '200') { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); $action = 'createcontainer'; - } - else { + } else { // Remove comments $tmp['content'] = removeHtmlComment($tmp['content']); @@ -679,36 +698,34 @@ if ($action == 'addcontainer') $head = $regs[1]; $objectpage->type_container = 'page'; - $objectpage->pageurl = $pageurl; - if (empty($objectpage->pageurl)) - { - $tmpdomain = getDomainFromURL($urltograb); - $objectpage->pageurl = $tmpdomain.'-home'; - } + $objectpage->pageurl = $pageurl; + if (empty($objectpage->pageurl)) { + $tmpdomain = getDomainFromURL($urltograb); + $objectpage->pageurl = $tmpdomain.'-home'; + } - $objectpage->aliasalt = ''; + $objectpage->aliasalt = ''; - if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1]; + if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) { + $objectpage->aliasalt = $regs[1]; + } - $regtmp = array(); - if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp)) - { + $regtmp = array(); + if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp)) { $objectpage->title = $regtmp[1]; } - if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) - { - if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> + if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { + if (empty($objectpage->title)) { + $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> + } } - if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) - { + if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { $objectpage->description = $regtmp[1]; } - if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) - { + if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { $objectpage->keywords = $regtmp[1]; } - if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) - { + if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) { $tmplang = explode('-', $regtmp[1]); $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); } @@ -749,22 +766,18 @@ if ($action == 'addcontainer') // We grab files found into <script> tags preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs); $errorforsubresource = 0; - foreach ($regs[0] as $key => $val) - { + foreach ($regs[0] as $key => $val) { dol_syslog("We will grab the script resource found into script tag ".$regs[2][$key]); $linkwithoutdomain = $regs[2][$key]; - if (preg_match('/^\//', $regs[2][$key])) - { + if (preg_match('/^\//', $regs[2][$key])) { $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot - } - else { + } else { $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; - if (preg_match('/^http/', $regs[2][$key])) - { + if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; @@ -776,17 +789,19 @@ if ($action == 'addcontainer') // Test if this is an external URL of grabbed web site. If yes, we do not load resource $domaintograb = getDomainFromURL($urltograbdirwithoutslash); $domaintograbbis = getDomainFromURL($urltograbbis); - if ($domaintograb != $domaintograbbis) continue; + if ($domaintograb != $domaintograbbis) { + continue; + } /* - $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) - { - $error++; - setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $errorforsubresource++; - $action='createcontainer'; - } + $tmpgeturl = getURLContent($urltograbbis); + if ($tmpgeturl['curl_error_no']) + { + $error++; + setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); + $errorforsubresource++; + $action='createcontainer'; + } elseif ($tmpgeturl['http_code'] != '200') { $error++; @@ -795,15 +810,15 @@ if ($action == 'addcontainer') $action='createcontainer'; } else - { - dol_mkdir(dirname($filetosave)); + { + dol_mkdir(dirname($filetosave)); - $fp = fopen($filetosave, "w"); - fputs($fp, $tmpgeturl['content']); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + $fp = fopen($filetosave, "w"); + fputs($fp, $tmpgeturl['content']); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } */ //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; @@ -817,22 +832,18 @@ if ($action == 'addcontainer') preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs); $errorforsubresource = 0; - foreach ($regs[0] as $key => $val) - { + foreach ($regs[0] as $key => $val) { dol_syslog("We will grab the css resources found into link tag ".$regs[2][$key]); $linkwithoutdomain = $regs[2][$key]; - if (preg_match('/^\//', $regs[2][$key])) - { + if (preg_match('/^\//', $regs[2][$key])) { $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot - } - else { + } else { $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; - if (preg_match('/^http/', $regs[2][$key])) - { + if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; @@ -844,24 +855,22 @@ if ($action == 'addcontainer') // Test if this is an external URL of grabbed web site. If yes, we do not load resource $domaintograb = getDomainFromURL($urltograbdirwithoutslash); $domaintograbbis = getDomainFromURL($urltograbbis); - if ($domaintograb != $domaintograbbis) continue; + if ($domaintograb != $domaintograbbis) { + continue; + } $tmpgeturl = getURLContent($urltograbbis); - if ($tmpgeturl['curl_error_no']) - { + if ($tmpgeturl['curl_error_no']) { $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); $action = 'createcontainer'; - } - elseif ($tmpgeturl['http_code'] != '200') - { + } elseif ($tmpgeturl['http_code'] != '200') { $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); $action = 'createcontainer'; - } - else { + } else { // Clean some comment //$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1); //$tmpgeturl['content'] = utf8_encode(utf8_decode($tmpgeturl['content'])); @@ -959,7 +968,9 @@ if ($action == 'addcontainer') $objectpage->fk_page = $pageidfortranslation; $sample = GETPOST('sample', 'alpha'); - if (empty($sample)) $sample = 'empty'; + if (empty($sample)) { + $sample = 'empty'; + } $pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.dol_sanitizeFileName($sample).'.html'; @@ -967,38 +978,31 @@ if ($action == 'addcontainer') $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } - if (!$error) - { - if (empty($objectpage->pageurl)) - { + if (!$error) { + if (empty($objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); $error++; $action = 'createcontainer'; - } - elseif (!preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) - { + } elseif (!preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); $error++; $action = 'createcontainer'; } - if (empty($objectpage->title)) - { + if (empty($objectpage->title)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); $error++; $action = 'createcontainer'; } - if ($objectpage->fk_page > 0 && empty($objectpage->lang)) - { + if ($objectpage->fk_page > 0 && empty($objectpage->lang)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorLanguageRequiredIfPageIsTranslationOfAnother"), null, 'errors'); $error++; $action = 'createcontainer'; } - if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) - { + if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) { if ($objectpage->lang == $website->lang) { $langs->load("errors"); setEventMessages($langs->trans("ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"), null, 'errors'); @@ -1008,8 +1012,7 @@ if ($action == 'addcontainer') } } - if (!$error) - { + if (!$error) { $pageid = $objectpage->create($user); if ($pageid <= 0) { $error++; @@ -1022,8 +1025,7 @@ if ($action == 'addcontainer') // Website categories association $categoriesarray = GETPOST('categories', 'array'); $result = $objectpage->setCategories($categoriesarray); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } @@ -1034,8 +1036,7 @@ if ($action == 'addcontainer') if (empty($object->fk_default_home)) { $object->fk_default_home = $pageid; $res = $object->update($user); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -1044,50 +1045,44 @@ if ($action == 'addcontainer') // Generate the index.php page (to be the home page) and wrapper.php file $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); - if ($result <= 0) setEventMessages('Failed to write file '.$fileindex, null, 'errors'); + if ($result <= 0) { + setEventMessages('Failed to write file '.$fileindex, null, 'errors'); + } } } } - if (!$error) - { - if (!empty($objectpage->content)) - { + if (!$error) { + if (!empty($objectpage->content)) { $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; // Save page alias $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) - { + if (!$result) { setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); } // Save page of content $result = dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { + if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - } - else { + } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); $action = 'createcontainer'; } } } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); $action = ''; - } - else { + } else { $db->rollback(); } - if (!$error) - { + if (!$error) { $pageid = $objectpage->id; // To generate the CSS, robot and htmlheader file. @@ -1095,64 +1090,54 @@ if ($action == 'addcontainer') // Check symlink to medias and restore it if ko $pathtomedias = DOL_DATA_ROOT.'/medias'; $pathtomediasinwebsite = $pathofwebsite.'/medias'; - if (!is_link(dol_osencode($pathtomediasinwebsite))) - { + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } // Now generate the master.inc.php page if it does not exists yet - if (!dol_is_file($filemaster)) - { + if (!dol_is_file($filemaster)) { $result = dolSaveMasterFile($filemaster); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemaster, null, 'errors'); } } - if (!dol_is_file($filehtmlheader)) - { + if (!dol_is_file($filehtmlheader)) { $htmlheadercontent = "<html>\n"; $htmlheadercontent .= $htmlheadercontentdefault; $htmlheadercontent .= "</html>"; $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); } - if (!dol_is_file($filecss)) - { + if (!dol_is_file($filecss)) { $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; $result = dolSaveCssFile($filecss, $csscontent); } - if (!dol_is_file($filejs)) - { + if (!dol_is_file($filejs)) { $jscontent = "/* JS content (all pages) */\n"; $result = dolSaveJsFile($filejs, $jscontent); } - if (!dol_is_file($filerobot)) - { + if (!dol_is_file($filerobot)) { $robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/"; $result = dolSaveRobotFile($filerobot, $robotcontent); } - if (!dol_is_file($filehtaccess)) - { + if (!dol_is_file($filehtaccess)) { $htaccesscontent = "# Order allow,deny\n# Deny from all"; $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); } - if (!dol_is_file($filemanifestjson)) - { + if (!dol_is_file($filemanifestjson)) { $manifestjsoncontent = ""; $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); } - if (!dol_is_file($filereadme)) - { + if (!dol_is_file($filereadme)) { $readmecontent = "Website generated by Dolibarr ERP CRM"; $result = dolSaveReadme($filereadme, $readmecontent); } @@ -1162,8 +1147,7 @@ if ($action == 'addcontainer') } // Delete site -if ($action == 'confirm_deletesite' && $confirm == 'yes') -{ +if ($action == 'confirm_deletesite' && $confirm == 'yes') { $error = 0; $db->begin(); @@ -1171,40 +1155,33 @@ if ($action == 'confirm_deletesite' && $confirm == 'yes') $res = $object->fetch(GETPOST('id', 'int')); $website = $object; - if ($res > 0) - { + if ($res > 0) { $res = $object->delete($user); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - if (!$error) - { - if (GETPOST('delete_also_js', 'alpha') == 'on') - { + if (!$error) { + if (GETPOST('delete_also_js', 'alpha') == 'on') { $pathofwebsitejs = DOL_DATA_ROOT.'/medias/js/'.$object->ref; dol_delete_dir_recursive($pathofwebsitejs); } - if (GETPOST('delete_also_medias', 'alpha') == 'on') - { + if (GETPOST('delete_also_medias', 'alpha') == 'on') { $pathofwebsitemedias = DOL_DATA_ROOT.'/medias/image/'.$object->ref; dol_delete_dir_recursive($pathofwebsitemedias); } } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteDeleted", $object->ref), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); exit; - } - else { + } else { $db->rollback(); dol_print_error($db); } @@ -1221,25 +1198,21 @@ if (GETPOSTISSET('pageid') && $action == 'delete' && $permissiontodelete) { $res = $objectpage->fetch($pageid, $object->id); - if ($res > 0) - { + if ($res > 0) { $res = $objectpage->delete($user); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $websitekey), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey); exit; - } - else { + } else { $db->rollback(); dol_print_error($db); } @@ -1250,25 +1223,23 @@ if (!GETPOSTISSET('pageid')) { // Add part of code from actions_massactions.inc.php // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) - if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) - { + if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $result = $objecttmp->delete($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1276,10 +1247,12 @@ if (!GETPOSTISSET('pageid')) { } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1302,29 +1275,23 @@ if (!GETPOSTISSET('pageid')) { } // Update css Update site properties -if ($action == 'updatecss') -{ +if ($action == 'updatecss') { // If we tried to reload another site/page, we stay on editcss mode. - if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) - { + if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) { $action = 'editcss'; - } - else { + } else { $res = $object->fetch(0, $websitekey); $website = $object; - if (GETPOSTISSET('virtualhost')) - { + if (GETPOSTISSET('virtualhost')) { $tmpvirtualhost = preg_replace('/\/$/', '', GETPOST('virtualhost', 'alpha')); - if ($tmpvirtualhost && !preg_match('/^http/', $tmpvirtualhost)) - { + if ($tmpvirtualhost && !preg_match('/^http/', $tmpvirtualhost)) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); $action = 'editcss'; } - if (!$error) - { + if (!$error) { $arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml')); foreach ($arrayotherlang as $key => $val) { $arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only @@ -1336,8 +1303,7 @@ if ($action == 'updatecss') $object->use_manifest = GETPOST('use_manifest', 'alpha'); $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'editcss'; @@ -1345,8 +1311,7 @@ if ($action == 'updatecss') } } - if (!$error) - { + if (!$error) { // Save master.inc.php file dol_syslog("Save master file ".$filemaster); @@ -1354,8 +1319,7 @@ if ($action == 'updatecss') // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemaster, null, 'errors'); } @@ -1365,26 +1329,25 @@ if ($action == 'updatecss') $htmlheadercontent = ''; /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. - $htmlheadercontent.= "<?php // BEGIN PHP\n"; - $htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n"; - $htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; - $htmlheadercontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $htmlheadercontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $htmlheadercontent.= "ob_start();\n"; - // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page - $htmlheadercontent.= "// END PHP ?>\n";*/ + $htmlheadercontent.= "<?php // BEGIN PHP\n"; + $htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n"; + $htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; + $htmlheadercontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $htmlheadercontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $htmlheadercontent.= "ob_start();\n"; + // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page + $htmlheadercontent.= "// END PHP ?>\n";*/ $htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none')); /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; - $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; - $htmlheadercontent.= "// END PHP ?>"."\n";*/ + $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; + $htmlheadercontent.= "// END PHP ?>"."\n";*/ $htmlheadercontent = trim($htmlheadercontent)."\n"; $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); } @@ -1414,8 +1377,7 @@ if ($action == 'updatecss') dol_syslog("Save css content into ".$filecss); $result = dolSaveCssFile($filecss, $csscontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filecss, null, 'errors'); } @@ -1441,8 +1403,7 @@ if ($action == 'updatecss') $jscontent .= "// END PHP ?>\n"; $result = dolSaveJsFile($filejs, $jscontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filejs, null, 'errors'); } @@ -1452,24 +1413,23 @@ if ($action == 'updatecss') $robotcontent = ''; /*$robotcontent.= "<?php // BEGIN PHP\n"; - $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; - $robotcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; - $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $robotcontent.= "ob_start();\n"; - $robotcontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $robotcontent.= "header('Content-type: text/css');\n"; - $robotcontent.= "// END PHP ?>\n";*/ + $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; + $robotcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; + $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $robotcontent.= "ob_start();\n"; + $robotcontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $robotcontent.= "header('Content-type: text/css');\n"; + $robotcontent.= "// END PHP ?>\n";*/ $robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'restricthtml'))."\n"; /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; - $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; - $robotcontent.= "// END PHP ?>"."\n";*/ + $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; + $robotcontent.= "// END PHP ?>"."\n";*/ $result = dolSaveRobotFile($filerobot, $robotcontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filerobot, null, 'errors'); } @@ -1480,87 +1440,80 @@ if ($action == 'updatecss') $htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'restricthtml'))."\n"; $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); } - // manifest.json file - $manifestjsoncontent = ''; + // manifest.json file + $manifestjsoncontent = ''; - $manifestjsoncontent .= "<?php // BEGIN PHP\n"; - $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; - $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file. - $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $manifestjsoncontent .= "ob_start();\n"; - $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; - $manifestjsoncontent .= "// END PHP ?>\n"; + $manifestjsoncontent .= "<?php // BEGIN PHP\n"; + $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; + $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file. + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $manifestjsoncontent .= "ob_start();\n"; + $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; + $manifestjsoncontent .= "// END PHP ?>\n"; - $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; + $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; - $manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; - $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; - $manifestjsoncontent .= "// END PHP ?>\n"; + $manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; + $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; + $manifestjsoncontent .= "// END PHP ?>\n"; - $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); - if (!$result) - { - $error++; - setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); - } + $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); + if (!$result) { + $error++; + setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); + } - // README.md file - $readmecontent = ''; + // README.md file + $readmecontent = ''; - /*$readmecontent.= "<?php // BEGIN PHP\n"; - $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; - $readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $readmecontent.= "ob_start();\n"; - $readmecontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $readmecontent.= "header('Content-type: application/manifest+json');\n"; - $readmecontent.= "// END PHP ?>\n";*/ + /*$readmecontent.= "<?php // BEGIN PHP\n"; + $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; + $readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $readmecontent.= "ob_start();\n"; + $readmecontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $readmecontent.= "header('Content-type: application/manifest+json');\n"; + $readmecontent.= "// END PHP ?>\n";*/ - $readmecontent .= trim(GETPOST('WEBSITE_README', 'restricthtml'))."\n"; + $readmecontent .= trim(GETPOST('WEBSITE_README', 'restricthtml'))."\n"; - /*$readmecontent.= '<?php // BEGIN PHP'."\n"; - $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; - $readmecontent.= "// END PHP ?>"."\n";*/ + /*$readmecontent.= '<?php // BEGIN PHP'."\n"; + $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; + $readmecontent.= "// END PHP ?>"."\n";*/ - $result = dolSaveReadme($filereadme, $readmecontent); - if (!$result) - { - $error++; - setEventMessages('Failed to write file '.$filereadme, null, 'errors'); - } + $result = dolSaveReadme($filereadme, $readmecontent); + if (!$result) { + $error++; + setEventMessages('Failed to write file '.$filereadme, null, 'errors'); + } - // Save wrapper.php + // Save wrapper.php $result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper); // Message if no error - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); } - if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect - { + if (!GETPOSTISSET('updateandstay')) { // If we click on "Save And Stay", we don not make the redirect $action = 'preview'; - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } - } - else { + } else { $action = 'editcss'; } } @@ -1568,22 +1521,19 @@ if ($action == 'updatecss') } // Update page -if ($action == 'setashome') -{ +if ($action == 'setashome') { $db->begin(); $object->fetch(0, $websitekey); $website = $object; $object->fk_default_home = $pageid; $res = $object->update($user); - if (! ($res > 0)) - { + if (! ($res > 0)) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } - if (!$error) - { + if (!$error) { $db->commit(); $filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; @@ -1591,19 +1541,20 @@ if ($action == 'setashome') // Generate the index.php page to be the home page $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); - if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); - else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); + if ($result) { + setEventMessages($langs->trans("Saved"), null, 'mesgs'); + } else { + setEventMessages('Failed to write file '.$fileindex, null, 'errors'); + } $action = 'preview'; - } - else { + } else { $db->rollback(); } } // Update page properties (meta) -if ($action == 'updatemeta') -{ +if ($action == 'updatemeta') { $db->begin(); $result = $object->fetch(0, $websitekey); @@ -1612,8 +1563,7 @@ if ($action == 'updatemeta') $objectpage->fk_website = $object->id; // Check parameters - if (!preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) - { + if (!preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); @@ -1621,38 +1571,32 @@ if ($action == 'updatemeta') } $res = $objectpage->fetch($pageid, $object->id); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages('Page not found '.$objectpage->error, $objectpage->errors, 'errors'); } // Check alias not exists - if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) - { + if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) { $websitepagetemp = new WebsitePage($db); $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha')); - if ($result < 0) - { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($websitepagetemp->error, $websitepagetemp->errors, 'errors'); $action = 'editmeta'; } - if ($result > 0) - { + if ($result > 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null, 'errors'); $action = 'editmeta'; } } - if (!$error && GETPOST('WEBSITE_ALIASALT', 'alpha')) - { + if (!$error && GETPOST('WEBSITE_ALIASALT', 'alpha')) { $arrayofaliastotest = explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); $websitepagetemp = new WebsitePage($db); - foreach ($arrayofaliastotest as $aliastotest) - { + foreach ($arrayofaliastotest as $aliastotest) { // Disallow alias name pageX (already used to save the page with id) if (preg_match('/^page\d+/i', $aliastotest)) { $error++; @@ -1662,16 +1606,14 @@ if ($action == 'updatemeta') break; } else { $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest); - if ($result < 0) - { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($websitepagetemp->error, $websitepagetemp->errors, 'errors'); $action = 'editmeta'; break; } - if ($result > 0) - { + if ($result > 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null, 'errors'); @@ -1682,8 +1624,7 @@ if ($action == 'updatemeta') } } - if (!$error) - { + if (!$error) { $objectpage->old_object = clone $objectpage; $objectpage->title = str_replace(array('<', '>'), '', GETPOST('WEBSITE_TITLE', 'alphanohtml')); @@ -1703,20 +1644,19 @@ if ($action == 'updatemeta') $objectpage->fk_object = GETPOST('WEBSITE_OBJECTID', 'aZ09'); $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); - if ($newdatecreation) $objectpage->date_creation = $newdatecreation; + if ($newdatecreation) { + $objectpage->date_creation = $newdatecreation; + } $res = $objectpage->update($user); - if (!($res > 0)) - { + if (!($res > 0)) { $langs->load("errors"); - if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists"), null, 'errors'); $action = 'editmeta'; - } - else { + } else { $error++; $langs->load("errors"); setEventMessages($objectpage->error, $objectpage->errors, 'errors'); @@ -1729,23 +1669,19 @@ if ($action == 'updatemeta') // Website categories association $categoriesarray = GETPOST('categories', 'array'); $result = $objectpage->setCategories($categoriesarray); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); - } - else { + } else { $db->rollback(); } - if (!$error) - { + if (!$error) { $filemaster = $pathofwebsite.'/master.inc.php'; $fileoldalias = $pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; @@ -1754,11 +1690,12 @@ if ($action == 'updatemeta') // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) { + setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + } // Now delete the alias.php page - if (!empty($fileoldalias)) - { + if (!empty($fileoldalias)) { dol_syslog("We delete old alias page name=".$fileoldalias." to build a new alias page=".$filealias); dol_delete_file($fileoldalias); @@ -1774,13 +1711,10 @@ if ($action == 'updatemeta') } } // Now delete the alternative alias.php pages - if (!empty($objectpage->old_object->aliasalt)) - { + if (!empty($objectpage->old_object->aliasalt)) { $tmpaltaliases = explode(',', $objectpage->old_object->aliasalt); - if (is_array($tmpaltaliases)) - { - foreach ($tmpaltaliases as $tmpaliasalt) - { + if (is_array($tmpaltaliases)) { + foreach ($tmpaltaliases as $tmpaliasalt) { dol_syslog("We delete old alt alias pages name=".trim($tmpaliasalt)); dol_delete_file($pathofwebsite.'/'.trim($tmpaliasalt).'.php'); @@ -1800,20 +1734,20 @@ if ($action == 'updatemeta') // Save page main alias $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + if (!$result) { + setEventMessages('Failed to write file '.$filealias, null, 'errors'); + } // Save alt aliases - if (!empty($objectpage->aliasalt)) - { + if (!empty($objectpage->aliasalt)) { $tmpaltaliases = explode(',', $objectpage->aliasalt); - if (is_array($tmpaltaliases)) - { - foreach ($tmpaltaliases as $tmpaliasalt) - { - if (trim($tmpaliasalt)) - { + if (is_array($tmpaltaliases)) { + foreach ($tmpaltaliases as $tmpaliasalt) { + if (trim($tmpaliasalt)) { $filealias = $pathofwebsite.'/'.trim($tmpaliasalt).'.php'; $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); + if (!$result) { + setEventMessages('Failed to write file '.basename($filealias), null, 'errors'); + } } } } @@ -1822,24 +1756,20 @@ if ($action == 'updatemeta') // Save page of content $result = dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { + if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we do not make the redirect - { + if (!GETPOSTISSET('updateandstay')) { // If we click on "Save And Stay", we do not make the redirect //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; $action = 'preview'; - } - else { + } else { $action = 'editmeta'; } - } - else { + } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); - //exit; + //exit; $action = 'preview'; } } @@ -1847,27 +1777,23 @@ if ($action == 'updatemeta') // Update page if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'confirm_createfromclone' || $action == 'confirm_createpagefromclone') - || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) -{ + || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) { $object->fetch(0, $websitekey); $website = $object; - if ($action == 'confirm_createfromclone') - { + if ($action == 'confirm_createfromclone') { $db->begin(); $objectnew = new Website($db); $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : '')); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($objectnew->error, $objectnew->errors, 'errors'); $action = 'preview'; $db->rollback(); - } - else { + } else { $object = $objectnew; $id = $object->id; $pageid = $object->fk_default_home; @@ -1877,12 +1803,10 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } } - if ($action == 'confirm_createpagefromclone') - { + if ($action == 'confirm_createpagefromclone') { $istranslation = (GETPOST('is_a_translation', 'aZ09') == 'on' ? 1 : 0); // Protection if it is a translation page - if ($istranslation) - { + if ($istranslation) { if (GETPOST('newlang', 'aZ09') == $objectpage->lang || !GETPOST('newlang', 'aZ09')) { $error++; setEventMessages($langs->trans("LanguageMustNotBeSameThanClonedPage"), null, 'errors'); @@ -1895,27 +1819,23 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } } - if (!$error) - { + if (!$error) { $db->begin(); $newwebsiteid = GETPOST('newwebsite', 'int'); $pathofwebsitenew = $pathofwebsite; $tmpwebsite = new Website($db); - if ($newwebsiteid > 0 && $newwebsiteid != $object->id) - { + if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; - } - else { + } else { $tmpwebsite = $object; } $objectpage = new WebsitePage($db); $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('newpageurl', 'aZ09'), (GETPOST('newlang', 'aZ09') ? GETPOST('newlang', 'aZ09') : ''), $istranslation, $newwebsiteid, GETPOST('newtitle', 'alphanohtml')); - if ($resultpage < 0) - { + if ($resultpage < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); $action = 'createpagefromclone'; @@ -1933,8 +1853,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf dolSavePageContent($filetpl, $tmpwebsite, $resultpage); // Switch on the new page if web site of new page/container is same - if (empty($newwebsiteid) || $newwebsiteid == $object->id) - { + if (empty($newwebsiteid) || $newwebsiteid == $object->id) { $pageid = $resultpage->id; } @@ -1945,47 +1864,39 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $res = 0; - if (!$error) - { + if (!$error) { // Check symlink to medias and restore it if ko $pathtomedias = DOL_DATA_ROOT.'/medias'; $pathtomediasinwebsite = $pathofwebsite.'/medias'; - if (!is_link(dol_osencode($pathtomediasinwebsite))) - { + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) - { - $object->virtualhost = GETPOST('previewsite', 'alpha'); - $object->update($user); - }*/ + { + $object->virtualhost = GETPOST('previewsite', 'alpha'); + $object->update($user); + }*/ $objectpage->fk_website = $object->id; - if ($pageid > 0) - { + if ($pageid > 0) { $res = $objectpage->fetch($pageid); - } - else { + } else { $res = 0; - if ($object->fk_default_home > 0) - { + if ($object->fk_default_home > 0) { $res = $objectpage->fetch($object->fk_default_home); } - if (!($res > 0)) - { + if (!($res > 0)) { $res = $objectpage->fetch(0, $object->id); } } } - if (!$error && $res > 0) - { - if ($action == 'updatesource' || $action == 'updatecontent') - { + if (!$error && $res > 0) { + if ($action == 'updatesource' || $action == 'updatecontent') { $db->begin(); $phpfullcodestringold = dolKeepOnlyPhpCode($objectpage->content); @@ -1996,29 +1907,32 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); //print dol_escape_htmltag($phpfullcodestring);exit; $forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open"); - if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files - { + if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) { // If option is not on, we disallow functions to write files $forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); } - foreach ($forbiddenphpcommands as $forbiddenphpcommand) - { - if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) - { + foreach ($forbiddenphpcommands as $forbiddenphpcommand) { + if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) { $error++; setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors'); - if ($action == 'updatesource') $action = 'editsource'; - if ($action == 'updatecontent') $action = 'editcontent'; + if ($action == 'updatesource') { + $action = 'editsource'; + } + if ($action == 'updatecontent') { + $action = 'editcontent'; + } } } - if (empty($user->rights->website->writephp)) - { - if ($phpfullcodestringold != $phpfullcodestring) - { + if (empty($user->rights->website->writephp)) { + if ($phpfullcodestringold != $phpfullcodestring) { $error++; setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors'); - if ($action == 'updatesource') $action = 'editsource'; - if ($action == 'updatecontent') $action = 'editcontent'; + if ($action == 'updatesource') { + $action = 'editsource'; + } + if ($action == 'updatecontent') { + $action = 'editcontent'; + } } } @@ -2028,16 +1942,18 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $res = $objectpage->update($user); - if ($res < 0) - { + if ($res < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - if ($action == 'updatesource') $action = 'editsource'; - if ($action == 'updatecontent') $action = 'editcontent'; + if ($action == 'updatesource') { + $action = 'editsource'; + } + if ($action == 'updatecontent') { + $action = 'editcontent'; + } } - if (!$error) - { + if (!$error) { $db->commit(); $filemaster = $pathofwebsite.'/master.inc.php'; @@ -2049,7 +1965,9 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (!$result) setEventMessages('Failed to write the master file file '.$filemaster, null, 'errors'); + if (!$result) { + setEventMessages('Failed to write the master file file '.$filemaster, null, 'errors'); + } // Now delete the old alias.php page if we removed one /*if (!empty($fileoldalias)) @@ -2071,16 +1989,16 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Save page alias $result = dolSavePageAlias($filealias, $object, $objectpage); - if (!$result) setEventMessages('Failed to write the alias file '.basename($filealias), null, 'errors'); + if (!$result) { + setEventMessages('Failed to write the alias file '.basename($filealias), null, 'errors'); + } // Save page content $result = dolSavePageContent($filetpl, $object, $objectpage); - if ($result) - { + if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we do not make the redirect - { + if (!GETPOSTISSET('updateandstay')) { // If we click on "Save And Stay", we do not make the redirect if ($backtopage) { header("Location: ".$backtopage); exit; @@ -2089,13 +2007,17 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf exit; } } else { - if ($action == 'updatesource') $action = 'editsource'; - if ($action == 'updatecontent') $action = 'editcontent'; + if ($action == 'updatesource') { + $action = 'editsource'; + } + if ($action == 'updatecontent') { + $action = 'editcontent'; + } } } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); - exit; + exit; } } else { $db->rollback(); @@ -2105,10 +2027,8 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf exit; } } else { - if (!$error) - { - if (empty($websitekey) || $websitekey == '-1') - { + if (!$error) { + if (empty($websitekey) || $websitekey == '-1') { setEventMessages($langs->trans("NoWebSiteCreateOneFirst"), null, 'warnings'); } else { setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); @@ -2119,12 +2039,10 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } // Export site -if ($action == 'exportsite') -{ +if ($action == 'exportsite') { $fileofzip = $object->exportWebSite(); - if ($fileofzip) - { + if ($fileofzip) { $file_name = basename($fileofzip); header("Content-Type: application/zip"); @@ -2133,19 +2051,16 @@ if ($action == 'exportsite') readfile($fileofzip); exit; - } - else { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'preview'; } } // Regenerate site -if ($action == 'regeneratesite') -{ +if ($action == 'regeneratesite') { $result = $object->rebuildWebSiteFiles(); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("PagesRegenerated", $result), null, 'mesgs'); $action = 'preview'; } else { @@ -2155,83 +2070,68 @@ if ($action == 'regeneratesite') } // Import site -if ($action == 'importsiteconfirm') -{ - if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) - { +if ($action == 'importsiteconfirm') { + if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; - } - else { - if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) - { + } else { + if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) { // Check symlink to medias and restore it if ko $pathtomedias = DOL_DATA_ROOT.'/medias'; $pathtomediasinwebsite = $pathofwebsite.'/medias'; - if (!is_link(dol_osencode($pathtomediasinwebsite))) - { + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); - if (!$result) - { + if (!$result) { setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors'); $action = 'importsite'; } } $fileofzip = ''; - if (GETPOSTISSET('templateuserfile')) - { + if (GETPOSTISSET('templateuserfile')) { $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); - } - elseif (!empty($_FILES)) - { - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; - else $userfiles = array($_FILES['userfile']['tmp_name']); + } elseif (!empty($_FILES)) { + if (is_array($_FILES['userfile']['tmp_name'])) { + $userfiles = $_FILES['userfile']['tmp_name']; + } else { + $userfiles = array($_FILES['userfile']['tmp_name']); + } - foreach ($userfiles as $key => $userfile) - { - if (empty($_FILES['userfile']['tmp_name'][$key])) - { + foreach ($userfiles as $key => $userfile) { + if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); $action = 'importsite'; - } - else { + } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; } } } - if (!$error) - { + if (!$error) { $upload_dir = $conf->website->dir_temp; $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); } // Get name of file (take last one if several name provided) $fileofzip = $upload_dir.'/unknown'; - foreach ($_FILES as $key => $ifile) - { - foreach ($ifile['name'] as $key2 => $ifile2) - { + foreach ($_FILES as $key => $ifile) { + foreach ($ifile['name'] as $key2 => $ifile2) { $fileofzip = $upload_dir.'/'.$ifile2; } } } - if (!$error) - { + if (!$error) { $result = $object->importWebSite($fileofzip); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'importsite'; - } - else { + } else { // Force mode dynamic on dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1, 'chaine', 0, '', $conf->entity); @@ -2271,7 +2171,9 @@ $moreheadjs = ''; $arrayofjs[] = 'includes/jquery/plugins/blockUI/jquery.blockUI.js'; $arrayofjs[] = 'core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) { + $arrayofjs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +} $moreheadjs .= '<script type="text/javascript">'."\n"; $moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; @@ -2284,56 +2186,43 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/ print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; -if ($action == 'createsite') -{ +if ($action == 'createsite') { print '<input type="hidden" name="action" value="addsite">'; } -if ($action == 'createcontainer') -{ +if ($action == 'createcontainer') { print '<input type="hidden" name="action" value="addcontainer">'; } -if ($action == 'editcss') -{ +if ($action == 'editcss') { print '<input type="hidden" name="action" value="updatecss">'; } -if ($action == 'editmenu') -{ +if ($action == 'editmenu') { print '<input type="hidden" name="action" value="updatemenu">'; } -if ($action == 'setashome') -{ +if ($action == 'setashome') { print '<input type="hidden" name="action" value="updateashome">'; } -if ($action == 'editmeta') -{ +if ($action == 'editmeta') { print '<input type="hidden" name="action" value="updatemeta">'; } -if ($action == 'editsource') -{ +if ($action == 'editsource') { print '<input type="hidden" name="action" value="updatesource">'; } -if ($action == 'editcontent') -{ +if ($action == 'editcontent') { print '<input type="hidden" name="action" value="updatecontent">'; } -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="hidden" name="action" value="update">'; } -if ($action == 'importsite') -{ +if ($action == 'importsite') { print '<input type="hidden" name="action" value="importsiteconfirm">'; } -if ($action == 'file_manager') -{ +if ($action == 'file_manager') { print '<input type="hidden" name="action" value="file_manager">'; } -if ($action == 'replacesite') -{ +if ($action == 'replacesite') { print '<input type="hidden" name="action" value="replacesiteconfirm">'; } -if ($action == 'replacesiteconfirm') -{ +if ($action == 'replacesiteconfirm') { print '<input type="hidden" name="action" value="replacesiteconfirm">'; } @@ -2341,28 +2230,33 @@ print '<div>'; // Add a margin under toolbar ? $style = ''; -if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource' && !GETPOST('createpagefromclone', 'alphanohtml')) $style = ' margin-bottom: 5px;'; +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource' && !GETPOST('createpagefromclone', 'alphanohtml')) { + $style = ' margin-bottom: 5px;'; +} -if (!GETPOST('hide_websitemenu')) -{ +if (!GETPOST('hide_websitemenu')) { $disabled = ''; - if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; + if (empty($user->rights->website->write)) { + $disabled = ' disabled="disabled"'; + } - if ($websitekey) - { + if ($websitekey) { $virtualurl = ''; $dataroot = DOL_DATA_ROOT.'/website/'.$websitekey; - if (!empty($object->virtualhost)) $virtualurl = $object->virtualhost; + if (!empty($object->virtualhost)) { + $virtualurl = $object->virtualhost; + } } $array = array(); - if ($object->id > 0) - { + if ($object->id > 0) { $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); $object->lines = $array; } - if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + if (!is_array($array) && $array < 0) { + dol_print_error('', $objectpage->error, $objectpage->errors); + } $atleastonepage = (is_array($array) && count($array) > 0); @@ -2390,21 +2284,26 @@ if (!GETPOST('hide_websitemenu')) print '<span class="websiteselection">'; $out = ''; $out .= '<select name="website" class="minwidth100 width200 maxwidth150onsmartphone" id="website">'; - if (empty($object->records)) $out .= '<option value="-1">&nbsp;</option>'; + if (empty($object->records)) { + $out .= '<option value="-1">&nbsp;</option>'; + } if (!empty($conf->use_javascript_ajax)) { $valueoption = '<span class="classlink">'.img_picto('', 'add', 'class="paddingrightonly"').$langs->trans("AddWebsite").'</span>'; $out .= '<option value="-2" data-html="'.dol_escape_htmltag($valueoption).'">'.$valueoption.'</option>'; } // Loop on each sites $i = 0; - foreach ($object->records as $key => $valwebsite) - { + foreach ($object->records as $key => $valwebsite) { if (empty($websitekey)) { - if ($action != 'createsite') $websitekey = $valwebsite->ref; + if ($action != 'createsite') { + $websitekey = $valwebsite->ref; + } } $out .= '<option value="'.$valwebsite->ref.'"'; - if ($websitekey == $valwebsite->ref) $out .= ' selected'; // To preselect a value + if ($websitekey == $valwebsite->ref) { + $out .= ' selected'; // To preselect a value + } //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' '; $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span class="opacitymedium">' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>' : ''); $out .= ' data-html="'.dol_escape_htmltag($outoption).'"'; @@ -2436,8 +2335,7 @@ if (!GETPOST('hide_websitemenu')) print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshsite" value="'.$langs->trans("Load").'">'; } - if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) - { + if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { print ' &nbsp; '; print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">'; @@ -2449,11 +2347,9 @@ if (!GETPOST('hide_websitemenu')) $exportlabel = $langs->trans("Export"); } - if ($atleastonepage) - { + if ($atleastonepage) { print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).'" name="importsite">'; - } - else { + } else { print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($importlabel).'" name="importsite">'; } @@ -2474,8 +2370,7 @@ if (!GETPOST('hide_websitemenu')) print '</span>'; - if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) - { + if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { print '<span class="websiteselection">'; //print '<a href="'.$_SERVER["PHP_SELF"].'?action=file_manager&website='.$website->ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("MediaFiles")).'"><span class="fa fa-image"><span></a>'; print dolButtonToOpenUrlInDialogPopup('file_manager', $langs->transnoentitiesnoconv("MediaFiles"), '<span class="fa fa-image"><span>', '/website/index.php?action=file_manager&website='.$website->ref, $disabled); @@ -2494,8 +2389,7 @@ if (!GETPOST('hide_websitemenu')) print '<span class="websitetools websiteselection">'; - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') - { + if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { $urlext = $virtualurl; $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; @@ -2504,22 +2398,16 @@ if (!GETPOST('hide_websitemenu')) $linktotestonwebserver .= '<span class="hideonsmartphone paddingrightonly">'.$langs->trans("TestDeployOnWeb", $virtualurl).'</span>'.img_picto('', 'globe'); $linktotestonwebserver .= '</a>'; $htmltext = ''; - if (empty($object->fk_default_home)) - { + if (empty($object->fk_default_home)) { $htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; - } - elseif (empty($virtualurl)) - { + } elseif (empty($virtualurl)) { //$htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; - } - else { + } else { $htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; } - if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) - { + if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) { $htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); - } - else { + } else { $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot); $htmltext .= '<br>'; $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); @@ -2556,12 +2444,19 @@ if (!GETPOST('hide_websitemenu')) print '</span>'; } - if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) - { - if ($action == 'editcss') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; - if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; - if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; - if ($action != 'preview') print '<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; + if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) { + if ($action == 'editcss') { + print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; + } + if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') { + print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; + } + if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') { + print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; + } + if ($action != 'preview') { + print '<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; + } } print '</span>'; @@ -2570,8 +2465,7 @@ if (!GETPOST('hide_websitemenu')) // Toolbar for pages // - if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm')) && !$file_manager) - { + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm')) && !$file_manager) { print '</div>'; // Close current websitebar to open a new one print '<!-- Bar for websitepage -->'; @@ -2587,8 +2481,7 @@ if (!GETPOST('hide_websitemenu')) //print '<span class="websiteselection">'; - if ($action != 'addcontainer') - { + if ($action != 'addcontainer') { $out = ''; $s = $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action, 'maxwidth200onsmartphone'); @@ -2617,8 +2510,7 @@ if (!GETPOST('hide_websitemenu')) } print $out; - } - else { + } else { print $langs->trans("New"); } @@ -2629,47 +2521,50 @@ if (!GETPOST('hide_websitemenu')) // Print nav arrows $pagepreviousid = 0; $pagenextid = 0; - if ($pageid) - { + if ($pageid) { $sql = 'SELECT MAX(rowid) as pagepreviousid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid < '.$pageid.' AND fk_website = '.$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $pagepreviousid = $obj->pagepreviousid; } + } else { + dol_print_error($db); } - else dol_print_error($db); $sql = 'SELECT MIN(rowid) as pagenextid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid > '.$pageid.' AND fk_website = '.$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $pagenextid = $obj->pagenextid; } + } else { + dol_print_error($db); } - else dol_print_error($db); } - if ($pagepreviousid) print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagepreviousid.'&action='.$action.'">'.img_previous($langs->trans("PreviousContainer")).'</a>'; - else print '<span class="valignmiddle opacitymedium">'.img_previous($langs->trans("Previous")).'</span>'; - if ($pagenextid) print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagenextid.'&action='.$action.'">'.img_next($langs->trans("NextContainer")).'</a>'; - else print '<span class="valignmiddle opacitymedium">'.img_next($langs->trans("Next")).'</span>'; + if ($pagepreviousid) { + print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagepreviousid.'&action='.$action.'">'.img_previous($langs->trans("PreviousContainer")).'</a>'; + } else { + print '<span class="valignmiddle opacitymedium">'.img_previous($langs->trans("Previous")).'</span>'; + } + if ($pagenextid) { + print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagenextid.'&action='.$action.'">'.img_next($langs->trans("NextContainer")).'</a>'; + } else { + print '<span class="valignmiddle opacitymedium">'.img_next($langs->trans("Next")).'</span>'; + } $websitepage = new WebSitePage($db); - if ($pageid > 0 && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) - { + if ($pageid > 0 && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) { $websitepage->fetch($pageid); } - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') - { + if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { $disabled = ''; - if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; + if (empty($user->rights->website->write)) { + $disabled = ' disabled="disabled"'; + } // Confirmation delete site if ($action == 'deletesite') { @@ -2698,8 +2593,7 @@ if (!GETPOST('hide_websitemenu')) print $formconfirm; } - if ($pageid > 0 && $atleastonepage) // pageid can be set without pages, if homepage of site is set and all pages were removed - { + if ($pageid > 0 && $atleastonepage) { // pageid can be set without pages, if homepage of site is set and all pages were removed // Confirmation to clone if ($action == 'createpagefromclone') { // Create an array for form @@ -2730,7 +2624,7 @@ if (!GETPOST('hide_websitemenu')) $value= $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, $textifempty, 0, 0, 'minwidth200', 1, 0, 0, $onlylang, 1); $formquestion[] = array('type' => 'other', 'name' => 'newlang', 'label' => $form->textwithpicto($langs->trans("Language"), $langs->trans("DefineListOfAltLanguagesInWebsiteProperties")), 'value' => $value); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); print $formconfirm; } @@ -2746,11 +2640,9 @@ if (!GETPOST('hide_websitemenu')) print '<div class="inline-block marginrightonly">'; // Button include dynamic contant print $langs->trans("ShowSubcontainers"); - if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) - { + if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) { print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; - } - else { + } else { print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>'; } print '</div>'; @@ -2807,18 +2699,14 @@ if (!GETPOST('hide_websitemenu')) //$disableeditinline = $websitepage->grabbed_from; $disableeditinline = 0; - if ($disableeditinline) - { + if ($disableeditinline) { //print '<input type="submit" class="button bordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">'; print '<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.' href="#" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'">'.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; - } - else { + } else { //print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">'; - if (empty($conf->global->WEBSITE_EDITINLINE)) - { + if (empty($conf->global->WEBSITE_EDITINLINE)) { print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=seteditinline&token='.newToken().'">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; - } - else { + } else { print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline&token='.newToken().'">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>'; } } @@ -2828,14 +2716,12 @@ if (!GETPOST('hide_websitemenu')) print '</div>'; // Set page as homepage - if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) - { + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) { //$disabled=' disabled="disabled"'; //print '<span class="button bordertransp disabled"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home"></span></span>'; //print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; print '<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; - } - else { + } else { //$disabled=''; //print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; print '<a href="'.$_SERVER["PHP_SEFL"].'?action=setashome&token='.newToken().'&website='.$website->ref.'&pageid='.$pageid.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; @@ -2849,8 +2735,7 @@ if (!GETPOST('hide_websitemenu')) print '<span class="websitetools">'; - if (($pageid > 0 && $atleastonepage) && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) - { + if (($pageid > 0 && $atleastonepage) && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { $realpage = $urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; @@ -2886,30 +2771,34 @@ if (!GETPOST('hide_websitemenu')) // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) - { - if ($action == 'editsource' || $action == 'editmeta') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; - if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; - if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; - if ($action != 'preview') print '<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; + if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) { + if ($action == 'editsource' || $action == 'editmeta') { + print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; + } + if (preg_match('/^create/', $action)) { + print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; + } + if (preg_match('/^edit/', $action)) { + print '<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; + } + if ($action != 'preview') { + print '<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; + } } print '</span>'; // end websitetools print '<span class="websitehelp">'; - if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) - { + if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) { $url = 'https://wiki.dolibarr.org/index.php/Module_Website'; $htmltext = $langs->transnoentitiesnoconv("YouCanEditHtmlSource", $url); $htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource2", $url); $htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSourceMore", $url); $htmltext .= '<br>'; - if ($conf->browser->layout == 'phone') - { + if ($conf->browser->layout == 'phone') { print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); - } - else { + } else { //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); } @@ -2917,11 +2806,9 @@ if (!GETPOST('hide_websitemenu')) print '</span>'; // end websitehelp - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') - { + if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { jQuery("#websiteinputurl").keyup(function() { @@ -2979,115 +2866,96 @@ $head = array(); * Edit Site HTML header and CSS */ -if ($action == 'editcss') -{ +if ($action == 'editcss') { print '<div class="fiche">'; print '<br>'; - if (!GETPOSTISSET('WEBSITE_CSS_INLINE')) - { + if (!GETPOSTISSET('WEBSITE_CSS_INLINE')) { $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $csscontent); - } - else { + } else { $csscontent = GETPOST('WEBSITE_CSS_INLINE', 'none'); } if (!trim($csscontent)) { $csscontent = '/* CSS content (all pages) */'."\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; } - if (!GETPOSTISSET('WEBSITE_JS_INLINE')) - { + if (!GETPOSTISSET('WEBSITE_JS_INLINE')) { $jscontent = @file_get_contents($filejs); // Clean the php js file to remove php code and get only js part $jscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $jscontent); - } - else { + } else { $jscontent = GETPOST('WEBSITE_JS_INLINE', 'none'); } - if (!trim($jscontent)) $jscontent = '/* JS content (all pages) */'."\n"; + if (!trim($jscontent)) { + $jscontent = '/* JS content (all pages) */'."\n"; + } - if (!GETPOSTISSET('WEBSITE_HTML_HEADER')) - { + if (!GETPOSTISSET('WEBSITE_HTML_HEADER')) { $htmlheadercontent = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part $htmlheadercontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheadercontent); - } - else { + } else { $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); } - if (!trim($htmlheadercontent)) - { + if (!trim($htmlheadercontent)) { $htmlheadercontent = "<html>\n"; $htmlheadercontent .= $htmlheadercontentdefault; $htmlheadercontent .= "</html>"; - } - else { + } else { $htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent); $htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent); $htmlheadercontent = '<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; } - if (!GETPOSTISSET('WEBSITE_ROBOT')) - { + if (!GETPOSTISSET('WEBSITE_ROBOT')) { $robotcontent = @file_get_contents($filerobot); // Clean the php htmlheader file to remove php code and get only html part $robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $robotcontent); - } - else { + } else { $robotcontent = GETPOST('WEBSITE_ROBOT', 'nothtml'); } - if (!trim($robotcontent)) - { + if (!trim($robotcontent)) { $robotcontent .= "# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; $robotcontent .= "User-agent: *\n"; $robotcontent .= "Allow: /public/\n"; $robotcontent .= "Disallow: /administrator/\n"; } - if (!GETPOSTISSET('WEBSITE_HTACCESS')) - { + if (!GETPOSTISSET('WEBSITE_HTACCESS')) { $htaccesscontent = @file_get_contents($filehtaccess); // Clean the php htaccesscontent file to remove php code and get only html part $htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htaccesscontent); - } - else { + } else { $htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); } - if (!trim($htaccesscontent)) - { + if (!trim($htaccesscontent)) { $htaccesscontent .= "# Order allow,deny\n"; $htaccesscontent .= "# Deny from all\n"; } - if (!GETPOSTISSET('WEBSITE_MANIFEST_JSON')) - { + if (!GETPOSTISSET('WEBSITE_MANIFEST_JSON')) { $manifestjsoncontent = @file_get_contents($filemanifestjson); // Clean the manifestjson file to remove php code and get only html part $manifestjsoncontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $manifestjsoncontent); - } - else { + } else { $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON', 'restricthtml'); } - if (!trim($manifestjsoncontent)) - { + if (!trim($manifestjsoncontent)) { //$manifestjsoncontent.=""; } - if (!GETPOSTISSET('WEBSITE_README')) - { + if (!GETPOSTISSET('WEBSITE_README')) { $readmecontent = @file_get_contents($filereadme); // Clean the readme file to remove php code and get only html part $readmecontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $readmecontent); - } - else { + } else { $readmecontent = GETPOST('WEBSITE_README', 'none'); } - if (!trim($readmecontent)) - { + if (!trim($readmecontent)) { //$readmecontent.=""; } @@ -3245,8 +3113,7 @@ if ($action == 'editcss') } -if ($action == 'createsite') -{ +if ($action == 'createsite') { print '<div class="fiche">'; print '<br>'; @@ -3256,12 +3123,14 @@ if ($action == 'createsite') $head[$h][0] = dol_buildpath('/website/index.php',1).'?id='.$object->id; $head[$h][1] = $langs->trans("AddSite"); - $head[$h][2] = 'card'; + $head[$h][2] = 'card'; $h++; - print dol_get_fiche_head($head, 'card', $langs->trans("AddSite"), -1, 'globe'); - */ - if ($action == 'createcontainer') print load_fiche_titre($langs->trans("AddSite")); + print dol_get_fiche_head($head, 'card', $langs->trans("AddSite"), -1, 'globe'); + */ + if ($action == 'createcontainer') { + print load_fiche_titre($langs->trans("AddSite")); + } print '<!-- Add site -->'."\n"; //print '<div class="fichecenter">'; @@ -3269,10 +3138,18 @@ if ($action == 'createsite') print '<table class="border centpercent">'; $siteref = $sitedesc = $sitelang = $siteotherlang = ''; - if (GETPOST('WEBSITE_REF')) $siteref = GETPOST('WEBSITE_REF', 'alpha'); - if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); - if (GETPOST('WEBSITE_LANG')) $sitelang = GETPOST('WEBSITE_LANG', 'aZ09'); - if (GETPOST('WEBSITE_OTHERLANG')) $siteotherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); + if (GETPOST('WEBSITE_REF')) { + $siteref = GETPOST('WEBSITE_REF', 'alpha'); + } + if (GETPOST('WEBSITE_DESCRIPTION')) { + $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + } + if (GETPOST('WEBSITE_LANG')) { + $sitelang = GETPOST('WEBSITE_LANG', 'aZ09'); + } + if (GETPOST('WEBSITE_OTHERLANG')) { + $siteotherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); + } print '<tr><td class="titlefieldcreate fieldrequired">'; print $form->textwithpicto($langs->trans('WebSite'), $langs->trans("Example").': www.mywebsite.com, myportal, ...'); @@ -3317,8 +3194,7 @@ if ($action == 'createsite') print '</table>'; - if ($action == 'createsite') - { + if ($action == 'createsite') { print '<div class="center">'; print '<input class="button" type="submit" name="addcontainer" value="'.$langs->trans("Create").'">'; @@ -3337,8 +3213,7 @@ if ($action == 'createsite') print '<br>'; } -if ($action == 'importsite') -{ +if ($action == 'importsite') { print '<div class="fiche">'; print '<br>'; @@ -3368,8 +3243,7 @@ if ($action == 'importsite') print '<br>'; } -if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of a web site OR properties of a web page -{ +if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties of a web site OR properties of a web page print '<div class="fiche">'; print '<br>'; @@ -3379,31 +3253,38 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $head[$h][0] = dol_buildpath('/website/index.php',1).'?id='.$object->id; $head[$h][1] = $langs->trans("AddPage"); - $head[$h][2] = 'card'; + $head[$h][2] = 'card'; $h++; - print dol_get_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe'); - */ - if ($action == 'createcontainer') print load_fiche_titre($langs->trans("AddPage")); + print dol_get_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe'); + */ + if ($action == 'createcontainer') { + print load_fiche_titre($langs->trans("AddPage")); + } print '<!-- Edit or create page/container -->'."\n"; //print '<div class="fichecenter">'; $hiddenfromfetchingafterload = ' hideobject'; $hiddenmanuallyafterload = ' hideobject'; - if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') $hiddenfromfetchingafterload = ''; - if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; + if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') { + $hiddenfromfetchingafterload = ''; + } + if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') { + $hiddenmanuallyafterload = ''; + } if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case $hiddenfromfetchingafterload = ''; $hiddenmanuallyafterload = ''; } - if ($action == 'createcontainer') - { + if ($action == 'createcontainer') { print '<br>'; - if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) { + print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; + } print '<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>'; print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; @@ -3424,15 +3305,16 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '<br>'; - if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) { + print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; + } print '<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>'; print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; } print '<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; - if ($action != 'createcontainer') - { + if ($action != 'createcontainer') { print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('IDOfPage').' - '.$langs->trans('InternalURLOfPage'); print '</td><td>'; @@ -3462,9 +3344,8 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $pageauthorid = $objectpage->fk_user_creat; $pageusermodifid = $objectpage->fk_user_modif; $pageauthoralias = $objectpage->author_alias; - $pagestatus = $objectpage->status; - } - else { + $pagestatus = $objectpage->status; + } else { $type_container = 'page'; $pagedatecreation = dol_now(); $pageauthorid = $user->id; @@ -3472,18 +3353,35 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $pageauthoralias = ''; $pagestatus = 1; } - if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = str_replace(array('<', '>'), '', GETPOST('WEBSITE_TITLE', 'alphanohtml')); - if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); - if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt = str_replace(array('<', '>'), '', GETPOST('WEBSITE_ALIASALT', 'alphanohtml')); - if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription = str_replace(array('<', '>'), '', GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml')); - if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); - if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); - if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); - if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); - if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); + if (GETPOST('WEBSITE_TITLE', 'alpha')) { + $pagetitle = str_replace(array('<', '>'), '', GETPOST('WEBSITE_TITLE', 'alphanohtml')); + } + if (GETPOST('WEBSITE_PAGENAME', 'alpha')) { + $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); + } + if (GETPOST('WEBSITE_ALIASALT', 'alpha')) { + $pagealiasalt = str_replace(array('<', '>'), '', GETPOST('WEBSITE_ALIASALT', 'alphanohtml')); + } + if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) { + $pagedescription = str_replace(array('<', '>'), '', GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml')); + } + if (GETPOST('WEBSITE_IMAGE', 'alpha')) { + $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); + } + if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) { + $pagekeywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); + } + if (GETPOST('WEBSITE_LANG', 'aZ09')) { + $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); + } + if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) { + $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); + } + if (GETPOST('htmlheader', 'none')) { + $pagehtmlheader = GETPOST('htmlheader', 'none'); + } - if ($action != 'createcontainer') - { + if ($action != 'createcontainer') { print '<!-- Status of page -->'."\n"; print '<tr><td class="fieldrequired">'; print $langs->trans('Status'); @@ -3501,8 +3399,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ? GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container), 0, '', 1); print '</td></tr>'; - if ($action == 'createcontainer') - { + if ($action == 'createcontainer') { print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_PAGE_EXAMPLE'); print '</td><td>'; @@ -3556,8 +3453,11 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print $langs->trans('Language'); print '</td><td>'; $onlykeys = array(); - if ($object->lang) $onlykeys[$object->lang] = $object->lang; - else $onlykeys[$langs->defaultlang] = $langs->defaultlang; + if ($object->lang) { + $onlykeys[$object->lang] = $object->lang; + } else { + $onlykeys[$langs->defaultlang] = $langs->defaultlang; + } if ($object->otherlang) { $tmparray = explode(',', $object->otherlang); foreach ($tmparray as $key) { @@ -3582,47 +3482,45 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '<!-- Translation of --><tr><td>'; print $langs->trans('TranslationLinks'); print '</td><td>'; - if ($action != 'createcontainer') - { + if ($action != 'createcontainer') { // Has translation pages $sql = 'SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $db->num_rows($resql); - if ($num_rows > 0) - { + if ($num_rows > 0) { print '<span class="opacitymedium">'.$langs->trans('ThisPageHasTranslationPages').':</span>'; $i = 0; $tmppage = new WebsitePage($db); $tmpstring = ''; - while ($obj = $db->fetch_object($resql)) - { + while ($obj = $db->fetch_object($resql)) { $result = $tmppage->fetch($obj->rowid); if ($result > 0) { - if ($i > 0) $tmpstring .= '<br>'; + if ($i > 0) { + $tmpstring .= '<br>'; + } $tmpstring .= $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; $translatedby++; $i++; } } - if ($i > 1) print '<br>'; - else print ' '; + if ($i > 1) { + print '<br>'; + } else { + print ' '; + } print $tmpstring; } + } else { + dol_print_error($db); } - else dol_print_error($db); } - if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) - { + if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { $sourcepage = new WebsitePage($db); $result = $sourcepage->fetch($objectpage->fk_page); - if ($result == 0) - { + if ($result == 0) { // not found, we can reset value to clean database - } - elseif ($result > 0) - { + } elseif ($result > 0) { $translationof = $objectpage->fk_page; print '<span class="opacitymedium">'.$langs->trans('ThisPageIsTranslationOf').'</span> '; print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); @@ -3643,8 +3541,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '</td></tr>'; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); if (!GETPOSTISSET('categories')) { @@ -3686,8 +3583,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '<tr><td>'; print $langs->trans('Author'); print '</td><td>'; - if ($pageauthorid > 0) - { + if ($pageauthorid > 0) { $fuser->fetch($pageauthorid); print $fuser->getNomUrl(1); } else { @@ -3708,13 +3604,11 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of //print dol_print_date($pagedatecreation, 'dayhour'); print '</td></tr>'; - if ($action != 'createcontainer') - { + if ($action != 'createcontainer') { print '<tr><td>'; print $langs->trans('UserModif'); print '</td><td>'; - if ($pageusermodifid > 0) - { + if ($pageusermodifid > 0) { $fuser->fetch($pageusermodifid); print $fuser->getNomUrl(1); } @@ -3738,8 +3632,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '</td></tr>'; print '</table>'; - if ($action == 'createcontainer') - { + if ($action == 'createcontainer') { print '<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; print '<input class="button" type="submit" name="addcontainer" value="'.$langs->trans("Create").'">'; @@ -3748,8 +3641,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '</div>'; } - if ($action == 'createcontainer') - { + if ($action == 'createcontainer') { print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { var disableautofillofalias = 0; @@ -3794,27 +3686,26 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '<br>'; } -if ($action == 'editfile' || $action == 'file_manager') -{ +if ($action == 'editfile' || $action == 'file_manager') { print '<!-- Edit Media -->'."\n"; print '<div class="fiche"><br>'; //print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; $module = 'medias'; - if (empty($url)) $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param + if (empty($url)) { + $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param + } include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; print '</div>'; } -if ($action == 'editmenu') -{ +if ($action == 'editmenu') { print '<!-- Edit Menu -->'."\n"; print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; } -if ($action == 'editsource') -{ +if ($action == 'editsource') { // Editing with source editor $contentforedit = ''; @@ -3824,10 +3715,13 @@ if ($action == 'editsource') $contentforedit .= $objectpage->content; //var_dump($_SESSION["dol_screenheight"]); $maxheightwin = 480; - if (isset($_SESSION["dol_screenheight"])) - { - if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"] - 400; - if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"] - 490; + if (isset($_SESSION["dol_screenheight"])) { + if ($_SESSION["dol_screenheight"] > 680) { + $maxheightwin = $_SESSION["dol_screenheight"] - 400; + } + if ($_SESSION["dol_screenheight"] > 800) { + $maxheightwin = $_SESSION["dol_screenheight"] - 490; + } } //var_dump($_SESSION["dol_screenheight"]); require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -3841,8 +3735,8 @@ if ($action == 'editsource') $contentforedit = ''; //$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers - //$contentforedit.=$csscontent; - //$contentforedit.='</style>'."\n"; + //$contentforedit.=$csscontent; + //$contentforedit.='</style>'."\n"; $contentforedit .= $objectpage->content; $contentforedit = preg_replace('/(<img.*src=")(?!http)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep); @@ -3856,8 +3750,7 @@ print "</div>\n"; print "</form>\n"; -if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction == 'replace') -{ +if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction == 'replace') { print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="replacesiteconfirm">'; @@ -3919,8 +3812,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '</div>'; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '<div class="tagtr">'; print '<div class="tagtd paddingrightonly marginrightonly opacitymedium" style="padding-right: 10px !important">'; print $langs->trans("Category"); @@ -3939,16 +3831,14 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '</div></div>'; - if ($action == 'replacesiteconfirm') - { + if ($action == 'replacesiteconfirm') { print '<!-- List of search result -->'."\n"; print '<div class="rowsearchresult clearboth">'; print '<br>'; print '<br>'; - if ($listofpages['code'] == 'OK') - { + if ($listofpages['code'] == 'OK') { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; $nbtotalofrecords = count($listofpages['list']); @@ -3957,10 +3847,18 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = // List of mass actions available $arrayofmassactions = array(); - if ($user->rights->website->writephp && $searchkey) $arrayofmassactions['replace'] = $langs->trans("Replace"); - if ($user->rights->website->write) $arrayofmassactions['setcategory'] = $langs->trans("ClassifyInCategory"); - if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->rights->website->writephp && $searchkey) { + $arrayofmassactions['replace'] = $langs->trans("Replace"); + } + if ($user->rights->website->write) { + $arrayofmassactions['setcategory'] = $langs->trans("ClassifyInCategory"); + } + if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton .= '<div class="massactionother massactionreplace hidden">'; @@ -3988,12 +3886,24 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = $param = 'action=replacesiteconfirm&website='.urlencode($website->ref); $param .= '&searchstring='.urlencode($searchkey); - if (GETPOST('optioncontent')) $param .= '&optioncontent=content'; - if (GETPOST('optionmeta')) $param .= '&optionmeta=meta'; - if (GETPOST('optionsitefiles')) $param .= '&optionsitefiles=optionsitefiles'; - if (GETPOST('optioncontainertype')) $param .= '&optioncontainertype='.GETPOST('optioncontainertype', 'aZ09'); - if (GETPOST('optionlanguage')) $param .= '&optionlanguage='.GETPOST('optionlanguage', 'aZ09'); - if (GETPOST('optioncategory')) $param .= '&optioncategory='.GETPOST('optioncategory', 'aZ09'); + if (GETPOST('optioncontent')) { + $param .= '&optioncontent=content'; + } + if (GETPOST('optionmeta')) { + $param .= '&optionmeta=meta'; + } + if (GETPOST('optionsitefiles')) { + $param .= '&optionsitefiles=optionsitefiles'; + } + if (GETPOST('optioncontainertype')) { + $param .= '&optioncontainertype='.GETPOST('optioncontainertype', 'aZ09'); + } + if (GETPOST('optionlanguage')) { + $param .= '&optionlanguage='.GETPOST('optionlanguage', 'aZ09'); + } + if (GETPOST('optioncategory')) { + $param .= '&optioncategory='.GETPOST('optioncategory', 'aZ09'); + } print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; @@ -4012,10 +3922,8 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = $totalnbwords = 0; - foreach ($listofpages['list'] as $answerrecord) - { - if (get_class($answerrecord) == 'WebsitePage') - { + foreach ($listofpages['list'] as $answerrecord) { + if (get_class($answerrecord) == 'WebsitePage') { print '<tr>'; // Type of container @@ -4035,8 +3943,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = // Categories - Tags print '<td>'; - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Get current categories $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE, 'object'); if (is_array($existing)) { @@ -4103,10 +4010,11 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '<td class="nowrap center">'; print '<!-- Status of page -->'."\n"; - if ($massactionbutton || $massaction) - { + if ($massactionbutton || $massaction) { $selected = 0; - if (in_array($answerrecord->id, $arrayofselected)) $selected = 1; + if (in_array($answerrecord->id, $arrayofselected)) { + $selected = 1; + } print '<input id="'.$answerrecord->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; @@ -4213,8 +4121,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '</table>'; print '</div>'; print '<br>'; - } - else { + } else { print '<div class="warning">'.$listofpages['message'].'</div>'; } @@ -4224,10 +4131,8 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '</form>'; } -if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') -{ - if ($pageid > 0 && $atleastonepage) - { +if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { + if ($pageid > 0 && $atleastonepage) { // $filejs // $filecss // $filephp @@ -4291,10 +4196,11 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $tmp = preg_split('(<style[^>]*>|</style>)', $objectpage->htmlheader); $tmpstyleinheader = ''; $i = 0; - foreach ($tmp as $valtmp) - { + foreach ($tmp as $valtmp) { $i++; - if ($i % 2 == 0) $tmpstyleinheader .= $valtmp."\n"; + if ($i % 2 == 0) { + $tmpstyleinheader .= $valtmp."\n"; + } } $tmpout .= $tmpstyleinheader."\n"; // Clean style that may affect global style of Dolibarr @@ -4312,8 +4218,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $newcontent = $objectpage->content; // If mode WEBSITE_SUBCONTAINERSINLINE is on - if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) - { + if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) { // TODO Check file $filephp exists, if not create it. //var_dump($filetpl); @@ -4324,8 +4229,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa if (empty($res)) { print "ERROR: Failed to include file '".$filephp."'. Try to edit and save page."; } - } catch (Exception $e) - { + } catch (Exception $e) { print $e->getMessage(); } $newcontent = ob_get_contents(); @@ -4333,12 +4237,10 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa } // Change the contenteditable to "true" or "false" when mode Edit Inline is on or off - if (empty($conf->global->WEBSITE_EDITINLINE)) - { + if (empty($conf->global->WEBSITE_EDITINLINE)) { // Remove the contenteditable="true" $newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent); - } - else { + } else { // Keep the contenteditable="true" when mode Edit Inline is on } $out .= dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; @@ -4359,33 +4261,30 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa print $out; /*file_put_contents($filetpl, $out); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); - // Output file on browser - dol_syslog("index.php include $filetpl $filename content-type=$type"); - $original_file_osencoded=dol_osencode($filetpl); // New file name encoded in OS encoding charset + // Output file on browser + dol_syslog("index.php include $filetpl $filename content-type=$type"); + $original_file_osencoded=dol_osencode($filetpl); // 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)) - { - dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); - exit; - } + // This test if file exists should be useless. We keep it to find bug more easily + if (! file_exists($original_file_osencoded)) + { + dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + exit; + } - //include_once $original_file_osencoded; - */ + //include_once $original_file_osencoded; + */ /*print '<iframe class="websiteiframenoborder centpercent" src="'.DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$pageid.'"/>'; - print '</iframe>';*/ - } - else { - if (empty($websitekey) || $websitekey == '-1') - { + print '</iframe>';*/ + } else { + if (empty($websitekey) || $websitekey == '-1') { print '<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans("NoWebSiteCreateOneFirst").'</span></div><br><br><br>'; print '<div class="center"><div class="logo_setup"></div></div>'; - } - else { + } else { print '<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</span></div><br><br><br>'; print '<div class="center"><div class="logo_setup"></div></div>'; } diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 24b804058ea..b847f607bf3 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -1,8 +1,12 @@ <?php // BEGIN PHP File wrapper.php - DO NOT MODIFY - It is just a copy of file website/samples/wrapper.php $websitekey = basename(__DIR__); -if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) die("Sample file for website module. Can be called directly."); -if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded +if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) { + die("Sample file for website module. Can be called directly."); +} +if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { + require_once './master.inc.php'; +} // Load master if not already loaded include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $encoding = ''; @@ -17,42 +21,36 @@ $limit = GETPOST('limit', 'int'); // Parameters for RSS $rss = GETPOST('rss', 'aZ09'); -if ($rss) $original_file = 'blog.rss'; +if ($rss) { + $original_file = 'blog.rss'; +} // If we have a hash public (hashp), we guess the original_file. -if (!empty($hashp)) -{ +if (!empty($hashp)) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(0, '', '', '', $hashp); - if ($result > 0) - { + if ($result > 0) { $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory // filepath can be 'users/X' or 'X/propale/PR11111' - if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. - { + if (is_numeric($tmp[0])) { // If first tmp is numeric, it is subdir of company for multicompany, we take next part. $tmp = explode('/', $tmp[1], 2); } $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path - if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. - { - if ($moduleparttocheck == $modulepart) - { + if ($modulepart) { // Not required, so often not defined, for link using public hashp parameter. + if ($moduleparttocheck == $modulepart) { // We remove first level of directory $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir //var_dump($original_file); exit; - } - else { + } else { print 'Bad link. File is from another module part.'; } - } - else { + } else { $modulepart = $moduleparttocheck; $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } - } - else { + } else { print "ErrorFileNotFoundWithSharedLink"; exit; } @@ -60,21 +58,29 @@ if (!empty($hashp)) // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; -if (preg_match('/\.(html|htm)$/i', $original_file)) $attachment = false; -if (isset($_GET["attachment"])) $attachment = (GETPOST("attachment", 'alphanohtml') ? true : false); -if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) $attachment = false; +if (preg_match('/\.(html|htm)$/i', $original_file)) { + $attachment = false; +} +if (isset($_GET["attachment"])) { + $attachment = (GETPOST("attachment", 'alphanohtml') ? true : false); +} +if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) { + $attachment = false; +} // Define mime type $type = 'application/octet-stream'; -if (GETPOSTISSET('type')) $type = GETPOST('type', 'alpha'); -else $type = dol_mimetype($original_file); +if (GETPOSTISSET('type')) { + $type = GETPOST('type', 'alpha'); +} else { + $type = dol_mimetype($original_file); +} // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); // Cache or not -if (GETPOST("cache", 'aZ09') || image_format_supported($original_file) >= 0) -{ +if (GETPOST("cache", 'aZ09') || image_format_supported($original_file) >= 0) { // Important: Following code is to avoid page request by browser and PHP CPU at // each Dolibarr page access. header('Cache-Control: max-age=3600, public, must-revalidate'); @@ -99,7 +105,9 @@ if ($rss) { $website->fetch('', $websitekey); $filters = array('type_container'=>'blogpost'); - if ($l) $filters['lang'] = $l; + if ($l) { + $filters['lang'] = $l; + } $MAXNEWS = ($limit ? $limit : 20); $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); @@ -118,8 +126,7 @@ if ($rss) { dol_syslog("build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); // Clean parameters - if (!$filename) - { + if (!$filename) { $extension = 'rss'; $filename = $format.'.'.$extension; } @@ -132,19 +139,16 @@ if ($rss) { $buildfile = true; - if ($cachedelay) - { + if ($cachedelay) { $nowgmt = dol_now(); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) - { + if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) { dol_syslog("build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); $buildfile = false; } } - if ($buildfile) - { + if ($buildfile) { $langs->load("other"); $title = $desc = $langs->transnoentities('LatestBlogPosts'); @@ -155,18 +159,17 @@ if ($rss) { // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); - if ($result >= 0) - { - if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; - else { + if ($result >= 0) { + if (dol_move($outputfiletmp, $outputfile, 0, 1)) { + $result = 1; + } else { $error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; dol_syslog("build_exportfile ".$error, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); print $error; exit(-1); } - } - else { + } else { dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $langs->load("errors"); @@ -175,56 +178,63 @@ if ($rss) { } } - if ($result >= 0) - { + if ($result >= 0) { $attachment = false; - if (isset($_GET["attachment"])) $attachment = $_GET["attachment"]; + if (isset($_GET["attachment"])) { + $attachment = $_GET["attachment"]; + } //$attachment = false; $contenttype = 'application/rss+xml'; - if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"]; + if (isset($_GET["contenttype"])) { + $contenttype = $_GET["contenttype"]; + } //$contenttype='text/plain'; $outputencoding = 'UTF-8'; - if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + if ($contenttype) { + header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); + } + if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); + } // Ajout directives pour resoudre bug IE //header('Cache-Control: Public, must-revalidate'); //header('Pragma: public'); - if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate'); - else header('Cache-Control: private, must-revalidate'); + if ($cachedelay) { + header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate'); + } else { + header('Cache-Control: private, must-revalidate'); + } // Clean parameters $outputfile = $dir_temp.'/'.$filename; $result = readfile($outputfile); - if (!$result) print 'File '.$outputfile.' was empty.'; + if (!$result) { + print 'File '.$outputfile.' was empty.'; + } // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); exit; } -} -// Get logos -elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file)) -{ +} elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file)) { + // Get logos readfile(dol_osencode($conf->mycompany->dir_output."/".$original_file)); -} -else { +} else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name - if ($hashp) - { + if ($hashp) { $accessallowed = 1; // When using hashp, link is public so we force $accessallowed $sqlprotectagainstexternals = ''; } // Security: // Limit access if permissions are wrong - if (!$accessallowed) - { + if (!$accessallowed) { print 'Access forbidden'; exit; } @@ -238,8 +248,7 @@ else { $fullpath_original_file_osencoded = dol_osencode($fullpath_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($fullpath_original_file_osencoded)) - { + if (!file_exists($fullpath_original_file_osencoded)) { print "ErrorFileDoesNotExists: ".$original_file; exit; } @@ -248,13 +257,20 @@ else { //top_httphead($type); header('Content-Type: '.$type); header('Content-Description: File Transfer'); - if ($encoding) header('Content-Encoding: '.$encoding); + if ($encoding) { + header('Content-Encoding: '.$encoding); + } // Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open) - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); + if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); + } else { + header('Content-Disposition: inline; filename="'.$filename.'"'); + } header('Content-Length: '.dol_filesize($fullpath_original_file)); readfile($fullpath_original_file_osencoded); } -if (is_object($db)) $db->close(); +if (is_object($db)) { + $db->close(); +} // END PHP diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 17f50e709b7..e63c3cb8fef 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -53,12 +53,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -80,10 +83,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $permissiontoadd = $user->rights->website->write; @@ -130,8 +134,7 @@ jQuery(document).ready(function() { // Part to create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount"))); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; @@ -163,8 +166,7 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("WebsiteAccount")); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; @@ -194,9 +196,10 @@ if (($id || $ref) && $action == 'edit') } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ - if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc; +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + if ($object->fk_soc > 0 && empty($socid)) { + $socid = $object->fk_soc; + } $res = $object->fetch_optionals(); @@ -213,8 +216,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -223,8 +229,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ $linkback = ''; - if ($socid) $linkback = '<a href="'.DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToListForThirdParty").'</a>'; - if ($fk_website) $linkback = '<a href="'.DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; + if ($socid) { + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToListForThirdParty").'</a>'; + } + if ($fk_website) { + $linkback = '<a href="'.DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; + } $morehtmlref = '<div class="refidno">'; /* @@ -236,41 +246,43 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; - if ($user->rights->website->creer) - { - if ($action != 'classify') - { - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($user->rights->website->creer) + { + if ($action != 'classify') + { + $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref.='<input type="hidden" name="action" value="classin">'; + $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref.='</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; + $morehtmlref.=$proj->ref; + $morehtmlref.='</a>'; + } else { + $morehtmlref.=''; + } + } } */ $morehtmlref .= '</div>'; - if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid; + if ($socid > 0) { + $object->next_prev_filter = 'te.fk_soc = '.$socid; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); @@ -301,36 +313,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Send if (empty($user->socid)) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'."\n"; } - if ($user->rights->website->write) - { + if ($user->rights->website->write) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; } /* - if ($user->rights->sellyoursaas->create) - { - if ($object->status == 1) - { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a></div>'."\n"; - } - else - { - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a></div>'."\n"; - } - } - */ - - if ($user->rights->website->delete) + if ($user->rights->sellyoursaas->create) { + if ($object->status == 1) + { + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a></div>'."\n"; + } + else + { + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a></div>'."\n"; + } + } + */ + + if ($user->rights->website->delete) { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n"; } } @@ -343,21 +354,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre print '</div><div class="fichehalfright"><div class="ficheaddleft">'; /* - $MAXEVENT = 10; + $MAXEVENT = 10; - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT); - */ + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT); + */ print '</div></div></div>'; } From 00d2d28d687cc3e85edd62b2a1646b53bc410947 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 12:34:41 +0100 Subject: [PATCH 125/173] NEW: Can create a lot from list Make code like modulebuilder --- .../product/stock/class/productlot.class.php | 3 +- htdocs/product/stock/productlot_card.php | 263 +++++++++++------- htdocs/product/stock/productlot_list.php | 9 +- 3 files changed, 174 insertions(+), 101 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 90df912e69d..96650c034f3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -95,7 +95,8 @@ class Productlot extends CommonObject 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), ); /** diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 64902b02e86..0fd29543c6c 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -36,8 +36,35 @@ $langs->loadLangs(array('stocks', 'other', 'productbatch')); // Get parameters $id = GETPOST('id', 'int'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object = new ProductLot($db); +$extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + $batch = GETPOST('batch', 'alpha'); $productid = GETPOST('productid', 'int'); $ref = GETPOST('ref', 'alpha'); // ref is productid_batch @@ -51,22 +78,6 @@ $search_import_key = GETPOST('search_import_key', 'int'); if (empty($action) && empty($id) && empty($ref)) $action = 'list'; - -// Protection if external user -if ($user->socid > 0) -{ - //accessforbidden(); -} -//$result = restrictedArea($user, 'mymodule', $id); - - -$object = new ProductLot($db); -$extrafields = new ExtraFields($db); -$formfile = new FormFile($db); - -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id || $ref) @@ -81,6 +92,15 @@ if ($id || $ref) $object->ref = $object->batch; // For document management ( it use $object->ref) } +// Protection if external user +if ($user->socid > 0) +{ + //accessforbidden(); +} +//$result = restrictedArea($user, 'mymodule', $id); + + + // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('productlotcard', 'globalcard')); @@ -93,16 +113,26 @@ $usercanread = $user->rights->produit->lire; $usercancreate = $user->rights->produit->creer; $usercandelete = $user->rights->produit->supprimer; +$upload_dir = $conf->productbatch->multidir_output[$conf->entity]; + +$permissiontoadd = $usercancreate; + + /* * Actions */ $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + $error = 0; + + $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); -if (empty($reshook)) -{ if ($action == 'seteatby' && $user->rights->stock->creer) { $newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); @@ -117,6 +147,11 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } + $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + /* if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -152,8 +187,6 @@ if (empty($reshook)) $error = 0; - /* object_prop_getpost_prop */ - $object->entity = GETPOST('entity', 'int'); $object->fk_product = GETPOST('fk_product', 'int'); $object->batch = GETPOST('batch', 'alpha'); @@ -241,11 +274,15 @@ if (empty($reshook)) else setEventMessages($object->error, null, 'errors'); } } - - // Actions to build doc - $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; - $permissiontoadd = $usercancreate; +*/ + // Action to build doc include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + // Actions to send emails + $triggersendname = 'PRODUCT_LOT_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO'; + $trackid = 'productlot'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -255,69 +292,98 @@ if (empty($reshook)) * View */ -llxHeader('', 'ProductLot', ''); - $form = new Form($db); +$formfile = new FormFile($db); + +$title = $langs->trans("ProductLot"); +$help_url = ''; +llxHeader('', $title, $help_url); + // Part to create -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("Batch")); +if ($action == 'create') { + print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } + if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + } - print dol_get_fiche_head(); + print dol_get_fiche_head(array(), ''); - print '<table class="border centpercent">'."\n"; - // print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>'; - // - print '<tr><td class="fieldrequired">'.$langs->trans("Fieldfk_product").'</td><td><input class="flat" type="text" name="fk_product" value="'.GETPOST('fk_product').'"></td></tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("Fieldbatch").'</td><td><input class="flat" type="text" name="batch" value="'.GETPOST('batch').'"></td></tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("Fieldfk_user_creat").'</td><td><input class="flat" type="text" name="fk_user_creat" value="'.GETPOST('fk_user_creat').'"></td></tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("Fieldfk_user_modif").'</td><td><input class="flat" type="text" name="fk_user_modif" value="'.GETPOST('fk_user_modif').'"></td></tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("Fieldimport_key").'</td><td><input class="flat" type="text" name="import_key" value="'.GETPOST('import_key').'"></td></tr>'; + // Set some default values + //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; + + print '<table class="border centpercent tableforfieldcreate">'."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '</table>'."\n"; print dol_get_fiche_end(); - print '<div class="center"><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"> &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'"></div>'; + print '<div class="center">'; + print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; + print '&nbsp; '; + print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage + print '</div>'; print '</form>'; + + //dol_set_focus('input[name="ref"]'); } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); - //print load_fiche_titre($langs->trans("Batch")); - $head = productlot_prepare_head($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, 'barcode'); - + print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, $object->picto); + $formconfirm = ''; + + // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); - print $formconfirm; } - + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + // Object card + // ------------------------------------------------------------ $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; - dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); + $morehtmlref = ''; + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; - - print '<table class="border centpercent">'."\n"; + print '<table class="border centpercent tableforfield">'."\n"; // Product print '<tr><td class="titlefield">'.$langs->trans("Product").'</td><td>'; @@ -345,44 +411,49 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</td>'; print '</tr>'; } - // Other attributes - $cols = 2; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; print '</div>'; + print '<div class="clearboth"></div>'; + print dol_get_fiche_end(); - - // Buttons - print '<div class="tabsAction">'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook)) - { - /*TODO if ($user->rights->stock->lire) - { - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; - } - - if ($user->rights->stock->supprimer) - { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n"; - } - */ - } - print '</div>'."\n"; - - + // Link to other lists print '<a href="'.DOL_URL_ROOT.'/product/reassortlot.php?sref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.$langs->trans("ShowCurrentStockOfLot").'</a><br>'; print '<br>'; print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.$langs->trans("ShowLogOfMovementIfLot").'</a><br>'; - + print '<br>'; + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '<div class="tabsAction">'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) { + /*TODO if ($user->rights->stock->lire) + { + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; + } + + if ($user->rights->stock->supprimer) + { + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n"; + } + */ + } + + print '</div>'."\n"; + } + } @@ -391,30 +462,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Documents generes */ -if (empty($action)) -{ +if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre + $includedocgeneration = 1; + // Documents - $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $usercanread; - $delallowed = $usercancreate; + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; // If you can read, you can build the PDF to read content + $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->default_lang, '', $object); + } - print $formfile->showdocuments('product_batch', dol_sanitizeFileName($object->ref), $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown = $formfile->numoffiles; - - print '</div>'; - - // List of actions on element - print '<div class="fichehalfright"><div class="ficheaddleft">'; + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; + + $MAXEVENT = 10; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'productlot', $socid, 1); - print '</div></div>'; + $somethingshown = $formactions->showactions($object, 'productlot', $socid, 1, '', $MAXEVENT); - print '</div>'; + print '</div></div></div>'; } // End of page diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index e03de931a58..6e818be629d 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -124,9 +124,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->stock->read; -$permissiontoadd = $user->rights->stock->write; -$permissiontodelete = $user->rights->stock->delete; +$permissiontoread = $user->rights->stock->lire; +$permissiontoadd = $user->rights->stock->mouvement->creer; +//$permissiontodelete = $user->rights->stock->supprimer; @@ -321,8 +321,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; //print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); -$newcardbutton = ''; +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/product/stock/productlot_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); From 16906abc097f27e538038b97781caf7f4e351004 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 12:47:57 +0100 Subject: [PATCH 126/173] FIX File attachment on lots --- htdocs/core/class/conf.class.php | 4 ++-- htdocs/product/stock/productlot_card.php | 2 +- htdocs/product/stock/productlot_document.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3191e5edd47..39600605414 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -437,8 +437,8 @@ class Conf $this->service->dir_temp = $rootfortemp."/produit/temp"; // Module productbatch - $this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot"); - $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/produitlot/temp"); + $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot"); + $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp"); // Module contrat $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract"); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 8601ce25ebc..0968e2ea7ce 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -397,7 +397,7 @@ if (empty($action)) print '<a name="builddoc"></a>'; // ancre // Documents - $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); + $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch'); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 535486f8c62..2882bbf1c9f 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -26,7 +26,7 @@ /** * \file htdocs/product/stock/productlot_document.php * \ingroup product - * \brief Page des documents joints sur les lots produits + * \brief Page of attached documents for porudct lots */ require '../../main.inc.php'; @@ -79,7 +79,7 @@ if ($id || $ref) $object->fetch($id, $productid, $batch); $object->ref = $object->batch; // For document management ( it use $object->ref) - if (!empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, $modulepart).dol_sanitizeFileName($object->ref); + if (!empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); } From 886965be7604250b3e4fec896f119195be3b61bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 12:54:57 +0100 Subject: [PATCH 127/173] Show product on lot record tab document --- htdocs/product/stock/productlot_document.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index db3e5aebe14..ca522f48da7 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -142,6 +142,13 @@ if ($object->id) print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; + // Product + print '<tr><td class="titlefield">'.$langs->trans("Product").'</td><td>'; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '</td></tr>'; + print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>'; print '</table>'; From cb1e36de9ca910ad84cfcb1303b6d60d924004cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Fri, 26 Feb 2021 12:58:41 +0100 Subject: [PATCH 128/173] really fix typo --- htdocs/projet/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/event.php b/htdocs/projet/event.php index 91f763a5e83..8cbd1895b89 100644 --- a/htdocs/projet/event.php +++ b/htdocs/projet/event.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page -$langs->load('projects', 'enventorganization'); +$langs->load('projects', 'eventorganization'); $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); From ad63ac6bb0b95ca5b64aefcb09af28b54fe4c0c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 13:08:24 +0100 Subject: [PATCH 129/173] Update societe.class.php --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 899e03438f5..0ac078280c1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1601,7 +1601,7 @@ class Societe extends CommonObject $sql .= ', fj.libelle as forme_juridique'; $sql .= ', e.libelle as effectif'; $sql .= ', c.code as country_code, c.label as country'; - $sql .= ', d.code_departement as state_code,r.code_region as region_code, d.nom as state'; + $sql .= ', d.code_departement as state_code, d.nom as state, r.code_region as region_code'; $sql .= ', st.libelle as stcomm, st.picto as stcomm_picto'; $sql .= ', te.code as typent_code'; $sql .= ', i.libelle as label_incoterms'; @@ -1612,7 +1612,7 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as fj ON s.fk_forme_juridique = fj.code'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON d.fk_region = r.rowid '; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON d.fk_region = r.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_remise as sr ON sr.rowid = (SELECT MAX(rowid) FROM '.MAIN_DB_PREFIX.'societe_remise WHERE fk_soc = s.rowid AND entity IN ('.getEntity('discount').'))'; From db871994fbf426ecf3e60dfa95cc634ddf410261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 13:10:10 +0100 Subject: [PATCH 130/173] code syntax variants webservice directory --- htdocs/variants/admin/admin.php | 3 +- htdocs/variants/ajax/getCombinations.php | 20 +- htdocs/variants/ajax/get_attribute_values.php | 20 +- htdocs/variants/ajax/orderAttribute.php | 24 +- htdocs/variants/card.php | 16 +- .../variants/class/ProductAttribute.class.php | 9 +- .../class/ProductCombination.class.php | 37 +- htdocs/variants/combinations.php | 126 +++--- htdocs/variants/create.php | 3 +- htdocs/variants/create_val.php | 6 +- htdocs/variants/list.php | 3 +- htdocs/webservices/admin/index.php | 32 +- htdocs/webservices/index.php | 3 +- htdocs/webservices/server_actioncomm.php | 121 +++--- htdocs/webservices/server_category.php | 62 ++- htdocs/webservices/server_contact.php | 135 +++--- htdocs/webservices/server_invoice.php | 230 +++++----- htdocs/webservices/server_order.php | 406 +++++++++--------- htdocs/webservices/server_other.php | 68 ++- htdocs/webservices/server_payment.php | 22 +- .../webservices/server_productorservice.php | 4 +- htdocs/webservices/server_project.php | 107 ++--- .../webservices/server_supplier_invoice.php | 75 ++-- htdocs/webservices/server_thirdparty.php | 219 +++++----- htdocs/webservices/server_user.php | 171 ++++---- 25 files changed, 894 insertions(+), 1028 deletions(-) diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 64209076916..f5467760a89 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -25,8 +25,9 @@ $langs->loadLangs(array("admin", "products")); $action = GETPOST('action', 'alphanohtml'); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) +if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { accessforbidden(); +} $error = 0; diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php index 67c1dd4284c..adb227c2fd6 100644 --- a/htdocs/variants/ajax/getCombinations.php +++ b/htdocs/variants/ajax/getCombinations.php @@ -16,11 +16,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -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('NOREQUIRESOC')) define('NOREQUIRESOC', '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('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index e80cb9aae2b..e61676339ee 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -15,11 +15,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -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('NOREQUIRESOC')) define('NOREQUIRESOC', '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('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/variants/ajax/orderAttribute.php b/htdocs/variants/ajax/orderAttribute.php index 8b851c9be6b..c787517e5c7 100644 --- a/htdocs/variants/ajax/orderAttribute.php +++ b/htdocs/variants/ajax/orderAttribute.php @@ -16,12 +16,24 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable 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('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disable 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('NOREQUIRETRAN')) { + define('NOREQUIRETRAN', '1'); +} require '../../main.inc.php'; diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 986db1b14bc..ecaa4e77948 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -41,7 +41,9 @@ if ($object->fetch($id) < 1) { * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} if ($action) { if ($action == 'update') { @@ -60,19 +62,16 @@ if ($action) { $objectval->ref = $ref; $objectval->value = GETPOST('value', 'alpha'); - if (empty($objectval->ref)) - { + if (empty($objectval->ref)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (empty($objectval->value)) - { + if (empty($objectval->value)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } - if (!$error) - { + if (!$error) { if ($objectval->update($user) > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } else { @@ -102,8 +101,7 @@ if ($confirm == 'yes') { header('Location: '.dol_buildpath('/variants/list.php', 2)); } exit(); - } elseif ($action == 'confirm_deletevalue') - { + } elseif ($action == 'confirm_deletevalue') { if ($objectval->fetch($valueid) > 0) { if ($objectval->delete($user) < 1) { setEventMessages($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors'); diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index bbc3a188137..b823cbea470 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -116,8 +116,7 @@ class ProductAttribute extends CommonObject $sql = 'SELECT rowid, ref, ref_ext, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')'; $sql .= $this->db->order('rang', 'asc'); $query = $this->db->query($sql); - if ($query) - { + if ($query) { while ($result = $this->db->fetch_object($query)) { $tmp = new ProductAttribute($this->db); $tmp->id = $result->rowid; @@ -128,8 +127,9 @@ class ProductAttribute extends CommonObject $return[] = $tmp; } + } else { + dol_print_error($this->db); } - else dol_print_error($this->db); return $return; } @@ -159,8 +159,7 @@ class ProductAttribute extends CommonObject VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")"; $query = $this->db->query($sql); - if ($query) - { + if ($query) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'product_attribute'); return $this->id; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 9152336bbe4..e60b99298fa 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -174,8 +174,7 @@ class ProductCombination */ if ($fk_price_level > 0) { $combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level); - } - else { + } else { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i); } @@ -227,8 +226,7 @@ class ProductCombination if ($error) { return $error * -1; - } - else { + } else { return 1; } } @@ -327,7 +325,9 @@ class ProductCombination $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) $nb = $obj->nb; + if ($obj) { + $nb = $obj->nb; + } } return $nb; @@ -506,8 +506,7 @@ class ProductCombination // MultiPrix if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) { $new_type = $parent->multiprices_base_type[$i]; $new_min_price = $parent->multiprices_min[$i]; @@ -709,8 +708,7 @@ class ProductCombination //Final price impact if (!is_array($forced_pricevar)) { $price_impact[1] = (float) $forced_pricevar; // If false, return 0 - } - else { + } else { $price_impact = $forced_pricevar; } @@ -765,8 +763,7 @@ class ProductCombination // Manage Price levels if ($conf->global->PRODUIT_MULTIPRICES) { - for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $price_impact[$i] += (float) price2num($variations[$currcombattr][$currcombval]['price']); } } @@ -826,8 +823,7 @@ class ProductCombination $newproduct->barcode = -1; $result = $newproduct->create($user); - if ($result < 0) - { + if ($result < 0) { //In case the error is not related with an already existing product if ($newproduct->error != 'ErrorProductAlreadyExists') { $this->error[] = $newproduct->error; @@ -867,8 +863,7 @@ class ProductCombination } } else { $result = $newproduct->update($newproduct->id, $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } @@ -876,8 +871,7 @@ class ProductCombination $newcomb->fk_product_child = $newproduct->id; - if ($newcomb->update($user) < 0) - { + if ($newcomb->update($user) < 0) { $this->error = $newcomb->error; $this->errors = $newcomb->errors; $this->db->rollback(); @@ -925,8 +919,7 @@ class ProductCombination $combination->variation_price_percentage, $combination->variation_price, $combination->variation_weight - ) < 0) - { + ) < 0) { return -1; } } @@ -954,12 +947,10 @@ class ProductCombination $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($obj->label) - { + if ($obj->label) { $label .= ' '.$obj->label; } $i++; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 933d379e48a..f950f764ad7 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -58,8 +58,7 @@ $prodattr = new ProductAttribute($db); $prodattr_val = new ProductAttributeValue($db); $object = new Product($db); -if ($id > 0 || $ref) -{ +if ($id > 0 || $ref) { $object->fetch($id, $ref); } @@ -80,16 +79,13 @@ if (!$object->isProduct() && !$object->isService()) { header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2)); exit(); } -if ($action == 'add') -{ +if ($action == 'add') { unset($selectedvariant); unset($_SESSION['addvariant_'.$object->id]); } -if ($action == 'create' && GETPOST('selectvariant', 'alpha')) // We click on select combination -{ +if ($action == 'create' && GETPOST('selectvariant', 'alpha')) { // We click on select combination $action = 'add'; - if (GETPOST('attribute') != '-1' && GETPOST('value') != '-1') - { + if (GETPOST('attribute') != '-1' && GETPOST('value') != '-1') { $selectedvariant[GETPOST('attribute').':'.GETPOST('value')] = GETPOST('attribute').':'.GETPOST('value'); $_SESSION['addvariant_'.$object->id] = $selectedvariant; } @@ -101,9 +97,8 @@ $prodcomb2val = new ProductCombination2ValuePair($db); $productCombination2ValuePairs1 = array(); -if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations -{ - //$features = GETPOST('features', 'array'); +if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) { // We click on Create all defined combinations +//$features = GETPOST('features', 'array'); $features = $_SESSION['addvariant_'.$object->id]; if (!$features) { @@ -121,8 +116,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( // for conf PRODUIT_MULTIPRICES if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); - } - else { + } else { $level_price_impact = array(1 => $price_impact); $level_price_impact_percent = array(1 => $price_impact_percent); } @@ -156,11 +150,9 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( // sanit_feature is an array with 1 (and only 1) value per attribute. // For example: Color->blue, Size->Small, Option->2 //var_dump($sanit_features); - if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) - { + if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); unset($_SESSION['addvariant_'.$object->id]); @@ -243,8 +235,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $prodcomb->variation_price = $level_price_impact[1]; $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; - } - else { + } else { $level_price_impact = array(1 => $price_impact); $level_price_impact_percent = array(1 => $price_impact_percent); @@ -330,12 +321,13 @@ if ($action === 'confirm_deletecombination') { $form = new Form($db); -if (!empty($id) || !empty($ref)) -{ +if (!empty($id) || !empty($ref)) { llxHeader("", "", $langs->trans("CardProduct".$object->type)); $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { + $showbarcode = 0; + } $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); @@ -357,17 +349,25 @@ if (!empty($id) || !empty($ref)) print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>'; $positiverates = ''; - if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + } + if (price2num($object->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + } + if (price2num($object->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); /* - if ($object->default_vat_code) - { - print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; - } - else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/ + if ($object->default_vat_code) + { + print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; + } + else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/ print '</td></tr>'; // Price @@ -390,8 +390,7 @@ if (!empty($id) || !empty($ref)) // Weight print '<tr><td>'.$langs->trans("Weight").'</td><td>'; - if ($object->weight != '') - { + if ($object->weight != '') { print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { print '&nbsp;'; @@ -466,14 +465,14 @@ if (!empty($id) || !empty($ref)) foreach ($productCombination2ValuePairs1 as $pc2v) { $prodattr_val->fetch($pc2v->fk_prod_attr_val); ?> - variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>); - variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = { - attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>], - value: { - id: <?php echo $pc2v->fk_prod_attr_val ?>, - label: '<?php echo $prodattr_val->value ?>' - } - }; + variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>); + variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = { + attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>], + value: { + id: <?php echo $pc2v->fk_prod_attr_val ?>, + label: '<?php echo $prodattr_val->value ?>' + } + }; <?php } ?> @@ -604,8 +603,7 @@ if (!empty($id) || !empty($ref)) print '<table class="border" style="width: 100%">'; // When in edit mode - if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) - { + if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) { ?> <tr> <td class="titlefieldcreate tdtop"><label for="features"><?php echo $langs->trans('Combination') ?></label></td> @@ -616,8 +614,7 @@ if (!empty($id) || !empty($ref)) $result1 = $prodattr->fetch($val->fk_prod_attr); $result2 = $prodattr_val->fetch($val->fk_prod_attr_val); //print 'rr'.$result1.' '.$result2; - if ($result1 > 0 && $result2 > 0) - { + if ($result1 > 0 && $result2 > 0) { print $prodattr->label.' - '.$prodattr_val->value.'<br>'; // TODO Add delete link } @@ -651,8 +648,7 @@ if (!empty($id) || !empty($ref)) } else { $prodcomb->fetchCombinationPriceLevels(); - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print '<tr>'; print '<td><label for="level_price_impact_'.$i.'">'.$langs->trans('ImpactOnPriceLevel', $i).'</label>'; if ($i === 1) { @@ -703,7 +699,9 @@ if (!empty($id) || !empty($ref)) ?> <div style="text-align: center"> - <input type="submit" name="create" <?php if (!is_array($productCombination2ValuePairs1)) print ' disabled="disabled"'; ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save") ?>" class="button button-save"> + <input type="submit" name="create" <?php if (!is_array($productCombination2ValuePairs1)) { + print ' disabled="disabled"'; + } ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save") ?>" class="button button-save"> &nbsp; <input type="submit" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>" class="button button-cancel"> </div> @@ -732,8 +730,7 @@ if (!empty($id) || !empty($ref)) $comb2val = new ProductCombination2ValuePair($db); - if ($productCombinations) - { + if ($productCombinations) { ?> <script type="text/javascript"> @@ -767,8 +764,7 @@ if (!empty($id) || !empty($ref)) print '<a href="combinations.php?id='.$object->id.'&action=add&token='.newToken().'" class="butAction">'.$langs->trans('NewProductCombination').'</a>'; // NewVariant - if ($productCombinations) - { + if ($productCombinations) { print '<a href="combinations.php?id='.$object->id.'&action=copy&token='.newToken().'" class="butAction">'.$langs->trans('PropagateVariant').'</a>'; } @@ -791,8 +787,8 @@ if (!empty($id) || !empty($ref)) // List of mass actions available /* $arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->product->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -800,8 +796,7 @@ if (!empty($id) || !empty($ref)) */ $aaa = ''; - if (count($productCombinations)) - { + if (count($productCombinations)) { $aaa = '<label for="massaction">'.$langs->trans('BulkActions').'</label>'; $aaa .= '<select id="bulk_action" name="massaction" class="flat">'; $aaa .= ' <option value="nothing">&nbsp;</option>'; @@ -826,11 +821,13 @@ if (!empty($id) || !empty($ref)) <td class="liste_titre"><?php echo $langs->trans('Product') ?></td> <td class="liste_titre"><?php echo $langs->trans('Combination') ?></td> <td class="liste_titre right"><?php echo $langs->trans('PriceImpact') ?></td> - <?php if ($object->isProduct()) print'<td class="liste_titre right">'.$langs->trans('WeightImpact').'</td>'; ?> + <?php if ($object->isProduct()) { + print'<td class="liste_titre right">'.$langs->trans('WeightImpact').'</td>'; + } ?> <td class="liste_titre center"><?php echo $langs->trans('OnSell') ?></td> <td class="liste_titre center"><?php echo $langs->trans('OnBuy') ?></td> <td class="liste_titre"></td> - <?php + <?php print '<td class="liste_titre center">'; $searchpicto = $form->showCheckAddButtons('checkforselect', 1); print $searchpicto; @@ -839,10 +836,8 @@ if (!empty($id) || !empty($ref)) </tr> <?php - if (count($productCombinations)) - { - foreach ($productCombinations as $currcomb) - { + if (count($productCombinations)) { + foreach ($productCombinations as $currcomb) { $prodstatic->fetch($currcomb->fk_product_child); print '<tr class="oddeven">'; print '<td>'.$prodstatic->getNomUrl(1).'</td>'; @@ -869,10 +864,11 @@ if (!empty($id) || !empty($ref)) print '<a class="paddingleft paddingright" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=delete&token='.newToken().'&valueid='.$currcomb->id.'">'.img_delete().'</a>'; print '</td>'; print '<td class="nowrap center">'; - if ($productCombinations || $massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($productCombinations || $massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($prodstatic->id, $arrayofselected)) $selected = 1; + if (in_array($prodstatic->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$prodstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index e37548f39f3..ee178f2728d 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -40,8 +40,7 @@ if ($action == 'add') { $resid = $prodattr->create($user); if ($resid > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - if ($backtopage) - { + if ($backtopage) { header('Location: '.$backtopage); } else { header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$resid.'&backtopage='.urlencode($backtopage)); diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index b422df90120..ce03f314265 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -41,8 +41,7 @@ if ($object->fetch($id) < 1) { * Actions */ -if ($cancel) -{ +if ($cancel) { $action = ''; header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); @@ -56,8 +55,7 @@ if ($cancel) * View */ -if ($action == 'add') -{ +if ($action == 'add') { if (empty($ref) || empty($value)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 683b28719a9..dde43397671 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -56,8 +56,7 @@ $variants = $object->fetchAll(); llxHeader('', $title); $newcardbutton = ''; -if ($user->rights->produit->creer) -{ +if ($user->rights->produit->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('Create'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/create.php'); } diff --git a/htdocs/webservices/admin/index.php b/htdocs/webservices/admin/index.php index 2c14d2d07f5..1c78acae84d 100644 --- a/htdocs/webservices/admin/index.php +++ b/htdocs/webservices/admin/index.php @@ -29,26 +29,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $actionsave = GETPOST("save"); // Sauvegardes parametres -if ($actionsave) -{ +if ($actionsave) { $i = 0; $db->begin(); $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity); - if ($i >= 1) - { + if ($i >= 1) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else { + } else { $db->rollback(); setEventMessages($langs->trans("Error"), null, 'errors'); } @@ -84,8 +82,9 @@ print "</tr>"; print '<tr class="oddeven">'; print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>'; print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'.(GETPOST('WEBSERVICES_KEY') ?GETPOST('WEBSERVICES_KEY') : (!empty($conf->global->WEBSERVICES_KEY) ? $conf->global->WEBSERVICES_KEY : '')).'" size="40">'; -if (!empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +} print '</td>'; print '<td>&nbsp;</td>'; print '</tr>'; @@ -118,9 +117,10 @@ $webservices = array( // WSDL print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>'; -foreach ($webservices as $name => $right) -{ - if (!empty($right) && !verifCond($right)) continue; +foreach ($webservices as $name => $right) { + if (!empty($right) && !verifCond($right)) { + continue; + } $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl'; print img_picto('', 'globe').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; } @@ -129,9 +129,10 @@ print '<br>'; // Endpoint print '<u>'.$langs->trans("EndPointIs").':</u><br>'; -foreach ($webservices as $name => $right) -{ - if (!empty($right) && !verifCond($right)) continue; +foreach ($webservices as $name => $right) { + if (!empty($right) && !verifCond($right)) { + continue; + } $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php'; print img_picto('', 'globe').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; } @@ -141,8 +142,7 @@ print '<br>'; print '<br>'; print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php'); -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print "\n".'<script type="text/javascript">'; print '$(document).ready(function () { $("#generate_token").click(function() { diff --git a/htdocs/webservices/index.php b/htdocs/webservices/index.php index e6e76692b05..72b0548ec52 100644 --- a/htdocs/webservices/index.php +++ b/htdocs/webservices/index.php @@ -38,8 +38,7 @@ $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 140351e7d21..4be0847bc51 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -23,7 +23,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require "../master.inc.php"; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -37,8 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; dol_syslog("Call ActionComm webservices interfaces"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -122,18 +123,21 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array); +} // Define other specific objects $server->wsdl->addComplexType( @@ -255,7 +259,9 @@ function getActionComm($authentication, $id) dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -263,22 +269,18 @@ function getActionComm($authentication, $id) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if ($error || (!$id)) - { + if ($error || (!$id)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->agenda->allactions->read) - { + if ($fuser->rights->agenda->allactions->read) { $actioncomm = new ActionComm($db); $result = $actioncomm->fetch($id); - if ($result > 0) - { + if ($result > 0) { $actioncomm_result_fields = array( 'id' => $actioncomm->id, 'ref'=> $actioncomm->ref, @@ -315,10 +317,8 @@ function getActionComm($authentication, $id) //Get extrafield values $actioncomm->fetch_optionals(); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key])); } } @@ -327,20 +327,17 @@ function getActionComm($authentication, $id) $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'actioncomm'=>$actioncomm_result_fields); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -360,7 +357,9 @@ function getListActionCommType($authentication) dol_syslog("Function: getListActionCommType login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -368,18 +367,15 @@ function getListActionCommType($authentication) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->agenda->myactions->read) - { + if ($fuser->rights->agenda->myactions->read) { $cactioncomm = new CActionComm($db); $result = $cactioncomm->liste_array('', 'code'); - if ($result > 0) - { + if ($result > 0) { $resultarray = array(); - foreach ($cactioncomm->liste_array as $code=>$libeller) { + foreach ($cactioncomm->liste_array as $code => $libeller) { $resultarray[] = array('code'=>$code, 'libelle'=>$libeller); } @@ -396,8 +392,7 @@ function getListActionCommType($authentication) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -420,7 +415,9 @@ function createActionComm($authentication, $actioncomm) dol_syslog("Function: createActionComm login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -428,8 +425,7 @@ function createActionComm($authentication, $actioncomm) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if (!$error) - { + if (!$error) { $newobject = new ActionComm($db); $newobject->datep = $actioncomm['datep']; @@ -454,10 +450,8 @@ function createActionComm($authentication, $actioncomm) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $newobject->array_options[$key] = $actioncomm[$key]; } @@ -466,17 +460,14 @@ function createActionComm($authentication, $actioncomm) $db->begin(); $result = $newobject->create($fuser); - if ($result <= 0) - { + if ($result <= 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -484,8 +475,7 @@ function createActionComm($authentication, $actioncomm) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -507,7 +497,9 @@ function updateActionComm($authentication, $actioncomm) dol_syslog("Function: updateActionComm login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -519,8 +511,7 @@ function updateActionComm($authentication, $actioncomm) $error++; $errorcode = 'KO'; $errorlabel = "Actioncomm id is mandatory."; } - if (!$error) - { + if (!$error) { $objectfound = false; $object = new ActionComm($db); @@ -551,10 +542,8 @@ function updateActionComm($authentication, $actioncomm) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $object->array_options[$key] = $actioncomm[$key]; } @@ -568,16 +557,13 @@ function updateActionComm($authentication, $actioncomm) } } - if ((!$error) && ($objectfound)) - { + if ((!$error) && ($objectfound)) { $db->commit(); $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$object->id ); - } - elseif ($objectfound) - { + } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; @@ -589,8 +575,7 @@ function updateActionComm($authentication, $actioncomm) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 949c95dc530..f016a65f61f 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -21,7 +21,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require "../master.inc.php"; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -32,8 +34,7 @@ require_once DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"; dol_syslog("Call Dolibarr webservices interfaces"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -109,12 +110,12 @@ $server->wsdl->addComplexType( * Image of product */ $server->wsdl->addComplexType( - 'PhotosArray', - 'complexType', - 'array', - 'sequence', - '', - array( + 'PhotosArray', + 'complexType', + 'array', + 'sequence', + '', + array( 'image' => array( 'name' => 'image', 'type' => 'tns:image', @@ -128,12 +129,12 @@ $server->wsdl->addComplexType( * An image */ $server->wsdl->addComplexType( - 'image', - 'complexType', - 'struct', - 'all', - '', - array( + 'image', + 'complexType', + 'struct', + 'all', + '', + array( 'photo' => array('name'=>'photo', 'type'=>'xsd:string'), 'photo_vignette' => array('name'=>'photo_vignette', 'type'=>'xsd:string'), 'imgWidth' => array('name'=>'imgWidth', 'type'=>'xsd:string'), @@ -194,30 +195,28 @@ function getCategory($authentication, $id) dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if (!$error && !$id) - { + if (!$error && !$id) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); $nbmax = 10; - if ($fuser->rights->categorie->lire) - { + if ($fuser->rights->categorie->lire) { $categorie = new Categorie($db); $result = $categorie->fetch($id); - if ($result > 0) - { + if ($result > 0) { $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output); $pdir = get_exdir($categorie->id, 2, 0, 0, $categorie, 'category').$categorie->id."/photos/"; $dir = $dir.'/'.$pdir; @@ -235,10 +234,8 @@ function getCategory($authentication, $id) ); $cats = $categorie->get_filles(); - if (count($cats) > 0) - { - foreach ($cats as $fille) - { + if (count($cats) > 0) { + foreach ($cats as $fille) { $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output); $pdir = get_exdir($fille->id, 2, 0, 0, $categorie, 'category').$fille->id."/photos/"; $dir = $dir.'/'.$pdir; @@ -261,20 +258,17 @@ function getCategory($authentication, $id) 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'categorie'=> $cat ); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 97b219c7aba..9f57a445cc3 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -21,7 +21,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require "../master.inc.php"; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -33,8 +35,7 @@ require_once DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php"; dol_syslog("Call Contact webservices interfaces"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -127,18 +128,21 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $contact_fields = array_merge($contact_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $contact_fields = array_merge($contact_fields, $extrafield_array); +} // Define other specific objects $server->wsdl->addComplexType( @@ -247,7 +251,9 @@ function getContact($authentication, $id, $ref_ext) dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -255,24 +261,20 @@ function getContact($authentication, $id, $ref_ext) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && ($id && $ref_ext)) - { + if (!$error && ($id && $ref_ext)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); $contact = new Contact($db); $result = $contact->fetch($id, 0, $ref_ext); - if ($result > 0) - { + if ($result > 0) { // Only internal user who have contact read permission // Or for external user who have contact read permission, with restrict on socid - if ( - $fuser->rights->societe->contact->lire && !$fuser->socid + if ($fuser->rights->societe->contact->lire && !$fuser->socid || ($fuser->rights->societe->contact->lire && ($fuser->socid == $contact->socid)) ) { $contact_result_fields = array( @@ -319,10 +321,8 @@ function getContact($authentication, $id, $ref_ext) //Get extrafield values $contact->fetch_optionals(); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key])); } } @@ -332,20 +332,17 @@ function getContact($authentication, $id, $ref_ext) 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'contact'=>$contact_result_fields ); - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -368,7 +365,9 @@ function createContact($authentication, $contact) dol_syslog("Function: createContact login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -376,13 +375,11 @@ function createContact($authentication, $contact) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (empty($contact['lastname'])) - { + if (empty($contact['lastname'])) { $error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory."; } - if (!$error) - { + if (!$error) { $newobject = new Contact($db); $newobject->id = $contact['id']; @@ -424,10 +421,8 @@ function createContact($authentication, $contact) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $newobject->array_options[$key] = $contact[$key]; } @@ -439,17 +434,14 @@ function createContact($authentication, $contact) $db->begin(); $result = $newobject->create($fuser); - if ($result <= 0) - { + if ($result <= 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -457,8 +449,7 @@ function createContact($authentication, $contact) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -478,7 +469,9 @@ function getContactsForThirdParty($authentication, $idthirdparty) dol_syslog("Function: getContactsForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -486,14 +479,12 @@ function getContactsForThirdParty($authentication, $idthirdparty) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && empty($idthirdparty)) - { + if (!$error && empty($idthirdparty)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter id is not provided'; } - if (!$error) - { + if (!$error) { $linesinvoice = array(); $sql = "SELECT c.rowid, c.fk_soc, c.civility as civility_id, c.lastname, c.firstname, c.statut as status,"; @@ -515,12 +506,10 @@ function getContactsForThirdParty($authentication, $idthirdparty) $sql .= " WHERE c.fk_soc = ".$idthirdparty; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { // En attendant remplissage par boucle $obj = $db->fetch_object($resql); @@ -580,15 +569,13 @@ function getContactsForThirdParty($authentication, $idthirdparty) 'contacts'=>$linescontact ); - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -611,7 +598,9 @@ function updateContact($authentication, $contact) dol_syslog("Function: updateContact login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -623,14 +612,12 @@ function updateContact($authentication, $contact) $error++; $errorcode = 'KO'; $errorlabel = "Contact id or ref_ext is mandatory."; } // Check parameters - if (!$error && ($id && $ref_ext)) - { + if (!$error && ($id && $ref_ext)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them."; } - if (!$error) - { + if (!$error) { $objectfound = false; include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -650,7 +637,9 @@ function updateContact($authentication, $contact) $object->town = $contact['town']; $object->country_id = $contact['country_id']; - if ($contact['country_code']) $object->country_id = getCountry($contact['country_code'], 3); + if ($contact['country_code']) { + $object->country_id = getCountry($contact['country_code'], 3); + } $object->province_id = $contact['province_id']; @@ -671,10 +660,8 @@ function updateContact($authentication, $contact) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $object->array_options[$key] = $contact[$key]; } @@ -688,16 +675,13 @@ function updateContact($authentication, $contact) } } - if ((!$error) && ($objectfound)) - { + if ((!$error) && ($objectfound)) { $db->commit(); $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$object->id ); - } - elseif ($objectfound) - { + } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; @@ -709,8 +693,7 @@ function updateContact($authentication, $contact) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index e696258e5d9..d1382ac7c62 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -21,7 +21,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -38,8 +40,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -112,16 +113,16 @@ $server->wsdl->addComplexType( ); /*$server->wsdl->addComplexType( - 'LinesArray', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:line[]') - ), - 'tns:line' + 'LinesArray', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array( + array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:line[]') + ), + 'tns:line' );*/ $server->wsdl->addComplexType( 'LinesArray2', @@ -176,16 +177,16 @@ $server->wsdl->addComplexType( ); /* $server->wsdl->addComplexType( - 'InvoicesArray', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]') - ), - 'tns:invoice' + 'InvoicesArray', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array( + array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]') + ), + 'tns:invoice' );*/ $server->wsdl->addComplexType( 'InvoicesArray2', @@ -252,16 +253,16 @@ $server->register( 'WS to create an invoice' ); $server->register( - 'createInvoiceFromOrder', - // Entry values + 'createInvoiceFromOrder', + // Entry values array('authentication'=>'tns:authentication', 'id_order'=>'xsd:string', 'ref_order'=>'xsd:string', 'ref_ext_order'=>'xsd:string'), - // Exit values + // Exit values array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), - $ns, - $ns.'#createInvoiceFromOrder', - $styledoc, - $styleuse, - 'WS to create an invoice from an order' + $ns, + $ns.'#createInvoiceFromOrder', + $styledoc, + $styleuse, + 'WS to create an invoice from an order' ); $server->register( 'updateInvoice', @@ -292,7 +293,9 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') dol_syslog("Function: getInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -300,26 +303,21 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->facture->lire) - { + if ($fuser->rights->facture->lire) { $invoice = new Facture($db); $result = $invoice->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { $linesresp = array(); $i = 0; - foreach ($invoice->lines as $line) - { + foreach ($invoice->lines as $line) { //var_dump($line); exit; $linesresp[] = array( 'id'=>$line->id, @@ -346,7 +344,7 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'invoice'=>array( 'id' => $invoice->id, - 'ref' => $invoice->ref, + 'ref' => $invoice->ref, 'ref_ext' => $invoice->ref_ext ? $invoice->ref_ext : '', // If not defined, field is not added into soap 'thirdparty_id' => $invoice->socid, 'fk_user_author' => $invoice->user_author ? $invoice->user_author : '', @@ -369,20 +367,17 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') 'payment_mode_id' => $invoice->mode_reglement_id ? $invoice->mode_reglement_id : '', 'lines' => $linesresp )); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -403,7 +398,9 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -411,31 +408,31 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } // Check parameters - if (!$error && empty($idthirdparty)) - { + if (!$error && empty($idthirdparty)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter idthirdparty is not provided'; } - if (!$error) - { + if (!$error) { $linesinvoice = array(); $sql = 'SELECT f.rowid as facid, ref as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; - if ($idthirdparty != 'all') $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty); + if ($idthirdparty != 'all') { + $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty); + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { // En attendant remplissage par boucle $obj = $db->fetch_object($resql); @@ -443,18 +440,15 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) $invoice->fetch($obj->facid); // Sécurité pour utilisateur externe - if ($socid && ($socid != $invoice->socid)) - { + if ($socid && ($socid != $invoice->socid)) { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = $invoice->socid.' User does not have permission for this request'; } - if (!$error) - { + if (!$error) { // Define lines of invoice $linesresp = array(); - foreach ($invoice->lines as $line) - { + foreach ($invoice->lines as $line) { $linesresp[] = array( 'id'=>$line->id, 'type'=>$line->product_type, @@ -508,15 +502,13 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) 'invoices'=>$linesinvoice ); - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -539,7 +531,9 @@ function createInvoice($authentication, $invoice) dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice['id'].", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -552,8 +546,7 @@ function createInvoice($authentication, $invoice) $error++; $errorcode = 'KO'; $errorlabel = "Invoice id or ref or ref_ext is mandatory."; } - if (!$error) - { + if (!$error) { $new_invoice = new Facture($db); $new_invoice->socid = $invoice['thirdparty_id']; $new_invoice->type = $invoice['type']; @@ -571,16 +564,19 @@ function createInvoice($authentication, $invoice) if ($res > 0) { $new_invoice->mode_reglement_id = !empty($invoice['payment_mode_id']) ? $invoice['payment_mode_id'] : $soc->mode_reglement_id; $new_invoice->cond_reglement_id = $soc->cond_reglement_id; + } else { + $new_invoice->mode_reglement_id = $invoice['payment_mode_id']; } - else $new_invoice->mode_reglement_id = $invoice['payment_mode_id']; // Trick because nusoap does not store data with same structure if there is one or several lines $arrayoflines = array(); - if (isset($invoice['lines']['line'][0])) $arrayoflines = $invoice['lines']['line']; - else $arrayoflines = $invoice['lines']; + if (isset($invoice['lines']['line'][0])) { + $arrayoflines = $invoice['lines']['line']; + } else { + $arrayoflines = $invoice['lines']; + } - foreach ($arrayoflines as $line) - { + foreach ($arrayoflines as $line) { // $key can be 'line' or '0','1',... $newline = new FactureLigne($db); $newline->product_type = $line['type']; @@ -603,27 +599,22 @@ function createInvoice($authentication, $invoice) $db->begin(); $result = $new_invoice->create($fuser, 0, dol_stringtotime($invoice['date_due'], 'dayrfc')); - if ($result < 0) - { + if ($result < 0) { $error++; } - if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED) // We want invoice to have status validated - { + if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED) { // We want invoice to have status validated $result = $new_invoice->validate($fuser); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$new_invoice->id, 'ref'=>$new_invoice->ref, 'ref_ext'=>$new_invoice->ref_ext); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -632,8 +623,7 @@ function createInvoice($authentication, $invoice) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -655,14 +645,18 @@ function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = '' dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.", ref=".$ref_order.", ref_ext=".$ref_ext_order); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } // Check parameters if (empty($id_order) && empty($ref_order) && empty($ref_ext_order)) { @@ -670,51 +664,41 @@ function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = '' } ////////////////////// - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->commande->lire) - { + if ($fuser->rights->commande->lire) { $order = new Commande($db); $result = $order->fetch($id_order, $ref_order, $ref_ext_order); - if ($result > 0) - { + if ($result > 0) { // Security for external user - if ($socid && ($socid != $order->socid)) - { + if ($socid && ($socid != $order->socid)) { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.'User does not have permission for this request'; } - if (!$error) - { + if (!$error) { $newobject = new Facture($db); $result = $newobject->createFromOrder($order, $fuser); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog("Webservice server_invoice:: invoice creation from order failed", LOG_ERR); } } - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id_order.' nor ref='.$ref_order.' nor ref_ext='.$ref_ext_order; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } - else { + } else { $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref, 'ref_ext'=>$newobject->ref_ext); } @@ -735,7 +719,9 @@ function updateInvoice($authentication, $invoice) dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id']. ", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -748,8 +734,7 @@ function updateInvoice($authentication, $invoice) $error++; $errorcode = 'KO'; $errorlabel = "Invoice id or ref or ref_ext is mandatory."; } - if (!$error) - { + if (!$error) { $objectfound = false; $object = new Facture($db); @@ -760,18 +745,14 @@ function updateInvoice($authentication, $invoice) $db->begin(); - if (isset($invoice['status'])) - { - if ($invoice['status'] == Facture::STATUS_DRAFT) - { + if (isset($invoice['status'])) { + if ($invoice['status'] == Facture::STATUS_DRAFT) { $result = $object->setDraft($fuser); } - if ($invoice['status'] == Facture::STATUS_VALIDATED) - { + if ($invoice['status'] == Facture::STATUS_VALIDATED) { $result = $object->validate($fuser); - if ($result >= 0) - { + if ($result >= 0) { // Define output language $outputlangs = $langs; $object->generateDocument($object->model_pdf, $outputlangs); @@ -806,8 +787,7 @@ function updateInvoice($authentication, $invoice) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 8c278768990..8f3d5af17e6 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -22,7 +22,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -36,8 +38,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -56,12 +57,12 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), 'login' => array('name'=>'login', 'type'=>'xsd:string'), @@ -71,12 +72,12 @@ $server->wsdl->addComplexType( ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( + 'result', + 'complexType', + 'struct', + 'all', + '', + array( 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), ) @@ -120,27 +121,30 @@ $extrafield_line_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_line_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { //$value=$object->array_options["options_".$key]; $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_line_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_line_array)) $line_fields = array_merge($line_fields, $extrafield_line_array); +if (is_array($extrafield_line_array)) { + $line_fields = array_merge($line_fields, $extrafield_line_array); +} // Define other specific objects $server->wsdl->addComplexType( - 'line', - 'complexType', - 'struct', - 'all', - '', - $line_fields + 'line', + 'complexType', + 'struct', + 'all', + '', + $line_fields ); /*$server->wsdl->addComplexType( @@ -159,12 +163,12 @@ $server->wsdl->addComplexType( 'tns:line' );*/ $server->wsdl->addComplexType( - 'LinesArray2', - 'complexType', - 'array', - 'sequence', - '', - array( + 'LinesArray2', + 'complexType', + 'array', + 'sequence', + '', + array( 'line' => array( 'name' => 'line', 'type' => 'tns:line', @@ -224,26 +228,29 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { //$value=$object->array_options["options_".$key]; $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $order_fields = array_merge($order_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $order_fields = array_merge($order_fields, $extrafield_array); +} $server->wsdl->addComplexType( - 'order', - 'complexType', - 'struct', - 'all', - '', - $order_fields + 'order', + 'complexType', + 'struct', + 'all', + '', + $order_fields ); /* @@ -263,12 +270,12 @@ $server->wsdl->addComplexType( 'tns:order' );*/ $server->wsdl->addComplexType( - 'OrdersArray2', - 'complexType', - 'array', - 'sequence', - '', - array( + 'OrdersArray2', + 'complexType', + 'array', + 'sequence', + '', + array( 'order' => array( 'name' => 'order', 'type' => 'tns:order', @@ -289,58 +296,58 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped // Register WSDL $server->register( - 'getOrder', - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Entry values - array('result'=>'tns:result', 'order'=>'tns:order'), // Exit values - $ns, - $ns.'#getOrder', - $styledoc, - $styleuse, - 'WS to get a particular invoice' + 'getOrder', + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Entry values + array('result'=>'tns:result', 'order'=>'tns:order'), // Exit values + $ns, + $ns.'#getOrder', + $styledoc, + $styleuse, + 'WS to get a particular invoice' ); $server->register( - 'getOrdersForThirdParty', - array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'), // Entry values - array('result'=>'tns:result', 'orders'=>'tns:OrdersArray2'), // Exit values - $ns, - $ns.'#getOrdersForThirdParty', - $styledoc, - $styleuse, - 'WS to get all orders of a third party' + 'getOrdersForThirdParty', + array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'), // Entry values + array('result'=>'tns:result', 'orders'=>'tns:OrdersArray2'), // Exit values + $ns, + $ns.'#getOrdersForThirdParty', + $styledoc, + $styleuse, + 'WS to get all orders of a third party' ); $server->register( - 'createOrder', - array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values - array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'), // Exit values - $ns, - $ns.'#createOrder', - $styledoc, - $styleuse, - 'WS to create an order' + 'createOrder', + array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values + array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'), // Exit values + $ns, + $ns.'#createOrder', + $styledoc, + $styleuse, + 'WS to create an order' ); $server->register( - 'updateOrder', - array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values - array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Exit values - $ns, - $ns.'#updateOrder', - $styledoc, - $styleuse, - 'WS to update an order' + 'updateOrder', + array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values + array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Exit values + $ns, + $ns.'#updateOrder', + $styledoc, + $styleuse, + 'WS to update an order' ); $server->register( - 'validOrder', - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'id_warehouse'=>'xsd:string'), // Entry values - array('result'=>'tns:result'), // Exit values - $ns, - $ns.'#validOrder', - $styledoc, - $styleuse, - 'WS to valid an order' + 'validOrder', + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'id_warehouse'=>'xsd:string'), // Entry values + array('result'=>'tns:result'), // Exit values + $ns, + $ns.'#validOrder', + $styledoc, + $styleuse, + 'WS to valid an order' ); /** @@ -358,7 +365,9 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') dol_syslog("Function: getOrder login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -368,38 +377,33 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->commande->lire) - { + if ($fuser->rights->commande->lire) { $order = new Commande($db); $result = $order->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { // Security for external user - if ($socid && $socid != $order->socid) - { + if ($socid && $socid != $order->socid) { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } - if (!$error) - { + if (!$error) { $linesresp = array(); $i = 0; - foreach ($order->lines as $line) - { + foreach ($order->lines as $line) { //var_dump($line); exit; $linesresp[] = array( 'id'=>$line->rowid, @@ -473,22 +477,19 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') 'lines' => $linesresp )); } - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -509,7 +510,9 @@ function getOrdersForThirdParty($authentication, $idthirdparty) dol_syslog("Function: getOrdersForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -517,32 +520,32 @@ function getOrdersForThirdParty($authentication, $idthirdparty) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } // Check parameters - if (!$error && empty($idthirdparty)) - { + if (!$error && empty($idthirdparty)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter id is not provided'; } - if (!$error) - { + if (!$error) { $linesorders = array(); $sql = 'SELECT c.rowid as orderid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql .= " WHERE c.entity = ".$conf->entity; - if ($idthirdparty != 'all') $sql .= " AND c.fk_soc = ".$db->escape($idthirdparty); + if ($idthirdparty != 'all') { + $sql .= " AND c.fk_soc = ".$db->escape($idthirdparty); + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { // En attendant remplissage par boucle $obj = $db->fetch_object($resql); @@ -550,19 +553,16 @@ function getOrdersForThirdParty($authentication, $idthirdparty) $order->fetch($obj->orderid); // Sécurité pour utilisateur externe - if ($socid && ($socid != $order->socid)) - { + if ($socid && ($socid != $order->socid)) { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.' User does not have permission for this request'; } - if (!$error) - { + if (!$error) { // Define lines of invoice $linesresp = array(); - foreach ($order->lines as $line) - { + foreach ($order->lines as $line) { $linesresp[] = array( 'id'=>$line->rowid, 'type'=>$line->product_type, @@ -638,15 +638,13 @@ function getOrdersForThirdParty($authentication, $idthirdparty) 'orders'=>$linesorders ); - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -671,7 +669,9 @@ function createOrder($authentication, $order) dol_syslog("Function: createOrder login=".$authentication['login']." socid :".$order['socid']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -683,8 +683,7 @@ function createOrder($authentication, $order) // Check parameters - if (!$error) - { + if (!$error) { $newobject = new Commande($db); $newobject->socid = $order['thirdparty_id']; $newobject->type = $order['type']; @@ -706,10 +705,8 @@ function createOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $newobject->array_options[$key] = $order[$key]; } @@ -717,11 +714,13 @@ function createOrder($authentication, $order) // Trick because nusoap does not store data with same structure if there is one or several lines $arrayoflines = array(); - if (isset($order['lines']['line'][0])) $arrayoflines = $order['lines']['line']; - else $arrayoflines = $order['lines']; + if (isset($order['lines']['line'][0])) { + $arrayoflines = $order['lines']['line']; + } else { + $arrayoflines = $order['lines']; + } - foreach ($arrayoflines as $key => $line) - { + foreach ($arrayoflines as $key => $line) { // $key can be 'line' or '0','1',... $newline = new OrderLine($db); @@ -744,10 +743,8 @@ function createOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $newline->array_options[$key] = $line[$key]; } @@ -761,30 +758,25 @@ function createOrder($authentication, $order) dol_syslog("Webservice server_order:: order creation start", LOG_DEBUG); $result = $newobject->create($fuser); dol_syslog('Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG); - if ($result < 0) - { + if ($result < 0) { dol_syslog("Webservice server_order:: order creation failed", LOG_ERR); $error++; } - if ($order['status'] == 1) // We want order to have status validated - { + if ($order['status'] == 1) { // We want order to have status validated dol_syslog("Webservice server_order:: order validation start", LOG_DEBUG); $result = $newobject->valid($fuser); - if ($result < 0) - { + if ($result < 0) { dol_syslog("Webservice server_order:: order validation failed", LOG_ERR); $error++; } } - if ($result >= 0) - { + if ($result >= 0) { dol_syslog("Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG); $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { + } else { dol_syslog("Webservice server_order:: order creation or validation failed, rollback", LOG_ERR); $db->rollback(); $error++; @@ -793,8 +785,7 @@ function createOrder($authentication, $order) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -821,45 +812,40 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) $errorcode = ''; $errorlabel = ''; $error = 0; - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->commande->lire) - { + if ($fuser->rights->commande->lire) { $order = new Commande($db); $result = $order->fetch($id); $order->fetch_thirdparty(); $db->begin(); - if ($result > 0) - { + if ($result > 0) { $result = $order->valid($fuser, $id_warehouse); - if ($result >= 0) - { + if ($result >= 0) { // Define output language $outputlangs = $langs; $order->generateDocument($order->model_pdf, $outputlangs); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $order->error; } - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $order->error; } - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -867,11 +853,9 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } - else { + } else { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>'')); } @@ -892,7 +876,9 @@ function updateOrder($authentication, $order) dol_syslog("Function: updateOrder login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -904,8 +890,7 @@ function updateOrder($authentication, $order) $error++; $errorcode = 'KO'; $errorlabel = "Order id or ref or ref_ext is mandatory."; } - if (!$error) - { + if (!$error) { $objectfound = false; include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -918,27 +903,33 @@ function updateOrder($authentication, $order) $db->begin(); - if (isset($order['status'])) - { - if ($order['status'] == -1) $result = $object->cancel($fuser); - if ($order['status'] == 1) - { + if (isset($order['status'])) { + if ($order['status'] == -1) { + $result = $object->cancel($fuser); + } + if ($order['status'] == 1) { $result = $object->valid($fuser); - if ($result >= 0) - { + if ($result >= 0) { // Define output language $outputlangs = $langs; $object->generateDocument($order->model_pdf, $outputlangs); } } - if ($order['status'] == 0) $result = $object->set_reopen($fuser); - if ($order['status'] == 3) $result = $object->cloture($fuser); + if ($order['status'] == 0) { + $result = $object->set_reopen($fuser); + } + if ($order['status'] == 3) { + $result = $object->cloture($fuser); + } } - if (isset($order['billed'])) - { - if ($order['billed']) $result = $object->classifyBilled($fuser); - if (!$order['billed']) $result = $object->classifyUnBilled($fuser); + if (isset($order['billed'])) { + if ($order['billed']) { + $result = $object->classifyBilled($fuser); + } + if (!$order['billed']) { + $result = $object->classifyUnBilled($fuser); + } } $elementtype = 'commande'; @@ -947,13 +938,10 @@ function updateOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; - if (isset($order[$key])) - { + if (isset($order[$key])) { $result = $object->setValueFrom($key, $order[$key], 'commande_extrafields'); } } @@ -964,8 +952,7 @@ function updateOrder($authentication, $order) } } - if ((!$error) && ($objectfound)) - { + if ((!$error) && ($objectfound)) { $db->commit(); $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), @@ -973,9 +960,7 @@ function updateOrder($authentication, $order) 'ref'=>$object->ref, 'ref_ext'=>$object->ref_ext ); - } - elseif ($objectfound) - { + } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; @@ -987,8 +972,7 @@ function updateOrder($authentication, $order) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index 3494f928cde..ae1a480710f 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -20,7 +20,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -35,8 +37,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -149,7 +150,9 @@ function getVersions($authentication) dol_syslog("Function: getVersions login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -159,8 +162,7 @@ function getVersions($authentication) // Check parameters - if (!$error) - { + if (!$error) { $objectresp['result'] = array('result_code'=>'OK', 'result_label'=>''); $objectresp['dolibarr'] = version_dolibarr(); $objectresp['os'] = version_os(); @@ -168,8 +170,7 @@ function getVersions($authentication) $objectresp['webserver'] = version_webserver(); } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -192,7 +193,9 @@ function getDocument($authentication, $modulepart, $file, $refname = '') dol_syslog("Function: getDocument login=".$authentication['login'].' - modulepart='.$modulepart.' - file='.$file); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } $objectresp = array(); $errorcode = ''; $errorlabel = ''; @@ -208,24 +211,26 @@ function getDocument($authentication, $modulepart, $file, $refname = '') $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } // Check parameters - if (!$error && (!$file || !$modulepart)) - { + if (!$error && (!$file || !$modulepart)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter file and modulepart must be both provided."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); // Suppression de la chaine de caractere ../ dans $original_file $original_file = str_replace("../", "/", $original_file); // find the subdirectory name as the reference - if (empty($refname)) $refname = basename(dirname($original_file)."/"); + if (empty($refname)) { + $refname = basename(dirname($original_file)."/"); + } // Security check $check_access = dol_check_secure_access_document($modulepart, $original_file, $conf->entity, $fuser, $refname); @@ -234,20 +239,15 @@ function getDocument($authentication, $modulepart, $file, $refname = '') $original_file = $check_access['original_file']; // Basic protection (against external users only) - if ($fuser->socid > 0) - { - if ($sqlprotectagainstexternals) - { + if ($fuser->socid > 0) { + if ($sqlprotectagainstexternals) { $resql = $db->query($sqlprotectagainstexternals); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($fuser->socid != $obj->fk_soc) - { + if ($fuser->socid != $obj->fk_soc) { $accessallowed = 0; break; } @@ -259,8 +259,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') // Security: // Limite acces si droits non corrects - if (!$accessallowed) - { + if (!$accessallowed) { $errorcode = 'NOT_PERMITTED'; $errorlabel = 'Access not allowed'; $error++; @@ -269,8 +268,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') // Security: // On interdit les remontees de repertoire ainsi que les pipe dans // les noms de fichiers. - if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) - { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { dol_syslog("Refused to deliver file ".$original_file); $errorcode = 'REFUSED'; $errorlabel = ''; @@ -279,10 +277,8 @@ function getDocument($authentication, $modulepart, $file, $refname = '') clearstatcache(); - if (!$error) - { - if (file_exists($original_file)) - { + if (!$error) { + if (file_exists($original_file)) { dol_syslog("Function: getDocument $original_file content-type=$type"); $f = fopen($original_file, 'r'); @@ -300,8 +296,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'document'=>$objectret ); - } - else { + } else { dol_syslog("File doesn't exist ".$original_file); $errorcode = 'NOT_FOUND'; $errorlabel = ''; @@ -310,8 +305,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') } } - if ($error) - { + if ($error) { $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel) ); diff --git a/htdocs/webservices/server_payment.php b/htdocs/webservices/server_payment.php index 3fd3868a36a..6bf43bf78f6 100644 --- a/htdocs/webservices/server_payment.php +++ b/htdocs/webservices/server_payment.php @@ -42,8 +42,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); @@ -147,7 +146,9 @@ function createPayment($authentication, $payment) dol_syslog("Function: createPayment login=".$authentication['login']." id=".$payment->id. ", ref=".$payment->ref.", ref_ext=".$payment->ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -163,8 +164,7 @@ function createPayment($authentication, $payment) $errorlabel = "You must specify the amount and the third party's ID."; } - if (!$error) - { + if (!$error) { $soc = new Societe($db); $soc->fetch($payment['thirdparty_id']); @@ -188,17 +188,14 @@ function createPayment($authentication, $payment) $new_payment->addPaymentToBank($fuser, 'payment', $payment['int_label'], $payment['bank_account'], $payment['emitter'], $payment['bank_source']); } - if ($result < 0) - { + if ($result < 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$new_payment->id); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -207,8 +204,7 @@ function createPayment($authentication, $payment) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 3b2110b9602..259f3ec67fe 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -712,7 +712,9 @@ function updateProductOrService($authentication, $product) $newobject->seuil_stock_alerte = isset($product['stock_alert']) ? $product['stock_alert'] : null; $newobject->country_id = isset($product['country_id']) ? $product['country_id'] : 0; - if (!empty($product['country_code'])) $newobject->country_id = getCountry($product['country_code'], 3); + if (!empty($product['country_code'])) { + $newobject->country_id = getCountry($product['country_code'], 3); + } $newobject->customcode = isset($product['customcode']) ? $product['customcode'] : ''; $newobject->canvas = isset($product['canvas']) ? $product['canvas'] : ''; diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 8d76786df71..b64ccc94d59 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -21,7 +21,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -37,8 +39,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -131,8 +132,7 @@ $server->wsdl->addComplexType( ); $project_elements = array(); -foreach ($listofreferent as $key => $label) -{ +foreach ($listofreferent as $key => $label) { $project_elements[$key] = array('name'=>$key, 'type'=>'tns:elementsArray'); } $server->wsdl->addComplexType( @@ -169,18 +169,21 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { //$value=$object->array_options["options_".$key]; $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $project_fields = array_merge($project_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $project_fields = array_merge($project_fields, $extrafield_array); +} $server->wsdl->addComplexType( 'project', @@ -240,7 +243,9 @@ function createProject($authentication, $project) dol_syslog("Function: createProject login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -248,18 +253,15 @@ function createProject($authentication, $project) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (empty($project['ref'])) - { + if (empty($project['ref'])) { $error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->projet->creer) - { + if ($fuser->rights->projet->creer) { $newobject = new Project($db); $newobject->ref = $project['ref']; $newobject->title = $project['label']; @@ -277,10 +279,8 @@ function createProject($authentication, $project) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; $newobject->array_options[$key] = $project[$key]; } @@ -289,39 +289,32 @@ function createProject($authentication, $project) $db->begin(); $result = $newobject->create($fuser); - if (!$error && $result > 0) - { + if (!$error && $result > 0) { // Add myself as project leader $result = $newobject->add_contact($fuser->id, 'PROJECTLEADER', 'internal'); - if ($result < 0) - { + if ($result < 0) { $error++; } - } - else { + } else { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $newobject->error; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -342,7 +335,9 @@ function getProject($authentication, $id = '', $ref = '') dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -350,22 +345,18 @@ function getProject($authentication, $id = '', $ref = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref))) - { + if (!$error && (($id && $ref))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->projet->lire) - { + if ($fuser->rights->projet->lire) { $project = new Project($db); $result = $project->fetch($id, $ref); - if ($result > 0) - { + if ($result > 0) { $project_result_fields = array( 'id' => $project->id, 'ref' => $project->ref, @@ -386,11 +377,9 @@ function getProject($authentication, $id = '', $ref = '') $extrafields->fetch_name_optionals_label($elementtype, true); //Get extrafield values - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { $project->fetch_optionals(); - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $project_result_fields = array_merge($project_result_fields, array('options_'.$key => $project->array_options['options_'.$key])); } } @@ -398,14 +387,11 @@ function getProject($authentication, $id = '', $ref = '') //Get linked elements global $listofreferent; $elements = array(); - foreach ($listofreferent as $key => $tablename) - { + foreach ($listofreferent as $key => $tablename) { $elements[$key] = array(); $element_array = $project->get_element_list($key, $tablename); - if (count($element_array) > 0 && is_array($element_array)) - { - foreach ($element_array as $element) - { + if (count($element_array) > 0 && is_array($element_array)) { + foreach ($element_array as $element) { $tmp = explode('_', $element); $idofelement = count($tmp) > 0 ? $tmp[0] : ""; $idofelementuser = count($tmp) > 1 ? $tmp[1] : ""; @@ -420,20 +406,17 @@ function getProject($authentication, $id = '', $ref = '') 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'project'=>$project_result_fields ); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 507095ac78b..122d4b10694 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -20,7 +20,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -34,8 +36,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -229,7 +230,9 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') dol_syslog("Function: getSupplierInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -237,26 +240,21 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->fournisseur->facture->lire) - { + if ($fuser->rights->fournisseur->facture->lire) { $invoice = new FactureFournisseur($db); $result = $invoice->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { $linesresp = array(); $i = 0; - foreach ($invoice->lines as $line) - { + foreach ($invoice->lines as $line) { //var_dump($line); exit; $linesresp[] = array( 'id'=>$line->rowid, @@ -275,7 +273,7 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'invoice'=>array( 'id' => $invoice->id, - 'ref' => $invoice->ref, + 'ref' => $invoice->ref, 'ref_supplier'=>$invoice->ref_supplier, 'ref_ext' => $invoice->ref_ext, 'fk_user_author' => $invoice->fk_user_author, @@ -302,20 +300,17 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') // '1'=>array('id'=>333,'type'=>1)), )); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -337,7 +332,9 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) dol_syslog("Function: getSupplierInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -346,14 +343,12 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && empty($idthirdparty)) - { + if (!$error && empty($idthirdparty)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter id is not provided'; } - if (!$error) - { + if (!$error) { $linesinvoice = array(); $sql .= 'SELECT f.rowid as facid'; @@ -363,22 +358,21 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; $sql .= " WHERE f.entity = ".$conf->entity; - if ($idthirdparty != 'all') $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty); + if ($idthirdparty != 'all') { + $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty); + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { // En attendant remplissage par boucle $obj = $db->fetch_object($resql); $invoice = new FactureFournisseur($db); $result = $invoice->fetch($obj->facid); - if ($result < 0) - { + if ($result < 0) { $error++; $errorcode = $result; $errorlabel = $invoice->error; break; @@ -386,9 +380,8 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) // Define lines of invoice $linesresp = array(); - foreach ($invoice->lines as $line) - { - $linesresp[] = array( + foreach ($invoice->lines as $line) { + $linesresp[] = array( 'id'=>$line->rowid, 'type'=>$line->product_type, 'desc'=>dol_htmlcleanlastbr($line->description), @@ -397,10 +390,10 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) 'total'=>$line->total_ttc, 'vat_rate'=>$line->tva_tx, 'qty'=>$line->qty, - 'product_ref'=>$line->product_ref, + 'product_ref'=>$line->product_ref, 'product_label'=>$line->product_label, 'product_desc'=>$line->product_desc, - ); + ); } // Now define invoice @@ -439,15 +432,13 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) 'invoices'=>$linesinvoice ); - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index d7ded82cc3f..60b28ad06d0 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -20,7 +20,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -36,8 +38,7 @@ dol_syslog("Call Dolibarr webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -130,20 +131,23 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { //$value=$object->array_options["options_".$key]; $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array); +} // Define other specific objects $server->wsdl->addComplexType( @@ -265,16 +269,16 @@ $server->register( // Register WSDL $server->register( - 'deleteThirdParty', - // Entry values + 'deleteThirdParty', + // Entry values array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), - // Exit values + // Exit values array('result'=>'tns:result', 'id'=>'xsd:string'), - $ns, - $ns.'#deleteThirdParty', - $styledoc, - $styleuse, - 'WS to delete a thirdparty from its id, ref or ref_ext' + $ns, + $ns.'#deleteThirdParty', + $styledoc, + $styleuse, + 'WS to delete a thirdparty from its id, ref or ref_ext' ); @@ -294,7 +298,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') dol_syslog("Function: getThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -302,27 +308,23 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->societe->lire) - { + if ($fuser->rights->societe->lire) { $thirdparty = new Societe($db); $result = $thirdparty->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { $thirdparty_result_fields = array( 'id' => $thirdparty->id, - 'ref' => $thirdparty->name, - 'ref_ext' => $thirdparty->ref_ext, - 'status' => $thirdparty->status, + 'ref' => $thirdparty->name, + 'ref_ext' => $thirdparty->ref_ext, + 'status' => $thirdparty->status, 'client' => $thirdparty->client, 'supplier' => $thirdparty->fournisseur, 'customer_code' => $thirdparty->code_client, @@ -351,7 +353,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') 'profid5' => $thirdparty->idprof5, 'profid6' => $thirdparty->idprof6, 'capital' => $thirdparty->capital, - 'barcode' => $thirdparty->barcode, + 'barcode' => $thirdparty->barcode, 'vat_used' => $thirdparty->tva_assuj, 'vat_number' => $thirdparty->tva_intra, 'note_private' => $thirdparty->note_private, @@ -366,10 +368,8 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') //Get extrafield values $thirdparty->fetch_optionals(); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { if (isset($thirdparty->array_options['options_'.$key])) { $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key])); } @@ -380,20 +380,17 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'thirdparty'=>$thirdparty_result_fields); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -417,7 +414,9 @@ function createThirdParty($authentication, $thirdparty) dol_syslog("Function: createThirdParty login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -425,14 +424,12 @@ function createThirdParty($authentication, $thirdparty) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (empty($thirdparty['ref'])) - { + if (empty($thirdparty['ref'])) { $error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory."; } - if (!$error) - { + if (!$error) { include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $newobject = new Societe($db); @@ -454,7 +451,9 @@ function createThirdParty($authentication, $thirdparty) $newobject->town = $thirdparty['town']; $newobject->country_id = $thirdparty['country_id']; - if ($thirdparty['country_code']) $newobject->country_id = getCountry($thirdparty['country_code'], 3); + if ($thirdparty['country_code']) { + $newobject->country_id = getCountry($thirdparty['country_code'], 3); + } $newobject->province_id = $thirdparty['province_id']; //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3); @@ -484,10 +483,8 @@ function createThirdParty($authentication, $thirdparty) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; if (isset($thirdparty[$key])) { $newobject->array_options[$key] = $thirdparty[$key]; @@ -503,22 +500,20 @@ function createThirdParty($authentication, $thirdparty) $newobject->name_bis = $thirdparty['lastname']; $result = $newobject->create_individual($fuser); } - if ($result <= 0) - { + if ($result <= 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); // Patch to add capability to associate (one) sale representative - if (!empty($thirdparty['commid']) && $thirdparty['commid'] > 0) + if (!empty($thirdparty['commid']) && $thirdparty['commid'] > 0) { $newobject->add_commercial($fuser, $thirdparty["commid"]); + } $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; @@ -526,8 +521,7 @@ function createThirdParty($authentication, $thirdparty) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -549,7 +543,9 @@ function updateThirdParty($authentication, $thirdparty) dol_syslog("Function: updateThirdParty login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -561,8 +557,7 @@ function updateThirdParty($authentication, $thirdparty) $error++; $errorcode = 'KO'; $errorlabel = "Thirdparty id is mandatory."; } - if (!$error) - { + if (!$error) { $objectfound = false; include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -591,7 +586,9 @@ function updateThirdParty($authentication, $thirdparty) $object->town = $thirdparty['town']; $object->country_id = $thirdparty['country_id']; - if ($thirdparty['country_code']) $object->country_id = getCountry($thirdparty['country_code'], 3); + if ($thirdparty['country_code']) { + $object->country_id = getCountry($thirdparty['country_code'], 3); + } $object->province_id = $thirdparty['province_id']; //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3); @@ -620,10 +617,8 @@ function updateThirdParty($authentication, $thirdparty) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; if (isset($thirdparty[$key])) { $object->array_options[$key] = $thirdparty[$key]; @@ -639,16 +634,13 @@ function updateThirdParty($authentication, $thirdparty) } } - if ((!$error) && ($objectfound)) - { + if ((!$error) && ($objectfound)) { $db->commit(); $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$object->id ); - } - elseif ($objectfound) - { + } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; @@ -660,8 +652,7 @@ function updateThirdParty($authentication, $thirdparty) } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -683,7 +674,9 @@ function getListOfThirdParties($authentication, $filterthirdparty) dol_syslog("Function: getListOfThirdParties login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -694,20 +687,26 @@ function getListOfThirdParties($authentication, $filterthirdparty) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error) - { + if (!$error) { $sql = "SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON s.fk_pays = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as extra ON s.rowid=fk_object"; $sql .= " WHERE entity=".$conf->entity; - foreach ($filterthirdparty as $key => $val) - { - if ($key == 'name' && $val != '') $sql .= " AND s.name LIKE '%".$db->escape($val)."%'"; - if ($key == 'client' && (int) $val > 0) $sql .= " AND s.client = ".$db->escape($val); - if ($key == 'supplier' && (int) $val > 0) $sql .= " AND s.fournisseur = ".$db->escape($val); - if ($key == 'category' && (int) $val > 0) $sql .= " AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") "; + foreach ($filterthirdparty as $key => $val) { + if ($key == 'name' && $val != '') { + $sql .= " AND s.name LIKE '%".$db->escape($val)."%'"; + } + if ($key == 'client' && (int) $val > 0) { + $sql .= " AND s.client = ".$db->escape($val); + } + if ($key == 'supplier' && (int) $val > 0) { + $sql .= " AND s.fournisseur = ".$db->escape($val); + } + if ($key == 'category' && (int) $val > 0) { + $sql .= " AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") "; + } } dol_syslog("Function: getListOfThirdParties", LOG_DEBUG); @@ -718,20 +717,16 @@ function getListOfThirdParties($authentication, $filterthirdparty) $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $extrafieldsOptions = array(); $obj = $db->fetch_object($resql); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { if (isset($obj->{$key})) { $extrafieldsOptions['options_'.$key] = $obj->{$key}; } @@ -753,22 +748,19 @@ function getListOfThirdParties($authentication, $filterthirdparty) $i++; } - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'thirdparties'=>$arraythirdparties ); - } - else { + } else { $objectresp = array( 'result'=>array('result_code' => 'OK', 'result_label' => ''), 'thirdparties'=>$arraythirdparties @@ -793,7 +785,9 @@ function deleteThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -801,56 +795,47 @@ function deleteThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { dol_syslog("Function: deleteThirdParty checkparam"); $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } dol_syslog("Function: deleteThirdParty 1"); - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer) - { + if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer) { $thirdparty = new Societe($db); $result = $thirdparty->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { $db->begin(); $result = $thirdparty->delete($thirdparty->id, $fuser); - if ($result > 0) - { + if ($result > 0) { $db->commit(); $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>'')); - } - else { + } else { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $thirdparty->error; dol_syslog("Function: deleteThirdParty cant delete"); } - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 6c4e472d1c7..cdd39ae24d7 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -20,7 +20,9 @@ * \brief File that is entry point to call Dolibarr WebServices */ -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); +if (!defined("NOCSRFCHECK")) { + define("NOCSRFCHECK", '1'); +} require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -36,8 +38,7 @@ dol_syslog("Call User webservices interfaces"); $langs->load("main"); // Enable and test if module web services is enabled -if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) -{ +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { $langs->load("admin"); dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>'; @@ -193,19 +194,22 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) -{ - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $type = $extrafields->attributes[$elementtype]['type'][$key]; - if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; } - else {$type = 'xsd:string'; } + if ($type == 'date' || $type == 'datetime') { + $type = 'xsd:dateTime'; + } else { + $type = 'xsd:string'; + } $extrafield_array['contact_options_'.$key] = array('name'=>'contact_options_'.$key, 'type'=>$type); } } -if (is_array($extrafield_array)) $thirdpartywithuser_fields = array_merge($thirdpartywithuser_fields, $extrafield_array); +if (is_array($extrafield_array)) { + $thirdpartywithuser_fields = array_merge($thirdpartywithuser_fields, $extrafield_array); +} $server->wsdl->addComplexType( @@ -312,7 +316,9 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -320,25 +326,21 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); if ($fuser->rights->user->user->lire || ($fuser->rights->user->self->creer && $id && $id == $fuser->id) || ($fuser->rights->user->self->creer && $ref && $ref == $fuser->login) - || ($fuser->rights->user->self->creer && $ref_ext && $ref_ext == $fuser->ref_ext)) - { + || ($fuser->rights->user->self->creer && $ref_ext && $ref_ext == $fuser->ref_ext)) { $user = new User($db); $result = $user->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { // Create $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), @@ -371,20 +373,17 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') 'canvas' => $user->canvas ) ); - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } @@ -403,7 +402,9 @@ function getListOfGroups($authentication) dol_syslog("Function: getListOfGroups login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } // Init and check authentication $objectresp = array(); @@ -413,47 +414,39 @@ function getListOfGroups($authentication) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters - if (!$error) - { + if (!$error) { $sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) - { + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; - } - else { + } else { $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; } $sql .= " GROUP BY g.rowid, g.nom, g.entity, g.datec"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $arraygroups[] = array('id'=>$obj->rowid, 'name'=>$obj->name, 'datec'=>$obj->datec, 'nb'=>$obj->nb); $i++; } - } - else { + } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } - if ($error) - { + if ($error) { $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'groups'=>$arraygroups ); - } - else { + } else { $objectresp = array( 'result'=>array('result_code' => 'OK', 'result_label' => ''), 'groups'=>$arraygroups @@ -477,7 +470,9 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) dol_syslog("Function: createUserFromThirdparty login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } $objectresp = array(); $errorcode = ''; $errorlabel = ''; @@ -485,20 +480,19 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } - if (!$error && !$thirdpartywithuser) - { + if (!$error && !$thirdpartywithuser) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter thirdparty must be provided."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->societe->creer) - { + if ($fuser->rights->societe->creer) { $thirdparty = new Societe($db); // If a contact / company already exists with the email, return the corresponding socid @@ -510,16 +504,13 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $sql .= $db->plimit(1); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { // If a company or contact is found with the same email we return an error $row = $db->fetch_object($resql); - if ($row) - { + if ($row) { $error++; $errorcode = 'ALREADY_EXIST'; $errorlabel = 'Object not create : company or contact exists '.$thirdpartywithuser['email']; - } - else { + } else { $db->begin(); /* * Company creation @@ -541,11 +532,9 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $sql .= " AND code='".$db->escape($thirdparty->country_code)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $obj = $db->fetch_object($resql); $thirdparty->country_id = $obj->rowid; } @@ -567,8 +556,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $socid_return = $thirdparty->create($fuser); - if ($socid_return > 0) - { + if ($socid_return > 0) { $thirdparty->fetch($socid_return); /* @@ -597,10 +585,8 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) - { + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'contact_options_'.$key; $key = substr($key, 8); // Remove 'contact_' prefix $contact->array_options[$key] = $thirdpartywithuser[$key]; @@ -609,8 +595,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $contact_id = $contact->create($fuser); - if ($contact_id > 0) - { + if ($contact_id > 0) { /* * User creation * @@ -618,19 +603,17 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $edituser = new User($db); $id = $edituser->create_from_contact($contact, $thirdpartywithuser["login"]); - if ($id > 0) - { + if ($id > 0) { $edituser->setPassword($fuser, trim($thirdpartywithuser['password'])); - if ($thirdpartywithuser['group_id'] > 0) + if ($thirdpartywithuser['group_id'] > 0) { $edituser->SetInGroup($thirdpartywithuser['group_id'], $conf->entity); - } - else { + } + } else { $error++; $errorcode = 'NOT_CREATE'; $errorlabel = 'Object not create : '.$edituser->error; } - } - else { + } else { $error++; $errorcode = 'NOT_CREATE'; $errorlabel = 'Object not create : '.$contact->error; } @@ -656,8 +639,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) } } - if ($error) - { + if ($error) { $db->rollback(); $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel) @@ -682,7 +664,9 @@ function setUserPassword($authentication, $shortuser) dol_syslog("Function: setUserPassword login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) { + $conf->entity = $authentication['entity']; + } $objectresp = array(); $errorcode = ''; $errorlabel = ''; @@ -690,50 +674,43 @@ function setUserPassword($authentication, $shortuser) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->socid) $socid = $fuser->socid; + if ($fuser->socid) { + $socid = $fuser->socid; + } - if (!$error && !$shortuser) - { + if (!$error && !$shortuser) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter shortuser must be provided."; } - if (!$error) - { + if (!$error) { $fuser->getrights(); - if ($fuser->rights->user->user->password || $fuser->rights->user->self->password) - { + if ($fuser->rights->user->user->password || $fuser->rights->user->self->password) { $userstat = new User($db); $res = $userstat->fetch('', $shortuser['login']); - if ($res) - { + if ($res) { $res = $userstat->setPassword($userstat, $shortuser['password']); - if ($res) - { + if ($res) { $objectresp = array( 'result'=>array('result_code' => 'OK', 'result_label' => ''), ); - } - else { + } else { $error++; $errorcode = 'NOT_MODIFIED'; $errorlabel = 'Error when changing password'; } - } - else { + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'User not found'; } - } - else { + } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } - if ($error) - { + if ($error) { $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel) ); From 2cbdbf4f60f530d7f2273396455533701f45c519 Mon Sep 17 00:00:00 2001 From: stickler-ci <support@stickler-ci.com> Date: Fri, 26 Feb 2021 12:12:30 +0000 Subject: [PATCH 131/173] Fixing style errors. --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index f950f764ad7..218ee874bd6 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -98,7 +98,7 @@ $prodcomb2val = new ProductCombination2ValuePair($db); $productCombination2ValuePairs1 = array(); if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) { // We click on Create all defined combinations -//$features = GETPOST('features', 'array'); + //$features = GETPOST('features', 'array'); $features = $_SESSION['addvariant_'.$object->id]; if (!$features) { From a296b86ee1a4f75cbadef9e5cb5030eeaaae6973 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 13:15:02 +0100 Subject: [PATCH 132/173] Update societe.class.php --- htdocs/societe/class/societe.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0ac078280c1..115750dd0ab 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1601,7 +1601,8 @@ class Societe extends CommonObject $sql .= ', fj.libelle as forme_juridique'; $sql .= ', e.libelle as effectif'; $sql .= ', c.code as country_code, c.label as country'; - $sql .= ', d.code_departement as state_code, d.nom as state, r.code_region as region_code'; + $sql .= ', d.code_departement as state_code, d.nom as state'; + $sql .= ', r.rowid as region_id, r.code_region as region_code'; $sql .= ', st.libelle as stcomm, st.picto as stcomm_picto'; $sql .= ', te.code as typent_code'; $sql .= ', i.libelle as label_incoterms'; @@ -1690,6 +1691,7 @@ class Societe extends CommonObject $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; + $this->region_id = $obj->region_id; $this->region_code = $obj->region_code; $this->state = ($obj->state != '-' ? $obj->state : ''); From b970f4eca621654f0b82e0be7474bd85d4864e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 13:18:40 +0100 Subject: [PATCH 133/173] code syntax user directory --- htdocs/user/admin/group_extrafields.php | 17 +- htdocs/user/admin/user_extrafields.php | 17 +- htdocs/user/agenda_extsites.php | 26 +- htdocs/user/bank.php | 221 ++--- htdocs/user/card.php | 846 +++++++++----------- htdocs/user/class/userbankaccount.class.php | 40 +- htdocs/user/class/usergroup.class.php | 269 ++++--- htdocs/user/clicktodial.php | 40 +- htdocs/user/document.php | 43 +- htdocs/user/group/card.php | 173 ++-- htdocs/user/group/ldap.php | 41 +- htdocs/user/group/list.php | 86 +- htdocs/user/group/perms.php | 114 ++- htdocs/user/hierarchy.php | 38 +- htdocs/user/home.php | 63 +- htdocs/user/info.php | 12 +- htdocs/user/ldap.php | 42 +- htdocs/user/list.php | 704 +++++++++------- htdocs/user/logout.php | 62 +- htdocs/user/note.php | 28 +- htdocs/user/notify/card.php | 165 ++-- htdocs/user/param_ihm.php | 113 +-- htdocs/user/passwordforgotten.php | 224 +++--- htdocs/user/perms.php | 167 ++-- htdocs/user/vcard.php | 53 +- 25 files changed, 1866 insertions(+), 1738 deletions(-) diff --git a/htdocs/user/admin/group_extrafields.php b/htdocs/user/admin/group_extrafields.php index fd71d43d4f0..627af1c3b9d 100644 --- a/htdocs/user/admin/group_extrafields.php +++ b/htdocs/user/admin/group_extrafields.php @@ -38,13 +38,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'usergroup'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -79,8 +83,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -93,8 +96,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -106,8 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/user/admin/user_extrafields.php b/htdocs/user/admin/user_extrafields.php index 45d645ce3dd..25141ed4fcd 100644 --- a/htdocs/user/admin/user_extrafields.php +++ b/htdocs/user/admin/user_extrafields.php @@ -37,13 +37,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'user'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +82,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +107,7 @@ if ($action == 'create') /* Editing an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 8d320a839ef..3bd0468cc27 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -41,7 +41,9 @@ $actiontest = GETPOST('test', 'alpha'); $actionsave = GETPOST('save', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search -if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; +if (empty($conf->global->AGENDA_EXT_NB)) { + $conf->global->AGENDA_EXT_NB = 5; +} $MAXAGENDA = $conf->global->AGENDA_EXT_NB; // List of available colors @@ -55,14 +57,17 @@ $object->getrights(); // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (!$user->rights->user->user->lire)) - accessforbidden(); +if (($object->id != $user->id) && (!$user->rights->user->user->lire)) { + accessforbidden(); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); @@ -73,7 +78,9 @@ $hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($actionsave) { @@ -168,7 +175,11 @@ print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span print "<br>\n"; $selectedvalue = $conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; +if ($selectedvalue == 1) { + $selectedvalue = 0; +} else { + $selectedvalue = 1; +} print '<div class="div-table-responsive">'; @@ -183,8 +194,7 @@ print '<td class="right">'.$langs->trans("Color").'</td>'; print "</tr>"; $i = 1; -while ($i <= $MAXAGENDA) -{ +while ($i <= $MAXAGENDA) { $key = $i; $name = 'AGENDA_EXT_NAME_'.$id.'_'.$key; $src = 'AGENDA_EXT_SRC_'.$id.'_'.$key; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 20369e37d69..65bf7c5c8ac 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -32,9 +32,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; -if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +if (!empty($conf->holiday->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +} +if (!empty($conf->expensereport->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +} +if (!empty($conf->salaries->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +} // Load translation files required by page $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries')); @@ -47,35 +53,44 @@ $cancel = GETPOST('cancel', 'alpha'); // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); // Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); $ok = false; -if ($user->id == $id) $ok = true; // A user can always read its own card -if (!empty($user->rights->salaries->read)) $ok = true; -if (!empty($user->rights->hrm->read)) $ok = true; -if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true; -if (!$ok) -{ +if ($user->id == $id) { + $ok = true; // A user can always read its own card +} +if (!empty($user->rights->salaries->read)) { + $ok = true; +} +if (!empty($user->rights->hrm->read)) { + $ok = true; +} +if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) { + $ok = true; +} +if (!$ok) { accessforbidden(); } $object = new User($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->getrights(); } $account = new UserBankAccount($db); -if (!$bankid) -{ +if (!$bankid) { $account->fetch(0, '', $id); } else { $account->fetch($bankid); } -if (empty($account->userid)) $account->userid = $object->id; +if (empty($account->userid)) { + $account->userid = $object->id; +} $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer)); @@ -84,8 +99,7 @@ $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty( * Actions */ -if ($action == 'add' && !$cancel) -{ +if ($action == 'add' && !$cancel) { $account->userid = $object->id; $account->bank = GETPOST('bank', 'alpha'); @@ -103,8 +117,7 @@ if ($action == 'add' && !$cancel) $result = $account->create($user); - if (!$result) - { + if (!$result) { setEventMessages($account->error, $account->errors, 'errors'); $action = 'edit'; // Force chargement page edition } else { @@ -113,52 +126,51 @@ if ($action == 'add' && !$cancel) } } -if ($action == 'update' && !$cancel) -{ +if ($action == 'update' && !$cancel) { $account->userid = $object->id; /* - if ($action == 'update' && !$cancel) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + if ($action == 'update' && !$cancel) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($canedituser) // Case we can edit all field - { - $error = 0; + if ($canedituser) // Case we can edit all field + { + $error = 0; - if (!$error) - { - $objectuser->fetch($id); + if (!$error) + { + $objectuser->fetch($id); - $objectuser->oldcopy = clone $objectuser; + $objectuser->oldcopy = clone $objectuser; - $db->begin(); + $db->begin(); - $objectuser->default_range = GETPOST('default_range'); - $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat'); + $objectuser->default_range = GETPOST('default_range'); + $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat'); - if (!$error) { - $ret = $objectuser->update($user); - if ($ret < 0) { - $error++; - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors'); - } else { - setEventMessages($objectuser->error, $objectuser->errors, 'errors'); - } - } - } + if (!$error) { + $ret = $objectuser->update($user); + if ($ret < 0) { + $error++; + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors'); + } else { + setEventMessages($objectuser->error, $objectuser->errors, 'errors'); + } + } + } - if (!$error && !count($objectuser->errors)) { - setEventMessages($langs->trans("UserModified"), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } - } - } - }*/ + if (!$error && !count($objectuser->errors)) { + setEventMessages($langs->trans("UserModified"), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } + } + } + }*/ $account->bank = GETPOST('bank', 'alpha'); $account->label = GETPOST('label', 'alpha'); @@ -188,28 +200,36 @@ if ($action == 'update' && !$cancel) if ($action == 'setpersonal_email') { $object->personal_email = (string) GETPOST('personal_email', 'alphanohtml'); $result = $object->update($user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // update personal mobile if ($action == 'setpersonal_mobile') { $object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml'); $result = $object->update($user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // update default_c_exp_tax_cat if ($action == 'setdefault_c_exp_tax_cat') { $object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int'); $result = $object->update($user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // update default range if ($action == 'setdefault_range') { $object->default_range = GETPOST('default_range', 'int'); $result = $object->update($user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } @@ -226,16 +246,14 @@ llxHeader(null, $langs->trans("BankAccounts")); $head = user_prepare_head($object); -if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) -{ +if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'; print '<input type="hidden" name="bankid" value="'.$bankid.'">'; } -if ($id && $action == 'create' && $user->rights->user->user->creer) -{ +if ($id && $action == 'create' && $user->rights->user->user->creer) { print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; @@ -244,8 +262,7 @@ if ($id && $action == 'create' && $user->rights->user->user->creer) // View -if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty -{ +if ($action != 'edit' && $action != 'create') { // If not bank account yet, $account may be empty $title = $langs->trans("User"); print dol_get_fiche_head($head, 'bank', $title, -1, 'user'); @@ -283,8 +300,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '</td>'; print '</tr>'; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) - { + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print '<tr class="nowrap">'; print '<td>'; print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer); @@ -338,8 +354,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco // Latest payments of salaries if (!empty($conf->salaries->enabled) && $user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id) - ) - { + ) { $salary = new PaymentSalary($db); $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount"; @@ -349,20 +364,18 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $sql .= " ORDER BY ps.datesp DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; - print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; - print '</tr></table></td>'; - print '</tr>'; + print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; + print '</tr></table></td>'; + print '</tr>'; $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -381,7 +394,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } $db->free($resql); - if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + if ($num <= 0) { + print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + } print "</table>"; } else { dol_print_error($db); @@ -393,8 +408,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco */ if (!empty($conf->holiday->enabled) && ($user->rights->holiday->readall || ($user->rights->holiday->read && $object->id == $user->id)) - ) - { + ) { $holiday = new Holiday($db); $sql = "SELECT h.rowid, h.statut as status, h.fk_type, h.date_debut, h.date_fin, h.halfday"; @@ -404,20 +418,18 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $sql .= " ORDER BY h.date_debut DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; - print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$object->id.'">'.$langs->trans("AllHolidays").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; - print '</tr></table></td>'; - print '</tr>'; + print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$object->id.'">'.$langs->trans("AllHolidays").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; + print '</tr></table></td>'; + print '</tr>'; $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $holiday->id = $objp->rowid; @@ -436,7 +448,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } $db->free($resql); - if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + if ($num <= 0) { + print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + } print "</table>"; } else { dol_print_error($db); @@ -448,8 +462,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco */ if (!empty($conf->expensereport->enabled) && ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id)) - ) - { + ) { $exp = new ExpenseReport($db); $sql = "SELECT e.rowid, e.ref, e.fk_statut as status, e.date_debut, e.total_ttc"; @@ -459,20 +472,18 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $sql .= " ORDER BY e.date_debut DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; - print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; - print '</tr></table></td>'; - print '</tr>'; + print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; + print '</tr></table></td>'; + print '</tr>'; $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $exp->id = $objp->rowid; @@ -490,7 +501,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } $db->free($resql); - if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + if ($num <= 0) { + print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; + } print "</table>"; } else { dol_print_error($db); @@ -589,8 +602,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } - if ($account->id == 0) - { + if ($account->id == 0) { $colspan = 6; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; } @@ -600,8 +612,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } // Edit -if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) -{ +if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) { $title = $langs->trans("User"); print dol_get_fiche_head($head, 'bank', $title, 0, 'user'); @@ -679,9 +690,13 @@ if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->us print '</div>'; } -if ($id && $action == 'edit' && $user->rights->user->user->creer) print '</form>'; +if ($id && $action == 'edit' && $user->rights->user->user->creer) { + print '</form>'; +} -if ($id && $action == 'create' && $user->rights->user->user->creer) print '</form>'; +if ($id && $action == 'create' && $user->rights->user->user->creer) { + print '</form>'; +} // End of page llxFooter(); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index c5820db60b7..45da6f2d6d0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -48,10 +48,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; -if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +if (!empty($conf->ldap->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +} +if (!empty($conf->adherent->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +} +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} +if (!empty($conf->stock->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +} $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); @@ -74,15 +82,13 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer); $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); $canreadgroup = $canreaduser; $caneditgroup = $canedituser; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } // Define value to know what current user can do on properties of edited user -if ($id) -{ +if ($id) { // $user est le user qui edite, $id est l'id de l'utilisateur edite $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer)); @@ -92,11 +98,15 @@ if ($id) // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) { + accessforbidden(); +} // Load translation files required by page $langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks')); @@ -120,7 +130,9 @@ $hookmanager->initHooks(array('usercard', 'globalcard')); $parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { @@ -153,12 +165,9 @@ if (empty($reshook)) { } } - if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) - { - if ($id <> $user->id) - { - if (!GETPOSTISSET('token')) - { + if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { + if ($id <> $user->id) { + if (!GETPOSTISSET('token')) { print 'Error, token required for this critical operation'; exit; } @@ -315,10 +324,8 @@ if (empty($reshook)) { } // Action add usergroup - if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup) - { - if ($group) - { + if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup) { + if ($group) { $editgroup = new UserGroup($db); $editgroup->fetch($group); $editgroup->oldcopy = clone $editgroup; @@ -340,12 +347,10 @@ if (empty($reshook)) { } } - if ($action == 'update' && !$cancel) - { + if ($action == 'update' && !$cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($caneditfield) // Case we can edit all field - { + if ($caneditfield) { // Case we can edit all field $error = 0; if (!GETPOST("lastname", 'alpha')) { @@ -359,8 +364,7 @@ if (empty($reshook)) { $error++; } - if (!$error) - { + if (!$error) { $object->fetch($id); $object->oldcopy = clone $object; @@ -374,7 +378,9 @@ if (empty($reshook)) { $object->gender = GETPOST("gender", 'aZ09'); $object->pass = GETPOST("password", 'none'); $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; - if (!empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request + if (!empty($user->admin)) { + $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request + } $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); @@ -421,20 +427,16 @@ if (empty($reshook)) { $object->dateendvalidity = $dateendvalidity; $object->birth = $dateofbirth; - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); } $object->lang = GETPOST('default_lang', 'aZ09'); - if (!empty($conf->multicompany->enabled)) - { - if (!empty($_POST["superadmin"])) - { + if (!empty($conf->multicompany->enabled)) { + if (!empty($_POST["superadmin"])) { $object->entity = 0; - } elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { + } elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users in master entity } else { $object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); @@ -452,11 +454,9 @@ if (empty($reshook)) { if (GETPOST('deletephoto')) { $object->photo = ''; } - if (!empty($_FILES['photo']['name'])) - { + if (!empty($_FILES['photo']['name'])) { $isimage = image_format_supported($_FILES['photo']['name']); - if ($isimage > 0) - { + if ($isimage > 0) { $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); } else { $error++; @@ -541,8 +541,7 @@ if (empty($reshook)) { } } - if (!$error && !count($object->errors)) - { + if (!$error && !count($object->errors)) { // Then we add the associated categories $categories = GETPOST('usercats', 'array'); $object->setCategories($categories); @@ -553,8 +552,7 @@ if (empty($reshook)) { $db->commit(); $login = $_SESSION["dol_login"]; - if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login - { + if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) { // Current user has changed its login $error++; $langs->load("errors"); setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings'); @@ -564,8 +562,7 @@ if (empty($reshook)) { } } } else { - if ($caneditpassword) // Case we can edit only password - { + if ($caneditpassword) { // Case we can edit only password dol_syslog("Not allowed to change fields, only password"); $object->fetch($id); @@ -574,8 +571,7 @@ if (empty($reshook)) { $object->oldcopy = clone $object; $ret = $object->setPassword($user, GETPOST("password", "none")); - if ($ret < 0) - { + if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -596,8 +592,7 @@ if (empty($reshook)) { } else { // Succes if ($action == 'confirm_passwordsend' && $confirm == 'yes') { - if ($object->send_password($user, $newpassword) > 0) - { + if ($object->send_password($user, $newpassword) > 0) { setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -686,25 +681,24 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $formadmin = new FormAdmin($db); $formfile = new FormFile($db); -if (!empty($conf->stock->enabled)) $formproduct = new FormProduct($db); +if (!empty($conf->stock->enabled)) { + $formproduct = new FormProduct($db); +} llxHeader('', $langs->trans("UserCard")); -if ($action == 'create' || $action == 'adduserldap') -{ +if ($action == 'create' || $action == 'adduserldap') { print load_fiche_titre($langs->trans("NewUser"), '', 'user'); print '<span class="opacitymedium">'.$langs->trans("CreateInternalUserDesc")."</span><br>\n"; print "<br>"; - if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) - { + if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result >= 0) - { + if ($result >= 0) { $required_fields = array( $conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, @@ -730,21 +724,17 @@ if ($action == 'create' || $action == 'adduserldap') // Get from LDAP database an array of results $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); - if (is_array($ldapusers)) - { + if (is_array($ldapusers)) { $liste = array(); - foreach ($ldapusers as $key => $ldapuser) - { + foreach ($ldapusers as $key => $ldapuser) { // Define the label string for this user $label = ''; - foreach ($required_fields as $value) - { - if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) - { - $label .= $value."=******* "; - } elseif ($value) { - $label .= $value."=".$ldapuser[$value]." "; - } + foreach ($required_fields as $value) { + if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) { + $label .= $value."=******* "; + } elseif ($value) { + $label .= $value."=".$ldapuser[$value]." "; + } } $liste[$key] = $label; } @@ -756,35 +746,36 @@ if ($action == 'create' || $action == 'adduserldap') } // If user list is full, we show drop-down list - print "\n\n<!-- Form liste LDAP debut -->\n"; + print "\n\n<!-- Form liste LDAP debut -->\n"; - print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<table class="border centpercent"><tr>'; - print '<td width="160">'; - print $langs->trans("LDAPUsers"); - print '</td>'; - print '<td>'; - print '<input type="hidden" name="action" value="adduserldap">'; - if (is_array($liste) && count($liste)) - { + print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<table class="border centpercent"><tr>'; + print '<td width="160">'; + print $langs->trans("LDAPUsers"); + print '</td>'; + print '<td>'; + print '<input type="hidden" name="action" value="adduserldap">'; + if (is_array($liste) && count($liste)) { print $form->selectarray('users', $liste, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth500'); print ajax_combobox('users'); } - print '</td><td class="center">'; - print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Get')).'"'.(count($liste) ? '' : ' disabled').'>'; - print '</td></tr></table>'; - print '</form>'; + print '</td><td class="center">'; + print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Get')).'"'.(count($liste) ? '' : ' disabled').'>'; + print '</td></tr></table>'; + print '</form>'; - print "\n<!-- Form liste LDAP fin -->\n\n"; - print '<br>'; + print "\n<!-- Form liste LDAP fin -->\n\n"; + print '<br>'; } print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="createuser">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - if (!empty($ldap_sid)) print '<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).'">'; + if (!empty($ldap_sid)) { + print '<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).'">'; + } print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; print dol_get_fiche_head('', '', '', 0, ''); @@ -802,8 +793,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr>'; print '<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td>'; print '<td>'; - if (!empty($ldap_lastname)) - { + if (!empty($ldap_lastname)) { print '<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).'">'; print $ldap_lastname; } else { @@ -814,8 +804,7 @@ if ($action == 'create' || $action == 'adduserldap') // Firstname print '<tr><td>'.$langs->trans("Firstname").'</td>'; print '<td>'; - if (!empty($ldap_firstname)) - { + if (!empty($ldap_firstname)) { print '<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).'">'; print $ldap_firstname; } else { @@ -826,12 +815,10 @@ if ($action == 'create' || $action == 'adduserldap') // Login print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>'; print '<td>'; - if (!empty($ldap_login)) - { + if (!empty($ldap_login)) { print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).'">'; print $ldap_login; - } elseif (!empty($ldap_loginsmb)) - { + } elseif (!empty($ldap_loginsmb)) { print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).'">'; print $ldap_loginsmb; } else { @@ -840,8 +827,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; $generated_password = ''; - if (empty($ldap_sid)) // ldap_sid is for activedirectory - { + if (empty($ldap_sid)) { // ldap_sid is for activedirectory $generated_password = getRandomPassword(false); } $password = (GETPOSTISSET('password') ?GETPOST('password') : $generated_password); @@ -850,18 +836,14 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td>'; print '<td>'; $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) - { + if (preg_match('/ldap/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("PasswordOfUserInLDAP"); } - if (preg_match('/http/', $dolibarr_main_authentication)) - { + if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("HTTPBasicPassword"); } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) - { - if (!empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read - { + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read $valuetoshow .= ($valuetoshow ? ', ' : '').'<input type="hidden" name="password" value="'.$ldap_pass.'">'; // Dolibarr password is preffiled with LDAP known password $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); } else { @@ -873,21 +855,24 @@ if ($action == 'create' || $action == 'adduserldap') // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace - else $valuetoshow .= $hookmanager->resPrint; // to add + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } print $valuetoshow; print '</td></tr>'; - if (!empty($conf->api->enabled)) - { + if (!empty($conf->api->enabled)) { // API key //$generated_password = getRandomPassword(false); print '<tr><td>'.$langs->trans("ApiKey").'</td>'; print '<td>'; print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">'; - if (!empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + } print '</td></tr>'; } else { // PARTIAL WORKAROUND @@ -896,16 +881,13 @@ if ($action == 'create' || $action == 'adduserldap') } // Administrator - if (!empty($user->admin)) - { + if (!empty($user->admin)) { print '<tr><td>'.$langs->trans("Administrator").'</td>'; print '<td>'; print $form->selectyesno('admin', GETPOST('admin'), 1); - if (!empty($conf->multicompany->enabled) && !$user->entity) - { - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->multicompany->enabled) && !$user->entity) { + if (!empty($conf->use_javascript_ajax)) { print '<script type="text/javascript"> $(function() { $("select[name=admin]").change(function() { @@ -961,8 +943,7 @@ if ($action == 'create' || $action == 'adduserldap') print "</tr>\n"; // Expense report validator - if (!empty($conf->expensereport->enabled)) - { + if (!empty($conf->expensereport->enabled)) { print '<tr><td class="titlefieldcreate">'; $text = $langs->trans("ForceUserExpenseValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); @@ -974,8 +955,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Holiday request validator - if (!empty($conf->holiday->enabled)) - { + if (!empty($conf->holiday->enabled)) { print '<tr><td class="titlefieldcreate">'; $text = $langs->trans("ForceUserHolidayValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); @@ -1014,12 +994,13 @@ if ($action == 'create' || $action == 'adduserldap') // Country print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">'; print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id)); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td></tr>'; // State - if (empty($conf->global->USER_DISABLE_STATE)) - { + if (empty($conf->global->USER_DISABLE_STATE)) { print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">'; print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); print '</td></tr>'; @@ -1029,8 +1010,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td>'.$langs->trans("PhonePro").'</td>'; print '<td>'; print img_picto('', 'object_phoning'); - if (!empty($ldap_phone)) - { + if (!empty($ldap_phone)) { print '<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).'">'; print $ldap_phone; } else { @@ -1042,8 +1022,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td>'.$langs->trans("PhoneMobile").'</td>'; print '<td>'; print img_picto('', 'object_phoning_mobile'); - if (!empty($ldap_mobile)) - { + if (!empty($ldap_mobile)) { print '<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).'">'; print $ldap_mobile; } else { @@ -1055,8 +1034,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td>'.$langs->trans("Fax").'</td>'; print '<td>'; print img_picto('', 'object_phoning_fax'); - if (!empty($ldap_fax)) - { + if (!empty($ldap_fax)) { print '<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).'">'; print $ldap_fax; } else { @@ -1068,8 +1046,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>'; print '<td>'; print img_picto('', 'object_email'); - if (!empty($ldap_mail)) - { + if (!empty($ldap_mail)) { print '<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).'">'; print $ldap_mail; } else { @@ -1101,8 +1078,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Accountancy code - if ($conf->accounting->enabled) - { + if ($conf->accounting->enabled) { print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; print '<td>'; print '<input type="text" name="accountancy_code" value="'.dol_escape_htmltag(GETPOST('accountancy_code', 'alphanohtml')).'">'; @@ -1110,8 +1086,7 @@ if ($action == 'create' || $action == 'adduserldap') } // User color - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { print '<tr><td>'.$langs->trans("ColorUser").'</td>'; print '<td>'; print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset'); @@ -1119,16 +1094,14 @@ if ($action == 'create' || $action == 'adduserldap') } // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td><td colspan="3">'; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); print "</td></tr>"; } - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n"; print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->lang ? $object->lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '</td>'; @@ -1136,14 +1109,11 @@ if ($action == 'create' || $action == 'adduserldap') } // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (!method_exists($mc, 'formObjectOptions')) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) // condition must be same for create and edit mode - { - print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; + if (!method_exists($mc, 'formObjectOptions')) { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { // condition must be same for create and edit mode + print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; print "<td>".$mc->select_entities($conf->entity); print "</td></tr>\n"; } else { @@ -1180,8 +1150,7 @@ if ($action == 'create' || $action == 'adduserldap') // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>'; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); print '</td></tr>'; @@ -1194,8 +1163,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) - || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) - { + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM @@ -1264,7 +1232,7 @@ if ($action == 'create' || $action == 'adduserldap') print "</table>\n"; - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '<div class="center">'; print '<input class="button" value="'.$langs->trans("CreateUser").'" name="create" type="submit">'; @@ -1275,31 +1243,30 @@ if ($action == 'create' || $action == 'adduserldap') print "</form>"; } else { // View and edit mode - if ($id > 0) - { + if ($id > 0) { $object->fetch($id, '', '', 1); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + if ($res < 0) { + dol_print_error($db, $object->error); exit; + } $res = $object->fetch_optionals(); // Check if user has rights - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->getrights(); - if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); + if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) { + setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); + } } // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) - { + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))'; $entries = $ldap->fetch($object->login, $userSearchFilter); - if (!$entries) - { + if (!$entries) { setEventMessages($ldap->error, $ldap->errors, 'errors'); } @@ -1309,12 +1276,9 @@ if ($action == 'create' || $action == 'adduserldap') $statutUACF = ''; // Check options of user account - if (count($ldap->uacf) > 0) - { - foreach ($ldap->uacf as $key => $statut) - { - if ($key == 65536) - { + if (count($ldap->uacf) > 0) { + foreach ($ldap->uacf as $key => $statut) { + if ($key == 65536) { $passDoNotExpire = 1; $statutUACF = $statut; } @@ -1324,16 +1288,14 @@ if ($action == 'create' || $action == 'adduserldap') $statutUACF = "ACCOUNTDISABLE"; } - if ($ldap->pwdlastset == 0) - { + if ($ldap->pwdlastset == 0) { $userChangePassNextLogon = 1; } } } // Show tabs - if ($mode == 'employee') // For HRM module development - { + if ($mode == 'employee') { // For HRM module development $title = $langs->trans("Employee"); $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; } else { @@ -1348,50 +1310,44 @@ if ($action == 'create' || $action == 'adduserldap') $head = user_prepare_head($object); /* - * Confirmation reinitialisation mot de passe - */ - if ($action == 'password') - { + * Confirmation reinitialisation mot de passe + */ + if ($action == 'password') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("ReinitPassword"), $langs->trans("ConfirmReinitPassword", $object->login), "confirm_password", '', 0, 1); } /* - * Confirmation envoi mot de passe - */ - if ($action == 'passwordsend') - { + * Confirmation envoi mot de passe + */ + if ($action == 'passwordsend') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("SendNewPassword"), $langs->trans("ConfirmSendNewPassword", $object->login), "confirm_passwordsend", '', 0, 1); } /* - * Confirm deactivation - */ - if ($action == 'disable') - { + * Confirm deactivation + */ + if ($action == 'disable') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DisableAUser"), $langs->trans("ConfirmDisableUser", $object->login), "confirm_disable", '', 0, 1); } /* - * Confirm activation - */ - if ($action == 'enable') - { + * Confirm activation + */ + if ($action == 'enable') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("EnableAUser"), $langs->trans("ConfirmEnableUser", $object->login), "confirm_enable", '', 0, 1); } /* - * Confirmation suppression - */ - if ($action == 'delete') - { + * Confirmation suppression + */ + if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DeleteAUser"), $langs->trans("ConfirmDeleteUser", $object->login), "confirm_delete", '', 0, 1); } /* - * Fiche en mode visu - */ - if ($action != 'edit') - { + * Fiche en mode visu + */ + if ($action != 'edit') { print dol_get_fiche_head($head, 'user', $title, -1, 'user'); dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); @@ -1404,8 +1360,7 @@ if ($action == 'create' || $action == 'adduserldap') // Login print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; - if (!empty($object->ldap_sid) && $object->statut == 0) - { + if (!empty($object->ldap_sid) && $object->statut == 0) { print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; } else { print '<td>'.$object->login.'</td>'; @@ -1417,18 +1372,13 @@ if ($action == 'create' || $action == 'adduserldap') print '<td class="wordbreak">'; $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) - { - if (!empty($object->ldap_sid)) - { - if ($passDoNotExpire) - { + if (preg_match('/ldap/', $dolibarr_main_authentication)) { + if (!empty($object->ldap_sid)) { + if ($passDoNotExpire) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF); - } elseif ($userChangePassNextLogon) - { + } elseif ($userChangePassNextLogon) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).'</span>'; - } elseif ($userDisabled) - { + } elseif ($userDisabled) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).'</span>'; } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); @@ -1437,12 +1387,10 @@ if ($action == 'create' || $action == 'adduserldap') $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } } - if (preg_match('/http/', $dolibarr_main_authentication)) - { + if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) - { + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { if ($object->pass) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; @@ -1453,16 +1401,20 @@ if ($action == 'create' || $action == 'adduserldap') $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; // TODO Add a feature to reveal the hash $valuetoshow .= '<!-- Crypted into '.$object->pass_indatabase_crypted.' -->'; + } else { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; } - else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="opacitymedium">'.$langs->trans("Hidden").'</span>'; } } // Other form for user password $parameters = array('valuetoshow' => $valuetoshow); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace - else $valuetoshow .= $hookmanager->resPrint; // to add + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } print $valuetoshow; print "</td>"; @@ -1472,7 +1424,9 @@ if ($action == 'create' || $action == 'adduserldap') if (!empty($conf->api->enabled) && $user->admin) { print '<tr><td>'.$langs->trans("ApiKey").'</td>'; print '<td>'; - if (!empty($object->api_key)) print '<span class="opacitymedium">'.preg_replace('/./', '*', $object->api_key).'</span>'; + if (!empty($object->api_key)) { + print '<span class="opacitymedium">'.preg_replace('/./', '*', $object->api_key).'</span>'; + } if ($user->admin || $user->id == $object->id) { // TODO Add a feature to reveal the hash } @@ -1481,11 +1435,9 @@ if ($action == 'create' || $action == 'adduserldap') // Administrator print '<tr><td>'.$langs->trans("Administrator").'</td><td>'; - if (!empty($conf->multicompany->enabled) && $object->admin && !$object->entity) - { + if (!empty($conf->multicompany->enabled) && $object->admin && !$object->entity) { print $form->textwithpicto(yn($object->admin), $langs->trans("SuperAdministratorDesc"), 1, "superadmin"); - } elseif ($object->admin) - { + } elseif ($object->admin) { print $form->textwithpicto(yn($object->admin), $langs->trans("AdministratorDesc"), 1, "admin"); } else { print yn($object->admin); @@ -1498,14 +1450,17 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("InternalExternalDesc")); print '</td><td>'; $type = $langs->trans("Internal"); - if ($object->socid > 0) $type = $langs->trans("External"); + if ($object->socid > 0) { + $type = $langs->trans("External"); + } print $type; - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + if ($object->ldap_sid) { + print ' ('.$langs->trans("DomainUser").')'; + } print '</td></tr>'."\n"; // Ldap sid - if ($object->ldap_sid) - { + if ($object->ldap_sid) { print '<tr><td>'.$langs->trans("Type").'</td><td>'; print $langs->trans("DomainUser", $ldap->domainFQDN); print '</td></tr>'."\n"; @@ -1514,7 +1469,9 @@ if ($action == 'create' || $action == 'adduserldap') // Gender print '<tr><td>'.$langs->trans("Gender").'</td>'; print '<td>'; - if ($object->gender) print $langs->trans("Gender".$object->gender); + if ($object->gender) { + print $langs->trans("Gender".$object->gender); + } print '</td></tr>'; // Employee @@ -1570,8 +1527,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Default warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>'; if ($object->fk_warehouse > 0) { @@ -1590,8 +1546,7 @@ if ($action == 'create' || $action == 'adduserldap') //$childids = $user->getAllChildIds(1); if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) - || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) - { + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). // However, he can see the valuation of timesheet of its subordinates even without these permissions. $langs->load("salaries"); @@ -1667,8 +1622,7 @@ if ($action == 'create' || $action == 'adduserldap') print "</tr>\n"; // Accountancy code - if ($conf->accounting->enabled) - { + if ($conf->accounting->enabled) { print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; print '<td>'.$object->accountancy_code.'</td></tr>'; } @@ -1682,8 +1636,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<table class="border tableforfield centpercent">'; // Color user - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { print '<tr><td>'.$langs->trans("ColorUser").'</td>'; print '<td>'; print $formother->showColor($object->color, ''); @@ -1692,8 +1645,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '<tr><td>'.$langs->trans("Categories").'</td>'; print '<td colspan="3">'; print $form->showCategories($object->id, Categorie::TYPE_USER, 1); @@ -1701,8 +1653,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>'; //$s=picto_from_langcode($object->default_lang); @@ -1713,8 +1664,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; } - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) - { + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print '<tr><td>'.$langs->trans("OpenIDURL").'</td>'; print '<td>'.$object->openid.'</td>'; print "</tr>\n"; @@ -1729,21 +1679,18 @@ if ($action == 'create' || $action == 'adduserldap') print "</tr>\n"; // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (!method_exists($mc, 'formObjectOptions')) - { - if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { - print '<tr><td>'.$langs->trans("Entity").'</td><td>'; - if (empty($object->entity)) { - print $langs->trans("AllEntities"); - } else { - $mc->getInfo($object->entity); - print $mc->label; - } - print "</td></tr>\n"; + if (!method_exists($mc, 'formObjectOptions')) { + if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { + print '<tr><td>'.$langs->trans("Entity").'</td><td>'; + if (empty($object->entity)) { + print $langs->trans("AllEntities"); + } else { + $mc->getInfo($object->entity); + print $mc->label; + } + print "</td></tr>\n"; } } } @@ -1752,13 +1699,11 @@ if ($action == 'create' || $action == 'adduserldap') include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Company / Contact - if (!empty($conf->societe->enabled)) - { + if (!empty($conf->societe->enabled)) { print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>'; print '<td>'; $s = ''; - if (isset($object->socid) && $object->socid > 0) - { + if (isset($object->socid) && $object->socid > 0) { $societe = new Societe($db); $societe->fetch($object->socid); if ($societe->id > 0) { @@ -1767,13 +1712,15 @@ if ($action == 'create' || $action == 'adduserldap') } else { $s .= '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ThisUserIsNot").'</span>'; } - if (!empty($object->contact_id)) - { + if (!empty($object->contact_id)) { $contact = new Contact($db); $contact->fetch($object->contact_id); if ($contact->id > 0) { - if ($object->socid > 0 && $s) $s .= ' / '; - else $s .= '<br>'; + if ($object->socid > 0 && $s) { + $s .= ' / '; + } else { + $s .= '<br>'; + } $s .= $contact->getNomUrl(1, ''); } } @@ -1783,13 +1730,11 @@ if ($action == 'create' || $action == 'adduserldap') } // Module Adherent - if (!empty($conf->adherent->enabled)) - { + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<td>'; - if ($object->fk_member) - { + if ($object->fk_member) { $adh = new Adherent($db); $adh->fetch($object->fk_member); $adh->ref = $adh->getFullname($langs); // Force to show login instead of id @@ -1826,18 +1771,16 @@ if ($action == 'create' || $action == 'adduserldap') /* - * Buttons actions - */ + * Buttons actions + */ print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { if (empty($user->socid)) { - if (!empty($object->email)) - { + if (!empty($object->email)) { $langs->load("mails"); print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; } else { @@ -1846,65 +1789,56 @@ if ($action == 'create' || $action == 'adduserldap') } } - if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DisabledInMonoUserMode")).'">'.$langs->trans("Modify").'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'; } } elseif ($caneditpassword && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a></div>'; } // Si on a un gestionnaire de generation de mot de passe actif - if ($conf->global->USER_PASSWORD_GENERATED != 'none') - { - if ($object->statut == 0) - { + if ($conf->global->USER_PASSWORD_GENERATED != 'none') { + if ($object->statut == 0) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>'; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a></div>'; } - if ($object->statut == 0) - { + if ($object->statut == 0) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>'; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { - if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>'; - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>'; + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + if ($object->email) { + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>'; + } } } // Enable user if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a></div>'; } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&amp;id='.$object->id.'">'.$langs->trans("DisableUser").'</a></div>'; } else { - if ($user->id == $id) - { + if ($user->id == $id) { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("CantDisableYourself").'">'.$langs->trans("DisableUser").'</a></div>'; } } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) - { - if ($user->admin || !$object->admin) // If user edited is admin, delete is possible on for an admin - { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id.'">'.$langs->trans("DeleteUser").'</a></div>'; } else { print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MustBeAdminToDeleteOtherAdmin")).'">'.$langs->trans("DeleteUser").'</a></div>'; @@ -1917,7 +1851,9 @@ if ($action == 'create' || $action == 'adduserldap') //Select mail models is same action as presend - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) { + $action = 'presend'; + } // Presend form $modelmail = 'user'; @@ -1927,14 +1863,12 @@ if ($action == 'create' || $action == 'adduserldap') include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - if ($action != 'presend' && $action != 'send') - { + if ($action != 'presend' && $action != 'send') { /* - * List of groups of user - */ + * List of groups of user + */ - if ($canreadgroup) - { + if ($canreadgroup) { print '<!-- Group section -->'."\n"; print load_fiche_titre($langs->trans("ListOfGroupsForUser"), '', ''); @@ -1945,10 +1879,8 @@ if ($action == 'create' || $action == 'adduserldap') $usergroup = new UserGroup($db); $groupslist = $usergroup->listGroupsForUser($object->id); - if (!empty($groupslist)) - { - foreach ($groupslist as $groupforuser) - { + if (!empty($groupslist)) { + foreach ($groupslist as $groupforuser) { $exclude[] = $groupforuser->id; } } @@ -1958,10 +1890,8 @@ if ($action == 'create' || $action == 'adduserldap') $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { - if ($caneditgroup) - { + if (empty($reshook)) { + if ($caneditgroup) { print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'" />'; print '<input type="hidden" name="action" value="addgroup" />'; @@ -1970,8 +1900,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<table class="noborder centpercent">'."\n"; print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Groups").'</th>'."\n"; print '<th class="liste_titre right">'; - if ($caneditgroup) - { + if ($caneditgroup) { print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); print ' &nbsp; '; print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; @@ -1980,22 +1909,18 @@ if ($action == 'create' || $action == 'adduserldap') print '</th></tr>'."\n"; // List of groups of user - if (!empty($groupslist)) - { - foreach ($groupslist as $group) - { + if (!empty($groupslist)) { + foreach ($groupslist as $group) { print '<tr class="oddeven">'; print '<td>'; - if ($caneditgroup) - { + if ($caneditgroup) { print $group->getNomUrl(1); } else { print img_object($langs->trans("ShowGroup"), "group").' '.$group->name; } print '</td>'; print '<td class="right">'; - if ($caneditgroup) - { + if ($caneditgroup) { print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">'; print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print '</a>'; @@ -2010,8 +1935,7 @@ if ($action == 'create' || $action == 'adduserldap') print "</table>"; - if ($caneditgroup) - { + if ($caneditgroup) { print '</form>'; } print "<br>"; @@ -2021,10 +1945,9 @@ if ($action == 'create' || $action == 'adduserldap') } /* - * Card in edit mode - */ - if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) - { + * Card in edit mode + */ + if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) { print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; @@ -2035,8 +1958,7 @@ if ($action == 'create' || $action == 'adduserldap') print '<table class="border centpercent">'; // Ref/ID - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) - { + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>'; print '<td>'; print $object->id; @@ -2053,8 +1975,7 @@ if ($action == 'create' || $action == 'adduserldap') print "<tr>"; print '<td class="titlefield fieldrequired">'.$langs->trans("Lastname").'</td>'; print '<td>'; - if ($caneditfield && !$object->ldap_sid) - { + if ($caneditfield && !$object->ldap_sid) { print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">'; } else { print '<input type="hidden" name="lastname" value="'.$object->lastname.'">'; @@ -2066,8 +1987,7 @@ if ($action == 'create' || $action == 'adduserldap') // Firstname print "<tr>".'<td>'.$langs->trans("Firstname").'</td>'; print '<td>'; - if ($caneditfield && !$object->ldap_sid) - { + if ($caneditfield && !$object->ldap_sid) { print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">'; } else { print '<input type="hidden" name="firstname" value="'.$object->firstname.'">'; @@ -2078,8 +1998,7 @@ if ($action == 'create' || $action == 'adduserldap') // Login print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>'; print '<td>'; - if ($user->admin && !$object->ldap_sid) - { + if ($user->admin && !$object->ldap_sid) { print '<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.'">'; } else { print '<input type="hidden" name="login" value="'.$object->login.'">'; @@ -2092,18 +2011,14 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td>'.$langs->trans("Password").'</td>'; print '<td>'; $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) - { + if (preg_match('/ldap/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } - if (preg_match('/http/', $dolibarr_main_authentication)) - { + if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) - { - if ($caneditpassword) - { + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if ($caneditpassword) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<input maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="new-password">'; } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); @@ -2113,27 +2028,29 @@ if ($action == 'create' || $action == 'adduserldap') // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace - else $valuetoshow .= $hookmanager->resPrint; // to add + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } print $valuetoshow; print "</td></tr>\n"; // API key - if (!empty($conf->api->enabled) && $user->admin) - { + if (!empty($conf->api->enabled) && $user->admin) { print '<tr><td>'.$langs->trans("ApiKey").'</td>'; print '<td>'; print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">'; - if (!empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + } print '</td></tr>'; } // Administrator print '<tr><td>'.$langs->trans("Administrator").'</td>'; - if ($object->socid > 0) - { + if ($object->socid > 0) { $langs->load("admin"); print '<td>'; print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin); @@ -2151,14 +2068,11 @@ if ($action == 'create' || $action == 'adduserldap') (empty($conf->multicompany->enabled) && $nbAdmin >= 1) || (!empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone ) - ) - { + ) { print $form->selectyesno('admin', $object->admin, 1); - if (!empty($conf->multicompany->enabled) && !$user->entity) - { - if ($conf->use_javascript_ajax) - { + if (!empty($conf->multicompany->enabled) && !$user->entity) { + if ($conf->use_javascript_ajax) { print '<script type="text/javascript"> $(function() { var admin = $("select[name=admin]").val(); @@ -2203,22 +2117,25 @@ if ($action == 'create' || $action == 'adduserldap') $yn = yn($object->admin); print '<input type="hidden" name="admin" value="'.$object->admin.'">'; print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">'; - if (!empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); - else print $yn; + if (!empty($conf->multicompany->enabled) && empty($object->entity)) { + print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); + } else { + print $yn; + } } print '</td></tr>'; } - // Gender - print '<tr><td>'.$langs->trans("Gender").'</td>'; - print '<td>'; - $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); - if ($caneditfield) { - print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1); - } else { - print $arraygender[$object->gender]; - } - print '</td></tr>'; + // Gender + print '<tr><td>'.$langs->trans("Gender").'</td>'; + print '<td>'; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); + if ($caneditfield) { + print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1); + } else { + print $arraygender[$object->gender]; + } + print '</td></tr>'; // Employee print '<tr>'; @@ -2235,19 +2152,18 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; // Hierarchy - print '<tr><td class="titlefield">'.$langs->trans("HierarchicalResponsible").'</td>'; - print '<td>'; - if ($caneditfield) - { - print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); - } else { - print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">'; - $huser = new User($db); - $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); - } - print '</td>'; - print "</tr>\n"; + print '<tr><td class="titlefield">'.$langs->trans("HierarchicalResponsible").'</td>'; + print '<td>'; + if ($caneditfield) { + print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + } else { + print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">'; + $huser = new User($db); + $huser->fetch($object->fk_user); + print $huser->getNomUrl(1); + } + print '</td>'; + print "</tr>\n"; // Expense report validator if (!empty($conf->expensereport->enabled)) { @@ -2256,8 +2172,7 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print '</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print $form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); } else { print '<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.'">'; @@ -2276,8 +2191,7 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print '</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print $form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); } else { print '<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.'">'; @@ -2292,26 +2206,35 @@ if ($action == 'create' || $action == 'adduserldap') // External user ? print '<tr><td>'.$langs->trans("ExternalUser").' ?</td>'; print '<td>'; - if ($user->id == $object->id || !$user->admin) - { + if ($user->id == $object->id || !$user->admin) { // Read mode $type = $langs->trans("Internal"); - if ($object->socid) $type = $langs->trans("External"); + if ($object->socid) { + $type = $langs->trans("External"); + } print $form->textwithpicto($type, $langs->trans("InternalExternalDesc")); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + if ($object->ldap_sid) { + print ' ('.$langs->trans("DomainUser").')'; + } } else { // Select mode $type = 0; - if ($object->contact_id) $type = $object->contact_id; + if ($object->contact_id) { + $type = $object->contact_id; + } if ($object->socid > 0 && !($object->contact_id > 0)) { // external user but no link to a contact print img_picto('', 'company').$form->select_company($object->socid, 'socid', '', '&nbsp;'); print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, '', false, 1); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + if ($object->ldap_sid) { + print ' ('.$langs->trans("DomainUser").')'; + } } elseif ($object->socid > 0 && $object->contact_id > 0) { // external user with a link to a contact print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;'); // We keep thirdparty empty, contact is already set print img_picto('', 'contact').$form->selectcontacts(0, $object->contact_id, 'contactid', 1, '', '', 1, '', false, 1); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + if ($object->ldap_sid) { + print ' ('.$langs->trans("DomainUser").')'; + } } else { // $object->socid is not > 0 here print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;'); // We keep thirdparty empty, contact is already set print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, '', false, 1); @@ -2319,15 +2242,19 @@ if ($action == 'create' || $action == 'adduserldap') } print '</td></tr>'; - print '</table><hr><table class="border centpercent">'; + print '</table><hr><table class="border centpercent">'; // Address print '<tr><td class="tdtop titlefield">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>'; print '<td>'; - if ($caneditfield) print '<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">'; + if ($caneditfield) { + print '<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">'; + } print $object->address; - if ($caneditfield) print '</textarea>'; + if ($caneditfield) { + print '</textarea>'; + } print '</td></tr>'; // Zip @@ -2352,7 +2279,9 @@ if ($action == 'create' || $action == 'adduserldap') print '<tr><td>'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).'</td><td>'; if ($caneditfield) { print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } } else { $countrylabel = getCountry($object->country_id, '0'); print $countrylabel; @@ -2360,8 +2289,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; // State - if (empty($conf->global->USER_DISABLE_STATE)) - { + if (empty($conf->global->USER_DISABLE_STATE)) { print '<tr><td class="tdoverflow">'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td>'; if ($caneditfield) { print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); @@ -2375,8 +2303,7 @@ if ($action == 'create' || $action == 'adduserldap') print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>'; print '<td>'; print img_picto('', 'object_phoning'); - if ($caneditfield && empty($object->ldap_sid)) - { + if ($caneditfield && empty($object->ldap_sid)) { print '<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.'">'; } else { print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">'; @@ -2388,8 +2315,7 @@ if ($action == 'create' || $action == 'adduserldap') print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>'; print '<td>'; print img_picto('', 'object_phoning_mobile'); - if ($caneditfield && empty($object->ldap_sid)) - { + if ($caneditfield && empty($object->ldap_sid)) { print '<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.'">'; } else { print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">'; @@ -2401,8 +2327,7 @@ if ($action == 'create' || $action == 'adduserldap') print "<tr>".'<td>'.$langs->trans("Fax").'</td>'; print '<td>'; print img_picto('', 'object_phoning_fax'); - if ($caneditfield && empty($object->ldap_sid)) - { + if ($caneditfield && empty($object->ldap_sid)) { print '<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.'">'; } else { print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">'; @@ -2414,8 +2339,7 @@ if ($action == 'create' || $action == 'adduserldap') print "<tr>".'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>'; print '<td>'; print img_picto('', 'object_email'); - if ($caneditfield && empty($object->ldap_sid)) - { + if ($caneditfield && empty($object->ldap_sid)) { print '<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.'">'; } else { print '<input type="hidden" name="email" value="'.$object->email.'">'; @@ -2443,12 +2367,10 @@ if ($action == 'create' || $action == 'adduserldap') } // OpenID url - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) - { + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">'; } else { print '<input type="hidden" name="openid" value="'.$object->openid.'">'; @@ -2460,13 +2382,11 @@ if ($action == 'create' || $action == 'adduserldap') print '</table><hr><table class="border centpercent">'; // Accountancy code - if ($conf->accounting->enabled) - { + if ($conf->accounting->enabled) { print "<tr>"; print '<td class="titlefield">'.$langs->trans("AccountancyCode").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">'; } else { print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">'; @@ -2477,12 +2397,10 @@ if ($action == 'create' || $action == 'adduserldap') } // User color - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { print '<tr><td>'.$langs->trans("ColorUser").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset'); } else { print $formother->showColor($object->color, ''); @@ -2499,8 +2417,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</tr>'; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td>'; print '<td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); @@ -2509,8 +2426,7 @@ if ($action == 'create' || $action == 'adduserldap') foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - if ($caneditfield) - { + if ($caneditfield) { print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); } else { print $form->showCategories($object->id, Categorie::TYPE_USER, 1); @@ -2519,8 +2435,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n"; print $formadmin->select_language($object->lang, 'default_lang', 0, 0, 1); print '</td>'; @@ -2534,17 +2449,14 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; // Company / Contact - if (!empty($conf->societe->enabled)) - { + if (!empty($conf->societe->enabled)) { print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>'; print '<td>'; - if ($object->socid > 0) - { + if ($object->socid > 0) { $societe = new Societe($db); $societe->fetch($object->socid); print $societe->getNomUrl(1, ''); - if ($object->contact_id) - { + if ($object->contact_id) { $contact = new Contact($db); $contact->fetch($object->contact_id); print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"), 'contact').' '.dol_trunc($contact->getFullName($langs), 32).'</a>'; @@ -2558,13 +2470,11 @@ if ($action == 'create' || $action == 'adduserldap') } // Module Adherent - if (!empty($conf->adherent->enabled)) - { + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<td>'; - if ($object->fk_member) - { + if ($object->fk_member) { $adh = new Adherent($db); $adh->fetch($object->fk_member); $adh->ref = $adh->login; // Force to show login instead of id @@ -2578,13 +2488,10 @@ if ($action == 'create' || $action == 'adduserldap') // Multicompany // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (!method_exists($mc, 'formObjectOptions')) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!method_exists($mc, 'formObjectOptions')) { + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) { print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities' print "</td></tr>\n"; @@ -2599,8 +2506,7 @@ if ($action == 'create' || $action == 'adduserldap') //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { if ($caneditfield) { print $object->showOptionals($extrafields, 'edit'); } else { @@ -2611,8 +2517,7 @@ if ($action == 'create' || $action == 'adduserldap') // Signature print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); @@ -2628,8 +2533,7 @@ if ($action == 'create' || $action == 'adduserldap') // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) - { + if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>'; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddWarehouse").'"></span></a>'; @@ -2639,8 +2543,7 @@ if ($action == 'create' || $action == 'adduserldap') // Position/Job print '<tr><td class="titlefield">'.$langs->trans("PostOrFunction").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print '<input size="30" type="text" name="job" value="'.dol_escape_htmltag($object->job).'">'; } else { print '<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).'">'; @@ -2649,8 +2552,7 @@ if ($action == 'create' || $action == 'adduserldap') print '</td></tr>'; if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) - || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) - { + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM @@ -2673,8 +2575,7 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); print '</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm') ?GETPOST('tjm') : $object->tjm).'">'; } else { print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : ''); @@ -2693,8 +2594,7 @@ if ($action == 'create' || $action == 'adduserldap') // Weeklyhours print '<tr><td>'.$langs->trans("WeeklyHours").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours') ?GETPOST('weeklyhours') : $object->weeklyhours).'">'; } else { print price2num($object->weeklyhours); @@ -2705,17 +2605,17 @@ if ($action == 'create' || $action == 'adduserldap') // Date employment print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1); } else { print dol_print_date($object->dateemployment, 'day'); } - if ($dateemployment && $dateemploymentend) print ' - '; + if ($dateemployment && $dateemploymentend) { + print ' - '; + } - if ($caneditfield) - { + if ($caneditfield) { print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); } else { print dol_print_date($object->dateemploymentend, 'day'); @@ -2727,17 +2627,17 @@ if ($action == 'create' || $action == 'adduserldap') // Date login validity print '<tr><td>'.$langs->trans("RangeOfLoginValidity").'</td>'; print '<td>'; - if ($caneditfield) - { + if ($caneditfield) { print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); } else { print dol_print_date($object->datestartvalidity, 'day'); } - if ($datestartvalidity && $dateendvalidity) print ' - '; + if ($datestartvalidity && $dateendvalidity) { + print ' - '; + } - if ($caneditfield) - { + if ($caneditfield) { print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); } else { print dol_print_date($object->dateendvalidity, 'day'); @@ -2770,12 +2670,11 @@ if ($action == 'create' || $action == 'adduserldap') print '</form>'; } - if ($action != 'edit' && $action != 'presend') - { + if ($action != 'edit' && $action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; /* - * Documents generes - */ + * Documents generes + */ $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->user->dir_output."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; @@ -2800,12 +2699,13 @@ if ($action == 'create' || $action == 'adduserldap') print '</div></div></div>'; } - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) $ldap->close(); + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { + $ldap->close(); + } } } -if (!empty($conf->api->enabled) && !empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->api->enabled) && !empty($conf->use_javascript_ajax)) { print "\n".'<script type="text/javascript">'; print '$(document).ready(function () { $("#generate_api_key").click(function() { diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 2fc43e929ec..f113fb3ea32 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -96,10 +96,8 @@ class UserBankAccount extends Account $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rib (fk_user, datec)"; $sql .= " VALUES (".$this->userid.", '".$this->db->idate($now)."')"; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->affected_rows($resql)) - { + if ($resql) { + if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib"); return $this->update($user); @@ -121,8 +119,7 @@ class UserBankAccount extends Account { global $conf; - if (!$this->id) - { + if (!$this->id) { $this->create(); } @@ -138,14 +135,15 @@ class UserBankAccount extends Account $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - if (trim($this->label) != '') + if (trim($this->label) != '') { $sql .= ",label = '".$this->db->escape($this->label)."'"; - else $sql .= ",label = NULL"; + } else { + $sql .= ",label = NULL"; + } $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else { dol_print_error($this->db); @@ -163,20 +161,26 @@ class UserBankAccount extends Account */ public function fetch($id, $ref = '', $userid = 0) { - if (empty($id) && empty($ref) && empty($userid)) return -1; + if (empty($id) && empty($ref) && empty($userid)) { + return -1; + } $sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql .= " owner_address, label, datec, tms as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."user_rib"; - if ($id) $sql .= " WHERE rowid = ".$id; - if ($ref) $sql .= " WHERE label = '".$this->db->escape($ref)."'"; - if ($userid) $sql .= " WHERE fk_user = ".((int) $userid); + if ($id) { + $sql .= " WHERE rowid = ".$id; + } + if ($ref) { + $sql .= " WHERE label = '".$this->db->escape($ref)."'"; + } + if ($userid) { + $sql .= " WHERE fk_user = ".((int) $userid); + } $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 5ba6b5553af..f0b6bcdfe87 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -28,7 +28,9 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +if (!empty($conf->ldap->enabled)) { + require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; +} /** @@ -154,8 +156,7 @@ class UserGroup extends CommonObject global $conf; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - if (!empty($groupname)) - { + if (!empty($groupname)) { $result = $this->fetchCommon(0, '', ' AND nom = \''.$this->db->escape($groupname).'\''); } else { $result = $this->fetchCommon($id); @@ -163,10 +164,8 @@ class UserGroup extends CommonObject $this->name = $this->nom; // For compatibility with field name - if ($result) - { - if ($load_members) - { + if ($result) { + if ($load_members) { $this->members = $this->listUsersForGroup(); } @@ -196,8 +195,7 @@ class UserGroup extends CommonObject $sql .= " ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " WHERE ug.fk_usergroup = g.rowid"; $sql .= " AND ug.fk_user = ".$userid; - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { $sql .= " AND g.entity IS NOT NULL"; } else { $sql .= " AND g.entity IN (0,".$conf->entity.")"; @@ -206,12 +204,9 @@ class UserGroup extends CommonObject dol_syslog(get_class($this)."::listGroupsForUser", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - while ($obj = $this->db->fetch_object($result)) - { - if (!array_key_exists($obj->rowid, $ret)) - { + if ($result) { + while ($obj = $this->db->fetch_object($result)) { + if (!array_key_exists($obj->rowid, $ret)) { $newgroup = new UserGroup($this->db); $newgroup->fetch($obj->rowid, '', $load_members); $ret[$obj->rowid] = $newgroup; @@ -243,37 +238,43 @@ class UserGroup extends CommonObject $ret = array(); $sql = "SELECT u.rowid"; - if (!empty($this->id)) $sql .= ", ug.entity as usergroup_entity"; + if (!empty($this->id)) { + $sql .= ", ug.entity as usergroup_entity"; + } $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (!empty($this->id)) $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + if (!empty($this->id)) { + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + } $sql .= " WHERE 1 = 1"; - if (!empty($this->id)) $sql .= " AND ug.fk_user = u.rowid"; - if (!empty($this->id)) $sql .= " AND ug.fk_usergroup = ".$this->id; - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!empty($this->id)) { + $sql .= " AND ug.fk_user = u.rowid"; + } + if (!empty($this->id)) { + $sql .= " AND ug.fk_usergroup = ".$this->id; + } + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { $sql .= " AND u.entity IS NOT NULL"; } else { $sql .= " AND u.entity IN (0,".$conf->entity.")"; } - if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; + if (!empty($excludefilter)) { + $sql .= ' AND ('.$excludefilter.')'; + } dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { - if (!array_key_exists($obj->rowid, $ret)) - { - if ($mode != 1) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if (!array_key_exists($obj->rowid, $ret)) { + if ($mode != 1) { $newuser = new User($this->db); $newuser->fetch($obj->rowid); $ret[$obj->rowid] = $newuser; - } else $ret[$obj->rowid] = $obj->rowid; + } else { + $ret[$obj->rowid] = $obj->rowid; + } } - if ($mode != 1 && !empty($obj->usergroup_entity)) - { + if ($mode != 1 && !empty($obj->usergroup_entity)) { $ret[$obj->rowid]->usergroup_entity[] = $obj->usergroup_entity; } } @@ -308,8 +309,7 @@ class UserGroup extends CommonObject $this->db->begin(); - if (!empty($rid)) - { + if (!empty($rid)) { $module = $perms = $subperms = ''; // Si on a demande ajout d'un droit en particulier, on recupere @@ -335,25 +335,27 @@ class UserGroup extends CommonObject // Where pour la liste des droits a ajouter $whereforadd = "id=".((int) $rid); // Find also rights that are herited to add them too - if ($subperms) $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))"; - elseif ($perms) $whereforadd .= " OR (module='".$this->db->escape($module)."' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; + if ($subperms) { + $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))"; + } elseif ($perms) { + $whereforadd .= " OR (module='".$this->db->escape($module)."' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; + } } else { // Where pour la liste des droits a ajouter - if (!empty($allmodule)) - { - if ($allmodule == 'allmodules') - { + if (!empty($allmodule)) { + if ($allmodule == 'allmodules') { $whereforadd = 'allmodules'; } else { $whereforadd = "module='".$this->db->escape($allmodule)."'"; - if (!empty($allperms)) $whereforadd .= " AND perms='".$this->db->escape($allperms)."'"; + if (!empty($allperms)) { + $whereforadd .= " AND perms='".$this->db->escape($allperms)."'"; + } } } } // Add permission of the list $whereforadd - if (!empty($whereforadd)) - { + if (!empty($whereforadd)) { //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; @@ -363,19 +365,21 @@ class UserGroup extends CommonObject } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $nid = $obj->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity; - if (!$this->db->query($sql)) $error++; + if (!$this->db->query($sql)) { + $error++; + } $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")"; - if (!$this->db->query($sql)) $error++; + if (!$this->db->query($sql)) { + $error++; + } $i++; } @@ -384,14 +388,15 @@ class UserGroup extends CommonObject dol_print_error($this->db); } - if (!$error) - { + if (!$error) { $langs->load("other"); $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : '')); // Call trigger $result = $this->call_trigger('USERGROUP_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -426,8 +431,7 @@ class UserGroup extends CommonObject $this->db->begin(); - if (!empty($rid)) - { + if (!empty($rid)) { $module = $perms = $subperms = ''; // Si on a demande supression d'un droit en particulier, on recupere @@ -453,29 +457,32 @@ class UserGroup extends CommonObject // Where pour la liste des droits a supprimer $wherefordel = "id=".$this->db->escape($rid); // Suppression des droits induits - if ($subperms == 'lire' || $subperms == 'read') $wherefordel .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND subperms IS NOT NULL)"; - if ($perms == 'lire' || $perms == 'read') $wherefordel .= " OR (module='".$this->db->escape($module)."')"; + if ($subperms == 'lire' || $subperms == 'read') { + $wherefordel .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND subperms IS NOT NULL)"; + } + if ($perms == 'lire' || $perms == 'read') { + $wherefordel .= " OR (module='".$this->db->escape($module)."')"; + } // Pour compatibilite, si lowid = 0, on est en mode suppression de tout // TODO A virer quand sera gere par l'appelant //if (substr($rid,-1,1) == 0) $wherefordel="module='$module'"; } else { // Add permission of the list $wherefordel - if (!empty($allmodule)) - { - if ($allmodule == 'allmodules') - { + if (!empty($allmodule)) { + if ($allmodule == 'allmodules') { $wherefordel = 'allmodules'; } else { $wherefordel = "module='".$this->db->escape($allmodule)."'"; - if (!empty($allperms)) $wherefordel .= " AND perms='".$this->db->escape($allperms)."'"; + if (!empty($allperms)) { + $wherefordel .= " AND perms='".$this->db->escape($allperms)."'"; + } } } } // Suppression des droits de la liste wherefordel - if (!empty($wherefordel)) - { + if (!empty($wherefordel)) { //print "$module-$perms-$subperms"; $sql = "SELECT id"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; @@ -485,12 +492,10 @@ class UserGroup extends CommonObject } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $nid = 0; $obj = $this->db->fetch_object($result); @@ -501,7 +506,9 @@ class UserGroup extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; $sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; $sql .= " AND entity = ".$entity; - if (!$this->db->query($sql)) $error++; + if (!$this->db->query($sql)) { + $error++; + } $i++; } @@ -510,14 +517,15 @@ class UserGroup extends CommonObject dol_print_error($this->db); } - if (!$error) - { + if (!$error) { $langs->load("other"); $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : '')); // Call trigger $result = $this->call_trigger('USERGROUP_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -542,14 +550,12 @@ class UserGroup extends CommonObject { global $conf; - if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) - { + if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { // Rights for this module are already loaded, so we leave return; } - if (!empty($this->all_permissions_are_loaded)) - { + if (!empty($this->all_permissions_are_loaded)) { // We already loaded all rights for this group, so we leave return; } @@ -564,16 +570,16 @@ class UserGroup extends CommonObject $sql .= " AND u.entity = ".$conf->entity; $sql .= " AND u.fk_usergroup = ".$this->id; $sql .= " AND r.perms IS NOT NULL"; - if ($moduletag) $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; + if ($moduletag) { + $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; + } dol_syslog(get_class($this).'::getrights', LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -581,17 +587,25 @@ class UserGroup extends CommonObject $perms = $obj->perms; $subperms = $obj->subperms; - if ($perms) - { - if (!isset($this->rights)) $this->rights = new stdClass(); // For avoid error - if (!isset($this->rights->$module) || !is_object($this->rights->$module)) $this->rights->$module = new stdClass(); - if ($subperms) - { - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); - if (empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; + if ($perms) { + if (!isset($this->rights)) { + $this->rights = new stdClass(); // For avoid error + } + if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { + $this->rights->$module = new stdClass(); + } + if ($subperms) { + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { + $this->rights->$module->$perms = new stdClass(); + } + if (empty($this->rights->$module->$perms->$subperms)) { + $this->nb_rights++; + } $this->rights->$module->$perms->$subperms = 1; } else { - if (empty($this->rights->$module->$perms)) $this->nb_rights++; + if (empty($this->rights->$module->$perms)) { + $this->nb_rights++; + } $this->rights->$module->$perms = 1; } } @@ -602,8 +616,7 @@ class UserGroup extends CommonObject $this->db->free($resql); } - if ($moduletag == '') - { + if ($moduletag == '') { // Si module etait non defini, alors on a tout charge, on peut donc considerer // que les droits sont en cache (car tous charges) pour cet instance de group $this->all_permissions_are_loaded = 1; @@ -641,7 +654,9 @@ class UserGroup extends CommonObject $this->nom = $this->name; // Field for 'name' is called 'nom' in database } - if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value + if (!isset($this->entity)) { + $this->entity = $conf->entity; // If not defined, we use default value + } return $this->createCommon($user, $notrigger); } @@ -708,7 +723,9 @@ class UserGroup extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto = 0; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) { + $withpicto = 0; + } $result = ''; $label = ''; @@ -720,19 +737,20 @@ class UserGroup extends CommonObject $url = DOL_URL_ROOT.'/user/group/card.php?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ""; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label = $langs->trans("ShowGroup"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; @@ -753,16 +771,23 @@ class UserGroup extends CommonObject $linkend = '</a>'; $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->name; + 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->name; + } $result .= $linkend; global $action; $hookmanager->initHooks(array('groupdao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -783,9 +808,15 @@ class UserGroup extends CommonObject // phpcs:enable global $conf; $dn = ''; - if ($mode == 0) $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN; - if ($mode == 1) $dn = $conf->global->LDAP_GROUP_DN; - if ($mode == 2) $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS]; + if ($mode == 0) { + $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN; + } + if ($mode == 1) { + $dn = $conf->global->LDAP_GROUP_DN; + } + if ($mode == 2) { + $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS]; + } return $dn; } @@ -808,14 +839,16 @@ class UserGroup extends CommonObject $info["objectclass"] = explode(',', $conf->global->LDAP_GROUP_OBJECT_CLASS); // Champs - if ($this->name && !empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; + if ($this->name && !empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) { + $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; + } //if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name; - if ($this->note && !empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2); - if (!empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) - { + if ($this->note && !empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) { + $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2); + } + if (!empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) { $valueofldapfield = array(); - foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database. - { + foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database. $muser = new User($this->db); $muser->fetch($val->id); $info2 = $muser->_load_ldap_info(); @@ -875,10 +908,8 @@ class UserGroup extends CommonObject $langs->load("user"); // Positionne le modele sur le nom du modele a utiliser - if (!dol_strlen($modele)) - { - if (!empty($conf->global->USERGROUP_ADDON_PDF)) - { + if (!dol_strlen($modele)) { + if (!empty($conf->global->USERGROUP_ADDON_PDF)) { $modele = $conf->global->USERGROUP_ADDON_PDF; } else { $modele = 'grass'; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index cb113166cad..06db482094d 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -33,7 +33,9 @@ $id = (int) GETPOST('id', 'int'); // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); @@ -47,7 +49,9 @@ $hookmanager->initHooks(array('usercard', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'update' && !GETPOST('cancel', 'alpha')) { @@ -76,8 +80,7 @@ $form = new Form($db); llxHeader("", "ClickToDial"); -if ($id > 0) -{ +if ($id > 0) { $object = new User($db); $object->fetch($id, '', '', 1); $object->getrights(); @@ -107,17 +110,14 @@ if ($id > 0) print '<div class="underbanner clearboth"></div>'; // Edit mode - if ($action == 'edit') - { + if ($action == 'edit') { print '<table class="border centpercent">'; - if ($user->admin) - { + if ($user->admin) { print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>'; print '<td class="valeur">'; print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">'; - if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) - { + if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) { $langs->load("errors"); print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>'; } else { @@ -147,14 +147,14 @@ if ($id > 0) { print '<table class="border centpercent tableforfield">'; - if (!empty($user->admin)) - { + if (!empty($user->admin)) { print '<tr><td class="titlefield">ClickToDial URL</td>'; print '<td class="valeur">'; $url = $conf->global->CLICKTODIAL_URL; - if (!empty($object->clicktodial_url)) $url = $object->clicktodial_url; - if (empty($url)) - { + if (!empty($object->clicktodial_url)) { + $url = $object->clicktodial_url; + } + if (empty($url)) { $langs->load("errors"); print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>'; } else { @@ -181,8 +181,7 @@ if ($id > 0) print dol_get_fiche_end(); - if ($action == 'edit') - { + if ($action == 'edit') { print '<br>'; print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; @@ -194,12 +193,11 @@ if ($id > 0) print '</form>'; /* - * Barre d'actions - */ + * Barre d'actions + */ print '<div class="tabsAction">'; - if (!empty($user->admin) && $action <> 'edit') - { + if (!empty($user->admin) && $action <> 'edit') { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; } diff --git a/htdocs/user/document.php b/htdocs/user/document.php index b9f282f17ed..138408a3c2d 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -47,14 +47,12 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer); $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); $canreadgroup = $canreaduser; $caneditgroup = $canedituser; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } // Define value to know what current user can do on properties of edited user -if ($id) -{ +if ($id) { // $user est le user qui edite, $id est l'id de l'utilisateur edite $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer)); @@ -64,28 +62,37 @@ if ($id) // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) { + accessforbidden(); +} // Get parameters $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 (empty($page) || $page == -1) { $page = 0; } +if (empty($page) || $page == -1) { + $page = 0; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $object = new User($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->getrights(); //$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ; @@ -103,7 +110,9 @@ $hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -118,12 +127,13 @@ $form = new Form($db); llxHeader('', $langs->trans("UserCard").' - '.$langs->trans("Files")); -if ($object->id) -{ +if ($object->id) { /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = user_prepare_head($object); $form = new Form($db); @@ -143,8 +153,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 68d9639990c..599df7aa2ee 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -38,8 +38,7 @@ $candisableperms = ($user->admin || $user->rights->user->user->supprimer); $feature2 = 'user'; // Advanced permissions -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || $user->rights->user->group_advance->read); $caneditperms = ($user->admin || $user->rights->user->group_advance->write); $candisableperms = ($user->admin || $user->rights->user->group_advance->delete); @@ -62,8 +61,7 @@ $userid = GETPOST('user', 'int'); $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2); // Users/Groups management only in master entity if transverse mode -if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) -{ +if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -87,29 +85,31 @@ $hookmanager->initHooks(array('groupcard', 'globalcard')); $parameters = array('id' => $id, 'userid' => $userid, 'caneditperms' => $caneditperms); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { $backurlforlist = DOL_URL_ROOT.'/user/group/list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } } } - if ($cancel) - { + if ($cancel) { header("Location: ".$backtopage); exit; } // Action remove group - if ($action == 'confirm_delete' && $confirm == "yes") - { - if ($caneditperms) - { + if ($action == 'confirm_delete' && $confirm == "yes") { + if ($caneditperms) { $object->fetch($id); $object->delete($user); header("Location: ".DOL_URL_ROOT."/user/group/list.php?restore_lastsearch_values=1"); @@ -121,10 +121,8 @@ if (empty($reshook)) { } // Action add group - if ($action == 'add') - { - if ($caneditperms) - { + if ($action == 'add') { + if ($caneditperms) { if (!GETPOST("nom", "nohtml")) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); $action = "create"; // Go back to create page @@ -134,17 +132,21 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; - else $object->entity = $_POST["entity"]; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $object->entity = 0; + } else { + $object->entity = $_POST["entity"]; + } $db->begin(); $id = $object->create(); - if ($id > 0) - { + if ($id > 0) { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -164,22 +166,22 @@ if (empty($reshook)) { } // Add/Remove user into group - if ($action == 'adduser' || $action == 'removeuser') - { - if ($caneditperms) - { - if ($userid > 0) - { + if ($action == 'adduser' || $action == 'removeuser') { + if ($caneditperms) { + if ($userid > 0) { $object->fetch($id); $object->oldcopy = clone $object; $edituser = new User($db); $edituser->fetch($userid); - if ($action == 'adduser') $result = $edituser->SetInGroup($object->id, $object->entity); - if ($action == 'removeuser') $result = $edituser->RemoveFromGroup($object->id, $object->entity); + if ($action == 'adduser') { + $result = $edituser->SetInGroup($object->id, $object->entity); + } + if ($action == 'removeuser') { + $result = $edituser->RemoveFromGroup($object->id, $object->entity); + } - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -193,10 +195,8 @@ if (empty($reshook)) { } - if ($action == 'update') - { - if ($caneditperms) - { + if ($action == 'update') { + if ($caneditperms) { $db->begin(); $object->fetch($id); @@ -208,15 +208,19 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; - else $object->entity = $_POST["entity"]; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $object->entity = 0; + } else { + $object->entity = $_POST["entity"]; + } $ret = $object->update(); - if ($ret >= 0 && !count($object->errors)) - { + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("GroupModified"), null, 'mesgs'); $db->commit(); } else { @@ -247,8 +251,7 @@ $fuserstatic = new User($db); $form = new Form($db); $formfile = new FormFile($db); -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group'); print dol_set_focus('#nom'); @@ -263,10 +266,8 @@ if ($action == 'create') print '<table class="border centpercent tableforfieldcreate">'; // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<td>".$mc->select_entities($conf->entity); print "</td></tr>\n"; @@ -292,17 +293,13 @@ if ($action == 'create') print '</div>'; print "</form>"; -} - - -/* ************************************************************************** */ -/* */ -/* Visu et edition */ -/* */ -/* ************************************************************************** */ -else { - if ($id) - { +} else { + /* ************************************************************************** */ + /* */ + /* Visu et edition */ + /* */ + /* ************************************************************************** */ + if ($id) { $res = $object->fetch_optionals(); $head = group_prepare_head($object); @@ -311,8 +308,7 @@ else { /* * Confirmation suppression */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAGroup"), $langs->trans("ConfirmDeleteGroup", $object->name), "confirm_delete", '', 0, 1); } @@ -320,8 +316,7 @@ else { * Fiche en mode visu */ - if ($action != 'edit') - { + if ($action != 'edit') { print dol_get_fiche_head($head, 'group', $title, -1, 'group'); $linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -335,20 +330,17 @@ else { print '<table class="border centpercent tableforfield">'; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) - if (!empty($conf->mutlicompany->enabled)) - { + if (!empty($conf->mutlicompany->enabled)) { print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<td class="valeur">'.dol_escape_htmltag($object->name); - if (empty($object->entity)) - { + if (empty($object->entity)) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "</td></tr>\n"; } // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { $mc->getInfo($object->entity); print "<tr>".'<td class="titlefield">'.$langs->trans("Entity").'</td>'; print '<td class="valeur">'.dol_escape_htmltag($mc->label); @@ -381,15 +373,15 @@ else { $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if ($caneditperms) - { + if ($caneditperms) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;token='.newToken().'">'.$langs->trans("Modify").'</a>'; } - if ($candisableperms) - { + if ($candisableperms) { print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'&amp;token='.newToken().'">'.$langs->trans("DeleteGroup").'</a>'; } @@ -402,10 +394,8 @@ else { // On selectionne les users qui ne sont pas deja dans le groupe $exclude = array(); - if (!empty($object->members)) - { - foreach ($object->members as $useringroup) - { + if (!empty($object->members)) { + foreach ($object->members as $useringroup) { $exclude[] = $useringroup->id; } } @@ -415,10 +405,8 @@ else { $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { - if ($caneditperms) - { + if (empty($reshook)) { + if ($caneditperms) { print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="adduser">'; @@ -447,10 +435,8 @@ else { print '<td class="liste_titre right" width="5">&nbsp;</td>'; print "</tr>\n"; - if (!empty($object->members)) - { - foreach ($object->members as $useringroup) - { + if (!empty($object->members)) { + foreach ($object->members as $useringroup) { print '<tr class="oddeven">'; print '<td>'; print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); @@ -484,8 +470,8 @@ else { print '<div class="fichecenter"><div class="fichehalfleft">'; /* - * Documents generes - */ + * Documents generes + */ $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->usergroup->dir_output."/".dol_sanitizeFileName($object->ref); @@ -510,11 +496,10 @@ else { } /* - * Fiche en mode edition - */ + * Fiche en mode edition + */ - if ($action == 'edit' && $caneditperms) - { + if ($action == 'edit' && $caneditperms) { print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="updategroup" enctype="multipart/form-data">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; @@ -526,10 +511,8 @@ else { print '<table class="border centpercent tableforfieldedit">'."\n"; // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<td>".$mc->select_entities($object->entity); print "</td></tr>\n"; diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index c17512b6169..59728f4c982 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -34,14 +34,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; $langs->loadLangs(array('companies', 'ldap', 'users', 'admin')); // Users/Groups management only in master entity if transverse mode -if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) -{ +if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } $canreadperms = true; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || $user->rights->user->group_advance->read); } @@ -49,7 +47,9 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $object = new Usergroup($db); $object->fetch($id); @@ -60,13 +60,11 @@ $object->getrights(); * Actions */ -if ($action == 'dolibarr2ldap') -{ +if ($action == 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); // Get a gid number for objectclass PosixGroup @@ -80,8 +78,7 @@ if ($action == 'dolibarr2ldap') $result = $ldap->update($dn, $info, $user, $olddn); } - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("GroupSynchronized"), null, 'mesgs'); } else { setEventMessages($ldap->error, $ldap->errors, 'errors'); @@ -111,12 +108,10 @@ print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) -if (!empty($conf->mutlicompany->enabled)) -{ +if (!empty($conf->mutlicompany->enabled)) { print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<td class="valeur">'.$object->name; - if (!$object->entity) - { + if (!$object->entity) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "</td></tr>\n"; @@ -153,14 +148,15 @@ print dol_get_fiche_end(); print '<div class="tabsAction">'; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') -{ +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; } print "</div>\n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n"; +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { + print "<br>\n"; +} @@ -177,8 +173,7 @@ print '</tr>'; // Lecture LDAP $ldap = new Ldap(); $result = $ldap->connect_bind(); -if ($result > 0) -{ +if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; @@ -188,10 +183,8 @@ if ($result > 0) //var_dump($records); // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) - { - if (!is_array($records)) - { + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; } else { $result = show_ldap_content($records, 0, $records['count'], true); diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 3fce8718287..7281bc93639 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -28,15 +28,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ - if (!$user->rights->user->group_advance->read && !$user->admin) +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + if (!$user->rights->user->group_advance->read && !$user->admin) { accessforbidden(); + } } // Users/Groups management only in master entity if transverse mode -if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) -{ +if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -50,8 +49,7 @@ $optioncss = GETPOST('optioncss', 'alpha'); // Defini si peux lire/modifier utilisateurs et permisssions $caneditperms = ($user->admin || $user->rights->user->user->creer); // Advanced permissions -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $caneditperms = ($user->admin || $user->rights->user->group_advance->write); } @@ -60,13 +58,19 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } +if (empty($page) || $page == -1) { + $page = 0; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "g.nom"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "g.nom"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -79,21 +83,25 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_label = ""; $search_date_creation = ""; $search_date_update = ""; @@ -113,20 +121,22 @@ $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, COUNT(DISTINCT $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid"; -if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) -{ +if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; } else { $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; } -if (!empty($search_group)) natural_search(array("g.nom", "g.note"), $search_group); -if ($sall) $sql .= natural_search(array("g.nom", "g.note"), $sall); +if (!empty($search_group)) { + natural_search(array("g.nom", "g.note"), $search_group); +} +if ($sall) { + $sql .= natural_search(array("g.nom", "g.note"), $sall); +} $sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec"; $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $nbtotalofrecords = $num; @@ -134,18 +144,21 @@ if ($resql) $i = 0; $param = "&amp;search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall); - if ($optioncss != '') $param .= '&amp;optioncss='.$optioncss; + if ($optioncss != '') { + $param .= '&amp;optioncss='.$optioncss; + } $text = $langs->trans("ListOfGroups"); $newcardbutton = ''; - if ($caneditperms) - { + if ($caneditperms) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu='); } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; @@ -155,9 +168,10 @@ if ($resql) print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'object_group', 0, $newcardbutton, '', $limit, 0, 0, 1); - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -172,8 +186,7 @@ if ($resql) print '<tr class="liste_titre">'; print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder); //multicompany - if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) - { + if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center '); } print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center '); @@ -184,8 +197,7 @@ if ($resql) $grouptemp = new UserGroup($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $grouptemp->id = $obj->rowid; @@ -195,14 +207,12 @@ if ($resql) print '<tr class="oddeven">'; print '<td>'; print $grouptemp->getNomUrl(1); - if (!$obj->entity) - { + if (!$obj->entity) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "</td>"; //multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) - { + if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { $mc->getInfo($obj->entity); print '<td class="center">'.$mc->label.'</td>'; } diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index ee60b90b994..618d705bfcf 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -47,14 +47,15 @@ $canreadperms = ($user->admin || $user->rights->user->user->lire); $caneditperms = ($user->admin || $user->rights->user->user->creer); // Advanced permissions $advancedpermsactive = false; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $advancedpermsactive = true; $canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms)); $caneditperms = ($user->admin || $user->rights->user->group_advance->write); } -if (!$canreadperms) accessforbidden(); +if (!$canreadperms) { + accessforbidden(); +} $object = new Usergroup($db); $object->fetch($id); @@ -71,7 +72,9 @@ $hookmanager->initHooks(array('groupperms', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'addrights' && $caneditperms) { @@ -110,8 +113,7 @@ $form = new Form($db); llxHeader('', $langs->trans("Permissions")); -if ($object->id > 0) -{ +if ($object->id > 0) { /* * Affichage onglets */ @@ -127,32 +129,24 @@ if ($object->id > 0) $db->begin(); - foreach ($modulesdir as $dir) - { + foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + 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 ($modName) { include_once $dir.$file; $objMod = new $modName($db); // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach ($objMod->langfiles as $domain) - { + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } } // Load all permissions - if ($objMod->rights_class) - { + if ($objMod->rights_class) { $ret = $objMod->insert_permissions(0, $entity); $modules[$objMod->rights_class] = $objMod; } @@ -176,15 +170,14 @@ if ($object->id > 0) dol_syslog("get user perms", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); - if (!isset($permsgroupbyentity[$obj->entity])) + if (!isset($permsgroupbyentity[$obj->entity])) { $permsgroupbyentity[$obj->entity] = array(); + } array_push($permsgroupbyentity[$obj->entity], $obj->id); $i++; } @@ -207,12 +200,10 @@ if ($object->id > 0) print '<table class="border centpercent tableforfield">'; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) - if (!empty($conf->mutlicompany->enabled)) - { + if (!empty($conf->mutlicompany->enabled)) { print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<td colspan="2">'.$object->name.''; - if (!$object->entity) - { + if (!$object->entity) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "</td></tr>\n"; @@ -227,19 +218,22 @@ if ($object->id > 0) print '</table><br>'; - if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); + if ($user->admin) { + print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); + } $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraHeader', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print "\n"; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Module").'</td>'; - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center nowrap">'; print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>"; print '/'; @@ -248,36 +242,36 @@ if ($object->id > 0) } print '<td class="center" width="24">&nbsp;</td>'; print '<td>'.$langs->trans("Permissions").'</td>'; - if ($user->admin) print '<td class="right">'.$langs->trans("ID").'</td>'; + if ($user->admin) { + print '<td class="right">'.$langs->trans("ID").'</td>'; + } print '</tr>'."\n"; $sql = "SELECT r.id, r.libelle as label, r.module"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql .= " AND r.entity = ".$entity; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable + } $sql .= " ORDER BY r.module, r.id"; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; $oldmod = ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it - if (empty($modules[$obj->module])) - { + if (empty($modules[$obj->module])) { $i++; continue; } - if ($oldmod <> $obj->module) - { + if ($oldmod <> $obj->module) { $oldmod = $obj->module; // Break detected, we get objMod @@ -290,8 +284,7 @@ if ($object->id > 0) print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print '<a name="'.$objMod->getName().'"></a>'; print '</td>'; - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center nowrap">'; print '<a class="reposition" title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>"; print '/'; @@ -303,7 +296,9 @@ if ($object->id > 0) print '<td colspan="2">&nbsp;</td>'; // Permission id - if ($user->admin) print '<td class="right"></td>'; + if ($user->admin) { + print '<td class="right"></td>'; + } print '</tr>'; } @@ -316,13 +311,10 @@ if ($object->id > 0) //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName(); print '</td>'; - if (is_array($permsgroupbyentity[$entity])) - { - if (in_array($obj->id, $permsgroupbyentity[$entity])) - { + if (is_array($permsgroupbyentity[$entity])) { + if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Own permission by group - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); @@ -333,8 +325,7 @@ if ($object->id > 0) print '</td>'; } else { // Do not own permission - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); @@ -344,8 +335,7 @@ if ($object->id > 0) } } else { // Do not own permission - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); @@ -358,7 +348,9 @@ if ($object->id > 0) print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>'; // Permission id - if ($user->admin) print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; + if ($user->admin) { + print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; + } print '</tr>'."\n"; @@ -372,7 +364,9 @@ if ($object->id > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraFooter', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print dol_get_fiche_end(); } diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 1a6a630d27c..10cc58d43b9 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -29,16 +29,18 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; -if (!$user->rights->user->user->lire && !$user->admin) +if (!$user->rights->user->user->lire && !$user->admin) { accessforbidden(); +} // Load translation files required by page $langs->loadLangs(array('users', 'companies')); // Security check (for external users) $socid = 0; -if ($user->socid > 0) +if ($user->socid > 0) { $socid = $user->socid; +} $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_user = GETPOST('search_user', 'alpha'); @@ -49,10 +51,11 @@ $mode = GETPOST("mode", 'alpha'); $userstatic = new User($db); $search_statut = GETPOST('search_statut', 'int'); -if ($search_statut == '') $search_statut = '1'; +if ($search_statut == '') { + $search_statut = '1'; +} -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers $search_statut = ""; } @@ -79,8 +82,7 @@ llxHeader('', $langs->trans("ListOfUsers").' - '.$langs->trans("HierarchicView") // Load hierarchy of users $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); -if (!is_array($user_arbo) && $user_arbo < 0) -{ +if (!is_array($user_arbo) && $user_arbo < 0) { setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); } else { // Define fulltree array @@ -89,8 +91,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) // 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) - { + foreach ($fulltree as $key => $val) { $userstatic->id = $val['id']; $userstatic->ref = $val['label']; $userstatic->login = $val['login']; @@ -108,10 +109,8 @@ if (!is_array($user_arbo) && $user_arbo < 0) $entitystring = ''; // TODO Set of entitystring should be done with a hook - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($entity)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity)) { $entitystring = $langs->trans("AllEntities"); } else { $mc->getInfo($entity); @@ -120,11 +119,9 @@ if (!is_array($user_arbo) && $user_arbo < 0) } $li = $userstatic->getNomUrl(-1, '', 0, 1); - if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) - { + if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) { $li .= img_picto($langs->trans("SuperAdministrator"), 'redstar'); - } elseif ($userstatic->admin) - { + } elseif ($userstatic->admin) { $li .= img_picto($langs->trans("Administrator"), 'star'); } $li .= ' ('.$val['login'].($entitystring ? ' - '.$entitystring : '').')'; @@ -155,7 +152,9 @@ if (!is_array($user_arbo) && $user_arbo < 0) print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton, 'user'); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; @@ -188,8 +187,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) $nbofentries = (count($data) - 1); - if ($nbofentries > 0) - { + if ($nbofentries > 0) { print '<tr><td colspan="3">'; tree_recur($data, $data[0], 0); print '</td>'; diff --git a/htdocs/user/home.php b/htdocs/user/home.php index b10bd9267f8..4863ed4b9d3 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search -if (!$user->rights->user->user->lire && !$user->admin) -{ +if (!$user->rights->user->user->lire && !$user->admin) { // Redirection vers la page de l'utilisateur header("Location: card.php?id=".$user->id); exit; @@ -38,14 +37,15 @@ if (!$user->rights->user->user->lire && !$user->admin) $langs->load("users"); $canreadperms = true; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || $user->rights->user->group_advance->read); } // Security check (for external users) $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $companystatic = new Societe($db); $fuserstatic = new User($db); @@ -77,8 +77,7 @@ print '<tr><td>'; print $langs->trans("User").':</td><td><input class="flat inputsearch" type="text" name="search_user" size="18"></td></tr>'; // Search Group -if ($canreadperms) -{ +if ($canreadperms) { print '<tr><td>'; print $langs->trans("Group").':</td><td><input class="flat inputsearch" type="text" name="search_group" size="18"></td></tr>'; } @@ -115,13 +114,14 @@ if ($reshook > 0) { } else { $sql .= " WHERE u.entity IN (".getEntity('user').")"; } -if (!empty($socid)) $sql .= " AND u.fk_soc = ".$socid; +if (!empty($socid)) { + $sql .= " AND u.fk_soc = ".$socid; +} $sql .= $db->order("u.datec", "DESC"); $sql .= $db->plimit($max); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); print '<div class="div-table-responsive-no-min">'; @@ -131,8 +131,7 @@ if ($resql) print '</tr>'."\n"; $i = 0; - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); $fuserstatic->id = $obj->rowid; @@ -153,34 +152,28 @@ if ($resql) print '<tr class="oddeven">'; print '<td class="nowraponall">'; print $fuserstatic->getNomUrl(-1); - if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) - { + if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { print img_picto($langs->trans("SuperAdministrator"), 'redstar'); - } elseif ($obj->admin) - { + } elseif ($obj->admin) { print img_picto($langs->trans("Administrator"), 'star'); } print "</td>"; print '<td>'.$obj->login.'</td>'; print "<td>"; - if ($obj->fk_soc) - { + if ($obj->fk_soc) { print $companystatic->getNomUrl(1); } else { print $langs->trans("InternalUser"); } - if ($obj->ldap_sid) - { + if ($obj->ldap_sid) { print ' ('.$langs->trans("DomainUser").')'; } $entity = $obj->entity; $entitystring = ''; // TODO Set of entitystring should be done with a hook - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($entity)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity)) { $entitystring = $langs->trans("AllEntities"); } else { $mc->getInfo($entity); @@ -210,14 +203,12 @@ if ($resql) /* * Last groups created */ -if ($canreadperms) -{ +if ($canreadperms) { $max = 5; $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) - { + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; } else { $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; @@ -226,10 +217,11 @@ if ($canreadperms) $sql .= $db->plimit($max); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $colspan = 1; - if (!empty($conf->multicompany->enabled)) $colspan++; + if (!empty($conf->multicompany->enabled)) { + $colspan++; + } $num = $db->num_rows($resql); print '<div class="div-table-responsive-no-min">'; @@ -241,8 +233,7 @@ if ($canreadperms) $grouptemp = new UserGroup($db); - while ($i < $num && (!$max || $i < $max)) - { + while ($i < $num && (!$max || $i < $max)) { $obj = $db->fetch_object($resql); $grouptemp->id = $obj->rowid; @@ -252,13 +243,11 @@ if ($canreadperms) print '<tr class="oddeven">'; print '<td>'; print $grouptemp->getNomUrl(1); - if (!$obj->entity) - { + if (!$obj->entity) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "</td>"; - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); print '<td>'; print $mc->label; diff --git a/htdocs/user/info.php b/htdocs/user/info.php index f38d9ef2162..74b7e70e582 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -33,22 +33,24 @@ $langs->load("users"); // Security check $id = GETPOST('id', 'int'); $object = new User($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->getrights(); } // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (!$user->rights->user->user->lire)) - accessforbidden(); +if (($object->id != $user->id) && (!$user->rights->user->user->lire)) { + accessforbidden(); +} diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 44c7f553d11..5fbd29e9af9 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -35,7 +35,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'use // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); @@ -55,17 +57,16 @@ $hookmanager->initHooks(array('usercard', 'userldap', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($_GET["action"] == 'dolibarr2ldap') - { +if (empty($reshook)) { + if ($_GET["action"] == 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We can say that old dn = dn as we force synchro @@ -109,20 +110,17 @@ print '<table class="border centpercent">'; // Login print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; -if ($object->ldap_sid) -{ +if ($object->ldap_sid) { print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; } else { print '<td>'.$object->login.'</td>'; } print '</tr>'; -if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") -{ +if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $userSID = $ldap->getObjectSid($object->login); } print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>'; @@ -155,14 +153,15 @@ print dol_get_fiche_end(); print '<div class="tabsAction">'; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') -{ +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; } print "</div>\n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n"; +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { + print "<br>\n"; +} @@ -179,8 +178,7 @@ print '</tr>'; // Lecture LDAP $ldap = new Ldap(); $result = $ldap->connect_bind(); -if ($result > 0) -{ +if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; @@ -190,10 +188,8 @@ if ($result > 0) //print_r($records); // Affichage arbre - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) - { - if (!is_array($records)) - { + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; } else { $result = show_ldap_content($records, 0, $records['count'], true); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 1f471cd3ad9..d7debcbdd3a 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -62,7 +62,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -78,15 +80,20 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (!$sortfield) $sortfield = "u.login"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "u.login"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Initialize array of search criterias $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } $userstatic = new User($db); @@ -104,28 +111,27 @@ $fieldstosearchall = array( 'u.email'=>"EMail", 'u.note'=>"Note", ); -if (!empty($conf->api->enabled)) -{ +if (!empty($conf->api->enabled)) { $fieldstosearchall['u.api_key'] = "ApiKey"; } // Definition of fields for list $arrayfields = array( 'u.login'=>array('label'=>"Login", 'checked'=>1, 'position'=>10), - 'u.lastname'=>array('label'=>"Lastname", 'checked'=>1, 'position'=>15), - 'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20), - 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), - 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22), - 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25), - 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27), - 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30), + 'u.lastname'=>array('label'=>"Lastname", 'checked'=>1, 'position'=>15), + 'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20), + 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), + 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22), + 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25), + 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27), + 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30), 'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31), 'u.user_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1, 'position'=>32), - 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35), - 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>($conf->api->enabled && $user->admin)), - 'u.fk_soc'=>array('label'=>"Company", 'checked'=>($contextpage == 'employeelist' ? 0 : 1), 'position'=>45), - 'u.salary'=>array('label'=>"Salary", 'checked'=>1, 'position'=>80, 'enabled'=>($conf->salaries->enabled && !empty($user->rights->salaries->readall))), - 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100), + 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35), + 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>($conf->api->enabled && $user->admin)), + 'u.fk_soc'=>array('label'=>"Company", 'checked'=>($contextpage == 'employeelist' ? 0 : 1), 'position'=>45), + 'u.salary'=>array('label'=>"Salary", 'checked'=>1, 'position'=>80, 'enabled'=>($conf->salaries->enabled && !empty($user->rights->salaries->readall))), + 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100), 'u.datepreviouslogin'=>array('label'=>"PreviousConnexion", 'checked'=>0, 'position'=>110), 'u.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'u.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), @@ -158,8 +164,12 @@ $search_categ = GETPOST("search_categ", 'int'); $catid = GETPOST('catid', 'int'); // Default search -if ($search_statut == '') $search_statut = '1'; -if ($mode == 'employee' && !GETPOSTISSET('search_employee')) $search_employee = 1; +if ($search_statut == '') { + $search_statut = '1'; +} +if ($mode == 'employee' && !GETPOSTISSET('search_employee')) { + $search_employee = 1; +} // Define value to know what current user can do on users $permissiontoadd = (!empty($user->admin) || $user->rights->user->user->creer); @@ -168,8 +178,7 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer); $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); $canreadgroup = $canreaduser; $caneditgroup = $canedituser; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } @@ -183,21 +192,25 @@ $childids = $user->getAllChildIds(1); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_user = ""; $search_login = ""; $search_lastname = ""; @@ -227,17 +240,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Disable or Enable records - if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) - { + if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) { $objecttmp = new User($db); - if (!$error) - { + if (!$error) { $db->begin(); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { if ($toselectid == $user->id) { setEventMessages($langs->trans($massaction == 0 ? 'CantDisableYourself' : 'CanEnableYourself'), null, 'errors'); $error++; @@ -259,7 +269,9 @@ if (empty($reshook)) setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -275,10 +287,12 @@ if (empty($reshook)) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -327,7 +341,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; -if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ) || !empty($catid)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ +} // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -336,29 +352,67 @@ if ($reshook > 0) { } else { $sql .= " WHERE u.entity IN (".getEntity('user').")"; } -if ($socid > 0) $sql .= " AND u.fk_soc = ".$socid; +if ($socid > 0) { + $sql .= " AND u.fk_soc = ".$socid; +} //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); -if ($search_supervisor > 0) $sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")"; -if ($search_thirdparty != '') $sql .= natural_search(array('s.nom'), $search_thirdparty); -if ($search_login != '') $sql .= natural_search("u.login", $search_login); -if ($search_lastname != '') $sql .= natural_search("u.lastname", $search_lastname); -if ($search_firstname != '') $sql .= natural_search("u.firstname", $search_firstname); -if ($search_gender != '' && $search_gender != '-1') $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman +if ($search_supervisor > 0) { + $sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")"; +} +if ($search_thirdparty != '') { + $sql .= natural_search(array('s.nom'), $search_thirdparty); +} +if ($search_login != '') { + $sql .= natural_search("u.login", $search_login); +} +if ($search_lastname != '') { + $sql .= natural_search("u.lastname", $search_lastname); +} +if ($search_firstname != '') { + $sql .= natural_search("u.firstname", $search_firstname); +} +if ($search_gender != '' && $search_gender != '-1') { + $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman +} if (is_numeric($search_employee) && $search_employee >= 0) { $sql .= ' AND u.employee = '.(int) $search_employee; } -if ($search_accountancy_code != '') $sql .= natural_search("u.accountancy_code", $search_accountancy_code); -if ($search_phonepro != '') $sql .= natural_search("u.office_phone", $search_phonepro); -if ($search_phonemobile != '') $sql .= natural_search("u.user_mobile", $search_phonemobile); -if ($search_email != '') $sql .= natural_search("u.email", $search_email); -if ($search_api_key != '') $sql .= natural_search("u.api_key", $search_api_key); -if ($search_statut != '' && $search_statut >= 0) $sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")"; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($catid > 0) $sql .= " AND cu.fk_categorie = ".((int) $catid); -if ($catid == -2) $sql .= " AND cu.fk_categorie IS NULL"; -if ($search_categ > 0) $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql .= " AND cu.fk_categorie IS NULL"; -if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND u.fk_user IN (".join(',', $childids).")"; +if ($search_accountancy_code != '') { + $sql .= natural_search("u.accountancy_code", $search_accountancy_code); +} +if ($search_phonepro != '') { + $sql .= natural_search("u.office_phone", $search_phonepro); +} +if ($search_phonemobile != '') { + $sql .= natural_search("u.user_mobile", $search_phonemobile); +} +if ($search_email != '') { + $sql .= natural_search("u.email", $search_email); +} +if ($search_api_key != '') { + $sql .= natural_search("u.api_key", $search_api_key); +} +if ($search_statut != '' && $search_statut >= 0) { + $sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")"; +} +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($catid > 0) { + $sql .= " AND cu.fk_categorie = ".((int) $catid); +} +if ($catid == -2) { + $sql .= " AND cu.fk_categorie IS NULL"; +} +if ($search_categ > 0) { + $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ); +} +if ($search_categ == -2) { + $sql .= " AND cu.fk_categorie IS NULL"; +} +if ($mode == 'employee' && empty($user->rights->salaries->readall)) { + $sql .= " AND u.fk_user IN (".join(',', $childids).")"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -369,26 +423,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -397,8 +449,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id); @@ -411,40 +462,88 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $langs->trans("ListOfUsers"), $help_url); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&amp;contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&amp;limit='.urlencode($limit); -if ($sall != '') $param .= '&amp;sall='.urlencode($sall); -if ($search_user != '') $param .= "&amp;search_user=".urlencode($search_user); -if ($search_login != '') $param .= "&amp;search_login=".urlencode($search_login); -if ($search_lastname != '') $param .= "&amp;search_lastname=".urlencode($search_lastname); -if ($search_firstname != '') $param .= "&amp;search_firstname=".urlencode($search_firstname); -if ($search_gender != '') $param .= "&amp;search_gender=".urlencode($search_gender); -if ($search_employee != '') $param .= "&amp;search_employee=".urlencode($search_employee); -if ($search_accountancy_code != '') $param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code); -if ($search_phonepro != '') $param .= "&amp;search_phonepro=".urlencode($search_phonepro); -if ($search_phonemobile != '') $param .= "&amp;search_phonemobile=".urlencode($search_phonemobile); -if ($search_email != '') $param .= "&amp;search_email=".urlencode($search_email); -if ($search_api_key != '') $param .= "&amp;search_api_key=".urlencode($search_api_key); -if ($search_supervisor > 0) $param .= "&amp;search_supervisor=".urlencode($search_supervisor); -if ($search_statut != '') $param .= "&amp;search_statut=".urlencode($search_statut); -if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss); -if ($mode != '') $param .= '&amp;mode='.urlencode($mode); -if ($search_categ > 0) $param .= "&amp;search_categ=".urlencode($search_categ); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&amp;contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&amp;limit='.urlencode($limit); +} +if ($sall != '') { + $param .= '&amp;sall='.urlencode($sall); +} +if ($search_user != '') { + $param .= "&amp;search_user=".urlencode($search_user); +} +if ($search_login != '') { + $param .= "&amp;search_login=".urlencode($search_login); +} +if ($search_lastname != '') { + $param .= "&amp;search_lastname=".urlencode($search_lastname); +} +if ($search_firstname != '') { + $param .= "&amp;search_firstname=".urlencode($search_firstname); +} +if ($search_gender != '') { + $param .= "&amp;search_gender=".urlencode($search_gender); +} +if ($search_employee != '') { + $param .= "&amp;search_employee=".urlencode($search_employee); +} +if ($search_accountancy_code != '') { + $param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code); +} +if ($search_phonepro != '') { + $param .= "&amp;search_phonepro=".urlencode($search_phonepro); +} +if ($search_phonemobile != '') { + $param .= "&amp;search_phonemobile=".urlencode($search_phonemobile); +} +if ($search_email != '') { + $param .= "&amp;search_email=".urlencode($search_email); +} +if ($search_api_key != '') { + $param .= "&amp;search_api_key=".urlencode($search_api_key); +} +if ($search_supervisor > 0) { + $param .= "&amp;search_supervisor=".urlencode($search_supervisor); +} +if ($search_statut != '') { + $param .= "&amp;search_statut=".urlencode($search_statut); +} +if ($optioncss != '') { + $param .= '&amp;optioncss='.urlencode($optioncss); +} +if ($mode != '') { + $param .= '&amp;mode='.urlencode($mode); +} +if ($search_categ > 0) { + $param .= "&amp;search_categ=".urlencode($search_categ); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array(); -if ($permissiontoadd) $arrayofmassactions['disable'] = $langs->trans("DisableUser"); -if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactivate"); -if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); +if ($permissiontoadd) { + $arrayofmassactions['disable'] = $langs->trans("DisableUser"); +} +if ($permissiontoadd) { + $arrayofmassactions['reactivate'] = $langs->trans("Reactivate"); +} +if ($permissiontoadd) { + $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); +} //if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; @@ -453,7 +552,9 @@ print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; $url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu='; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); @@ -471,8 +572,7 @@ $objecttmp = new User($db); $trackid = 'use'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if (!empty($catid)) -{ +if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); $ways = $c->print_all_ways(' &gt; ', 'user/list.php'); @@ -480,9 +580,10 @@ if (!empty($catid)) print "</div><br>"; } -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -492,8 +593,7 @@ $moreforfilter = ''; $moreforfilter.= '</div>';*/ // Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1); @@ -502,11 +602,13 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -522,76 +624,60 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre_filter">'; -if (!empty($arrayfields['u.login']['checked'])) -{ +if (!empty($arrayfields['u.login']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; } -if (!empty($arrayfields['u.lastname']['checked'])) -{ +if (!empty($arrayfields['u.lastname']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="'.$search_lastname.'"></td>'; } -if (!empty($arrayfields['u.firstname']['checked'])) -{ +if (!empty($arrayfields['u.firstname']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="'.$search_firstname.'"></td>'; } -if (!empty($arrayfields['u.gender']['checked'])) -{ +if (!empty($arrayfields['u.gender']['checked'])) { print '<td class="liste_titre">'; $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print '</td>'; } -if (!empty($arrayfields['u.employee']['checked'])) -{ +if (!empty($arrayfields['u.employee']['checked'])) { print '<td class="liste_titre">'; print $form->selectyesno('search_employee', $search_employee, 1, false, 1); print '</td>'; } // Supervisor -if (!empty($arrayfields['u.fk_user']['checked'])) -{ - print '<td class="liste_titre">'; - print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); - print '</td>'; +if (!empty($arrayfields['u.fk_user']['checked'])) { + print '<td class="liste_titre">'; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); + print '</td>'; } -if (!empty($arrayfields['u.accountancy_code']['checked'])) -{ +if (!empty($arrayfields['u.accountancy_code']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="'.$search_accountancy_code.'"></td>'; } -if (!empty($arrayfields['u.office_phone']['checked'])) -{ +if (!empty($arrayfields['u.office_phone']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth75" value="'.$search_phonepro.'"></td>'; } -if (!empty($arrayfields['u.user_mobile']['checked'])) -{ +if (!empty($arrayfields['u.user_mobile']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth75" value="'.$search_phonemobile.'"></td>'; } -if (!empty($arrayfields['u.email']['checked'])) -{ +if (!empty($arrayfields['u.email']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="'.$search_email.'"></td>'; } -if (!empty($arrayfields['u.api_key']['checked'])) -{ +if (!empty($arrayfields['u.api_key']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="'.$search_api_key.'"></td>'; } -if (!empty($arrayfields['u.fk_soc']['checked'])) -{ +if (!empty($arrayfields['u.fk_soc']['checked'])) { print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="'.$search_thirdparty.'"></td>'; } -if (!empty($arrayfields['u.entity']['checked'])) -{ +if (!empty($arrayfields['u.entity']['checked'])) { print '<td class="liste_titre"></td>'; } -if (!empty($arrayfields['u.salary']['checked'])) -{ - print '<td class="liste_titre"></td>'; -} -if (!empty($arrayfields['u.datelastlogin']['checked'])) -{ +if (!empty($arrayfields['u.salary']['checked'])) { print '<td class="liste_titre"></td>'; } -if (!empty($arrayfields['u.datepreviouslogin']['checked'])) -{ +if (!empty($arrayfields['u.datelastlogin']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['u.datepreviouslogin']['checked'])) { print '<td class="liste_titre"></td>'; } // Extra fields @@ -600,20 +686,17 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['u.datec']['checked'])) -{ +if (!empty($arrayfields['u.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } -if (!empty($arrayfields['u.tms']['checked'])) -{ +if (!empty($arrayfields['u.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; } -if (!empty($arrayfields['u.statut']['checked'])) -{ +if (!empty($arrayfields['u.statut']['checked'])) { // Status print '<td class="liste_titre center">'; print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut); @@ -628,31 +711,69 @@ print '</tr>'."\n"; print '<tr class="liste_titre">'; -if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.gender']['checked'])) print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.employee']['checked'])) print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.office_phone']['checked'])) print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.user_mobile']['checked'])) print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.email']['checked'])) print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.api_key']['checked'])) print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.entity']['checked'])) print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.salary']['checked'])) print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['u.datelastlogin']['checked'])) print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.lastname']['checked'])) { + print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.firstname']['checked'])) { + print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.gender']['checked'])) { + print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.employee']['checked'])) { + print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.fk_user']['checked'])) { + print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.accountancy_code']['checked'])) { + print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.office_phone']['checked'])) { + print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.user_mobile']['checked'])) { + print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.email']['checked'])) { + print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.api_key']['checked'])) { + print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.fk_soc']['checked'])) { + print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.entity']['checked'])) { + print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); +} +if (!empty($arrayfields['u.salary']['checked'])) { + print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['u.datelastlogin']['checked'])) { + print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['u.datepreviouslogin']['checked'])) { + print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['u.datec']['checked'])) { + print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['u.tms']['checked'])) { + print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['u.statut']['checked'])) { + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center '); +} // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print '</tr>'."\n"; @@ -660,11 +781,11 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -674,10 +795,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co $i = 0; $totalarray = array(); $arrayofselected = is_array($toselect) ? $toselect : array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); @@ -700,154 +822,163 @@ while ($i < ($limit ? min($num, $limit) : $num)) $li = $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); print '<tr class="oddeven">'; - if (!empty($arrayfields['u.login']['checked'])) - { + if (!empty($arrayfields['u.login']['checked'])) { print '<td class="nowraponall">'; print $li; - if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) - { - print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } elseif ($obj->admin) - { + if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { + print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); + } elseif ($obj->admin) { print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.lastname']['checked'])) - { + if (!empty($arrayfields['u.lastname']['checked'])) { print '<td class="tdoverflowmax150">'.$obj->lastname.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.firstname']['checked'])) - { + if (!empty($arrayfields['u.firstname']['checked'])) { print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.gender']['checked'])) - { + if (!empty($arrayfields['u.gender']['checked'])) { print '<td>'; - if ($obj->gender) print $langs->trans("Gender".$obj->gender); + if ($obj->gender) { + print $langs->trans("Gender".$obj->gender); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.employee']['checked'])) - { + if (!empty($arrayfields['u.employee']['checked'])) { print '<td>'.yn($obj->employee).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Supervisor - if (!empty($arrayfields['u.fk_user']['checked'])) - { - // Resp - print '<td class="nowrap">'; - if ($obj->login2) - { - $user2->id = $obj->id2; - $user2->login = $obj->login2; - $user2->lastname = $obj->lastname2; - $user2->firstname = $obj->firstname2; - $user2->gender = $obj->gender2; - $user2->photo = $obj->photo2; - $user2->admin = $obj->admin2; + if (!empty($arrayfields['u.fk_user']['checked'])) { + // Resp + print '<td class="nowrap">'; + if ($obj->login2) { + $user2->id = $obj->id2; + $user2->login = $obj->login2; + $user2->lastname = $obj->lastname2; + $user2->firstname = $obj->firstname2; + $user2->gender = $obj->gender2; + $user2->photo = $obj->photo2; + $user2->admin = $obj->admin2; $user2->office_phone = $obj->office_phone; $user2->user_mobile = $obj->user_mobile; - $user2->email = $obj->email2; - $user2->socid = $obj->fk_soc2; - $user2->statut = $obj->statut2; - print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); - if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) - { - print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } elseif ($obj->admin2) - { - print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); - } - } - print '</td>'; - if (!$i) $totalarray['nbfield']++; + $user2->email = $obj->email2; + $user2->socid = $obj->fk_soc2; + $user2->statut = $obj->statut2; + print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); + if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) { + print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); + } elseif ($obj->admin2) { + print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); + } + } + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.accountancy_code']['checked'])) - { + if (!empty($arrayfields['u.accountancy_code']['checked'])) { print '<td>'.$obj->accountancy_code.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.office_phone']['checked'])) - { + if (!empty($arrayfields['u.office_phone']['checked'])) { print "<td>".dol_print_phone($obj->office_phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.user_mobile']['checked'])) - { + if (!empty($arrayfields['u.user_mobile']['checked'])) { print "<td>".dol_print_phone($obj->user_mobile, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.email']['checked'])) - { + if (!empty($arrayfields['u.email']['checked'])) { print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.api_key']['checked'])) - { + if (!empty($arrayfields['u.api_key']['checked'])) { print '<td>'.$obj->api_key.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['u.fk_soc']['checked'])) - { + if (!empty($arrayfields['u.fk_soc']['checked'])) { print "<td>"; - if ($obj->fk_soc) - { + if ($obj->fk_soc) { $companystatic->id = $obj->fk_soc; $companystatic->name = $obj->name; $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1); - } elseif ($obj->ldap_sid) - { + } elseif ($obj->ldap_sid) { print $langs->trans("DomainUser"); } else { print $langs->trans("InternalUser"); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Multicompany enabled - if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { - if (!empty($arrayfields['u.entity']['checked'])) - { + if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (!empty($arrayfields['u.entity']['checked'])) { print '<td>'; - if (!$obj->entity) - { + if (!$obj->entity) { print $langs->trans("AllEntities"); } else { $mc->getInfo($obj->entity); print $mc->label; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } } // Salary - if (!empty($arrayfields['u.salary']['checked'])) - { - print '<td class="nowraponall right">'.($obj->salary ? price($obj->salary) : '').'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['u.salary']['checked'])) { + print '<td class="nowraponall right">'.($obj->salary ? price($obj->salary) : '').'</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } // Date last login - if (!empty($arrayfields['u.datelastlogin']['checked'])) - { + if (!empty($arrayfields['u.datelastlogin']['checked'])) { print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date previous login - if (!empty($arrayfields['u.datepreviouslogin']['checked'])) - { + if (!empty($arrayfields['u.datepreviouslogin']['checked'])) { print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -857,38 +988,44 @@ while ($i < ($limit ? min($num, $limit) : $num)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['u.datec']['checked'])) - { + if (!empty($arrayfields['u.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['u.tms']['checked'])) - { + if (!empty($arrayfields['u.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['u.statut']['checked'])) - { + if (!empty($arrayfields['u.statut']['checked'])) { $userstatic->statut = $obj->statut; print '<td class="center">'.$userstatic->getLibStatut(5).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -899,10 +1036,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 5cb03af224f..57a653a01d1 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -24,17 +24,24 @@ */ //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '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'); // We need company to get correct logo onto home page -if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1'); +if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) { + define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1'); +} require_once '../main.inc.php'; // This can happen only with a bookmark or forged url call. -if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http')) -{ +if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http')) { unset($_SESSION["dol_login"]); die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]); } @@ -43,7 +50,9 @@ global $conf, $langs, $user; // Call trigger $result = $user->call_trigger('USER_LOGOUT', $user); -if ($result < 0) $error++; +if ($result < 0) { + $error++; +} // End call triggers // Hooks on logout @@ -51,26 +60,41 @@ $action = ''; $hookmanager->initHooks(array('logout')); $parameters = array(); $reshook = $hookmanager->executeHooks('afterLogout', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { $error++; } +if ($reshook < 0) { + $error++; +} // Define url to go after disconnect $urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"]; // Define url to go $url = DOL_URL_ROOT."/index.php"; // By default go to login page -if ($urlfrom) $url = DOL_URL_ROOT.$urlfrom; -if (!empty($conf->global->MAIN_LOGOUT_GOTO_URL)) $url = $conf->global->MAIN_LOGOUT_GOTO_URL; +if ($urlfrom) { + $url = DOL_URL_ROOT.$urlfrom; +} +if (!empty($conf->global->MAIN_LOGOUT_GOTO_URL)) { + $url = $conf->global->MAIN_LOGOUT_GOTO_URL; +} -if (GETPOST('dol_hide_topmenu')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_topmenu=1'; -if (GETPOST('dol_hide_leftmenu')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_leftmenu=1'; -if (GETPOST('dol_optimize_smallscreen')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_optimize_smallscreen=1'; -if (GETPOST('dol_no_mouse_hover')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_no_mouse_hover=1'; -if (GETPOST('dol_use_jmobile')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_use_jmobile=1'; +if (GETPOST('dol_hide_topmenu')) { + $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_topmenu=1'; +} +if (GETPOST('dol_hide_leftmenu')) { + $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_leftmenu=1'; +} +if (GETPOST('dol_optimize_smallscreen')) { + $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_optimize_smallscreen=1'; +} +if (GETPOST('dol_no_mouse_hover')) { + $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_no_mouse_hover=1'; +} +if (GETPOST('dol_use_jmobile')) { + $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_use_jmobile=1'; +} // Destroy session dol_syslog("End of session ".session_id()); -if (session_status() === PHP_SESSION_ACTIVE) -{ +if (session_status() === PHP_SESSION_ACTIVE) { session_destroy(); } @@ -80,5 +104,7 @@ unset($_SESSION['dol_login']); unset($_SESSION['dol_entity']); unset($_SESSION['urlfrom']); -if (GETPOST('noredirect')) return; +if (GETPOST('noredirect')) { + return; +} header("Location: ".$url); // Default behaviour is redirect to index.php page diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 95527747d2e..e0c23842347 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -39,11 +39,15 @@ $object->fetch($id, '', '', 1); $object->getrights(); // If user is not user read and no permission to read other users, we stop -if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden(); +if (($object->id != $user->id) && (!$user->rights->user->user->lire)) { + accessforbidden(); +} // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); @@ -58,7 +62,9 @@ $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) { @@ -83,8 +89,7 @@ llxHeader(); $form = new Form($db); -if ($id) -{ +if ($id) { $head = user_prepare_head($object); $title = $langs->trans("User"); @@ -114,8 +119,7 @@ if ($id) // Note print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>'; print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">'; - if ($editenabled) - { + if ($editenabled) { print "<input type=\"hidden\" name=\"action\" value=\"update\">"; print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">"; // Editeur wysiwyg @@ -132,8 +136,7 @@ if ($id) print dol_get_fiche_end(); - if ($action == 'edit') - { + if ($action == 'edit') { print '<div class="center">'; print '<input type="submit" class="button button-save" name="update" value="'.$langs->trans("Save").'">'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; @@ -143,13 +146,12 @@ if ($id) /* - * Actions - */ + * Actions + */ print '<div class="tabsAction">'; - if ($user->rights->user->user->creer && $action != 'edit') - { + if ($user->rights->user->user->creer && $action != 'edit') { print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>"; } diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index d09ee52077f..fa2cf5a5d41 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -39,16 +39,24 @@ $action = GETPOST('action', 'aZ09'); $actionid = GETPOST('actionid'); // Security check -if ($user->socid) $id = $user->socid; +if ($user->socid) { + $id = $user->socid; +} $result = restrictedArea($user, 'societe', '', ''); $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 (empty($page) || $page == -1) { $page = 0; } +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; @@ -61,29 +69,24 @@ $now = dol_now(); */ // Add a notification -if ($action == 'add') -{ +if ($action == 'add') { $error = 0; - if ($actionid <= 0) - { + if ($actionid <= 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid; - if ($db->query($sql)) - { + if ($db->query($sql)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)"; $sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")"; - if (!$db->query($sql)) - { + if (!$db->query($sql)) { $error++; dol_print_error($db); } @@ -91,8 +94,7 @@ if ($action == 'add') dol_print_error($db); } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -101,8 +103,7 @@ if ($action == 'add') } // Remove a notification -if ($action == 'delete') -{ +if ($action == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int"); $db->query($sql); } @@ -120,13 +121,14 @@ $result = $object->fetch($id, '', '', 1); $object->getrights(); $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"); +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); -if ($result > 0) -{ +if ($result > 0) { $langs->load("other"); $head = user_prepare_head($object); @@ -144,8 +146,7 @@ if ($result > 0) // Login print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; - if (!empty($object->ldap_sid) && $object->statut == 0) - { + if (!empty($object->ldap_sid) && $object->statut == 0) { print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; } else { print '<td>'.$object->login.'</td>'; @@ -153,16 +154,16 @@ if ($result > 0) print '</tr>'."\n"; /*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty - print '<td colspan="3">'; - $nbofrecipientemails=0; - $notify=new Notify($db); - $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); - foreach($tmparray as $tmpkey => $tmpval) - { - $nbofrecipientemails++; - } - print $nbofrecipientemails; - print '</td></tr>';*/ + print '<td colspan="3">'; + $nbofrecipientemails=0; + $notify=new Notify($db); + $tmparray = $notify->getNotificationsArray('', 0, null, $object->id, array('user')); + foreach($tmparray as $tmpkey => $tmpval) + { + $nbofrecipientemails++; + } + print $nbofrecipientemails; + print '</td></tr>';*/ print '</table>'; @@ -203,23 +204,20 @@ if ($result > 0) // $listofemails=$object->thirdparty_and_contact_email_array(); - if ($object->email) - { + if ($object->email) { $actions = array(); // Load array of available notifications $notificationtrigger = new InterfaceNotification($db); $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); - foreach ($listofnotifiedevents as $notifiedevent) - { - $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); + foreach ($listofnotifiedevents as $notifiedevent) { + $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); $actions[$notifiedevent['rowid']] = $label; } print '<tr class="oddeven nohover"><td>'; print $object->getNomUrl(1); - if (isValidEmail($object->email)) - { + if (isValidEmail($object->email)) { print ' &lt;'.$object->email.'&gt;'; } else { $langs->load("errors"); @@ -258,8 +256,7 @@ if ($result > 0) $sql .= " AND c.rowid = ".$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); } else { dol_print_error($db); @@ -280,24 +277,20 @@ if ($result > 0) $langs->load("errors"); $langs->load("other"); - if ($num) - { + if ($num) { $i = 0; $userstatic = new user($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $userstatic->id = $obj->userid; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; print '<tr class="oddeven"><td>'.$userstatic->getNomUrl(1); - if ($obj->type == 'email') - { - if (isValidEmail($obj->email)) - { + if ($obj->type == 'email') { + if (isValidEmail($obj->email)) { print ' &lt;'.$obj->email.'&gt;'; } else { $langs->load("errors"); @@ -310,8 +303,12 @@ if ($result > 0) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label; print '</td>'; print '<td>'; - if ($obj->type == 'email') print $langs->trans("Email"); - if ($obj->type == 'sms') print $langs->trans("SMS"); + if ($obj->type == 'email') { + print $langs->trans("Email"); + } + if ($obj->type == 'sms') { + print $langs->trans("SMS"); + } print '</td>'; print '<td class="right"><a href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'&amp;actid='.$obj->rowid.'">'.img_delete().'</a></td>'; print '</tr>'; @@ -322,8 +319,8 @@ if ($result > 0) // List of notifications enabled for fixed email /* - foreach($conf->global as $key => $val) { - if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; + foreach($conf->global as $key => $val) { + if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; print '<tr class="oddeven"><td>'; $listtmp=explode(',',$val); $first=1; @@ -332,7 +329,7 @@ if ($result > 0) if (! $first) print ', '; $first=0; $valemail=trim($valemail); - //print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>'; + //print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>'; if (isValidEmail($valemail, 1)) { if ($valemail == '__SUPERVISOREMAIL__') print $valemail; @@ -359,14 +356,14 @@ if ($result > 0) print '</td>'; print '<td class="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>'; print '</tr>'; - }*/ + }*/ /*if ($user->admin) - { - $var = ! $var; + { + $var = ! $var; print '<tr class="oddeven"><td colspan="4">'; print '+ <a href="'.DOL_URL_ROOT.'/admin/notification.php">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</a>'; print '</td></tr>'; - }*/ + }*/ print '</table>'; @@ -387,12 +384,10 @@ if ($result > 0) // Count total nb of records $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -401,19 +396,24 @@ if ($result > 0) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); } else { dol_print_error($db); } $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; @@ -434,19 +434,16 @@ if ($result > 0) print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); print '</tr>'; - if ($num) - { + if ($num) { $i = 0; $userstatic = new User($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven"><td>'; - if ($obj->id > 0) - { + if ($obj->id > 0) { $userstatic->id = $obj->id; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; @@ -461,18 +458,22 @@ if ($result > 0) print $label; print '</td>'; print '<td>'; - if ($obj->type == 'email') print $langs->trans("Email"); - if ($obj->type == 'sms') print $langs->trans("Sms"); + if ($obj->type == 'email') { + print $langs->trans("Email"); + } + if ($obj->type == 'sms') { + print $langs->trans("Sms"); + } print '</td>'; // TODO Add link to object here for other types /*print '<td>'; - if ($obj->object_type == 'order') - { + if ($obj->object_type == 'order') + { $orderstatic->id=$obj->object_id; $orderstatic->ref=... print $orderstatic->getNomUrl(1); - } - print '</td>';*/ + } + print '</td>';*/ // print print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>'; print '</tr>'; @@ -486,7 +487,9 @@ if ($result > 0) print '</table>'; print '</form>'; -} else dol_print_error('', 'RecordNotFound'); +} else { + dol_print_error('', 'RecordNotFound'); +} // End of page llxFooter(); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 52f7a28be44..228066b7051 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -38,8 +38,7 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userihm'; // To manage different context of search -if ($id) -{ +if ($id) { // $user est le user qui edite, $id est l'id de l'utilisateur edite $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer)); @@ -47,11 +46,15 @@ if ($id) // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) { + accessforbidden(); +} $dirtop = "../core/menus/standard"; $dirleft = "../core/menus/standard"; @@ -81,7 +84,9 @@ $hookmanager->initHooks(array('usercard', 'userihm', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'update' && ($caneditfield || !empty($user->admin))) { @@ -122,16 +127,20 @@ if (empty($reshook)) { if ($val == '') { $tabparam['THEME_ELDY_TOPMENU_BACK1'] = ''; } else { - $tabparam['THEME_ELDY_TOPMENU_BACK1'] = join(',', - colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1', 'alphanohtml'), array())); + $tabparam['THEME_ELDY_TOPMENU_BACK1'] = join( + ',', + colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1', 'alphanohtml'), array()) + ); } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array())))); if ($val == '') { $tabparam['THEME_ELDY_BACKTITLE1'] = ''; } else { - $tabparam['THEME_ELDY_BACKTITLE1'] = join(',', - colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array())); + $tabparam['THEME_ELDY_BACKTITLE1'] = join( + ',', + colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array()) + ); } if (GETPOST('check_THEME_ELDY_USE_HOVER') == 'on') { @@ -174,21 +183,36 @@ llxHeader(); // List of possible landing pages $tmparray = array('index.php'=>'Dashboard'); -if (!empty($conf->societe->enabled)) $tmparray['societe/index.php?mainmenu=companies&leftmenu='] = 'ThirdPartiesArea'; -if (!empty($conf->projet->enabled)) $tmparray['projet/index.php?mainmenu=project&leftmenu='] = 'ProjectsArea'; -if (!empty($conf->holiday->enabled) || !empty($conf->expensereport->enabled)) $tmparray['hrm/index.php?mainmenu=hrm&leftmenu='] = 'HRMArea'; // TODO Complete list with first level of menus -if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) $tmparray['product/index.php?mainmenu=products&leftmenu='] = 'ProductsAndServicesArea'; -if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->contrat->enabled)) $tmparray['comm/index.php?mainmenu=commercial&leftmenu='] = 'CommercialArea'; -if (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled)) $tmparray['compta/index.php?mainmenu=compta&leftmenu='] = 'AccountancyTreasuryArea'; -if (!empty($conf->adherent->enabled)) $tmparray['adherents/index.php?mainmenu=members&leftmenu='] = 'MembersArea'; -if (!empty($conf->agenda->enabled)) $tmparray['comm/action/index.php?mainmenu=agenda&leftmenu='] = 'Agenda'; +if (!empty($conf->societe->enabled)) { + $tmparray['societe/index.php?mainmenu=companies&leftmenu='] = 'ThirdPartiesArea'; +} +if (!empty($conf->projet->enabled)) { + $tmparray['projet/index.php?mainmenu=project&leftmenu='] = 'ProjectsArea'; +} +if (!empty($conf->holiday->enabled) || !empty($conf->expensereport->enabled)) { + $tmparray['hrm/index.php?mainmenu=hrm&leftmenu='] = 'HRMArea'; // TODO Complete list with first level of menus +} +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $tmparray['product/index.php?mainmenu=products&leftmenu='] = 'ProductsAndServicesArea'; +} +if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->contrat->enabled)) { + $tmparray['comm/index.php?mainmenu=commercial&leftmenu='] = 'CommercialArea'; +} +if (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled)) { + $tmparray['compta/index.php?mainmenu=compta&leftmenu='] = 'AccountancyTreasuryArea'; +} +if (!empty($conf->adherent->enabled)) { + $tmparray['adherents/index.php?mainmenu=members&leftmenu='] = 'MembersArea'; +} +if (!empty($conf->agenda->enabled)) { + $tmparray['comm/action/index.php?mainmenu=agenda&leftmenu='] = 'Agenda'; +} $head = user_prepare_head($object); $title = $langs->trans("User"); -if ($action == 'edit') -{ +if ($action == 'edit') { print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; @@ -196,8 +220,7 @@ if ($action == 'edit') } -if ($action == 'edit') -{ +if ($action == 'edit') { print dol_get_fiche_head($head, 'guisetup', $title, -1, 'user'); $linkback = ''; @@ -208,22 +231,20 @@ if ($action == 'edit') dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - if (!empty($conf->use_javascript_ajax)) - {/* - print '<script type="text/javascript" language="javascript"> - jQuery(document).ready(function() { - $("#main_lang_default").change(function() { - $("#check_MAIN_LANG_DEFAULT").prop("checked", true); - }); - $("#main_size_liste_limit").keyup(function() { - if ($(this).val().length) $("#check_SIZE_LISTE_LIMIT").prop("checked", true); - else $("#check_SIZE_LISTE_LIMIT").prop("checked", false); - }); - }); - </script>';*/ + if (!empty($conf->use_javascript_ajax)) {/* + print '<script type="text/javascript" language="javascript"> + jQuery(document).ready(function() { + $("#main_lang_default").change(function() { + $("#check_MAIN_LANG_DEFAULT").prop("checked", true); + }); + $("#main_size_liste_limit").keyup(function() { + if ($(this).val().length) $("#check_SIZE_LISTE_LIMIT").prop("checked", true); + else $("#check_SIZE_LISTE_LIMIT").prop("checked", false); + }); + }); + </script>';*/ } - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { function init_myfunc() @@ -357,10 +378,11 @@ if ($action == 'edit') print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").'</td>'; print '<td>'; - if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) - { + if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) { print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]); - } else print $object->conf->MAIN_LANDING_PAGE; + } else { + print $object->conf->MAIN_LANDING_PAGE; + } //print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1); print '</td></tr>'; @@ -371,7 +393,9 @@ if ($action == 'edit') print '<td class="nowrap" width="20%"><input class="oddeven" type="checkbox" disabled '.(!empty($object->conf->AGENDA_DEFAULT_VIEW) ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>'; print '<td>'."\n"; $tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); - if (!empty($object->conf->AGENDA_DEFAULT_VIEW)) print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, '', 0, 0, 1); + if (!empty($object->conf->AGENDA_DEFAULT_VIEW)) { + print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, '', 0, 0, 1); + } print '</td></tr>'."\n"; // Max size for lists @@ -390,12 +414,10 @@ if ($action == 'edit') print '<div class="tabsAction">'; - if (empty($user->admin) && !empty($dolibarr_main_demo)) - { + if (empty($user->admin) && !empty($dolibarr_main_demo)) { print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("FeatureDisabledInDemo")."\" href=\"#\">".$langs->trans("Modify")."</a>"; } else { - if ($caneditfield || !empty($user->admin)) // Si utilisateur edite = utilisateur courant (pas besoin de droits particulier car il s'agit d'une page de modif d'output et non de données) ou si admin - { + if ($caneditfield || !empty($user->admin)) { // Si utilisateur edite = utilisateur courant (pas besoin de droits particulier car il s'agit d'une page de modif d'output et non de données) ou si admin print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a>'; } else { print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("Modify")."</a>"; @@ -405,8 +427,7 @@ if ($action == 'edit') print '</div>'; } -if ($action == 'edit') -{ +if ($action == 'edit') { print '</form>'; } diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 15df6371891..f2ad3faf42e 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -29,21 +29,24 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +if (!empty($conf->ldap->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +} // Load translation files required by page $langs->loadLangs(array('errors', 'users', 'companies', 'ldap', 'other')); // Security check -if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) -{ +if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { header("Location: ".DOL_URL_ROOT.'/'); exit; } $action = GETPOST('action', 'aZ09'); $mode = $dolibarr_main_authentication; -if (!$mode) $mode = 'http'; +if (!$mode) { + $mode = 'http'; +} $username = GETPOST('username', 'alphanohtml'); $passwordhash = GETPOST('passwordhash', 'alpha'); @@ -53,11 +56,21 @@ $conf->entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : 1); $hookmanager->initHooks(array('passwordforgottenpage')); -if (GETPOST('dol_hide_leftmenu', 'alpha') || !empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu = 1; -if (GETPOST('dol_hide_topmenu', 'alpha') || !empty($_SESSION['dol_hide_topmenu'])) $conf->dol_hide_topmenu = 1; -if (GETPOST('dol_optimize_smallscreen', 'alpha') || !empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen = 1; -if (GETPOST('dol_no_mouse_hover', 'alpha') || !empty($_SESSION['dol_no_mouse_hover'])) $conf->dol_no_mouse_hover = 1; -if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) $conf->dol_use_jmobile = 1; +if (GETPOST('dol_hide_leftmenu', 'alpha') || !empty($_SESSION['dol_hide_leftmenu'])) { + $conf->dol_hide_leftmenu = 1; +} +if (GETPOST('dol_hide_topmenu', 'alpha') || !empty($_SESSION['dol_hide_topmenu'])) { + $conf->dol_hide_topmenu = 1; +} +if (GETPOST('dol_optimize_smallscreen', 'alpha') || !empty($_SESSION['dol_optimize_smallscreen'])) { + $conf->dol_optimize_smallscreen = 1; +} +if (GETPOST('dol_no_mouse_hover', 'alpha') || !empty($_SESSION['dol_no_mouse_hover'])) { + $conf->dol_no_mouse_hover = 1; +} +if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) { + $conf->dol_use_jmobile = 1; +} /** @@ -67,96 +80,86 @@ if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) $parameters = array('username' => $username); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $message = $hookmanager->error; + $message = $hookmanager->error; } if (empty($reshook)) { - // Validate new password - if ($action == 'validatenewpassword' && $username && $passwordhash) - { - $edituser = new User($db); - $result = $edituser->fetch('', $_GET["username"]); - if ($result < 0) - { - $message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>'; - } else { - if (dol_verifyHash($edituser->pass_temp, $passwordhash)) - { - // Clear session - unset($_SESSION['dol_login']); - $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page + // Validate new password + if ($action == 'validatenewpassword' && $username && $passwordhash) { + $edituser = new User($db); + $result = $edituser->fetch('', $_GET["username"]); + if ($result < 0) { + $message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>'; + } else { + if (dol_verifyHash($edituser->pass_temp, $passwordhash)) { + // Clear session + unset($_SESSION['dol_login']); + $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page - $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0); - dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database"); - header("Location: ".DOL_URL_ROOT.'/'); - exit; - } else { - $langs->load("errors"); - $message = '<div class="error">'.$langs->trans("ErrorFailedToValidatePasswordReset").'</div>'; - } - } - } - // Action modif mot de passe - if ($action == 'buildnewpassword' && $username) - { - $sessionkey = 'dol_antispam_value'; - $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); + $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0); + dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database"); + header("Location: ".DOL_URL_ROOT.'/'); + exit; + } else { + $langs->load("errors"); + $message = '<div class="error">'.$langs->trans("ErrorFailedToValidatePasswordReset").'</div>'; + } + } + } + // Action modif mot de passe + if ($action == 'buildnewpassword' && $username) { + $sessionkey = 'dol_antispam_value'; + $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); - // Verify code - if (!$ok) - { - $message = '<div class="error">'.$langs->trans("ErrorBadValueForCode").'</div>'; - } else { - $isanemail = preg_match('/@/', $username); + // Verify code + if (!$ok) { + $message = '<div class="error">'.$langs->trans("ErrorBadValueForCode").'</div>'; + } else { + $isanemail = preg_match('/@/', $username); - $edituser = new User($db); - $result = $edituser->fetch('', $username, '', 1); - if ($result == 0 && $isanemail) - { - $result = $edituser->fetch('', '', '', 1, -1, $username); - } + $edituser = new User($db); + $result = $edituser->fetch('', $username, '', 1); + if ($result == 0 && $isanemail) { + $result = $edituser->fetch('', '', '', 1, -1, $username); + } - if ($result <= 0 && $edituser->error == 'USERNOTFOUND') - { - $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; - if (!$isanemail) { - $message .= $langs->trans("IfLoginExistPasswordRequestSent"); - } else { - $message .= $langs->trans("IfEmailExistPasswordRequestSent"); - } - $message .= '</div>'; - $username = ''; - } else { - if (!$edituser->email) - { - $message = '<div class="error">'.$langs->trans("ErrorLoginHasNoEmail").'</div>'; - } else { - $newpassword = $edituser->setPassword($user, '', 1); - if ($newpassword < 0) - { - // Failed - $message = '<div class="error">'.$langs->trans("ErrorFailedToChangePassword").'</div>'; - } else { - // Success - if ($edituser->send_password($user, $newpassword, 1) > 0) - { - $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; - if (!$isanemail) { - $message .= $langs->trans("IfLoginExistPasswordRequestSent"); - } else { - $message .= $langs->trans("IfEmailExistPasswordRequestSent"); - } - //$message .= $langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)); - $message .= '</div>'; - $username = ''; - } else { - $message .= '<div class="error">'.$edituser->error.'</div>'; - } - } - } - } - } - } + if ($result <= 0 && $edituser->error == 'USERNOTFOUND') { + $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; + if (!$isanemail) { + $message .= $langs->trans("IfLoginExistPasswordRequestSent"); + } else { + $message .= $langs->trans("IfEmailExistPasswordRequestSent"); + } + $message .= '</div>'; + $username = ''; + } else { + if (!$edituser->email) { + $message = '<div class="error">'.$langs->trans("ErrorLoginHasNoEmail").'</div>'; + } else { + $newpassword = $edituser->setPassword($user, '', 1); + if ($newpassword < 0) { + // Failed + $message = '<div class="error">'.$langs->trans("ErrorFailedToChangePassword").'</div>'; + } else { + // Success + if ($edituser->send_password($user, $newpassword, 1) > 0) { + $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; + if (!$isanemail) { + $message .= $langs->trans("IfLoginExistPasswordRequestSent"); + } else { + $message .= $langs->trans("IfEmailExistPasswordRequestSent"); + } + //$message .= $langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)); + $message .= '</div>'; + $username = ''; + } else { + $message .= '<div class="error">'.$edituser->error.'</div>'; + } + } + } + } + } + } } @@ -168,46 +171,49 @@ $dol_url_root = DOL_URL_ROOT; // Title $title = 'Dolibarr '.DOL_VERSION; -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $title = $conf->global->MAIN_APPLICATION_TITLE; +} // Select templates -if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php")) -{ +if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php")) { $template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; } else { $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; } -if (!$username) $focus_element = 'username'; -else $focus_element = 'password'; +if (!$username) { + $focus_element = 'username'; +} else { + $focus_element = 'password'; +} // Send password button enabled ? $disabled = 'disabled'; -if (preg_match('/dolibarr/i', $mode)) $disabled = ''; -if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled = ''; // To force button enabled +if (preg_match('/dolibarr/i', $mode)) { + $disabled = ''; +} +if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) { + $disabled = ''; // To force button enabled +} // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $rowspan = 2; $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)) -{ +if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small); -} elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) -{ +} elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo); $width = 128; -} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg')) -{ +} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg')) { $urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg'; -} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) -{ +} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; } // Security graphical code -if (function_exists("imagecreatefrompng") && !$disabled) -{ +if (function_exists("imagecreatefrompng") && !$disabled) { $captcha = 1; $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index a05fd76df7b..f14fcee2e0f 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -26,7 +26,9 @@ * \brief Page to set permission of a user record */ -if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) { + define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +} require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; @@ -43,15 +45,16 @@ $module = GETPOST('module', 'alpha'); $rights = GETPOST('rights', 'int'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userperms'; // To manage different context of search -if (!isset($id) || empty($id)) accessforbidden(); +if (!isset($id) || empty($id)) { + accessforbidden(); +} // Define if user can read permissions $canreaduser = ($user->admin || $user->rights->user->user->lire); // Define if user can modify other users and permissions $caneditperms = ($user->admin || $user->rights->user->user->creer); // Advanced permissions -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreaduser = ($user->admin || ($user->rights->user->user->lire && $user->rights->user->user_advance->readperms)); $caneditselfperms = ($user->id == $id && $user->rights->user->self_advance->writeperms); $caneditperms = (($caneditperms || $caneditselfperms) ? 1 : 0); @@ -59,16 +62,19 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) // Security check $socid = 0; -if (isset($user->socid) && $user->socid > 0) $socid = $user->socid; +if (isset($user->socid) && $user->socid > 0) { + $socid = $user->socid; +} $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); // A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin -if ($user->id == $id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) -{ +if ($user->id == $id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) { accessforbidden(); } $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) { + accessforbidden(); +} $object = new User($db); $object->fetch($id, '', '', 1); @@ -86,15 +92,16 @@ $hookmanager->initHooks(array('usercard', 'userperms', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'addrights' && $caneditperms && $confirm == 'yes') { $edituser = new User($db); $edituser->fetch($object->id); $result = $edituser->addrights($rights, $module, '', $entity); - if ($result < 0) - { + if ($result < 0) { setEventMessages($edituser->error, $edituser->errors, 'errors'); } @@ -113,8 +120,7 @@ if (empty($reshook)) { $edituser = new User($db); $edituser->fetch($object->id); $result = $edituser->delrights($rights, $module, '', $entity); - if ($result < 0) - { + if ($result < 0) { setEventMessages($edituser->error, $edituser->errors, 'errors'); } @@ -151,33 +157,25 @@ $db->begin(); $modules = array(); $modulesdir = dolGetModulesDirs(); -foreach ($modulesdir as $dir) -{ +foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + 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 ($modName) { include_once $dir.$file; $objMod = new $modName($db); // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach ($objMod->langfiles as $domain) - { + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } } // Load all permissions - if ($objMod->rights_class) - { + if ($objMod->rights_class) { $ret = $objMod->insert_permissions(0, $entity); $modules[$objMod->rights_class] = $objMod; //print "modules[".$objMod->rights_class."]=$objMod;"; @@ -200,12 +198,10 @@ $sql .= " AND ur.fk_user = ".$object->id; dol_syslog("get user perms", LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); array_push($permsuser, $obj->fk_id); $i++; @@ -227,15 +223,14 @@ $sql .= " AND gu.fk_user = ".$object->id; dol_syslog("get user perms", LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); - if (!isset($permsgroupbyentity[$obj->entity])) + if (!isset($permsgroupbyentity[$obj->entity])) { $permsgroupbyentity[$obj->entity] = array(); + } array_push($permsgroupbyentity[$obj->entity], $obj->fk_id); $i++; } @@ -260,13 +255,19 @@ dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $use print '<div class="underbanner clearboth"></div>'; -if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); +if ($user->admin) { + print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); +} // Show warning about external users -if (empty($user->socid)) print info_admin(showModulesExludedForExternal($modules))."\n"; +if (empty($user->socid)) { + print info_admin(showModulesExludedForExternal($modules))."\n"; +} $parameters = array('permsgroupbyentity'=>$permsgroupbyentity); $reshook = $hookmanager->executeHooks('insertExtraHeader', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} print "\n"; @@ -275,10 +276,8 @@ print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Module").'</td>'; -if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) -{ - if ($caneditperms) - { +if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) { + if ($caneditperms) { print '<td class="center nowrap">'; print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>"; print ' / '; @@ -288,7 +287,9 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad print '<td class="center" width="24">&nbsp;</td>'; } print '<td>'.$langs->trans("Permissions").'</td>'; -if ($user->admin) print '<td class="right">'.$langs->trans("ID").'</td>'; +if ($user->admin) { + print '<td class="right">'.$langs->trans("ID").'</td>'; +} print '</tr>'."\n"; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; @@ -296,32 +297,29 @@ $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql .= " AND r.entity = ".$entity; -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled +} $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; $oldmod = ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it - if (empty($modules[$obj->module])) - { + if (empty($modules[$obj->module])) { $i++; continue; } // Save field module_position in database if value is still zero - if (empty($obj->module_position)) - { - if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) - { + if (empty($obj->module_position)) { + if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) { // TODO Define familyposition $family = $modules[$obj->module]->family_position; $familyposition = 0; @@ -332,8 +330,7 @@ if ($result) } } - if (isset($obj->module) && ($oldmod <> $obj->module)) - { + if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; // Break detected, we get objMod @@ -346,10 +343,8 @@ if ($result) print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print '<a name="'.$objMod->getName().'"></a>'; print '</td>'; - if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) - { - if ($caneditperms) - { + if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) { + if ($caneditperms) { print '<td class="center nowrap">'; print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>"; print ' / '; @@ -358,8 +353,7 @@ if ($result) } print '<td>&nbsp;</td>'; } else { - if ($caneditperms) - { + if ($caneditperms) { print '<td>&nbsp;</td>'; } print '<td>&nbsp;</td>'; @@ -367,7 +361,9 @@ if ($result) print '<td>&nbsp;</td>'; // Permission id - if ($user->admin) print '<td class="right"></td>'; + if ($user->admin) { + print '<td class="right"></td>'; + } print '</tr>'."\n"; } @@ -381,19 +377,15 @@ if ($result) print '</td>'; // Permission and tick - if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) // Permission granted because admin - { - if ($caneditperms) - { + if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) { // Permission granted because admin + if ($caneditperms) { print '<td class="center">'.img_picto($langs->trans("Administrator"), 'star').'</td>'; } print '<td class="center nowrap">'; print img_picto($langs->trans("Active"), 'tick'); print '</td>'; - } elseif (in_array($obj->id, $permsuser)) // Permission granted by user - { - if ($caneditperms) - { + } elseif (in_array($obj->id, $permsuser)) { // Permission granted by user + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); @@ -402,12 +394,9 @@ if ($result) print '<td class="center nowrap">'; print img_picto($langs->trans("Active"), 'tick'); print '</td>'; - } elseif (is_array($permsgroupbyentity[$entity])) - { - if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission granted by group - { - if ($caneditperms) - { + } elseif (is_array($permsgroupbyentity[$entity])) { + if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Permission granted by group + if ($caneditperms) { print '<td class="center">'; print $form->textwithtooltip($langs->trans("Inherited"), $langs->trans("PermissionInheritedFromAGroup")); print '</td>'; @@ -417,8 +406,7 @@ if ($result) print '</td>'; } else { // Do not own permission - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); @@ -428,8 +416,7 @@ if ($result) } } else { // Do not own permission - if ($caneditperms) - { + if ($caneditperms) { print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); @@ -450,19 +437,25 @@ if ($result) print '</td>'; // Permission id - if ($user->admin) print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; + if ($user->admin) { + print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; + } print '</tr>'."\n"; $i++; } -} else dol_print_error($db); +} else { + dol_print_error($db); +} print '</table>'; print '</div>'; $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraFooter', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} print dol_get_fiche_end(); diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 6cdcd04417f..57778c44259 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -36,14 +36,15 @@ $id = GETPOST('id', 'int'); // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user', $feature2); $result = $user2->fetch($id); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($user2->error); exit; } @@ -51,8 +52,7 @@ if ($result <= 0) $physicalperson = 1; $company = new Societe($db); -if ($user2->socid) -{ +if ($user2->socid) { $result = $company->fetch($user2->socid); } @@ -79,33 +79,32 @@ $v->setNote($user2->note); $v->setTitle($user2->poste); // Data from linked company -if ($company->id) -{ +if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (!$user2->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (!$user2->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (!$user2->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$user2->phone_pro) { + $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + } + if (!$user2->fax) { + $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + } + if (!$user2->zip) { + $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + } // when company e-mail is empty, use only user e-mail - if (empty(trim($company->email))) - { + if (empty(trim($company->email))) { // was set before, don't set twice - } - // when user e-mail is empty, use only company e-mail - elseif (empty(trim($user2->email))) - { + } elseif (empty(trim($user2->email))) { + // when user e-mail is empty, use only company e-mail $v->setEmail($company->email); - } - // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) - elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) - { + } elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) { + // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) $v->setEmail($user2->email); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); - } - // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) - else { + } else { + // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) @@ -113,12 +112,16 @@ if ($company->id) } // Si user lie a un tiers non de type "particulier" - if ($user2->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); + if ($user2->typent_code != 'TE_PRIVATE') { + $v->setOrg($company->name); + } } // Personal informations $v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE"); -if ($user2->birth) $v->setBirthday($user2->birth); +if ($user2->birth) { + $v->setBirthday($user2->birth); +} $db->close(); From 9e202467e02de9a313beb300e77af54ee8f11d9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 13:22:13 +0100 Subject: [PATCH 134/173] Code comment --- htdocs/variants/class/ProductCombination.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 9152336bbe4..3be211e6753 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -470,11 +470,12 @@ class ProductCombination } /** - * Updates the weight of the child product. The price must be updated using Product::updatePrices + * Updates the weight of the child product. The price must be updated using Product::updatePrices. + * This method is called by the update() of a product. * - * @param Product $parent Parent product + * @param Product $parent Parent product * @param User $user Object user - * @return int >0 OK <0 KO + * @return int >0 if OK, <0 if KO */ public function updateProperties(Product $parent, User $user) { From afcc3cb3e678bde54a905ea689255b417c6462be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 13:24:30 +0100 Subject: [PATCH 135/173] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index a0c6ce5efc6..a542257cc1c 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -488,7 +488,7 @@ class ProductCombination $child->price_autogen = $parent->price_autogen; $child->weight = $parent->weight; $child->status = $parent->status; - + if ($this->variation_weight) { // If we must add a delta on weight $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight; } From 4c1004ea5ddc00efff9091c1055fa264c5a62584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 13:27:00 +0100 Subject: [PATCH 136/173] code syntax ticket directory --- htdocs/ticket/agenda.php | 52 +- htdocs/ticket/card.php | 153 +++-- htdocs/ticket/class/actions_ticket.class.php | 7 +- htdocs/ticket/class/api_tickets.class.php | 3 +- htdocs/ticket/class/ticket.class.php | 176 +++--- htdocs/ticket/class/utils_diff.class.php | 15 +- htdocs/ticket/contact.php | 16 +- htdocs/ticket/css/styles.css.php | 95 +-- htdocs/ticket/document.php | 36 +- htdocs/ticket/list.php | 581 +++++++++++-------- htdocs/ticket/messaging.php | 52 +- htdocs/ticket/stats/index.php | 60 +- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 65 ++- 13 files changed, 745 insertions(+), 566 deletions(-) diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index be68e1f68ee..d2611e562d2 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -46,16 +46,21 @@ $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (!$sortfield) $sortfield = "a.datep,a.id"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "a.datep,a.id"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -83,8 +88,7 @@ if (!$user->rights->ticket->read) { accessforbidden(); } // restrict access for externals users -if ($user->socid > 0 && ($object->fk_soc != $user->socid)) -{ +if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { accessforbidden(); } // or for unauthorized internals users @@ -100,17 +104,17 @@ if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object- $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Set view style $_SESSION['ticket-view-type'] = "list"; } // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -126,7 +130,9 @@ $userstat = new User($db); $formticket = new FormTicket($db); $title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +} $help_url = 'FR:DocumentationModuleTicket'; llxHeader('', $title, $help_url); @@ -167,8 +173,7 @@ if (!empty($object->origin_email)) { } // Thirdparty -if (!empty($conf->societe->enabled)) -{ +if (!empty($conf->societe->enabled)) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty'); /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; @@ -182,12 +187,10 @@ if (!empty($conf->societe->enabled)) } // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project'); - if ($user->rights->ticket->write) - { + if ($user->rights->ticket->write) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; $morehtmlref .= ' : '; @@ -225,11 +228,14 @@ print dol_get_fiche_end(); print '<br>'; -if (!empty($object->id)) -{ +if (!empty($object->id)) { $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } $morehtmlright = ''; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 6d14d29202f..e7363b09e47 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -60,7 +60,9 @@ $sortorder = GETPOST('sortorder', 'aZ09comma'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -80,12 +82,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} //Select mail models is same action as add_message if (GETPOST('modelselected', 'alpha')) { @@ -96,8 +101,7 @@ if (GETPOST('modelselected', 'alpha')) { //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id || $track_id || $ref) { $res = $object->fetch($id, $ref, $track_id); - if ($res >= 0) - { + if ($res >= 0) { $id = $object->id; $track_id = $object->track_id; } @@ -125,13 +129,14 @@ $now = dol_now(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $error = 0; if (empty($reshook)) { // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers{ - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers{ $actioncode = ''; $search_agenda_label = ''; } @@ -159,7 +164,9 @@ if (empty($reshook)) { $action = 'create'; } $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $db->begin(); @@ -289,7 +296,9 @@ if (empty($reshook)) { array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); } $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } if (!$error) { @@ -301,7 +310,9 @@ if (empty($reshook)) { $object->severity_code = GETPOST('severity_code', 'alpha'); $ret = $object->update($user); - if ($ret <= 0) $error++; + if ($ret <= 0) { + $error++; + } if ($error) { $db->rollback(); @@ -354,11 +365,12 @@ if (empty($reshook)) { if (!$error) { $ret = $object->assignUser($user, $usertoassign); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if (!$error) // Update list of contacts - { + if (!$error) { // Update list of contacts // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal'); @@ -373,7 +385,9 @@ if (empty($reshook)) { } } - if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); + if ($usertoassign > 0) { + $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); + } } if (!$error) { @@ -517,16 +531,16 @@ if (empty($reshook)) { } } } - } // Categorisation dans projet - elseif ($action == 'classin' && $user->rights->ticket->write) { + } elseif ($action == 'classin' && $user->rights->ticket->write) { + // Categorisation dans projet if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setProject(GETPOST('projectid', 'int')); $url = 'card.php?action=view&track_id='.$object->track_id; header("Location: ".$url); exit(); } - } // Categorisation dans contrat - elseif ($action == 'setcontract' && $user->rights->ticket->write) { + } elseif ($action == 'setcontract' && $user->rights->ticket->write) { + // Categorisation dans contrat if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setContract(GETPOST('contractid', 'int')); $url = 'card.php?action=view&track_id='.$object->track_id; @@ -557,8 +571,8 @@ if (empty($reshook)) { } $action = 'view'; - } // Reopen ticket - elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { + } elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { + // Reopen ticket if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); $old_status = $object->fk_statut; @@ -582,11 +596,15 @@ if (empty($reshook)) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } } if ($error) { @@ -634,7 +652,9 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Set $action to correct value for the case we used presend action to add a message - if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; + if (GETPOSTISSET('actionbis') && $action == 'presend') { + $action = 'presend_addmessage'; + } } @@ -645,15 +665,16 @@ if (empty($reshook)) { $userstat = new User($db); $form = new Form($db); $formticket = new FormTicket($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $help_url = 'FR:DocumentationModuleTicket'; $page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); -if ($action == 'create' || $action == 'presend') -{ +if ($action == 'create' || $action == 'presend') { $formticket = new FormTicket($db); print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket'); @@ -725,12 +746,9 @@ if ($action == 'create' || $action == 'presend') print '</div>'; print '</form>'; -} -elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' - || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') -{ - if ($res > 0) - { +} elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' + || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { + if ($res > 0) { // or for unauthorized internals users if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { accessforbidden('', 0, 1); @@ -774,8 +792,8 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); /* - * Projet synthese pour rappel - */ + * Projet synthese pour rappel + */ print '<table class="border centpercent">'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -878,19 +896,20 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>'; - $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref .= '<input type="hidden" name="action" value="classin">'; - $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref .= '</form>'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + $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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; + } else { + $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)) { @@ -1010,8 +1029,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = print '</tr>'; // Timing (Duration sum of linked fichinter) - if ($conf->fichinter->enabled) - { + if ($conf->fichinter->enabled) { $object->fetchObjectLinked(); $num = count($object->linkedObjects); $timing = 0; @@ -1120,8 +1138,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = } - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png'); print '<div class="div-table-responsive-no-min">'; @@ -1245,10 +1262,11 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Show link to add a message (if read and not closed) if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { print '<div class="inline-block divButAction"><a class="butAction reposition" href="card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init">'.$langs->trans('TicketAddMessage').'</a></div>'; @@ -1292,11 +1310,12 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = $action = 'presend'; } // Set $action to correct value for the case we used presend action to add a message - if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; + if (GETPOSTISSET('actionbis') && $action == 'presend') { + $action = 'presend_addmessage'; + } // add a message - if ($action == 'presend' || $action == 'presend_addmessage') - { + if ($action == 'presend' || $action == 'presend_addmessage') { $action = 'add_message'; // action to use to post the message $modelmail = 'ticket_send'; @@ -1375,10 +1394,18 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab) if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - if ($actioncode) $param .= '&actioncode='.urlencode($actioncode); - if ($search_agenda_label) $param .= '&search_agenda_label='.urlencode($search_agenda_label); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } + if ($actioncode) { + $param .= '&actioncode='.urlencode($actioncode); + } + if ($search_agenda_label) { + $param .= '&search_agenda_label='.urlencode($search_agenda_label); + } $morehtmlright = ''; diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 40fc22e1347..eb6193d58f1 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -262,14 +262,15 @@ class ActionsTicket // Load logs in cache $ret = $this->dao->loadCacheMsgsTicket(); - if ($ret < 0) dol_print_error($this->dao->db); + if ($ret < 0) { + dol_print_error($this->dao->db); + } $action = GETPOST('action', 'aZ09'); $this->viewTicketOriginalMessage($user, $action, $object); - if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) - { + if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { print '<table class="border" style="width:100%;">'; print '<tr class="liste_titre">'; diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 4a0bcbe7b92..d8e36933ea6 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -114,8 +114,7 @@ class Tickets extends DolibarrApi { try { return $this->getCommon(0, '', $ref); - } catch (Exception $e) - { + } catch (Exception $e) { throw $e; } } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 306f861097b..fa06b94825e 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -410,7 +410,9 @@ class Ticket extends CommonObject // Clean parameters $this->datec = dol_now(); - if (empty($this->track_id)) $this->track_id = generate_random_id(16); + if (empty($this->track_id)) { + $this->track_id = generate_random_id(16); + } // Check more parameters // If error, this->errors[] is filled @@ -581,8 +583,7 @@ class Ticket extends CommonObject dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) - { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -991,7 +992,9 @@ class Ticket extends CommonObject if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } // Removed extrafields @@ -1319,7 +1322,9 @@ class Ticket 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 = ''; @@ -1332,33 +1337,40 @@ class Ticket extends CommonObject $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowTicket"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; $linkend = '</a>'; $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)) : ''); @@ -1437,8 +1449,7 @@ class Ticket extends CommonObject $this->oldcopy = dol_clone($this); $sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; - if ($id_assign_user > 0) - { + if ($id_assign_user > 0) { $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut = ".Ticket::STATUS_ASSIGNED; } else { $sql .= " SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ; @@ -1447,8 +1458,7 @@ class Ticket extends CommonObject dol_syslog(get_class($this)."::assignUser sql=".$sql); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->fk_user_assign = $id_assign_user; // May be used by trigger if (!$notrigger) { @@ -1588,29 +1598,29 @@ class Ticket extends CommonObject // TODO Read the table llx_actioncomm /* - $sql = "SELECT rowid, fk_user_create, datec, message"; - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs"; - $sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'"; - $sql .= " ORDER BY datec DESC"; + $sql = "SELECT rowid, fk_user_create, datec, message"; + $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs"; + $sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'"; + $sql .= " ORDER BY datec DESC"; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($resql); - $this->cache_logs_ticket[$i]['id'] = $obj->rowid; - $this->cache_logs_ticket[$i]['fk_user_create'] = $obj->fk_user_create; - $this->cache_logs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); - $this->cache_logs_ticket[$i]['message'] = $obj->message; - $i++; - } - return $num; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR); - return -1; - }*/ + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + $this->cache_logs_ticket[$i]['id'] = $obj->rowid; + $this->cache_logs_ticket[$i]['fk_user_create'] = $obj->fk_user_create; + $this->cache_logs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); + $this->cache_logs_ticket[$i]['message'] = $obj->message; + $i++; + } + return $num; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR); + return -1; + }*/ return 0; } @@ -1669,14 +1679,12 @@ class Ticket extends CommonObject $actioncomm->attachedfiles = $attachedfiles; } - if (!empty($mimefilename_list) && is_array($mimefilename_list)) - { + if (!empty($mimefilename_list) && is_array($mimefilename_list)) { $actioncomm->note_private = dol_concatdesc($actioncomm->note_private, "\n".$langs->transnoentities("AttachedFiles").': '.join(';', $mimefilename_list)); } $actionid = $actioncomm->create($user); - if ($actionid <= 0) - { + if ($actionid <= 0) { $error++; $this->error = $actioncomm->error; $this->errors = $actioncomm->errors; @@ -1760,8 +1768,7 @@ class Ticket extends CommonObject if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) { dol_syslog("We have closed the ticket, so we close all linked interventions"); $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); - if ($this->linkedObjectsIds) - { + if ($this->linkedObjectsIds) { foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { $fichinter = new Fichinter($this->db); $fichinter->fetch($fichinter_id); @@ -2148,8 +2155,7 @@ class Ticket extends CommonObject $sendto = $obj->firstname." ".$obj->lastname." <".$obj->email.">"; $actiondefid = $obj->adid; - if (dol_strlen($sendto)) - { + if (dol_strlen($sendto)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $application = ($conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 'Dolibarr ERP/CRM'); @@ -2465,8 +2471,7 @@ class Ticket extends CommonObject foreach ($filename as $i => $val) { $destfile = $destdir.'/'.$filename[$i]; // If destination file already exists, we add a suffix to avoid to overwrite - if (is_file($destfile)) - { + if (is_file($destfile)) { $pathinfo = pathinfo($filename[$i]); $now = dol_now(); $destfile = $destdir.'/'.$pathinfo['filename'].' - '.dol_print_date($now, 'dayhourlog').'.'.$pathinfo['extension']; @@ -2626,11 +2631,10 @@ class Ticket extends CommonObject $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); } } - } - /* - * Private area - */ - else { + } else { + /* + * Private area + */ /* * Send emails to internal users (linked contacts) */ @@ -2670,7 +2674,9 @@ class Ticket extends CommonObject } if ($info_sendto['email'] != '') { - if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; + if (!empty($info_sendto['email'])) { + $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; + } //Contact type $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; @@ -2686,7 +2692,9 @@ class Ticket extends CommonObject // Add global email address recipient if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { - if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) { + $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + } } // altairis: dont try to send email if no recipient @@ -2744,7 +2752,9 @@ class Ticket extends CommonObject } if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { - if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; + if (!empty($info_sendto['email'])) { + $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; + } $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : ''); @@ -2769,12 +2779,16 @@ class Ticket extends CommonObject if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) { $object->socid = $object->fk_soc; $object->fetch_thirdparty(); - if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; + if (!empty($object->thirdparty->email)) { + $sendto[] = $object->thirdparty->email; + } } // altairis: Add global email address reciepient if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { - if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) { + $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + } } // altairis: dont try to send email when no recipient @@ -2787,8 +2801,7 @@ class Ticket extends CommonObject } // Set status to "answered" if not set yet, but only if internal user - if ($object->fk_statut < 3 && !$user->socid) - { + if ($object->fk_statut < 3 && !$user->socid) { $object->setStatut(3); } @@ -2842,8 +2855,7 @@ class Ticket extends CommonObject $from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; if (is_array($array_receiver) && count($array_receiver) > 0) { - foreach ($array_receiver as $key => $receiver) - { + foreach ($array_receiver as $key => $receiver) { $deliveryreceipt = 0; $filepath = $filename_list; $filename = $mimefilename_list; @@ -2903,19 +2915,21 @@ class Ticket extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + if (!$user->rights->societe->client->voir && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; } $sql .= $clause." p.entity IN (".getEntity('ticket').")"; - if ($mode == 'opened') $sql .= " AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.", ".Ticket::STATUS_CANCELED.")"; - if ($user->socid) $sql .= " AND p.fk_soc = ".$user->socid; + if ($mode == 'opened') { + $sql .= " AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.", ".Ticket::STATUS_CANCELED.")"; + } + if ($user->socid) { + $sql .= " AND p.fk_soc = ".$user->socid; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $label = $labelShort = ''; $status = ''; if ($mode == 'opened') { @@ -2934,14 +2948,11 @@ class Ticket extends CommonObject $response->img = img_object('', "ticket"); // 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)) { $response->nbtodo++; - if ($mode == 'opened') - { + if ($mode == 'opened') { $datelimit = $this->db->jdate($obj->datefin); - if ($datelimit < ($now - $delay_warning)) - { + if ($datelimit < ($now - $delay_warning)) { //$response->nbtodolate++; } } @@ -2970,8 +2981,7 @@ class Ticket extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { + 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; $clause = "AND"; @@ -2979,11 +2989,9 @@ class Ticket extends CommonObject $sql .= " ".$clause." p.entity IN (".getEntity('ticket').")"; $resql = $this->db->query($sql); - if ($resql) - { + 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->nb["ticket"] = $obj->nb; } $this->db->free($resql); diff --git a/htdocs/ticket/class/utils_diff.class.php b/htdocs/ticket/class/utils_diff.class.php index 6edccdfa0ff..e18418d78a6 100644 --- a/htdocs/ticket/class/utils_diff.class.php +++ b/htdocs/ticket/class/utils_diff.class.php @@ -78,8 +78,7 @@ class Diff } $end2 = ($compareCharacters ? strlen($sequence1) : count($sequence1)); - for ($index = $end1 + 1; $index < $end2; $index++) - { + for ($index = $end1 + 1; $index < $end2; $index++) { $diff[] = array($sequence1[$index], self::UNMODIFIED); } @@ -313,12 +312,12 @@ class Diff self::DELETED ); $rightCell = self::getCellContent( - $diff, - $indentation, - $separator, - $index, - self::INSERTED - ); + $diff, + $indentation, + $separator, + $index, + self::INSERTED + ); break; // display the inserted content on the right diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 13419cf795e..7e04dd12104 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -124,8 +124,7 @@ $contactstatic = new Contact($db); $userstatic = new User($db); if ($id > 0 || !empty($track_id) || !empty($ref)) { - if ($object->fetch($id, $ref, $track_id) > 0) - { + if ($object->fetch($id, $ref, $track_id) > 0) { if ($socid > 0) { $object->fetch_thirdparty(); $head = societe_prepare_head($object->thirdparty); @@ -161,12 +160,11 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { } // Thirdparty - if (!empty($conf->societe->enabled)) - { + if (!empty($conf->societe->enabled)) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty'); /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { - $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; - }*/ + $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; + }*/ $morehtmlref .= ' : '; if ($action == 'editcustomer') { $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); @@ -176,12 +174,10 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->ticket->write) - { + if ($user->rights->ticket->write) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; $morehtmlref .= ' : '; diff --git a/htdocs/ticket/css/styles.css.php b/htdocs/ticket/css/styles.css.php index 7391dd19012..8898dbce104 100644 --- a/htdocs/ticket/css/styles.css.php +++ b/htdocs/ticket/css/styles.css.php @@ -22,14 +22,26 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); // File must be accessed by logon page so without login +} //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} session_cache_limiter('public'); @@ -39,13 +51,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Define css type top_httphead('text/css'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=3600, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} ?> html { - min-height: 100%; height: 100%; + min-height: 100%; height: 100%; } html { @@ -58,49 +73,49 @@ if (!empty($conf->global->TICKET_SHOW_MODULE_LOGO)) { div.ticketform { - font-family: arial; - position: static; - padding: 2em 1em; - overflow-x: auto; - border: 2px solid rgb(153, 153, 153); - background-color: rgb(255, 255, 255); - box-shadow: 2px 2px 2px rgb(245, 245, 245); - border-radius: 10px 10px 10px 10px; - margin: 1.5em; - background : #ffffff; + font-family: arial; + position: static; + padding: 2em 1em; + overflow-x: auto; + border: 2px solid rgb(153, 153, 153); + background-color: rgb(255, 255, 255); + box-shadow: 2px 2px 2px rgb(245, 245, 245); + border-radius: 10px 10px 10px 10px; + margin: 1.5em; + background : #ffffff; text-align: center; } div.ticketform .index_create, .index_display { display: inline-block; - width: 200px; - height: 45px; - text-align: center; - vertical-align: middle; - margin: 20px; - text-transform: uppercase; + width: 200px; + height: 45px; + text-align: center; + vertical-align: middle; + margin: 20px; + text-transform: uppercase; } #form_create_ticket, #form_view_ticket { - margin-left: 10px; - margin-right: 10px; - padding-left:1em; - padding-right:1em; - padding-top:1.5em; - padding-bottom:12px; + margin-left: 10px; + margin-right: 10px; + padding-left:1em; + padding-right:1em; + padding-top:1.5em; + padding-bottom:12px; - border: 1px solid #C0C0C0; - background-color: #E0E0E0; + border: 1px solid #C0C0C0; + background-color: #E0E0E0; - -moz-box-shadow: 4px 4px 4px #DDD; - -webkit-box-shadow: 4px 4px 4px #DDD; - box-shadow: 4px 4px 4px #DDD; + -moz-box-shadow: 4px 4px 4px #DDD; + -webkit-box-shadow: 4px 4px 4px #DDD; + box-shadow: 4px 4px 4px #DDD; - border-radius: 8px; - border:solid 1px rgba(168,168,168,.4); - border-top:solid 1px f8f8f8; - background-color: #f8f8f8; + border-radius: 8px; + border:solid 1px rgba(168,168,168,.4); + border-top:solid 1px f8f8f8; + background-color: #f8f8f8; } #form_create_ticket input.text, #form_create_ticket textarea { width:450px;} diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index c876e9d33d8..b8e0e79eede 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -52,12 +52,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $object = new Ticket($db); $result = $object->fetch($id, $ref, $track_id); @@ -86,8 +92,7 @@ $form = new Form($db); $help_url = ''; llxHeader('', $langs->trans("TicketDocumentsLinked").' - '.$langs->trans("Files"), $help_url); -if ($object->id) -{ +if ($object->id) { /* * Show tabs */ @@ -126,12 +131,11 @@ if ($object->id) } // Thirdparty - if (!empty($conf->societe->enabled)) - { + if (!empty($conf->societe->enabled)) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty'); /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { - $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; - }*/ + $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; + }*/ $morehtmlref .= ' : '; if ($action == 'editcustomer') { $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); @@ -141,12 +145,10 @@ if ($object->id) } // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->ticket->write) - { + if ($user->rights->ticket->write) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; $morehtmlref .= ' : '; @@ -190,11 +192,11 @@ if ($object->id) //$object->ref = $object->track_id; // For compatibility we use track ID for directory $modulepart = 'ticket'; - $permission = $user->rights->ticket->write; - $permtoedit = $user->rights->ticket->write; - $param = '&id='.$object->id; + $permission = $user->rights->ticket->write; + $permtoedit = $user->rights->ticket->write; + $param = '&id='.$object->id; - 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 { accessforbidden('', 0, 1); } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1a276c75f5f..f4482399495 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -72,7 +72,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -81,32 +83,44 @@ $pagenext = $page + 1; $object = new Ticket($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id; -if ($socid > 0) $hookmanager->initHooks(array('thirdpartyticket')); -elseif ($projectid > 0) $hookmanager->initHooks(array('projectticket')); -else $hookmanager->initHooks(array('ticketlist')); +if ($socid > 0) { + $hookmanager->initHooks(array('thirdpartyticket')); +} elseif ($projectid > 0) { + $hookmanager->initHooks(array('projectticket')); +} else { + $hookmanager->initHooks(array('ticketlist')); +} // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.datec"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "t.datec"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} -if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility +if (GETPOST('search_fk_status', 'alpha') == 'non_closed') { + $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility +} // Initialize array of search criterias $search_all = trim(GETPOSTISSET("search_all") ?GETPOSTISSET("search_all", 'alpha') : GETPOST('sall')); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } $fieldstosearchall['s.name_alias'] = "AliasNameShort"; $fieldstosearchall['s.zip'] = "Zip"; @@ -114,10 +128,11 @@ $fieldstosearchall['s.town'] = "Town"; // Definition of fields for list $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -136,8 +151,7 @@ if (!$user->rights->ticket->read) { // Store current page url $url_page_current = dol_buildpath('/ticket/list.php', 1); -if ($project_ref) -{ +if ($project_ref) { $tmpproject = new Project($db); $tmpproject->fetch(0, $project_ref); $projectid = $tmpproject->id; @@ -155,25 +169,32 @@ $error = 0; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); -if ($socid > 0) $parameters['socid'] = $socid; -if ($projectid > 0) $parameters['projectid'] = $projectid; +if ($socid > 0) { + $parameters['socid'] = $socid; +} +if ($projectid > 0) { + $parameters['projectid'] = $projectid; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; @@ -186,8 +207,7 @@ if (empty($reshook)) $search_dateclose_end = ''; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -198,26 +218,23 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (!$error && $massaction == 'close' && $permissiontoadd) - { + if (!$error && $massaction == 'close' && $permissiontoadd) { $objecttmp = new $objectclass($db); - if (!$error) - { + if (!$error) { $db->begin(); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $result = $objecttmp->close($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -225,10 +242,12 @@ if (empty($reshook)) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -238,27 +257,24 @@ if (empty($reshook)) } // Reopen records - if (!$error && $massaction == 'reopen' && $permissiontoadd) - { + if (!$error && $massaction == 'reopen' && $permissiontoadd) { $objecttmp = new $objectclass($db); - if (!$error) - { + if (!$error) { $db->begin(); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) { $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED); - if ($result < 0) - { + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { $langs->load("errors"); setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors'); @@ -272,10 +288,12 @@ if (empty($reshook)) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -307,34 +325,37 @@ $title = $langs->trans('TicketList'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql = preg_replace('/, $/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; +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 (t.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -if ($socid > 0) -{ +if ($socid > 0) { $sql .= " AND t.fk_soc = ".$socid; } -foreach ($search as $key => $val) -{ - if ($key == 'fk_statut' && !empty($search['fk_statut'])) - { +foreach ($search as $key => $val) { + if ($key == 'fk_statut' && !empty($search['fk_statut'])) { $newarrayofstatus = array(); foreach ($search['fk_statut'] as $key2 => $val2) { - if (in_array($val2, array('openall', 'closeall'))) continue; + if (in_array($val2, array('openall', 'closeall'))) { + continue; + } $newarrayofstatus[] = $val2; } if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) { @@ -349,31 +370,54 @@ foreach ($search as $key => $val) $newarrayofstatus[] = Ticket::STATUS_CLOSED; $newarrayofstatus[] = Ticket::STATUS_CANCELED; } - if (count($newarrayofstatus)) $sql .= natural_search($key, join(',', $newarrayofstatus), 2); + if (count($newarrayofstatus)) { + $sql .= natural_search($key, join(',', $newarrayofstatus), 2); + } continue; } - if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') - { - if ($search[$key] > 0) $sql .= natural_search($key, $search[$key], 2); + if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') { + if ($search[$key] > 0) { + $sql .= natural_search($key, $search[$key], 2); + } continue; } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], $mode_search); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], $mode_search); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); //if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); -if ($search_date_start) $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'"; -if ($search_date_end) $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'"; -if ($search_dateread_start) $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'"; -if ($search_dateread_end) $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'"; -if ($search_dateclose_start) $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'"; -if ($search_dateclose_end) $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'"; +if ($search_date_start) { + $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'"; +} +if ($search_dateread_start) { + $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'"; +} +if ($search_dateread_end) { + $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'"; +} +if ($search_dateclose_start) { + $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'"; +} +if ($search_dateclose_end) { + $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'"; +} if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql .= " AND (t.fk_user_assign = ".$user->id; - if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) $sql .= " OR t.fk_user_create = ".$user->id; + if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) { + $sql .= " OR t.fk_user_create = ".$user->id; + } $sql .= ")"; } @@ -388,26 +432,22 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) -{ +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -416,8 +456,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id); @@ -449,30 +488,30 @@ if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent tableforfield">'; - // Customer code - if ($socstat->client && !empty($socstat->code_client)) { - print '<tr><td class="titlefield">'; - print $langs->trans('CustomerCode').'</td><td>'; - print $socstat->code_client; - $tmpcheck = $socstat->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; - } - print '</td>'; - print '</tr>'; - } - // Supplier code - if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { - print '<tr><td class="titlefield">'; - print $langs->trans('SupplierCode').'</td><td>'; - print $socstat->code_fournisseur; - $tmpcheck = $socstat->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; - } - print '</td>'; - print '</tr>'; - } + // Customer code + if ($socstat->client && !empty($socstat->code_client)) { + print '<tr><td class="titlefield">'; + print $langs->trans('CustomerCode').'</td><td>'; + print $socstat->code_client; + $tmpcheck = $socstat->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; + } + print '</td>'; + print '</tr>'; + } + // Supplier code + if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { + print '<tr><td class="titlefield">'; + print $langs->trans('SupplierCode').'</td><td>'; + print $socstat->code_fournisseur; + $tmpcheck = $socstat->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; + } + print '</td>'; + print '</tr>'; + } print '</table>'; print '</div>'; @@ -506,15 +545,13 @@ if ($projectid > 0 || $project_ref) { // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -549,39 +586,75 @@ if ($projectid > 0 || $project_ref) { $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) -{ - 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 (!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 ($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'; -if ($socid) $param .= '&socid='.urlencode($socid); -if ($projectid) $param .= '&projectid='.urlencode($projectid); +if ($socid) { + $param .= '&socid='.urlencode($socid); +} +if ($projectid) { + $param .= '&projectid='.urlencode($projectid); +} -if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); -if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); -if ($search_dateread_start) $param .= '&search_dateread_start='.urlencode($search_dateread_start); -if ($search_dateread_end) $param .= '&search_dateread_end='.urlencode($search_dateread_end); -if ($search_dateclose_start) $param .= '&search_dateclose_start='.urlencode($search_dateclose_start); -if ($search_dateclose_end) $param .= '&search_dateclose_end='.urlencode($search_dateclose_end); +if ($search_date_start) { + $param .= '&search_date_start='.urlencode($search_date_start); +} +if ($search_date_end) { + $param .= '&search_date_end='.urlencode($search_date_end); +} +if ($search_dateread_start) { + $param .= '&search_dateread_start='.urlencode($search_dateread_start); +} +if ($search_dateread_end) { + $param .= '&search_dateread_end='.urlencode($search_dateread_end); +} +if ($search_dateclose_start) { + $param .= '&search_dateclose_start='.urlencode($search_dateclose_start); +} +if ($search_dateclose_end) { + $param .= '&search_dateclose_end='.urlencode($search_dateclose_end); +} // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->ticket->write) $arrayofmassactions['close'] = $langs->trans("Close"); -if ($user->rights->ticket->write) $arrayofmassactions['reopen'] = $langs->trans("ReOpen"); -if ($user->rights->ticket->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->ticket->write) { + $arrayofmassactions['close'] = $langs->trans("Close"); +} +if ($user->rights->ticket->write) { + $arrayofmassactions['reopen'] = $langs->trans("ReOpen"); +} +if ($user->rights->ticket->delete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -589,15 +662,23 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="mode" value="'.$mode.'" >'; -if ($socid) print '<input type="hidden" name="socid" value="'.$socid.'" >'; -if ($projectid) print '<input type="hidden" name="projectid" value="'.$projectid.'" >'; +if ($socid) { + print '<input type="hidden" name="socid" value="'.$socid.'" >'; +} +if ($projectid) { + print '<input type="hidden" name="projectid" value="'.$projectid.'" >'; +} $url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : ''); -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->write); $picto = 'ticket'; -if ($socid > 0) $picto = ''; +if ($socid > 0) { + $picto = ''; +} print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -611,9 +692,10 @@ $objecttmp = new Ticket($db); $trackid = 'tic'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -624,11 +706,13 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -645,13 +729,17 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if ($key == 'fk_statut') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } if (!empty($arrayfields['t.'.$key]['checked'])) { if ($key == 'type_code') { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; @@ -672,23 +760,26 @@ foreach ($object->fields as $key => $val) } elseif ($key == 'fk_statut') { $arrayofstatus = array(); $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; - foreach ($object->statuts_short as $key2 => $val2) - { - if ($key2 == Ticket::STATUS_CLOSED) $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; + foreach ($object->statuts_short as $key2 => $val2) { + if ($key2 == Ticket::STATUS_CLOSED) { + $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; + } $arrayofstatus[$key2] = $val2; } print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); $selectedarray = null; - if ($search[$key]) $selectedarray = array_values($search[$key]); + if ($search[$key]) { + $selectedarray = array_values($search[$key]); + } print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); print '</td>'; } elseif ($key == "fk_soc") { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; - } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close'){ + } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') { print '<td class="liste_titre center">'; print '<div class="nowrap">'; - switch ($key){ + switch ($key) { case 'datec': print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); break; @@ -700,7 +791,7 @@ foreach ($object->fields as $key => $val) } print '</div>'; print '<div class="nowrap">'; - switch ($key){ + switch ($key) { case 'datec': print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); break; @@ -712,13 +803,15 @@ foreach ($object->fields as $key => $val) } print '</div>'; print '</td>'; - } - else { + } else { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } print '</td>'; } } @@ -741,15 +834,18 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'fk_statut' || $key == 'severity_code') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -765,11 +861,11 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -779,70 +875,83 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co $i = 0; $totalarray = array(); $cacheofoutputfield = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->id = $obj->rowid; - foreach ($object->fields as $key => $val) - { - if (property_exists($obj, $key)) $object->$key = $obj->$key; + foreach ($object->fields as $key => $val) { + if (property_exists($obj, $key)) { + $object->$key = $obj->$key; + } } $langs->load("ticket"); // Show here line of result print '<tr class="oddeven">'; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($key, array('ref', 'fk_project'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; - if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + if (in_array($key, array('ref', 'fk_project'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; + } + if ($key == 'fk_statut' || $key == 'severity_code') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; - if ($cssforfield || $val['css']) print ' class="'; + if ($cssforfield || $val['css']) { + print ' class="'; + } print $cssforfield; - if ($cssforfield && $val['css']) print ' '; + if ($cssforfield && $val['css']) { + print ' '; + } print $val['css']; - if ($cssforfield || $val['css']) print '"'; + if ($cssforfield || $val['css']) { + print '"'; + } print '>'; - if ($key == 'fk_statut') print $object->getLibStatut(5); - elseif ($key == 'subject') { + if ($key == 'fk_statut') { + print $object->getLibStatut(5); + } elseif ($key == 'subject') { $s = $obj->subject; print '<span title="'.$s.'">'; print $s; print '</span>'; - } - elseif ($key == 'type_code') { + } elseif ($key == 'type_code') { $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print '<span title="'.$s.'">'; print $s; print '</span>'; - } - elseif ($key == 'category_code') { + } elseif ($key == 'category_code') { $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); print '<span title="'.$s.'">'; print $s; print '</span>'; - } - elseif ($key == 'severity_code') { + } elseif ($key == 'severity_code') { $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); print '<span title="'.$s.'">'; print $s; print '</span>'; - } - elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'fk_user_create') { + } elseif ($key == 'tms') { + print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); + } elseif ($key == 'fk_user_create') { if ($object->fk_user_create > 0) { $user_create->fetch($object->fk_user_create); print $user_create->getNomUrl(-1); } - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); - else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ... + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + } else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ... $tmp = explode(':', $val['type']); if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) { // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making. @@ -860,10 +969,13 @@ while ($i < min($num, $limit)) } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -876,14 +988,17 @@ while ($i < min($num, $limit)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'; @@ -895,10 +1010,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -916,10 +1034,11 @@ print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index 49f15412965..527b28c8fac 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -46,16 +46,21 @@ $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (!$sortfield) $sortfield = "a.datep,a.id"; -if (!$sortorder) $sortorder = "desc"; +if (!$sortfield) { + $sortfield = "a.datep,a.id"; +} +if (!$sortorder) { + $sortorder = "desc"; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -82,8 +87,7 @@ if (!$user->rights->ticket->read) { accessforbidden(); } // restrict access for externals users -if ($user->socid > 0 && ($object->fk_soc != $user->socid)) -{ +if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { accessforbidden(); } // or for unauthorized internals users @@ -99,17 +103,17 @@ if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object- $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Set view style $_SESSION['ticket-view-type'] = "messaging"; } // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -125,7 +129,9 @@ $userstat = new User($db); $formticket = new FormTicket($db); $title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +} $help_url = 'FR:DocumentationModuleTicket'; llxHeader('', $title, $help_url); @@ -166,8 +172,7 @@ if (!empty($object->origin_email)) { } // Thirdparty -if (!empty($conf->societe->enabled)) -{ +if (!empty($conf->societe->enabled)) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty'); /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; @@ -181,12 +186,10 @@ if (!empty($conf->societe->enabled)) } // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project'); - if ($user->rights->ticket->write) - { + if ($user->rights->ticket->write) { if ($action != 'classify') { //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; $morehtmlref .= ' : '; @@ -224,11 +227,14 @@ print dol_get_fiche_end(); print '<br>'; -if (!empty($object->id)) -{ +if (!empty($object->id)) { $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } $morehtmlright = ''; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 045943bbfda..9f6e1cc5471 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -30,15 +30,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -if (!$user->rights->ticket->read) accessforbidden(); +if (!$user->rights->ticket->read) { + accessforbidden(); +} $object_status = GETPOST('object_status', 'intcomma'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -70,7 +71,9 @@ print load_fiche_titre($title, '', 'ticket'); dol_mkdir($dir); $stats = new TicketStats($db, $socid, ($userid > 0 ? $userid : 0)); -if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($object_status != '' && $object_status >= -1) { + $stats->where .= ' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +} // Build graphic number of object @@ -80,8 +83,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png'; } else { @@ -91,12 +93,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -119,8 +119,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png'; } else { @@ -130,12 +129,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px2->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -156,8 +153,7 @@ if (!$mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->socid) -{ +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png'; } else { @@ -167,12 +163,10 @@ if (!$user->rights->societe->client->voir || $user->socid) $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px3->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -200,7 +194,9 @@ foreach ($data as $val) { $arrayyears[$val['year']] = $val['year']; } } -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; +if (!count($arrayyears)) { + $arrayyears[$nowyear] = $nowyear; +} $h = 0; $head = array(); @@ -239,8 +235,12 @@ print $form->selectarray('object_status', $liststatus, GETPOST('object_status', print '</td></tr>'; // Year print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; -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 '</td></tr>'; @@ -263,11 +263,9 @@ print '<td class="right">%</td>'; print '</tr>'; $oldyear = 0; -foreach ($data as $val) -{ +foreach ($data as $val) { $year = $val['year']; - while (!empty($year) && $oldyear > $year + 1) - { // If we have empty year + while (!empty($year) && $oldyear > $year + 1) { // If we have empty year $oldyear--; print '<tr class="oddeven" height="24">'; @@ -303,7 +301,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; // Show graphs print '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { print $px1->show(); print "<br>\n"; //print $px2->show(); diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 572ffc0672f..17da4cd2db5 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -16,8 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ // 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; } @@ -38,52 +37,54 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'datec', 'desc', 0, 0, 1 $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> - <tr class="<?php echo $trclass; ?>" > - <td class="linkedcol-element" ><?php echo $langs->trans("Ticket"); ?> - <?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?> - </td> - <td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td> - <td class="linkedcol-ref center"><?php echo $objectlink->ref_client; ?></td> - <td class="linkedcol-date center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td> - <?php + <tr class="<?php echo $trclass; ?>" > + <td class="linkedcol-element" ><?php echo $langs->trans("Ticket"); ?> + <?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; + } ?> + </td> + <td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td> + <td class="linkedcol-ref center"><?php echo $objectlink->ref_client; ?></td> + <td class="linkedcol-date center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td> + <?php //$objectlink->socid = $objectlink->fk_soc; //$objectlink->fetch_thirdparty(); ?> - <td class="linkedcol-amount right"><?php //echo $objectlink->thirdparty->getNomUrl(1); ?></td> - <td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td> - <td class="linkedcol-action right"> - <?php + <td class="linkedcol-amount right"><?php //echo $objectlink->thirdparty->getNomUrl(1); ?></td> + <td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td> + <td class="linkedcol-action right"> + <?php // For now, shipments must stay linked to order, so link is not deletable if ($object->element != 'shipping') { ?> - <a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a> - <?php + <a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a> + <?php } ?> - </td> + </td> </tr> <?php } -if (count($linkedObjectBlock) > 1) -{ +if (count($linkedObjectBlock) > 1) { ?> - <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> - <td><?php echo $langs->trans("Total"); ?></td> - <td></td> - <td class="center"></td> - <td class="center"></td> - <td class="right"><?php echo price($total); ?></td> - <td class="right"></td> - <td class="right"></td> - </tr> - <?php + <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> + <td><?php echo $langs->trans("Total"); ?></td> + <td></td> + <td class="center"></td> + <td class="center"></td> + <td class="right"><?php echo price($total); ?></td> + <td class="right"></td> + <td class="right"></td> + </tr> + <?php } print "<!-- END PHP TEMPLATE -->\n"; From 920dabaab7808782959a1933084e3e0861b6e7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 13:31:09 +0100 Subject: [PATCH 137/173] code syntax theme directory --- htdocs/theme/eldy/badges.inc.php | 182 +- htdocs/theme/eldy/btn.inc.php | 276 +- htdocs/theme/eldy/dropdown.inc.php | 474 +-- htdocs/theme/eldy/global.inc.php | 2691 +++++++++--------- htdocs/theme/eldy/info-box.inc.php | 164 +- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 86 +- htdocs/theme/eldy/manifest.json.php | 73 +- htdocs/theme/eldy/progress.inc.php | 144 +- htdocs/theme/eldy/style.css.php | 160 +- htdocs/theme/eldy/theme_vars.inc.php | 9 +- htdocs/theme/eldy/timeline.inc.php | 206 +- htdocs/theme/md/badges.inc.php | 168 +- htdocs/theme/md/btn.inc.php | 266 +- htdocs/theme/md/dropdown.inc.php | 488 ++-- htdocs/theme/md/info-box.inc.php | 140 +- htdocs/theme/md/main_menu_fa_icons.inc.php | 36 +- htdocs/theme/md/manifest.json.php | 73 +- htdocs/theme/md/progress.inc.php | 4 +- htdocs/theme/md/style.css.php | 2488 ++++++++-------- htdocs/theme/md/theme_vars.inc.php | 9 +- 20 files changed, 4213 insertions(+), 3924 deletions(-) diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 00c2a91a29c..f3f311eccca 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -1,140 +1,142 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* Badge style is based on boostrap framework */ .badge { - display: inline-block; - padding: .1em .35em; - font-size: 80%; - font-weight: 700 !important; - line-height: 1; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25rem; - transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; - border-width: 2px; - border-style: solid; - border-color: rgba(255,255,255,0); - box-sizing: border-box; + display: inline-block; + padding: .1em .35em; + font-size: 80%; + font-weight: 700 !important; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: .25rem; + transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; + border-width: 2px; + border-style: solid; + border-color: rgba(255,255,255,0); + box-sizing: border-box; } .badge-status { - font-size: 0.95em; - padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ + font-size: 0.95em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ } .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status { - font-size: 1.1em; - padding: .4em .4em; + font-size: 1.1em; + padding: .4em .4em; } /* Force values for small screen 767 */ @media only screen and (max-width: 767px) { .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status { - font-size: 0.95em; - padding: .3em .2em; + font-size: 0.95em; + padding: .3em .2em; } } .badge-pill, .tabs .badge { - padding-right: .5em; - padding-left: .5em; - border-radius: 0.25rem; + padding-right: .5em; + padding-left: .5em; + border-radius: 0.25rem; } .badge-dot { - padding: 0; - border-radius: 50%; - padding: 0.45em; - vertical-align: text-top; + padding: 0; + border-radius: 50%; + padding: 0.45em; + vertical-align: text-top; } a.badge:focus, a.badge:hover { - text-decoration: none; + text-decoration: none; } .liste_titre .badge:not(.nochangebackground) { - background-color: <?php print $badgeSecondary; ?>; - color: #fff; + background-color: <?php print $badgeSecondary; ?>; + color: #fff; } span.badgeneutral { - padding: 2px 7px 2px 7px; - background-color: #e4e4e4; - color: #666; - border-radius: 10px; + padding: 2px 7px 2px 7px; + background-color: #e4e4e4; + color: #666; + border-radius: 10px; } /* PRIMARY */ .badge-primary{ - color: #fff !important; - background-color: <?php print $badgePrimary; ?>; + color: #fff !important; + background-color: <?php print $badgePrimary; ?>; } a.badge-primary.focus, a.badge-primary:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>; } a.badge-primary:focus, a.badge-primary:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgePrimary, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgePrimary, 10); ?>; } /* SECONDARY */ .badge-secondary, .tabs .badge { - color: #fff !important; - background-color: <?php print $badgeSecondary; ?>; + color: #fff !important; + background-color: <?php print $badgeSecondary; ?>; } a.badge-secondary.focus, a.badge-secondary:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>; } a.badge-secondary:focus, a.badge-secondary:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeSecondary, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeSecondary, 10); ?>; } /* SUCCESS */ .badge-success { - color: #fff !important; - background-color: <?php print $badgeSuccess; ?>; + color: #fff !important; + background-color: <?php print $badgeSuccess; ?>; } a.badge-success.focus, a.badge-success:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>; } a.badge-success:focus, a.badge-success:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeSuccess, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeSuccess, 10); ?>; } /* DANGER */ .badge-danger { - color: #fff !important; - background-color: <?php print $badgeDanger; ?>; + color: #fff !important; + background-color: <?php print $badgeDanger; ?>; } a.badge-danger.focus, a.badge-danger:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>; } a.badge-danger:focus, a.badge-danger:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeDanger, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeDanger, 10); ?>; } /* WARNING */ .badge-warning { - color: #fff !important; - background-color: <?php print $badgeWarning; ?>; + color: #fff !important; + background-color: <?php print $badgeWarning; ?>; } a.badge-warning.focus, a.badge-warning:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>; } a.badge-warning:focus, a.badge-warning:hover { - color: #212529 !important; - background-color: <?php print colorDarker($badgeWarning, 10); ?>; + color: #212529 !important; + background-color: <?php print colorDarker($badgeWarning, 10); ?>; } /* WARNING colorblind */ @@ -150,53 +152,53 @@ body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover { /* INFO */ .badge-info { - color: #fff !important; - background-color: <?php print $badgeInfo; ?>; + color: #fff !important; + background-color: <?php print $badgeInfo; ?>; } a.badge-info.focus, a.badge-info:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>; } a.badge-info:focus, a.badge-info:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeInfo, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeInfo, 10); ?>; } /* LIGHT */ .badge-light { - color: #212529 !important; - background-color: <?php print $badgeLight; ?>; + color: #212529 !important; + background-color: <?php print $badgeLight; ?>; } a.badge-light.focus, a.badge-light:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>; } a.badge-light:focus, a.badge-light:hover { - color: #212529 !important; - background-color: <?php print colorDarker($badgeLight, 10); ?>; + color: #212529 !important; + background-color: <?php print colorDarker($badgeLight, 10); ?>; } /* DARK */ .badge-dark { - color: #fff !important; - background-color: <?php print $badgeDark; ?>; + color: #fff !important; + background-color: <?php print $badgeDark; ?>; } a.badge-dark.focus, a.badge-dark:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>; } a.badge-dark:focus, a.badge-dark:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeDark, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeDark, 10); ?>; } @media only screen and (max-width: 570px) { span.badge.badge-status { - overflow: hidden; - max-width: 130px; - text-overflow: ellipsis; + overflow: hidden; + max-width: 130px; + text-overflow: ellipsis; } } @@ -246,8 +248,12 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL $thisBadgeBackgroundColor = "#fff"; } - if (in_array((string) $statusName, array('0', '5', '9'))) $thisBadgeTextColor = '#999999'; - if (in_array((string) $statusName, array('6'))) $thisBadgeTextColor = '#777777'; + if (in_array((string) $statusName, array('0', '5', '9'))) { + $thisBadgeTextColor = '#999999'; + } + if (in_array((string) $statusName, array('6'))) { + $thisBadgeTextColor = '#777777'; + } print $cssPrefix.".badge-status".$statusName." {\n"; print " color: ".$thisBadgeTextColor." !important;\n"; diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index d6a2251b390..8cb51a152d4 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -1,19 +1,21 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ :root { - --btncolortext:rgb(<?php print $colortextlink; ?>); - --btncolorbg: #fbfbfb; - --btncolorborderhover: none; - --btncolorborder: #FFF; - /* --butactionbg:rgba(150, 110, 162, 0.95); */ - --butactionbg:rgb(118, 145, 225); - --butactionbg:rgba(150, 110, 162, 0.95); - --butactiondeletebg: rgb(234,228,225); - /* tertiary color */ - /* --butactionbg:rgb(218, 235, 225); */ - /* --butactionbg:rgb(228, 218, 235); */ + --btncolortext:rgb(<?php print $colortextlink; ?>); + --btncolorbg: #fbfbfb; + --btncolorborderhover: none; + --btncolorborder: #FFF; + /* --butactionbg:rgba(150, 110, 162, 0.95); */ + --butactionbg:rgb(118, 145, 225); + --butactionbg:rgba(150, 110, 162, 0.95); + --butactiondeletebg: rgb(234,228,225); + /* tertiary color */ + /* --butactionbg:rgb(218, 235, 225); */ + /* --butactionbg:rgb(228, 218, 235); */ } <?php @@ -45,60 +47,60 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { /* ============================================================================== */ div.divButAction { - margin-bottom: 1.4em; + margin-bottom: 1.4em; } div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { - margin-bottom: 1.4em !important; + margin-bottom: 1.4em !important; } div.tabsActionNoBottom > a.butAction, div.tabsActionNoBottom > a.butActionRefused { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } span.butAction, span.butActionDelete { - cursor: pointer; + cursor: pointer; } .paginationafterarrows .butAction { - font-size: 0.9em; + font-size: 0.9em; } .butAction { - background: var(--butactionbg); - color: #FFF !important; - border-radius: 3px; - /* background: rgb(230, 232, 239); */ + background: var(--butactionbg); + color: #FFF !important; + border-radius: 3px; + /* background: rgb(230, 232, 239); */ } .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { - text-decoration: none; - text-transform: uppercase; - font-weight: bold; + text-decoration: none; + text-transform: uppercase; + font-weight: bold; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; - padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; - display: inline-block; - text-align: center; - cursor: pointer; - /* color: #fff; */ - /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ - color: #444; - /* border: 1px solid #aaa; */ - /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; + padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; + display: inline-block; + text-align: center; + cursor: pointer; + /* color: #fff; */ + /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ + color: #444; + /* border: 1px solid #aaa; */ + /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ - /*border-top-right-radius: 0 !important; - border-bottom-right-radius: 0 !important; - border-top-left-radius: 0 !important; - border-bottom-left-radius: 0 !important;*/ + /*border-top-right-radius: 0 !important; + border-bottom-right-radius: 0 !important; + border-top-left-radius: 0 !important; + border-bottom-left-radius: 0 !important;*/ } .butActionNew, .butActionNewRefused, .butActionNew:link, .butActionNew:visited, .butActionNew:hover, .butActionNew:active { - text-decoration: none; - text-transform: uppercase; - font-weight: normal; + text-decoration: none; + text-transform: uppercase; + font-weight: normal; - margin: 0em 0.3em 0 0.3em !important; - padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em 0.3em; - font-family: <?php print $fontlist ?>; - display: inline-block; - /* text-align: center; New button are on right of screen */ - cursor: pointer; + margin: 0em 0.3em 0 0.3em !important; + padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em 0.3em; + font-family: <?php print $fontlist ?>; + display: inline-block; + /* text-align: center; New button are on right of screen */ + cursor: pointer; } .tableforfieldcreate a.butActionNew>span.fa-plus-circle, .tableforfieldcreate a.butActionNew>span.fa-plus-circle:hover, @@ -127,66 +129,66 @@ span.butActionNewRefused>span.fa, span.butActionNewRefused>span.fa:hover } .butAction:hover { - -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); } .butActionNew:hover { - text-decoration: underline; - box-shadow: unset !important; + text-decoration: underline; + box-shadow: unset !important; } .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active, .buttonDelete { - background: var(--butactiondeletebg); - /* border: 1px solid #633; */ - color: #633; + background: var(--butactiondeletebg); + /* border: 1px solid #633; */ + color: #633; } .butActionDelete:hover { - -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); } .butActionRefused { - text-decoration: none !important; - text-transform: uppercase; - font-weight: bold !important; + text-decoration: none !important; + text-transform: uppercase; + font-weight: bold !important; - white-space: nowrap !important; - cursor: not-allowed !important; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; - padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; - font-family: <?php print $fontlist ?> !important; - display: inline-block; - text-align: center; - cursor: pointer; - color: #999 !important; - border: 1px solid #ccc; - box-sizing: border-box; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; + white-space: nowrap !important; + cursor: not-allowed !important; + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; + padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; + font-family: <?php print $fontlist ?> !important; + display: inline-block; + text-align: center; + cursor: pointer; + color: #999 !important; + border: 1px solid #ccc; + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; } .butActionNewRefused, .butActionNewRefused:link, .butActionNewRefused:visited, .butActionNewRefused:hover, .butActionNewRefused:active { - text-decoration: none !important; - text-transform: uppercase; - font-weight: normal !important; + text-decoration: none !important; + text-transform: uppercase; + font-weight: normal !important; - white-space: nowrap !important; - cursor: not-allowed !important; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; - padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; - font-family: <?php print $fontlist ?> !important; - display: inline-block; - /* text-align: center; New button are on right of screen */ - cursor: pointer; - color: #999 !important; - padding-top: 0.2em; - box-shadow: none !important; - -webkit-box-shadow: none !important; + white-space: nowrap !important; + cursor: not-allowed !important; + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; + padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; + font-family: <?php print $fontlist ?> !important; + display: inline-block; + /* text-align: center; New button are on right of screen */ + cursor: pointer; + color: #999 !important; + padding-top: 0.2em; + box-shadow: none !important; + -webkit-box-shadow: none !important; } .butActionTransparent { - color: #222 ! important; - background-color: transparent ! important; + color: #222 ! important; + background-color: transparent ! important; } @@ -195,37 +197,37 @@ TITLE BUTTON */ .btnTitle, a.btnTitle { - display: inline-block; - padding: 4px 4px 4px 4px; - font-weight: 400; - /* line-height: 1; */ - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - box-shadow: var(--btncolorbg); - text-decoration: none; - position: relative; - /* margin: 0 0 0 8px; */ - min-width: 72px; - text-align: center; - color: var(--btncolortext); - border: none; - font-size: 12px; - font-weight: 300; - background-color: var(--btncolorbg); + display: inline-block; + padding: 4px 4px 4px 4px; + font-weight: 400; + /* line-height: 1; */ + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + box-shadow: var(--btncolorbg); + text-decoration: none; + position: relative; + /* margin: 0 0 0 8px; */ + min-width: 72px; + text-align: center; + color: var(--btncolortext); + border: none; + font-size: 12px; + font-weight: 300; + background-color: var(--btncolorbg); border: 1px solid var(--btncolorborder); } a.btnTitle.btnTitleSelected { - border: 1px solid #ccc; - border-radius: 3px; + border: 1px solid #ccc; + border-radius: 3px; } .btnTitle > .btnTitle-icon{ @@ -233,43 +235,43 @@ a.btnTitle.btnTitleSelected { } .btnTitle > .btnTitle-label{ - color: #666666; + color: #666666; } .btnTitle:hover, a.btnTitle:hover { border: 1px solid #bbb; - border-radius: 3px; - position: relative; - text-align: center; - /* color: #ffffff; - background-color: rgb(<?php print $colortextlink; ?>); */ - font-size: 12px; - text-decoration: none; - box-shadow: none; + border-radius: 3px; + position: relative; + text-align: center; + /* color: #ffffff; + background-color: rgb(<?php print $colortextlink; ?>); */ + font-size: 12px; + text-decoration: none; + box-shadow: none; } .btnTitle.refused, a.btnTitle.refused, .btnTitle.refused:hover, a.btnTitle.refused:hover { - color: #8a8a8a; - cursor: not-allowed; - background-color: #fbfbfb; - background: repeating-linear-gradient( 45deg, #ffffff, #f1f1f1 4px, #f1f1f1 4px, #f1f1f1 4px ); + color: #8a8a8a; + cursor: not-allowed; + background-color: #fbfbfb; + background: repeating-linear-gradient( 45deg, #ffffff, #f1f1f1 4px, #f1f1f1 4px, #f1f1f1 4px ); } .btnTitle:hover .btnTitle-label{ - color: var(--btncolorborderhover); + color: var(--btncolorborderhover); } .btnTitle.refused .btnTitle-label, .btnTitle.refused:hover .btnTitle-label{ - color: #8a8a8a; + color: #8a8a8a; } .btnTitle>.fa { - font-size: 20px; - display: block; + font-size: 20px; + display: block; } div.pagination li:first-child a.btnTitle{ - margin-left: 10px; + margin-left: 10px; } @@ -284,15 +286,15 @@ div.pagination li:first-child a.btnTitle{ font-size: 0.95em; } .btnTitle, a.btnTitle { - display: inline-block; - padding: 4px 4px 4px 4px; + display: inline-block; + padding: 4px 4px 4px 4px; min-width: unset; } } <?php if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin)) { ?> .butActionRefused, .butActionNewRefused, .btnTitle.refused { - display: none !important; + display: none !important; } <?php } ?> diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 1140589a2e2..871ee5aa68c 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -1,63 +1,65 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > dont remove this line it's an ide hack */ /* * Dropdown of user popup */ button.dropdown-item.global-search-item { - outline: none; + outline: none; } .open>.dropdown-search, .open>.dropdown-bookmark, .open>.dropdown-quickadd, .open>.dropdown-menu, .dropdown dd ul.open { - display: block; + display: block; } .dropdown-search { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-bookmark { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-quickadd { border-color: #eee; @@ -83,107 +85,107 @@ button.dropdown-item.global-search-item { box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-menu { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-toggle{ - text-decoration: none !important; + text-decoration: none !important; } .dropdown-toggle::after { - /* font part */ - font-family: "Font Awesome 5 Free"; - font-size: 0.7em; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - text-align:center; - text-decoration:none; - margin: auto 3px; - display: inline-block; - content: "\f078"; + /* font part */ + font-family: "Font Awesome 5 Free"; + font-size: 0.7em; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + text-align:center; + text-decoration:none; + margin: auto 3px; + display: inline-block; + content: "\f078"; - -webkit-transition: -webkit-transform .2s ease-in-out; - -ms-transition: -ms-transform .2s ease-in-out; - transition: transform .2s ease-in-out; + -webkit-transition: -webkit-transform .2s ease-in-out; + -ms-transition: -ms-transform .2s ease-in-out; + transition: transform .2s ease-in-out; } .open>.dropdown-toggle::after { - transform: rotate(180deg); + transform: rotate(180deg); } /* * MENU Dropdown */ .login_block.usedropdown .logout-btn{ - display: none; + display: none; } .tmenu .open.dropdown, .tmenu .open.dropdown { - background: rgba(0, 0, 0, 0.1); + background: rgba(0, 0, 0, 0.1); } .tmenu .dropdown-menu, .login_block .dropdown-menu, .topnav .dropdown-menu { - position: absolute; - right: 2px; - <?php echo $left; ?>: auto; - line-height:1.3em; + position: absolute; + right: 2px; + <?php echo $left; ?>: auto; + line-height:1.3em; } .tmenu .dropdown-menu, .login_block .dropdown-menu .user-body { - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; } .user-body { - color: #333; + color: #333; } .side-nav-vert .user-menu .dropdown-menu, .topnav .user-menu .dropdown-menu { - border-top-right-radius: 0; - border-top-left-radius: 0; - padding: 1px 0 0 0; - border-top-width: 0; - width: 300px; + border-top-right-radius: 0; + border-top-left-radius: 0; + padding: 1px 0 0 0; + border-top-width: 0; + width: 300px; } .topnav .user-menu .dropdown-menu { top: 50px; } .side-nav-vert .user-menu .dropdown-menu, .topnav .user-menu .dropdown-menu { - margin-top: 0; - border-top-left-radius: 0; - border-top-right-radius: 0; + margin-top: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; } .side-nav-vert .user-menu .dropdown-menu > .user-header, .topnav .user-menu .dropdown-menu > .user-header { - min-height: 100px; - padding: 10px; - text-align: center; - white-space: normal; + min-height: 100px; + padding: 10px; + text-align: center; + white-space: normal; } #topmenu-global-search-dropdown .dropdown-menu{ - width: 300px; - max-width: 100%; + width: 300px; + max-width: 100%; } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown, div#topmenu-quickadd-dropdown { @@ -192,184 +194,184 @@ div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown, div#topmenu-q <?php } ?> } a.top-menu-dropdown-link { - padding: 8px; + padding: 8px; } .dropdown-user-image { - border-radius: 50%; - vertical-align: middle; - z-index: 5; - height: 90px; - width: 90px; - border: 3px solid; - border-color: transparent; - border-color: rgba(255, 255, 255, 0.2); - max-width: 100%; - max-height :100%; + border-radius: 50%; + vertical-align: middle; + z-index: 5; + height: 90px; + width: 90px; + border: 3px solid; + border-color: transparent; + border-color: rgba(255, 255, 255, 0.2); + max-width: 100%; + max-height :100%; } .dropdown-menu > .user-header{ - background: var(--colorbackhmenu1); + background: var(--colorbackhmenu1); } .dropdown-menu .dropdown-header{ - padding: 8px 8px 8px 8px; + padding: 8px 8px 8px 8px; } .dropdown-menu > .user-footer { - border-top: 1px solid #f0f0f0; - background-color: #f9f9f9; - padding: 10px; + border-top: 1px solid #f0f0f0; + background-color: #f9f9f9; + padding: 10px; } .user-footer:after { - clear: both; + clear: both; } .dropdown-menu > .bookmark-footer{ - border-top: 1px solid #f0f0f0; - background-color: #f9f9f9; - padding: 10px; + border-top: 1px solid #f0f0f0; + background-color: #f9f9f9; + padding: 10px; } .dropdown-menu > .user-body, .dropdown-body{ - padding: 15px; - border-bottom: 1px solid #f4f4f4; - border-top: 1px solid #dddddd; - white-space: normal; + padding: 15px; + border-bottom: 1px solid #f4f4f4; + border-top: 1px solid #dddddd; + white-space: normal; } .dropdown-menu > .bookmark-body, .dropdown-body{ - overflow-y: auto; - max-height: 60vh ; /* fallback for browsers without support for calc() */ - max-height: calc(90vh - 110px) ; + overflow-y: auto; + max-height: 60vh ; /* fallback for browsers without support for calc() */ + max-height: calc(90vh - 110px) ; white-space: normal; } #topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ - max-height: 60vh ; /* fallback for browsers without support for calc() */ - max-height: calc(90vh - 200px) ; + max-height: 60vh ; /* fallback for browsers without support for calc() */ + max-height: calc(90vh - 200px) ; } .dropdown-body::-webkit-scrollbar { - width: 8px; - } + width: 8px; + } .dropdown-body::-webkit-scrollbar-thumb { - -webkit-border-radius: 0; - border-radius: 0; - /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ - background: #aaa; + -webkit-border-radius: 0; + border-radius: 0; + /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ + background: #aaa; } .dropdown-body::-webkit-scrollbar-track { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - -webkit-border-radius: 0; - border-radius: 0; + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + -webkit-border-radius: 0; + border-radius: 0; } #topmenu-login-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown { - padding: 0 5px 0 5px; + padding: 0 5px 0 5px; } #topmenu-login-dropdown a:hover{ - text-decoration: none; + text-decoration: none; } #topmenuloginmoreinfo-btn{ - display: block; - text-aling: right; - color:#666; - cursor: pointer; + display: block; + text-aling: right; + color:#666; + cursor: pointer; } #topmenuloginmoreinfo{ - display: none; - clear: both; - font-size: 0.95em; + display: none; + clear: both; + font-size: 0.95em; } .button-top-menu-dropdown { - display: inline-block; - padding: 6px 12px; - margin-bottom: 0; - font-size: 14px; - font-weight: 400; - line-height: 1.42857143; - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-image: none; + border: 1px solid transparent; + border-radius: 4px; } .user-footer .button-top-menu-dropdown { - color: #666666; - border-radius: 0; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - border-width: 1px; - background-color: #f4f4f4; - border-color: #ddd; + color: #666666; + border-radius: 0; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + border-width: 1px; + background-color: #f4f4f4; + border-color: #ddd; } .dropdown-menu a.top-menu-dropdown-link { - color: rgb(<?php print $colortextlink; ?>) !important; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - display: block; - margin: 5px 0px; + color: rgb(<?php print $colortextlink; ?>) !important; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + display: block; + margin: 5px 0px; } .dropdown-item { - display: block !important; - box-sizing: border-box; - width: 100%; - padding: .3em 1.5em .4em 1em; - clear: both; - font-weight: 400; - color: #212529 !important; - text-align: inherit; - background-color: transparent; - border: 0; + display: block !important; + box-sizing: border-box; + width: 100%; + padding: .3em 1.5em .4em 1em; + clear: both; + font-weight: 400; + color: #212529 !important; + text-align: inherit; + background-color: transparent; + border: 0; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; } .dropdown-item::before { - /* font part */ - font-family: "Font Awesome 5 Free"; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - text-align:center; - text-decoration:none; - margin-right: 5px; - display: inline-block; - content: "\f0da"; - /* color: rgba(0,0,0,0.3); */ + /* font part */ + font-family: "Font Awesome 5 Free"; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + text-align:center; + text-decoration:none; + margin-right: 5px; + display: inline-block; + content: "\f0da"; + /* color: rgba(0,0,0,0.3); */ } .dropdown-item.bookmark-item-external::before { content: "\f35d"; } .dropdown-item.active, .dropdown-item:hover, .dropdown-item:focus { - color: #<?php echo $colortextbackhmenu; ?> !important; - text-decoration: none; - background: rgb(<?php echo $colorbackhmenu1 ?>); + color: #<?php echo $colortextbackhmenu; ?> !important; + text-decoration: none; + background: rgb(<?php echo $colorbackhmenu1 ?>); } /* @@ -377,34 +379,34 @@ a.top-menu-dropdown-link { */ .dropdown-search-input { - width: 100%; - padding: 10px 35px 10px 20px; + width: 100%; + padding: 10px 35px 10px 20px; - background-color: transparent; - /*font-size: 14px; - line-height: 16px;*/ - box-sizing: border-box; + background-color: transparent; + /*font-size: 14px; + line-height: 16px;*/ + box-sizing: border-box; - color: #575756; - background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-size: 16px 16px; - background-position: 95% center; - border-radius: 10px; - border: 1px solid #c4c4c2 !important; - transition: all 250ms ease-in-out; - backface-visibility: hidden; - transform-style: preserve-3d; + color: #575756; + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-size: 16px 16px; + background-position: 95% center; + border-radius: 10px; + border: 1px solid #c4c4c2 !important; + transition: all 250ms ease-in-out; + backface-visibility: hidden; + transform-style: preserve-3d; } .dropdown-search-input::placeholder { - color: color(#575756 a(0.8)); - letter-spacing: 1.5px; + color: color(#575756 a(0.8)); + letter-spacing: 1.5px; } .hidden-search-result{ - display: none !important; + display: none !important; } /* @@ -468,11 +470,11 @@ div.quickaddblock:focus { @media only screen and (max-width: 767px) { .dropdown-search-input { - width: 100%; + width: 100%; } .tmenu .dropdown-menu, .login_block .dropdown-menu, .topnav .dropdown-menu { - margin-left: 5px; - right: 0; - } + margin-left: 5px; + right: 0; + } } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 326aac90390..6a92e16fdb0 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1,4 +1,6 @@ -<?php if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +<?php if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ /* ============================================================================== */ @@ -101,12 +103,12 @@ body { font-size: <?php print is_numeric($fontsize) ? $fontsize.'px' : $fontsize; ?>; line-height: 1.4; font-family: <?php print $fontlist ?>; - margin-top: 0; - margin-bottom: 0; - margin-right: 0; - margin-left: 0; - font-weight: 400; - <?php print 'direction: '.$langs->trans("DIRECTION").";\n"; ?> + margin-top: 0; + margin-bottom: 0; + margin-right: 0; + margin-left: 0; + font-weight: 400; + <?php print 'direction: '.$langs->trans("DIRECTION").";\n"; ?> } /* Style used to protect html content in output to avoid attack by replacing full page with js content */ @@ -138,10 +140,10 @@ select.vmenusearchselectcombo { } table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td.wrapcolumntitle.liste_titre:not(.maxwidthsearch) { - overflow: hidden; - white-space: nowrap; - max-width: 100px; - text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + max-width: 100px; + text-overflow: ellipsis; } .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], @@ -164,20 +166,20 @@ input[type=submit], input[type=submit]:hover { margin-left: 5px; } input[type=checkbox], input[type=radio] { - margin: 0 3px 0 3px; + margin: 0 3px 0 3px; } input, input.flat, form.flat select, select, select.flat, .dataTables_length label select { border: none; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { - font-family: <?php print $fontlist ?>; - outline: none; - margin: 0px 0px 0px 0px; - border<?php echo empty($conf->global->THEME_SHOW_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px var(--inputbordercolor); + font-family: <?php print $fontlist ?>; + outline: none; + margin: 0px 0px 0px 0px; + border<?php echo empty($conf->global->THEME_SHOW_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px var(--inputbordercolor); } input { - line-height: 1.3em; + line-height: 1.3em; padding: 4px; padding-left: 5px; } @@ -199,11 +201,11 @@ input, select { background: var(--butactionbg); color: #FFF !important; border-radius: 3px; - border-collapse: collapse; - border: none; + border-collapse: collapse; + border: none; } #mainbody span.websitetools input.button:not(.buttongen):not(.bordertransp) { - color: #000 !important; + color: #000 !important; } #mainbody input.buttongen, #mainbody button.buttongen { padding: 3px 4px; @@ -214,11 +216,11 @@ input.button:focus { } input.button.massactionconfirmed { - margin: 4px; + margin: 4px; } input:invalid, select:invalid { - border-color: #ea1212; + border-color: #ea1212; } /* Focus definitions must be after standard definition */ @@ -233,7 +235,7 @@ textarea.cke_source:focus box-shadow: none; } div#cke_dp_desc { - margin-top: 5px; + margin-top: 5px; } textarea { border-radius: 0; @@ -279,7 +281,7 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment { max-width: 350px; } div.buttonpayment input:focus { - color: #008; + color: #008; } .buttonpaymentsmall { font-size: 0.65em; @@ -287,12 +289,12 @@ div.buttonpayment input:focus { padding-right: 5px; } div.buttonpayment input { - background-color: unset; - color: #fff; - border-bottom: unset; - font-weight: bold; - text-transform: uppercase; - cursor: pointer; + background-color: unset; + color: #fff; + border-bottom: unset; + font-weight: bold; + text-transform: uppercase; + cursor: pointer; } input.buttonpaymentcb { background-image: url(<?php echo dol_buildpath($path.'/theme/common/credit_card.png', 1) ?>); @@ -329,17 +331,17 @@ input.buttonpaymentstripe { a.butStatus { padding-left: 5px; padding-right: 5px; - background-color: transparent; - color: var(--colortext) !important; - border: 2px solid var( --butactionbg); - margin: 0 0.45em !important; + background-color: transparent; + color: var(--colortext) !important; + border: 2px solid var( --butactionbg); + margin: 0 0.45em !important; } /* Used by timesheets */ span.timesheetalreadyrecorded input { - border: none; - border-bottom: solid 1px rgba(0,0,0,0.4); - margin-right: 1px !important; + border: none; + border-bottom: solid 1px rgba(0,0,0,0.4); + margin-right: 1px !important; } td.onholidaymorning, td.onholidayafternoon { background-color: #fdf6f2; @@ -363,15 +365,15 @@ td.rightborder { } td.actionbuttons a { - padding-left: 6px; + padding-left: 6px; } select.flat, form.flat select, .pageplusone { font-weight: normal; font-size: unset; } input.pageplusone { - padding-bottom: 4px; - padding-top: 4px; + padding-bottom: 4px; + padding-top: 4px; } .saturatemedium { @@ -400,17 +402,17 @@ input.pageplusone { color: #fff; } .colorgrey { - color: #888 !important; + color: #888 !important; } .colorblack { color: #000; } .vmirror { - transform: scale(1, -1); + transform: scale(1, -1); } .hmirror { - transform: scale(-1, 1); + transform: scale(-1, 1); } select:invalid { @@ -437,7 +439,7 @@ input[type=file ] { border-left: none; border-right: none; <?php } ?> - border<?php echo empty($conf->global->THEME_SHOW_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px var(--inputbordercolor); + border<?php echo empty($conf->global->THEME_SHOW_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px var(--inputbordercolor); } input[type=checkbox] { background-color: transparent; border: none; box-shadow: none; } input[type=radio] { background-color: transparent; border: none; box-shadow: none; } @@ -462,11 +464,11 @@ input#onlinepaymenturl, input#directdownloadlink { .formconsumeproduce { background: #f3f3f3; - padding: 20px 0px 0px 0px; + padding: 20px 0px 0px 0px; } div#moretabsList, div#moretabsListaction { - z-index: 5; + z-index: 5; } hr { border: 0; border-top: 1px solid #ccc; } @@ -511,38 +513,38 @@ hr { border: 0; border-top: 1px solid #ccc; } } .button:disabled, .buttonDelete:disabled, .button.disabled { opacity: 0.4; - box-shadow: none; - -webkit-box-shadow: none; - cursor: auto; + box-shadow: none; + -webkit-box-shadow: none; + cursor: auto; } .buttonRefused { pointer-events: none; - cursor: default; + cursor: default; opacity: 0.4; - box-shadow: none; - -webkit-box-shadow: none; + box-shadow: none; + -webkit-box-shadow: none; } .button_search, .button_removefilter { - border: unset; - background-color: unset; + border: unset; + background-color: unset; } .button_search:hover, .button_removefilter:hover { - cursor: pointer; + cursor: pointer; } form { - padding:0px; - margin:0px; + padding:0px; + margin:0px; } form#addproduct { - padding-top: 10px; + padding-top: 10px; } div.float, span.floatleft { - float:<?php print $left; ?>; + float:<?php print $left; ?>; } div.floatright { - float:<?php print $right; ?>; + float:<?php print $right; ?>; } .block { @@ -553,14 +555,14 @@ div.floatright display:inline-block; } .largenumber { - font-size: 1.4em; + font-size: 1.4em; } button[name='button_search_x'] span.fa.fa-search { - font-size: 1.3em; + font-size: 1.3em; } button[name='button_removefilter_x'] span.fa.fa-remove { - opacity: 0.5; - font-size: 1.3em; + opacity: 0.5; + font-size: 1.3em; } button:focus { outline: none; @@ -568,8 +570,8 @@ button:focus { th .button { - -webkit-box-shadow: none !important; - box-shadow: none !important; + -webkit-box-shadow: none !important; + box-shadow: none !important; -webkit-border-radius:0px !important; border-radius:0px !important; } @@ -608,27 +610,27 @@ textarea.centpercent { width: 96%; } .small, small { - font-size: 85%; + font-size: 85%; } .h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small { - font-size: 65%; + font-size: 65%; } .h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, .h4 .small, .h4 small, .h5 .small, .h5 small, .h6 .small, .h6 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small, h4 .small, h4 small, h5 .small, h5 small, h6 .small, h6 small { - font-weight: 400; - line-height: 1; - color: #777; + font-weight: 400; + line-height: 1; + color: #777; } .flip { transform: scaleX(-1) translate(2px, 0); } .center { - text-align: center; - margin: 0px auto; + text-align: center; + margin: 0px auto; } .alignstart { - text-align: start; + text-align: start; } .left { text-align: <?php print $left; ?>; @@ -640,10 +642,10 @@ textarea.centpercent { text-align: justify; } .pull-left { - float: left!important; + float: left!important; } .pull-right { - float: right!important; + float: right!important; } .nowrap { white-space: <?php print ($dol_optimize_smallscreen ? 'normal' : 'nowrap'); ?>; @@ -679,7 +681,7 @@ textarea.centpercent { text-transform: uppercase; } .nounderline { - text-decoration: none; + text-decoration: none; } .nopadding { padding: 0; @@ -733,48 +735,48 @@ textarea.centpercent { cursor: not-allowed; } .backgroundblank { - background-color: #fff; + background-color: #fff; } .nobackground, .nobackground tr { background: unset !important; } .checkboxattachfilelabel { - font-size: 0.85em; - opacity: 0.7; + font-size: 0.85em; + opacity: 0.7; } .borderimp { border: 1px solid #888 !important; } .text-warning{ - color : <?php print $textWarning; ?> + color : <?php print $textWarning; ?> } .longmessagecut { - max-height: 250px; - max-width: 100%; - overflow-y: auto; + max-height: 250px; + max-width: 100%; + overflow-y: auto; } body[class*="colorblind-"] .text-warning{ - color : <?php print $colorblind_deuteranopes_textWarning; ?> + color : <?php print $colorblind_deuteranopes_textWarning; ?> } .text-success{ - color : <?php print $textSuccess; ?> + color : <?php print $textSuccess; ?> } body[class*="colorblind-"] .text-success{ - color : <?php print $colorblind_deuteranopes_textSuccess; ?> + color : <?php print $colorblind_deuteranopes_textSuccess; ?> } .text-danger{ - color : <?php print $textDanger; ?> + color : <?php print $textDanger; ?> } .editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, .editfieldlang { - color: #ccc !important; + color: #ccc !important; } .editfielda span.fa-pencil-alt:hover, .editfielda span.fa-pencil-ruler:hover, .editfielda span.fa-trash:hover, .editfielda span.fa-crop:hover, .editfieldlang:hover { - color: var(--colortexttitle) !important; + color: var(--colortexttitle) !important; } .fawidth30 { width: 20px; @@ -784,9 +786,9 @@ body[class*="colorblind-"] .text-success{ } span.fa.fa-plus-circle.paddingleft { - padding-right: 4px; - padding-top: 3px; - padding-bottom: 2px; + padding-right: 4px; + padding-top: 3px; + padding-bottom: 2px; } .size15x { font-size: 1.5em !important; } @@ -801,7 +803,7 @@ span.fa.fa-plus-circle.paddingleft { /* Themes for badges */ - <?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?> + <?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?> .borderrightlight { @@ -815,8 +817,8 @@ span.fa.fa-plus-circle.paddingleft { margin-top: 4px; } #formuserfile input[type='file'] { - font-size: 1em; - /* opacity: 0.5em; */ + font-size: 1em; + /* opacity: 0.5em; */ } /*#formuserfile input[type='file']:valid { color: #a00; @@ -829,56 +831,56 @@ span.fa.fa-plus-circle.paddingleft { margin-left: 1px; } #formuserfile_link input[type='text'] { - font-size: 1em; + font-size: 1em; } .listofinvoicetype { height: 28px; vertical-align: middle; } .divsocialnetwork:not(:first-child) { - padding-left: 20px; + padding-left: 20px; } div.divsearchfield { float: <?php print $left; ?>; margin-<?php print $right; ?>: 12px; - margin-<?php print $left; ?>: 2px; + margin-<?php print $left; ?>: 2px; margin-top: 4px; - margin-bottom: 4px; - padding-left: 2px; + margin-bottom: 4px; + padding-left: 2px; } .divsearchfieldfilter { - text-overflow: clip; - overflow: auto; - padding-bottom: 5px; - opacity: 0.6; + text-overflow: clip; + overflow: auto; + padding-bottom: 5px; + opacity: 0.6; } .divadvancedsearchfield:first-child { - margin-top: 3px; + margin-top: 3px; } .divadvancedsearchfield { - float: left; - padding-left: 15px; - padding-right: 15px; - padding-bottom: 2px; - padding-top: 2px; + float: left; + padding-left: 15px; + padding-right: 15px; + padding-bottom: 2px; + padding-top: 2px; } .divadvancedsearchfield span.select2.select2-container.select2-container--default { padding-bottom: 4px; } .search_component_params { /*display: flex; */ - -webkit-flex-flow: row wrap; - flex-flow: row wrap; - background: #fff; - padding-top: 3px; - padding-bottom: 3px; - padding-left: 10px; - padding-right: 10px; - border-bottom: solid 1px rgba(0,0,0,.2); - height: 24px; + -webkit-flex-flow: row wrap; + flex-flow: row wrap; + background: #fff; + 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_searchtext { - padding-top: 2px; + padding-top: 2px; } .search_component_params_text, .search_component_params_text:focus { border-bottom: none; @@ -888,16 +890,16 @@ div.divsearchfield { } .a-filter, .a-mesure { - border-radius: 50px; - background: var(--colortexttitlenotab); - color: #fff; - padding: 8px 10px 8px 6px; + border-radius: 50px; + background: var(--colortexttitlenotab); + color: #fff; + padding: 8px 10px 8px 6px; } .a-filter:before { - content: "\f0b0"; + content: "\f0b0"; } .a-mesure:before { - content: "\f080"; + content: "\f080"; } .a-filter:before, .a-mesure:before { font-family: "Font Awesome 5 Free"; @@ -906,10 +908,10 @@ div.divsearchfield { padding-left: 5px; } .a-filter-disabled, .a-mesure-disabled { - border-radius: 50px; - background: var(--colorbacktitle1); - padding: 8px; - opacity: 0.6; + border-radius: 50px; + background: var(--colorbacktitle1); + padding: 8px; + opacity: 0.6; } div.div-for-modal { @@ -920,9 +922,9 @@ div.div-for-modal { width:500px; /* adjust as per your needs */ height:400px; /* adjust as per your needs */ background: #fff; - border: 1px solid #bbb; - box-shadow: 2px 2px 20px #ddd; - z-index: 100; + border: 1px solid #bbb; + box-shadow: 2px 2px 20px #ddd; + z-index: 100; } <?php @@ -930,7 +932,7 @@ div.div-for-modal { if ($conf->browser->layout == 'phone') { ?> .divsearchfieldfilter { - white-space: nowrap; + white-space: nowrap; } <?php } ?> div.confirmmessage { @@ -957,12 +959,12 @@ ul.attendees li { padding-bottom: 10px; } .checkallactions { - margin-left: 2px; /* left must be same than right to keep checkbox centered */ - margin-right: 2px; /* left must be same than right to keep checkbox centered */ - vertical-align: middle; + margin-left: 2px; /* left must be same than right to keep checkbox centered */ + margin-right: 2px; /* left must be same than right to keep checkbox centered */ + vertical-align: middle; } select.flat.selectlimit { - max-width: 62px; + max-width: 62px; } .selectlimit, .marginrightonly { margin-right: 10px !important; @@ -989,16 +991,16 @@ select.flat.selectlimit { margin-bottom: 3px !important; } .nomargintop { - margin-top: 0 !important; + margin-top: 0 !important; } .nomarginbottom { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } .selectlimit, .selectlimit:focus { - border-left: none !important; - border-top: none !important; - border-right: none !important; - outline: none; + border-left: none !important; + border-top: none !important; + border-right: none !important; + outline: none; } .strikefordisabled { text-decoration: line-through; @@ -1011,69 +1013,69 @@ select.flat.selectlimit { text-overflow: none; } .tdoverflow { - max-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax50 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 50px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 50px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax100 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax100imp { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px !important; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 100px !important; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax125 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 125px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 125px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax150 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 150px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax200 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 200px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 200px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax300 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 300px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 300px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowauto { - max-width: 0; - overflow: auto; + max-width: 0; + overflow: auto; } .divintowithtwolinesmax { - width: 75px; - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; + width: 75px; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; } .twolinesmax { - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; } .tablelistofcalendars { @@ -1082,8 +1084,8 @@ select.flat.selectlimit { /* Styles for amount on card */ table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay { - padding-top: 0px; - padding-bottom: 0px; + padding-top: 0px; + padding-bottom: 0px; } .amountalreadypaid { } @@ -1108,10 +1110,10 @@ table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaint } .onlinepaymentbody .amountpaymentcomplete { - background-color: var(--amountpaymentcomplete); - color: #fff; - padding: 5px; - border-radius: 5px; + background-color: var(--amountpaymentcomplete); + color: #fff; + padding: 5px; + border-radius: 5px; } .savingdocmask { @@ -1119,19 +1121,19 @@ table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaint margin-bottom: 12px; } #builddoc_form ~ .showlinkedobjectblock { - margin-top: 20px; + margin-top: 20px; } /* For the long description of module */ .moduledesclong p img, .moduledesclong p a img { - max-width: 90% !important; - height: auto !important; + max-width: 90% !important; + height: auto !important; } .imgdoc { - margin: 18px; - border: 1px solid #ccc; - box-shadow: 1px 1px 25px #aaa; - max-width: calc(100% - 56px); + margin: 18px; + border: 1px solid #ccc; + box-shadow: 1px 1px 25px #aaa; + max-width: calc(100% - 56px); } .fa-file-text-o, .fa-file-code-o, .fa-file-powerpoint-o, .fa-file-excel-o, .fa-file-word-o, .fa-file-o, .fa-file-image-o, .fa-file-video-o, .fa-file-audio-o, .fa-file-archive-o, .fa-file-pdf-o { color: #055; @@ -1143,51 +1145,53 @@ table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaint /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { - width: calc(100% - 330px); - margin-bottom: 15px; - overflow-y: hidden; - -ms-overflow-style: -ms-autohiding-scrollbar; + width: calc(100% - 330px); + margin-bottom: 15px; + overflow-y: hidden; + -ms-overflow-style: -ms-autohiding-scrollbar; }*/ /* Style used for most tables */ .div-table-responsive, .div-table-responsive-no-min { - overflow-x: auto; - min-height: 0.01%; + overflow-x: auto; + min-height: 0.01%; } .div-table-responsive { - line-height: 120%; + line-height: 120%; } /* Style used for full page tables with field selector and no content after table (priority before previous for such tables) */ div.fiche>form>div.div-table-responsive, div.fiche>form>div.div-table-responsive-no-min { - overflow-x: auto; + overflow-x: auto; } div.fiche>form>div.div-table-responsive { - min-height: 392px; + min-height: 392px; } div.fiche>div.tabBar>form>div.div-table-responsive { - min-height: 392px; + min-height: 392px; } div.fiche { /* text-align: justify; */ } .flexcontainer { - <?php if (in_array($conf->browser->name, array('chrome', 'firefox'))) echo 'display: inline-flex;'."\n"; ?> - flex-flow: row wrap; - justify-content: flex-start; + <?php if (in_array($conf->browser->name, array('chrome', 'firefox'))) { + echo 'display: inline-flex;'."\n"; + } ?> + flex-flow: row wrap; + justify-content: flex-start; } .thumbstat { - min-width: 148px; + min-width: 148px; } .thumbstat150 { - min-width: 168px; - max-width: 169px; - /* width: 168px; If I use with, there is trouble on size of flex boxes solved with min+max that is a little bit higer than min */ + min-width: 168px; + max-width: 169px; + /* width: 168px; If I use with, there is trouble on size of flex boxes solved with min+max that is a little bit higer than min */ } .thumbstat, .thumbstat150 { <?php if ($conf->browser->name == 'ie') { ?> - min-width: 150px; - width: 100%; - display: inline; + min-width: 150px; + width: 100%; + display: inline; <?php } else { ?> flex-grow: 1; flex-shrink: 0; @@ -1202,7 +1206,7 @@ select.selectarrowonleft option { } table[summary="list_of_modules"] .fa-cog { - font-size: 1.5em; + font-size: 1.5em; } .linkedcol-element { @@ -1238,24 +1242,24 @@ table[summary="list_of_modules"] .fa-cog { { .width20 { width: 20px; } .width25 { width: 25px; } - .width50 { width: 50px; } - .width75 { width: 75px; } - .width100 { width: 100px; } - .width200 { width: 200px; } - .minwidth100 { min-width: 100px; } - .minwidth150 { min-width: 150px; } - .minwidth200 { min-width: 200px; } - .minwidth300 { min-width: 300px; } - .minwidth400 { min-width: 400px; } - .minwidth500 { min-width: 500px; } - .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth200imp { min-width: 200px !important; } - .minwidth250imp { min-width: 250px !important; } - .minwidth300imp { min-width: 300px !important; } - .minwidth400imp { min-width: 400px !important; } - .minwidth500imp { min-width: 500px !important; } + .width50 { width: 50px; } + .width75 { width: 75px; } + .width100 { width: 100px; } + .width200 { width: 200px; } + .minwidth100 { min-width: 100px; } + .minwidth150 { min-width: 150px; } + .minwidth200 { min-width: 200px; } + .minwidth300 { min-width: 300px; } + .minwidth400 { min-width: 400px; } + .minwidth500 { min-width: 500px; } + .minwidth50imp { min-width: 50px !important; } + .minwidth75imp { min-width: 75px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth200imp { min-width: 200px !important; } + .minwidth250imp { min-width: 250px !important; } + .minwidth300imp { min-width: 300px !important; } + .minwidth400imp { min-width: 400px !important; } + .minwidth500imp { min-width: 500px !important; } } .widthauto { width: auto; } .width20 { width: 20px; } @@ -1307,16 +1311,16 @@ table[summary="list_of_modules"] .fa-cog { .titlefield { /* width: 30% !important; */ } .titlefieldcreate { width: 30% !important; } .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 150px !important; } - .minwidth200imp { min-width: 200px !important; } - .minwidth250imp { min-width: 250px !important; } - .minwidth300imp { min-width: 300px !important; } - .minwidth400imp { min-width: 300px !important; } - .minwidth500imp { min-width: 300px !important; } + .minwidth75imp { min-width: 75px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 150px !important; } + .minwidth200imp { min-width: 200px !important; } + .minwidth250imp { min-width: 250px !important; } + .minwidth300imp { min-width: 300px !important; } + .minwidth400imp { min-width: 300px !important; } + .minwidth500imp { min-width: 300px !important; } - .linkedcol-element { + .linkedcol-element { min-width: unset; } } @@ -1324,16 +1328,16 @@ table[summary="list_of_modules"] .fa-cog { /* Force values for small screen 1000 */ @media only screen and (max-width: 1000px) { - .maxwidthonsmartphone { max-width: 100px; } + .maxwidthonsmartphone { max-width: 100px; } .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 110px !important; } - .minwidth200imp { min-width: 110px !important; } - .minwidth250imp { min-width: 115px !important; } - .minwidth300imp { min-width: 120px !important; } - .minwidth400imp { min-width: 150px !important; } - .minwidth500imp { min-width: 250px !important; } + .minwidth75imp { min-width: 75px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 110px !important; } + .minwidth200imp { min-width: 110px !important; } + .minwidth250imp { min-width: 115px !important; } + .minwidth300imp { min-width: 120px !important; } + .minwidth400imp { min-width: 150px !important; } + .minwidth500imp { min-width: 250px !important; } } select.widthcentpercentminusx, span.widthcentpercentminusx:not(.select2-selection), input.widthcentpercentminusx { @@ -1352,16 +1356,16 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select font-size: <?php print is_numeric($fontsize) ? ($fontsize + 3).'px' : $fontsize; ?> !important; } .divadvancedsearchfield { - padding-left: 5px; - padding-right: 5px; - } - - div.divphotoref { - padding-right: 10px !important; + padding-left: 5px; + padding-right: 5px; } - .hideonsmartphone { display: none; } - .hideonsmartphoneimp { display: none !important; } + div.divphotoref { + padding-right: 10px !important; + } + + .hideonsmartphone { display: none; } + .hideonsmartphoneimp { display: none !important; } span.pictotitle { margin-<?php echo $left; ?>: 0 !important; @@ -1383,17 +1387,17 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select width: auto !important; } .poweredbypublicpayment { - float: unset !important; + float: unset !important; top: unset !important; - bottom: 8px; - position: relative !important; - } - .poweredbyimg { - width: 48px; - } - input.buttonpayment, button.buttonpayment, div.buttonpayment { - min-width: 270px; - } + bottom: 8px; + position: relative !important; + } + .poweredbyimg { + width: 48px; + } + input.buttonpayment, button.buttonpayment, div.buttonpayment { + min-width: 270px; + } } /* Force values for small screen 570 */ @@ -1419,31 +1423,31 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select .divmainbodylarge { margin-left: 20px !important; margin-right: 20px !important; } - .tdoverflowonsmartphone { - max-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - .tdoverflowmax100onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + .tdoverflowonsmartphone { + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } - .tdoverflowmax150onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + .tdoverflowmax100onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .tdoverflowmax150onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col { + height: 40px !important; } - .border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col { - height: 40px !important; - } - .quatrevingtpercent, .inputsearch { - width: 95%; - } + .quatrevingtpercent, .inputsearch { + width: 95%; + } select { padding-top: 4px; @@ -1455,36 +1459,36 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select } input, input[type=text], input[type=password], select, textarea { min-width: 20px; - } - .trinputlogin input[type=text], input[type=password] { + } + .trinputlogin input[type=text], input[type=password] { max-width: 140px; } - .vmenu .searchform input { + .vmenu .searchform input { max-width: 138px; /* length of input text in the quick search box when using a smartphone and without dolidroid */ } - .noenlargeonsmartphone { width : 50px !important; display: inline !important; } - .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } - .maxwidth50onsmartphone { max-width: 40px; } - .maxwidth75onsmartphone { max-width: 50px; } - .maxwidth100onsmartphone { max-width: 70px; } - .maxwidth150onsmartphone { max-width: 120px; } - .maxwidth150onsmartphoneimp { max-width: 120px !important; } - .maxwidth200onsmartphone { max-width: 200px; } - .maxwidth250onsmartphone { max-width: 250px; } - .maxwidth300onsmartphone { max-width: 300px; } - .maxwidth400onsmartphone { max-width: 400px; } + .noenlargeonsmartphone { width : 50px !important; display: inline !important; } + .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } + .maxwidth50onsmartphone { max-width: 40px; } + .maxwidth75onsmartphone { max-width: 50px; } + .maxwidth100onsmartphone { max-width: 70px; } + .maxwidth150onsmartphone { max-width: 120px; } + .maxwidth150onsmartphoneimp { max-width: 120px !important; } + .maxwidth200onsmartphone { max-width: 200px; } + .maxwidth250onsmartphone { max-width: 250px; } + .maxwidth300onsmartphone { max-width: 300px; } + .maxwidth400onsmartphone { max-width: 400px; } .minwidth50imp { min-width: 50px !important; } .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 110px !important; } - .minwidth200imp { min-width: 110px !important; } - .minwidth250imp { min-width: 115px !important; } - .minwidth300imp { min-width: 120px !important; } - .minwidth400imp { min-width: 150px !important; } - .minwidth500imp { min-width: 250px !important; } - .titlefield { width: auto; } - .titlefieldcreate { width: auto; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 110px !important; } + .minwidth200imp { min-width: 110px !important; } + .minwidth250imp { min-width: 115px !important; } + .minwidth300imp { min-width: 120px !important; } + .minwidth400imp { min-width: 150px !important; } + .minwidth500imp { min-width: 250px !important; } + .titlefield { width: auto; } + .titlefieldcreate { width: auto; } #tooltip { position: absolute; @@ -1499,38 +1503,38 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select div.divphotoref { padding-<?php echo $right; ?>: 5px; - padding-bottom: 5px; + padding-bottom: 5px; + } + img.photoref, div.photoref { + border: 1px solid rgba(0, 0, 0, 0.2); + box-shadow: none; + -webkit-box-shadow: none; + padding: 4px; + height: 20px; + width: 20px; + object-fit: contain; } - img.photoref, div.photoref { - border: 1px solid rgba(0, 0, 0, 0.2); - box-shadow: none; - -webkit-box-shadow: none; - padding: 4px; - height: 20px; - width: 20px; - object-fit: contain; - } div.statusref { - padding-right: 10px; - } + padding-right: 10px; + } div.statusref img { - padding-right: 3px !important; - } + padding-right: 3px !important; + } div.statusrefbis { - padding-right: 3px !important; - } + padding-right: 3px !important; + } /* TODO div.statusref { - padding-top: 0px !important; - padding-left: 0px !important; - border: none !important; - } + padding-top: 0px !important; + padding-left: 0px !important; + border: none !important; + } */ - input.buttonpayment { + input.buttonpayment { min-width: 300px; - } + } } .linkobject { cursor: pointer; } @@ -1629,23 +1633,23 @@ div.blockvmenulogo border-bottom: 0 !important; } .menulogocontainer { - margin: <?php echo $disableimages ? '0' : '6'; ?>px; - margin-left: 11px; - margin-right: 9px; - padding: 0; - height: <?php echo $disableimages ? '20' : '32'; ?>px; - /* width: 100px; */ - max-width: 100px; - vertical-align: middle; + margin: <?php echo $disableimages ? '0' : '6'; ?>px; + margin-left: 11px; + margin-right: 9px; + padding: 0; + height: <?php echo $disableimages ? '20' : '32'; ?>px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; } .backgroundforcompanylogo { - background-color: rgba(255,255,255,0.7); - border-radius: 4px; + background-color: rgba(255,255,255,0.7); + border-radius: 4px; } .menulogocontainer img.mycompany { - object-fit: contain; - width: inherit; - height: inherit; + object-fit: contain; + width: inherit; + height: inherit; } #mainmenutd_companylogo::after, #mainmenutd_menu::after { content: unset !important; @@ -1680,8 +1684,8 @@ div.vmenu, td.vmenu { padding-right: 10px !important; } .blockvmenu .menu_titre { - margin-top: 4px; - margin-bottom: 1px; + margin-top: 4px; + margin-bottom: 1px; } /* Try responsive even not on smartphone @@ -1721,7 +1725,7 @@ div.vmenu, td.vmenu { padding-left: 20px; padding-right: 20px; position: absolute; - z-index: 90; + z-index: 90; } div.blockvmenulogo { @@ -1759,8 +1763,12 @@ div.vmenu, td.vmenu { div.fiche { margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : (empty($conf->dol_optimize_smallscreen) ? '30' : '6')); ?>px; margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : (empty($conf->dol_optimize_smallscreen) ? '28' : '6')); ?>px; - <?php if (!empty($dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> - <?php if (!empty($dol_hide_leftmenu)) print 'margin-top: 12px;'."\n"; ?> + <?php if (!empty($dol_hide_leftmenu)) { + print 'margin-bottom: 12px;'."\n"; + } ?> + <?php if (!empty($dol_hide_leftmenu)) { + print 'margin-top: 12px;'."\n"; + } ?> } body.onlinepaymentbody div.fiche { /* For online payment page */ margin: 20px !important; @@ -1779,28 +1787,50 @@ div.fichecenterbis { margin-top: 8px; } div.fichethirdleft { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?> - <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px;\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$left.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: 50%;\n"; + } ?> + <?php if ($conf->browser->layout == 'phone') { + print "padding-bottom: 6px;\n"; + } ?> } div.fichetwothirdright { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?> - <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$right.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: 50%;\n"; + } ?> + <?php if ($conf->browser->layout == 'phone') { + print "padding-bottom: 6px\n"; + } ?> } div.fichetwothirdright div.ficheaddleft { - padding-<?php echo $left; ?>: 20px; + padding-<?php echo $left; ?>: 20px; } div.fichehalfleft { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: calc(50% - 10px);\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$left.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: calc(50% - 10px);\n"; + } ?> } div.fichehalfright { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: calc(50% - 10px);\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$right.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: calc(50% - 10px);\n"; + } ?> } div.fichehalfright { - <?php if ($conf->browser->layout == 'phone') { print "margin-top: 10px;\n"; } ?> + <?php if ($conf->browser->layout == 'phone') { + print "margin-top: 10px;\n"; + } ?> } div.firstcolumn div.box { padding-right: 10px; @@ -1811,42 +1841,42 @@ div.secondcolumn div.box { /* Force values on one colum for small screen */ @media only screen and (max-width: 1000px) { - div.fiche { - margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : ($dol_hide_leftmenu ? '6' : '20')); ?>px; - margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 8 : 6); ?>px; - } - div.fichecenter { - width: 100%; - clear: both; /* This is to have div fichecenter that are true rectangles */ - } - div.fichecenterbis { - margin-top: 8px; - } - div.fichethirdleft { - float: none; - width: auto; - padding-bottom: 6px; - } - div.fichetwothirdright { - float: none; - width: auto; - padding-bottom: 6px; - } - div.fichetwothirdright div.ficheaddleft { - padding-left: 0; + div.fiche { + margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : ($dol_hide_leftmenu ? '6' : '20')); ?>px; + margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 8 : 6); ?>px; } - div.fichehalfleft { - float: none; - width: auto; - } - div.fichehalfright { - float: none; - width: auto; - } - div.fichehalfright { - margin-top: 10px; - } - div.firstcolumn div.box { + div.fichecenter { + width: 100%; + clear: both; /* This is to have div fichecenter that are true rectangles */ + } + div.fichecenterbis { + margin-top: 8px; + } + div.fichethirdleft { + float: none; + width: auto; + padding-bottom: 6px; + } + div.fichetwothirdright { + float: none; + width: auto; + padding-bottom: 6px; + } + div.fichetwothirdright div.ficheaddleft { + padding-left: 0; + } + div.fichehalfleft { + float: none; + width: auto; + } + div.fichehalfright { + float: none; + width: auto; + } + div.fichehalfright { + margin-top: 10px; + } + div.firstcolumn div.box { padding-right: 0px; } div.secondcolumn div.box { @@ -1857,23 +1887,23 @@ div.secondcolumn div.box { /* Force values on one colum for small screen */ @media only screen and (max-width: 1599px) { - div.fichehalfleft-lg { - float: none; - width: auto; - } - div.fichehalfright-lg { - float: none; - width: auto; - } + div.fichehalfleft-lg { + float: none; + width: auto; + } + div.fichehalfright-lg { + float: none; + width: auto; + } - .fichehalfright-lg .fichehalfright { - padding-left:0; - } + .fichehalfright-lg .fichehalfright { + padding-left:0; + } } /* For table into table into card */ div.fichehalfright tr.liste_titre:first-child td table.nobordernopadding td { - padding: 0 0 0 0; + padding: 0 0 0 0; } div.nopadding { padding: 0 !important; @@ -1885,28 +1915,28 @@ div.nopadding { } td.nobordernopadding.widthpictotitle.col-picto { - color: #bbb; - opacity: 0.85; + color: #bbb; + opacity: 0.85; } .table-list-of-attached-files .col-picto, .table-list-of-links .col-picto { - opacity: 0.7 !important; - font-size: 0.7em; - width: 20px; + opacity: 0.7 !important; + font-size: 0.7em; + width: 20px; } .table-list-of-attached-files .col-picto .widthpictotitle, .table-list-of-links .col-picto .widthpictotitle { width: unset; - color: #999; + color: #999; } /* span.widthpictotitle.pictotitle { - background: var(--colortexttitlenotab); - opacity: 0.8; - color: #fff !important; - padding: 7px; - border-radius: 2px; - min-width: 30px; - text-align: center; + background: var(--colortexttitlenotab); + opacity: 0.8; + color: #fff !important; + padding: 7px; + border-radius: 2px; + min-width: 30px; + text-align: center; } */ .pictotitle { @@ -1918,8 +1948,8 @@ span.widthpictotitle.pictotitle { width: 14px; } .pictosubstatus { - padding-left: 2px; - padding-right: 2px; + padding-left: 2px; + padding-right: 2px; } .pictostatus { width: 15px; @@ -1927,14 +1957,14 @@ span.widthpictotitle.pictotitle { margin-top: -3px } .pictowarning, .pictoerror, .pictopreview { - padding-<?php echo $left; ?>: 3px; + padding-<?php echo $left; ?>: 3px; } .pictowarning { - /* vertical-align: text-bottom; */ - color: <?php echo $badgeWarning ?>; + /* vertical-align: text-bottom; */ + color: <?php echo $badgeWarning ?>; } .pictoerror { - color: <?php echo $badgeDanger ?>; + color: <?php echo $badgeDanger ?>; } .pictomodule { width: 14px; @@ -1945,12 +1975,12 @@ span.widthpictotitle.pictotitle { .fiche .arearef img.pictoedit, .fiche .arearef span.pictoedit, .fiche .fichecenter img.pictoedit, .fiche .fichecenter span.pictoedit, .tagtdnote span.pictoedit { - opacity: 0.4; + opacity: 0.4; } .pictofixedwidth { - text-align: left; - width: 18px; - padding-right: 0; + text-align: left; + width: 18px; + padding-right: 0; } .colorthumb { @@ -1990,9 +2020,9 @@ div.paginationref { } /* TODO div.statusref { - padding: 10px; - border: 1px solid #bbb; - border-radius: 6px; + padding: 10px; + border: 1px solid #bbb; + border-radius: 6px; } */ div.statusref { float: right; @@ -2000,33 +2030,33 @@ div.statusref { margin-top: 8px; margin-bottom: 10px; clear: both; - text-align: right; + text-align: right; } div.statusref img { - padding-left: 8px; - padding-right: 9px; - vertical-align: text-bottom; - width: 18px; + padding-left: 8px; + padding-right: 9px; + vertical-align: text-bottom; + width: 18px; } div.statusrefbis { - padding-left: 8px; - padding-right: 9px; - vertical-align: text-bottom; + padding-left: 8px; + padding-right: 9px; + vertical-align: text-bottom; } img.photoref, div.photoref { /* border: 1px solid #DDD; */ - -webkit-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); - box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); - padding: 4px; + -webkit-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); + box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); + padding: 4px; height: 80px; width: 80px; - object-fit: contain; + object-fit: contain; } div.photoref .fa, div.photoref .fas, div.photoref .far { font-size: 2.5em; } img.fitcontain { - object-fit: contain; + object-fit: contain; } div.photoref { display:table-cell; @@ -2034,12 +2064,12 @@ div.photoref { text-align:center; } img.photorefnoborder { - padding: 2px; + padding: 2px; height: 48px; width: 48px; - object-fit: contain; - border: 1px solid #AAA; - border-radius: 100px; + object-fit: contain; + border: 1px solid #AAA; + border-radius: 100px; } .underrefbanner { } @@ -2048,8 +2078,8 @@ img.photorefnoborder { /* border-bottom: 2px solid var(--colorbackhmenu1); */ } .trextrafieldseparator td, .trextrafields_collapse_last td { - /* border-bottom: 2px solid var(--colorbackhmenu1) !important; */ - border-bottom: 2px solid rgb(<?php echo $colortopbordertitle1 ?>) !important; + /* border-bottom: 2px solid var(--colorbackhmenu1) !important; */ + border-bottom: 2px solid rgb(<?php echo $colortopbordertitle1 ?>) !important; } .tdhrthin { @@ -2079,12 +2109,12 @@ div#tmenu_tooltip { <?php } ?> -webkit-touch-callout: none; /* iOS Safari */ - -webkit-user-select: none; /* Safari */ - -khtml-user-select: none; /* Konqueror HTML */ - -moz-user-select: none; /* Firefox */ - -ms-user-select: none; /* Internet Explorer/Edge */ - user-select: none; /* Non-prefixed version, currently - supported by Chrome and Opera */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Non-prefixed version, currently + supported by Chrome and Opera */ } @@ -2099,25 +2129,25 @@ div.tmenudiv { <?php if (GETPOST('optioncss', 'aZ09') == 'print') { ?> display:none; <?php } else { ?> - position: relative; - display: block; - white-space: nowrap; - border-top: 0px; - border-<?php print $left; ?>: 0px; - border-<?php print $right; ?>: 0px; - padding: 0px 0px 0px 0px; /* t r b l */ - margin: 0px 0px 0px 0px; /* t r b l */ + position: relative; + display: block; + white-space: nowrap; + border-top: 0px; + border-<?php print $left; ?>: 0px; + border-<?php print $right; ?>: 0px; + padding: 0px 0px 0px 0px; /* t r b l */ + margin: 0px 0px 0px 0px; /* t r b l */ font-size: 13px; - font-weight: normal; + font-weight: normal; color: #000000; - text-decoration: none; + text-decoration: none; <?php } ?> } div.tmenudisabled, a.tmenudisabled { opacity: 0.6; } a.tmenu, a.tmenusel, a.tmenudisabled { - /* font-weight: 300; */ + /* font-weight: 300; */ } a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudisabled:active { padding: 0px 5px 0px 5px; @@ -2131,7 +2161,7 @@ a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { padding: 0px 2px 0px 2px; white-space: nowrap; color: var(--colortextbackhmenu); - text-decoration: none; + text-decoration: none; } a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active { padding: 0px 4px 0px 4px; @@ -2143,8 +2173,8 @@ a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active { ul.tmenu { /* t r b l */ - padding: 0px 0px 0px 0px; - margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; list-style: none; display: table; } @@ -2156,7 +2186,7 @@ li.tmenu, li.tmenusel { vertical-align: bottom; <?php if (empty($conf->global->MAIN_MENU_INVERT)) { ?> float: <?php print $left; ?>; - <?php } ?> + <?php } ?> position:relative; display: block; padding: 0 0 0 0; @@ -2204,9 +2234,9 @@ div.tmenucenter height: 26px; <?php } else { ?> padding-top: 2px; - height: <?php print $heightmenu; ?>px; + height: <?php print $heightmenu; ?>px; <?php } ?> - /* width: 100%; */ + /* width: 100%; */ } #menu_titre_logo { padding-top: 0; @@ -2216,8 +2246,8 @@ div.menu_titre { padding-top: 4px; padding-bottom: 4px; overflow: hidden; - text-overflow: ellipsis; - width: 188px; /* required to have overflow working. must be same than menu_contenu */ + text-overflow: ellipsis; + width: 188px; /* required to have overflow working. must be same than menu_contenu */ } .mainmenuaspan { @@ -2237,10 +2267,10 @@ div.mainmenu { } a.tmenuimage:focus, .mainmenu.topmenuimage:focus { - outline: none; + outline: none; } button.ui-button.ui-corner-all.ui-widget:focus { - outline: none; + outline: none; } /* For mainmenu, we always load the img */ @@ -2250,10 +2280,10 @@ div.mainmenu.menu { <?php print $disableimages ? '' : 'top: 7px'; ?> } #mainmenutd_menu a.tmenuimage { - display: unset; + display: unset; } a.tmenuimage { - display: block; + display: block; } a.tmenuimage:hover{ @@ -2266,9 +2296,9 @@ a.tmenuimage:hover{ /* Do not load menu img for other if hidden to save bandwidth */ <?php if (empty($dol_hide_topmenu)) { ?> - <?php include dol_buildpath($path.'/theme/'.$theme.'/main_menu_fa_icons.inc.php', 0); ?> + <?php include dol_buildpath($path.'/theme/'.$theme.'/main_menu_fa_icons.inc.php', 0); ?> - <?php + <?php // Add here more div for other menu entries. moduletomainmenu=array('module name'=>'name of class for div') $moduletomainmenu = array( @@ -2280,8 +2310,7 @@ a.tmenuimage:hover{ 'barcode'=>'', 'fckeditor'=>'', 'categorie'=>'', ); $mainmenuused = 'home'; - foreach ($conf->modules as $val) - { + foreach ($conf->modules as $val) { $mainmenuused .= ','.(isset($moduletomainmenu[$val]) ? $moduletomainmenu[$val] : $val); } $mainmenuusedarray = array_unique(explode(',', $mainmenuused)); @@ -2291,29 +2320,29 @@ a.tmenuimage:hover{ $divalreadydefined = array('home', 'companies', 'products', 'mrp', 'commercial', 'externalsite', 'accountancy', 'project', 'tools', 'members', 'agenda', 'ftp', 'holiday', 'hrm', 'bookmark', 'cashdesk', 'takepos', 'ecm', 'geoipmaxmind', 'gravatar', 'clicktodial', 'paypal', 'stripe', 'webservices', 'website'); // Put here list of menu entries we are sure we don't want $divnotrequired = array('multicurrency', 'salaries', 'ticket', 'margin', 'opensurvey', 'paybox', 'expensereport', 'incoterm', 'prelevement', 'propal', 'workflow', 'notification', 'supplier_proposal', 'cron', 'product', 'productbatch', 'expedition'); - foreach ($mainmenuusedarray as $val) - { - if (empty($val) || in_array($val, $divalreadydefined)) continue; - if (in_array($val, $divnotrequired)) continue; + foreach ($mainmenuusedarray as $val) { + if (empty($val) || in_array($val, $divalreadydefined)) { + continue; + } + if (in_array($val, $divnotrequired)) { + continue; + } //print "XXX".$val; // Search img file in module dir $found = 0; $url = ''; - foreach ($conf->file->dol_document_root as $dirroot) - { - if (file_exists($dirroot."/".$val."/img/".$val.".png")) - { + foreach ($conf->file->dol_document_root as $dirroot) { + if (file_exists($dirroot."/".$val."/img/".$val.".png")) { $url = dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); $found = 1; break; } } // Img file not found - if (!$found) - { + if (!$found) { if (!defined('DISABLE_FONT_AWSOME')) { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one. */\n"; - print "/* Overwrite this definition in your own css with a different content to use your own font awesome icon. */\n"; + print "/* Overwrite this definition in your own css with a different content to use your own font awesome icon. */\n"; print 'div.mainmenu.'.$val.'::before { content: "\f249"; }'."\n"; @@ -2336,11 +2365,11 @@ a.tmenuimage:hover{ <?php } // End test if $dol_hide_topmenu ?> .tmenuimage { - padding:0 0 0 0 !important; - margin:0 0px 0 0 !important; - <?php if ($disableimages) { ?> - display: none; - <?php } ?> + padding:0 0 0 0 !important; + margin:0 0px 0 0 !important; + <?php if ($disableimages) { ?> + display: none; + <?php } ?> } @@ -2351,14 +2380,14 @@ a.tmenuimage:hover{ { background: #f0f0f0; display: table; - position: absolute; - height: 100%; - width: 100%; - font-size: 1em; + position: absolute; + height: 100%; + width: 100%; + font-size: 1em; } .login_center { display: table-cell; - vertical-align: middle; + vertical-align: middle; } .login_vertical_align { padding: 10px; @@ -2418,10 +2447,10 @@ if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { margin: 8px; } .login_table .tdinputlogin { - background-color: transparent; - /* border: 2px solid #ccc; */ - min-width: 220px; - border-radius: 2px; + background-color: transparent; + /* border: 2px solid #ccc; */ + min-width: 220px; + border-radius: 2px; } .login_table .tdinputlogin .fa { padding-left: 10px; @@ -2434,7 +2463,7 @@ if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { font-size: 1em; } .login_main_home { - word-break: break-word; + word-break: break-word; } .login_main_message { text-align: center; @@ -2455,7 +2484,7 @@ div#login_left, div#login_right { vertical-align: middle; } div#login_right select#entity { - margin-top: 10px; + margin-top: 10px; } table.login_table tr td table.none tr td { padding: 2px; @@ -2518,17 +2547,17 @@ div.login a:hover { text-decoration:underline; } .login_block_elem a span.atoplogin, .login_block_elem span.atoplogin { - vertical-align: middle; + vertical-align: middle; } div.login_block_user { display: inline-block; - vertical-align: middle; + vertical-align: middle; line-height: <?php echo $disableimages ? '25' : '50'; ?>px; height: <?php echo $disableimages ? '25' : '50'; ?>px; } div.login_block_other { display: inline-block; - vertical-align: middle; + vertical-align: middle; clear: <?php echo $disableimages ? 'none' : 'both'; ?>; padding-top: 0; text-align: right; @@ -2566,11 +2595,11 @@ div.login_block_other { text-decoration:underline !important; } span.fa.atoplogin, span.fa.atoplogin:hover { - font-size: 16px; - text-decoration: none !important; + font-size: 16px; + text-decoration: none !important; } .atoplogin #dropdown-icon-down, .atoplogin #dropdown-icon-up { - font-size: 0.7em; + font-size: 0.7em; } img.login, img.printer, img.entity { /* padding: 0px 0px 0px 4px; */ @@ -2581,33 +2610,33 @@ img.login, img.printer, img.entity { } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ width: <?php echo $disableimages ? '26' : '30'; ?>px; - height: <?php echo $disableimages ? '26' : '30'; ?>px; - border-radius: 50%; - background-size: contain; - background-size: contain; - border: 1px solid; - border-color: rgba(255, 255, 255, 0.2); + height: <?php echo $disableimages ? '26' : '30'; ?>px; + border-radius: 50%; + background-size: contain; + background-size: contain; + border: 1px solid; + border-color: rgba(255, 255, 255, 0.2); } img.userphoto { /* size for user photo in lists */ border-radius: 0.72em; width: 1.4em; - height: 1.4em; - background-size: contain; - vertical-align: middle; + height: 1.4em; + background-size: contain; + vertical-align: middle; } img.userphotosmall { /* size for user photo in lists */ border-radius: 0.6em; width: 1.2em; - height: 1.2em; - background-size: contain; - vertical-align: middle; - background-color: #FFF; + height: 1.2em; + background-size: contain; + vertical-align: middle; + background-color: #FFF; } img.userphoto[alt="Gravatar avatar"], img.photouserphoto.dropdown-user-image[alt="Gravatar avatar"] { - background: #fff; + background: #fff; } form[name="addtime"] img.userphoto { - border: 1px solid #444; + border: 1px solid #444; } .span-icon-user { background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/object_user.png', 1); ?>); @@ -2623,20 +2652,20 @@ form[name="addtime"] img.userphoto { /* ============================================================================== */ div.vmenu, td.vmenu { - margin-<?php print $right; ?>: 2px; - position: relative; - float: left; - padding: 0px; - padding-bottom: 0px; - padding-top: 1px; - width: 190px; + margin-<?php print $right; ?>: 2px; + position: relative; + float: left; + padding: 0px; + padding-bottom: 0px; + padding-top: 1px; + width: 190px; } .vmenu { - width: 190px; + width: 190px; margin-left: 6px; <?php if (GETPOST('optioncss', 'aZ09') == 'print') { ?> - display: none; + display: none; <?php } ?> } @@ -2652,8 +2681,8 @@ input.vmenusearchselectcombo[type=text] { padding-top: 3px; padding-bottom: 3px; overflow: hidden; - text-overflow: ellipsis; - width: 188px; /* required to have overflow working. must be same than .menu_titre */ + text-overflow: ellipsis; + width: 188px; /* required to have overflow working. must be same than .menu_titre */ } #menu_contenu_logo { /* padding-top: 0; */ } .companylogo { } @@ -2686,22 +2715,22 @@ a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align /* color: #f3e4ac !important; */ } .helppresentcircle { - color: var(--colorbackhmenu1); - filter: invert(0.8); - margin-left: -7px; - display: inline-block; - margin-top: -10px; - font-size: x-small; - vertical-align: super; - opacity: 0.95; + color: var(--colorbackhmenu1); + filter: invert(0.8); + margin-left: -7px; + display: inline-block; + margin-top: -10px; + font-size: x-small; + vertical-align: super; + opacity: 0.95; } .vmenu div.blockvmenufirst, .vmenu div.blockvmenulogo, .vmenu div.blockvmenusearchphone, .vmenu div.blockvmenubookmarks { - border-top: 1px solid #BBB; + border-top: 1px solid #BBB; } a.vsmenu.addbookmarkpicto { - padding-right: 10px; + padding-right: 10px; } div.blockvmenusearchphone { @@ -2735,16 +2764,16 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks, div.blockvmen color: #000000; text-align: <?php print $left; ?>; text-decoration: none; - padding-left: 5px; - padding-right: 1px; - padding-top: 4px; - padding-bottom: 7px; - margin: 0 0 0 2px; + padding-left: 5px; + padding-right: 1px; + padding-top: 4px; + padding-bottom: 7px; + margin: 0 0 0 2px; background: var(--colorbackvmenu1); - border-left: 1px solid #AAA; - border-right: 1px solid #BBB; + border-left: 1px solid #AAA; + border-right: 1px solid #BBB; } div.blockvmenusearch @@ -2753,7 +2782,7 @@ div.blockvmenusearch color: #000000; text-align: <?php print $left; ?>; text-decoration: none; - margin: 1px 0px 0px 2px; + margin: 1px 0px 0px 2px; background: var(--colorbackvmenu1); } @@ -2771,13 +2800,13 @@ div.blockvmenuhelp color: #000000; text-align: center; text-decoration: none; - padding-left: 0px; - padding-right: 6px; - padding-top: 3px; - padding-bottom: 3px; - margin: 4px 0px 0px 0px; + padding-left: 0px; + padding-right: 6px; + padding-top: 3px; + padding-bottom: 3px; + margin: 4px 0px 0px 0px; <?php } else { ?> - display: none; + display: none; <?php } ?> } @@ -2800,7 +2829,7 @@ td.barre_select { td.photo { background: #F4F4F4; color: #000000; - border: 1px solid #bbb; + border: 1px solid #bbb; } /* ============================================================================== */ @@ -2812,14 +2841,14 @@ td.photo { */ #mainContent, #leftContent .ui-layout-pane { - padding: 0px; - overflow: auto; + padding: 0px; + overflow: auto; } #mainContent, #leftContent .ui-layout-center { padding: 0px; position: relative; /* contain floated or positioned elements */ - overflow: auto; /* add scrolling to content-div */ + overflow: auto; /* add scrolling to content-div */ } @@ -2828,29 +2857,29 @@ td.photo { /* ============================================================================== */ td.ecmroot { - padding-bottom: 0 !important; + padding-bottom: 0 !important; } .largebutton { /* border-top: 1px solid #CCC !important; */ - padding: 0px 4px 14px 4px !important; - min-height: 32px; + padding: 0px 4px 14px 4px !important; + min-height: 32px; } a.toolbarbutton { - margin-top: 0px; - margin-left: 4px; - margin-right: 4px; - height: 30px; + margin-top: 0px; + margin-left: 4px; + margin-right: 4px; + height: 30px; } img.toolbarbutton { margin-top: 1px; - height: 30px; + height: 30px; } li.expanded > a.fmdirlia.jqft.ecmjqft { - font-weight: bold !important; + font-weight: bold !important; } @@ -2860,10 +2889,10 @@ li.expanded > a.fmdirlia.jqft.ecmjqft { /* Onglets */ /* ============================================================================== */ div.tabs { - text-align: <?php print $left; ?>; - margin-top: 10px; - padding-left: 6px; - padding-right: 6px; + text-align: <?php print $left; ?>; + margin-top: 10px; + padding-left: 6px; + padding-right: 6px; clear:both; height:100%; } @@ -2872,20 +2901,20 @@ div.tabsElem { } /* To avoid overlap of tabs when not browser */ /* div.tabsElem a.tabactive::before, div.tabsElem a.tabunactive::before { - content: "\f0da"; - font-family: "Font Awesome 5 Free"; - padding-right: 2px; - font-weight: 900; + content: "\f0da"; + font-family: "Font Awesome 5 Free"; + padding-right: 2px; + font-weight: 900; } */ div.tabBar { - color: var(--colortextbacktab); - padding-top: 16px; - padding-left: 0px; padding-right: 0px; - padding-bottom: 2px; - margin: 0px 0px 16px 0px; - border-top: 1px solid #BBB; - /* border-bottom: 1px solid #AAA; */ + color: var(--colortextbacktab); + padding-top: 16px; + padding-left: 0px; padding-right: 0px; + padding-bottom: 2px; + margin: 0px 0px 16px 0px; + border-top: 1px solid #BBB; + /* border-bottom: 1px solid #AAA; */ width: auto; background: var(--colorbacktabcard1); } @@ -2897,8 +2926,8 @@ div.fiche table:not(.table-fiche-title) tr.titre td { } div.tabBar.tabBarNoTop { - padding-top: 0; - border-top: 0; + padding-top: 0; + border-top: 0; } /* tabBar used for creation/update/send forms */ @@ -2914,11 +2943,11 @@ div.tabBarWithBottom table.border>tbody>tr:last-of-type>td { } div.tabBar table.tableforservicepart2:last-child { - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } .tableforservicepart1 .tdhrthin { height: unset; - padding-top: 0 !important; + padding-top: 0 !important; } /* Payment Screen : Pointer cursor in the autofill image */ .AutoFillAmount { @@ -2942,26 +2971,26 @@ div.popuptab { /* ============================================================================== */ div.tabsAction { - margin: 20px 0em 30px 0em; - padding: 0em 0em; - text-align: right; + margin: 20px 0em 30px 0em; + padding: 0em 0em; + text-align: right; } div.tabsActionNoBottom { - margin-bottom: 0px; + margin-bottom: 0px; } div.tabsAction > a { margin-bottom: 16px !important; } a.tabTitle { - color: rgba(0,0,0,0.4) !important; - text-shadow:1px 1px 1px #ffffff; + color: rgba(0,0,0,0.4) !important; + text-shadow:1px 1px 1px #ffffff; font-family: <?php print $fontlist ?>; font-weight: normal !important; - padding: 4px 6px 2px 0px; - margin-<?php print $right; ?>: 10px; - text-decoration: none; - white-space: nowrap; + padding: 4px 6px 2px 0px; + margin-<?php print $right; ?>: 10px; + text-decoration: none; + white-space: nowrap; } .tabTitleText { display: none; @@ -2970,18 +2999,18 @@ a.tabTitle { max-height: 14px; } div.tabs div.tabsElem:first-of-type a.tab { - margin-left: 0px !important; + margin-left: 0px !important; } a.tabunactive { - color: var(--colortextlink) !important; + color: var(--colortextlink) !important; } a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { font-family: <?php print $fontlist ?>; padding: 12px 14px 13px; - margin: 0em 0.2em; - text-decoration: none; - white-space: nowrap; + margin: 0em 0.2em; + text-decoration: none; + white-space: nowrap; /*border-right: 1px solid #ddd; border-left: 1px solid #ddd; @@ -3011,30 +3040,30 @@ a.tab:hover text-decoration: underline; } a.tabimage { - color: #434956; + color: #434956; font-family: <?php print $fontlist ?>; - text-decoration: none; - white-space: nowrap; + text-decoration: none; + white-space: nowrap; } td.tab { - background: #dee7ec; + background: #dee7ec; } span.tabspan { - background: #dee7ec; - color: #434956; + background: #dee7ec; + color: #434956; font-family: <?php print $fontlist ?>; - padding: 0px 6px; - margin: 0em 0.2em; - text-decoration: none; - white-space: nowrap; + padding: 0px 6px; + margin: 0em 0.2em; + text-decoration: none; + white-space: nowrap; -webkit-border-radius:4px 4px 0px 0px; border-radius:4px 4px 0px 0px; - border-<?php print $right; ?>: 1px solid #555555; - border-<?php print $left; ?>: 1px solid #D8D8D8; - border-top: 1px solid #D8D8D8; + border-<?php print $right; ?>: 1px solid #555555; + border-<?php print $left; ?>: 1px solid #D8D8D8; + border-top: 1px solid #D8D8D8; } /* ============================================================================== */ @@ -3082,10 +3111,10 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd } .smallpaddingimp { - padding: 4px !important; + padding: 4px !important; } input.button.smallpaddingimp { - font-size: 0.8em; + font-size: 0.8em; } .nopaddingleft { padding-<?php print $left; ?>: 0px; @@ -3122,8 +3151,8 @@ div.tabs.nopaddingleft { } table.tableforemailform tr td { - padding-top: 3px; - padding-bottom: 3px; + padding-top: 3px; + padding-bottom: 3px; } table.border, table.bordernooddeven, table.dataTable, .table-border, .table-border-col, .table-key-border-col, .table-val-border-col, div.border { @@ -3137,14 +3166,14 @@ table.borderplus { height: 22px; } tr.liste_titre.box_titre td table td, .bordernooddeven tr td { - height: 22px; + height: 22px; } div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar .table-val-border-col { vertical-align: middle; } div .tdtop { - vertical-align: top !important; + vertical-align: top !important; /*padding-top: 10px !important; padding-bottom: 2px !important; */ } @@ -3176,10 +3205,10 @@ td.border, div.tagtable div div.border { /* Main boxes */ .nobordertop, .nobordertop tr:first-of-type td { - border-top: none !important; + border-top: none !important; } .noborderbottom, .noborderbottom tr:last-of-type td { - border-bottom: none !important; + border-bottom: none !important; } .bordertop { border-top: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); @@ -3202,14 +3231,14 @@ table.liste, table.noborder, table.formdoc, div.noborder { margin: 0px 0px 5px 0px; /*width: calc(100% - 7px); - border-collapse: separate !important; - border-spacing: 0px; - border-top-width: 0px; - border-top-color: rgb(215,215,215); - border-top-style: solid; - margin: 0px 0px 5px 2px; - box-shadow: 1px 1px 5px #ddd; - */ + border-collapse: separate !important; + border-spacing: 0px; + border-top-width: 0px; + border-top-color: rgb(215,215,215); + border-top-style: solid; + margin: 0px 0px 5px 2px; + box-shadow: 1px 1px 5px #ddd; + */ } #tablelines { border-bottom-width: 1px; @@ -3222,7 +3251,7 @@ table.liste tr:last-of-type td, table.noborder:not(#tablelines) tr:last-of-type border-bottom-style: solid; } div.tabBar div.fichehalfright table.noborder:not(.margintable):not(.paymenttable):not(.lastrecordtable):last-of-type { - border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); + border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); } div.tabBar table.border>tbody>tr:last-of-type>td { border-bottom-width: 1px; @@ -3230,7 +3259,7 @@ div.tabBar table.border>tbody>tr:last-of-type>td { border-bottom-style: solid; } div.tabBar div.fichehalfright table.noborder { - border-bottom: none; + border-bottom: none; } table.paddingtopbottomonly tr td { @@ -3241,11 +3270,11 @@ table.paddingtopbottomonly tr td { background: var(--colorbacktitle1) !important; } .liste_titre2 { - background: var(--colorbackhmenu1) !important; - color: #fff; + background: var(--colorbackhmenu1) !important; + color: #fff; } table:not(.listwithfilterbefore) tr.liste_titre_filter:first-of-type td.liste_titre { - padding-top: 5px; + padding-top: 5px; } tr.liste_titre_filter td.liste_titre { @@ -3258,19 +3287,19 @@ tr.liste_titre_filter td.liste_titre:first-of-type { } .liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd { - border-bottom-width: 0 !important; - border-top-width: 1px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-bottom-width: 0 !important; + border-top-width: 1px; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } tr#trlinefordates td { - border-bottom: 0px !important; + border-bottom: 0px !important; } .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd { - border-top-width: 1px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-width: 1px; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } table.liste tr, table.noborder tr, div.noborder form { border-top-color: #FEFEFE; @@ -3308,13 +3337,13 @@ table.border tr td table.nobordernopadding tr td { padding-bottom: 0; } td.borderright { - border: none; /* to erase value for table.nobordernopadding td */ + border: none; /* to erase value for table.nobordernopadding td */ border-right-width: 1px !important; border-right-color: #BBB !important; border-right-style: solid !important; } td.borderleft { - border: none; /* to erase value for table.nobordernopadding td */ + border: none; /* to erase value for table.nobordernopadding td */ border-left-width: 1px !important; border-left-color: #BBB !important; border-left-style: solid !important; @@ -3339,19 +3368,19 @@ div.refidpadding { } div.refid { font-weight: bold; - color: var(--colortexttitlenotab); - font-size: 1.2em; - word-break: break-word; + color: var(--colortexttitlenotab); + font-size: 1.2em; + word-break: break-word; } div.refidno { padding-top: 3px; font-weight: normal; - color: var(--refidnocolor); - font-size: <?php print is_numeric($fontsize) ? $fontsize.'px' : $fontsize ?>; - line-height: 21px; + color: var(--refidnocolor); + font-size: <?php print is_numeric($fontsize) ? $fontsize.'px' : $fontsize ?>; + line-height: 21px; } div.refidno form { - display: inline-block; + display: inline-block; } div.pagination { @@ -3361,10 +3390,10 @@ div.pagination a { font-weight: normal; } /*div.pagination a.butAction, div.fichehalfright a.butAction { - margin-right: 0px !important; + margin-right: 0px !important; } div.tabsAction a.butActionDelete:last-child, div.tabsAction a.butAction:last-child { - margin-right: 0px !important; + margin-right: 0px !important; }*/ div.pagination ul { @@ -3402,8 +3431,8 @@ div.pagination li.pagination span.inactive { li.noborder.litext, li.noborder.litext a, div.pagination li a.inactive:hover, div.pagination li span.inactive:hover { - -webkit-box-shadow: none !important; - box-shadow: none !important; + -webkit-box-shadow: none !important; + box-shadow: none !important; } /*div.pagination li.litext { padding-top: 8px; @@ -3491,15 +3520,15 @@ table.hidepaginationnext .paginationnext { display: none; } .tabBar .arearef .pagination.paginationref { - max-width: calc(30%); + max-width: calc(30%); } .paginationafterarrows a.btnTitlePlus, .titre_right a.btnTitlePlus { - border: 1px solid var(--btncolorborder); + border: 1px solid var(--btncolorborder); } .paginationafterarrows a.btnTitlePlus:hover span:before, .titre_right a.btnTitlePlus:hover span:before { - /* text-shadow: 0px 0px 5px #ccc; */ - /* filter: invert(0.3); */ - font-size: 1.07em; + /* text-shadow: 0px 0px 5px #ccc; */ + /* filter: invert(0.3); */ + font-size: 1.07em; } @@ -3515,7 +3544,7 @@ table.hidepaginationnext .paginationnext { } .treditedlinefordate { background: var(--colorbacklinepairchecked) !important; /* Must be background to be stronger than background of odd or even */ - border-bottom: 0px; + border-bottom: 0px; } <?php if ($colorbacklinepairchecked) { ?> .highlight { @@ -3566,34 +3595,34 @@ td.evenodd, tr.nohoverpair td, #trlinefordates td { } .trforbreak td { font-weight: 500; - border-bottom: 1pt solid black !important; + border-bottom: 1pt solid black !important; background-color: var(--colorbacklinebreak) !important; } .trforbreak.nobold td a, .trforbreak.nobold span.secondary { - font-weight: normal !important; + font-weight: normal !important; } table.dataTable td { - padding: 5px 8px 5px 8px !important; + padding: 5px 8px 5px 8px !important; } tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd { - padding: 7px 8px 7px 8px; - border-bottom: 1px solid #ddd; + padding: 7px 8px 7px 8px; + border-bottom: 1px solid #ddd; } form.pair, form.impair { font-weight: normal; } form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-type td { - border-bottom: 0px !important; + border-bottom: 0px !important; } tr.nobottom td { - border-bottom: 0px !important; + border-bottom: 0px !important; } div.tableforcontact form.tagtr:last-of-type div.tagtd { - border-bottom: 1px solid #ddd !important; + border-bottom: 1px solid #ddd !important; } tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { - border-bottom: 0px !important; + border-bottom: 0px !important; } table.nobottomiftotal tr.liste_total td { background-color: #fff; @@ -3613,8 +3642,8 @@ div.liste_titre { } div.liste_titre_bydiv { border-top-width: <?php echo $borderwidth ?>px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; border-collapse: collapse; display: table; @@ -3639,9 +3668,9 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se background: var(--colorbacktitle1); font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - color: var(--colortexttitle); - font-family: <?php print $fontlist ?>; - text-align: <?php echo $left; ?>; + color: var(--colortexttitle); + font-family: <?php print $fontlist ?>; + text-align: <?php echo $left; ?>; } tr.liste_titre th, tr.liste_titre td, th.liste_titre { @@ -3653,10 +3682,10 @@ tr.liste_titre:first-child th, tr:first-child th.liste_titre { } tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste_titre div { - font-family: <?php print $fontlist ?>; - font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - vertical-align: middle; - height: 24px; + font-family: <?php print $fontlist ?>; + font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; + vertical-align: middle; + height: 24px; } tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a { text-shadow: none !important; @@ -3664,8 +3693,8 @@ tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, fo } tr.liste_titre_topborder td { border-top-width: <?php echo $borderwidth; ?>px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } .liste_titre td a { text-shadow: none !important; @@ -3678,8 +3707,8 @@ tr.liste_titre_topborder td { background: transparent; } tr.liste_titre:last-child th.liste_titre, tr.liste_titre:last-child th.liste_titre_sel, tr.liste_titre td.liste_titre, tr.liste_titre td.liste_titre_sel, form.liste_titre div.tagtd { /* For last line of table headers only */ - /* border-bottom: 1px solid #ddd; */ - border-bottom: unset; + /* border-bottom: 1px solid #ddd; */ + border-bottom: unset; } div.liste_titre { @@ -3687,30 +3716,30 @@ div.liste_titre { } tr.liste_titre_sel th, th.liste_titre_sel, tr.liste_titre_sel td, td.liste_titre_sel, form.liste_titre_sel div { - font-family: <?php print $fontlist ?>; - font-weight: normal; - border-bottom: 1px solid #FDFFFF; - text-decoration: underline; + font-family: <?php print $fontlist ?>; + font-weight: normal; + border-bottom: 1px solid #FDFFFF; + text-decoration: underline; } input.liste_titre { - background: transparent; - border: 0px; + background: transparent; + border: 0px; } .listactionlargetitle .liste_titre { line-height: 24px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div, .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { - color: var(--listetotal); - font-weight: normal; + color: var(--listetotal); + font-weight: normal; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { - white-space: nowrap; + white-space: nowrap; } .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { white-space: normal; } form.liste_total div { - border-top: 1px solid #DDDDDD; + border-top: 1px solid #DDDDDD; } tr.liste_sub_total, tr.liste_sub_total td { border-bottom: 1px solid #aaa; @@ -3723,10 +3752,10 @@ tr.liste_sub_total, tr.liste_sub_total td { border-bottom: none; } table.tableforservicepart1:first-of-type tr:first-of-type td { - border-top: 1px solid #888; + border-top: 1px solid #888; } table.tableforservicepart1 tr td { - border-top: 0px; + border-top: 0px; } .paymenttable, .margintable { @@ -3734,7 +3763,7 @@ table.tableforservicepart1 tr td { margin: 0px 0px 0px 0px !important; } table.noborder.paymenttable { - border-bottom: none !important; + border-bottom: none !important; } .paymenttable tr td:first-child, .margintable tr td:first-child { @@ -3763,7 +3792,7 @@ div.tabBar .noborder { border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>) !important; } #tablelines tr td { - height: unset; + height: unset; } /* Prepare to remove class pair - impair */ @@ -3810,48 +3839,48 @@ ul.noborder li:nth-child(even):not(.liste_titre) { */ .box { - overflow-x: auto; - min-height: 40px; - padding-right: 0px; - padding-left: 0px; - padding-bottom: 10px; + overflow-x: auto; + min-height: 40px; + padding-right: 0px; + padding-left: 0px; + padding-bottom: 10px; } .ficheaddleft div.boxstats, .ficheaddright div.boxstats { - border: none; + border: none; } .boxstatsborder { - /* border: 1px solid #CCC !important; */ + /* border: 1px solid #CCC !important; */ } .boxstats, .boxstats130 { - display: inline-block; - margin-left: 8px; - margin-right: 8px; - margin-top: 5px; - margin-bottom: 5px; - text-align: center; + display: inline-block; + margin-left: 8px; + margin-right: 8px; + margin-top: 5px; + margin-bottom: 5px; + text-align: center; - background: var(--colorbackbody); - border: 1px solid var(--colorboxstatsborder); - border-left: 6px solid var(--colorboxstatsborder); - /* box-shadow: 1px 1px 8px var(--colorboxstatsborder); */ - border-radius: 0px; + background: var(--colorbackbody); + border: 1px solid var(--colorboxstatsborder); + border-left: 6px solid var(--colorboxstatsborder); + /* box-shadow: 1px 1px 8px var(--colorboxstatsborder); */ + border-radius: 0px; } .boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; + text-overflow: ellipsis; } .boxstats130 { - width: 100%; - height: 59px; - /* padding: 3px; */ + width: 100%; + height: 59px; + /* padding: 3px; */ } .boxstats { - padding-left: 6px; - padding-right: 6px; - padding-top: 2px; - padding-bottom: 2px; - width: 118px; + padding-left: 6px; + padding-right: 6px; + padding-top: 2px; + padding-bottom: 2px; + width: 118px; } .boxtable:not(.widgetstats) td.tdboxstats .boxstats { @@ -3859,37 +3888,37 @@ ul.noborder li:nth-child(even):not(.liste_titre) { } .tabBar .fichehalfright .boxstats { - padding-top: 8px; - padding-bottom: 4px; + padding-top: 8px; + padding-bottom: 4px; } .boxstatscontent { padding: 3px; } .boxstatsempty { - width: 121px; - padding-left: 3px; - padding-right: 3px; - margin-left: 8px; - margin-right: 8px; + width: 121px; + padding-left: 3px; + padding-right: 3px; + margin-left: 8px; + margin-right: 8px; } .boxstats150empty { - width: 158px; - padding-left: 3px; - padding-right: 3px; - margin-left: 8px; - margin-right: 8px; + width: 158px; + padding-left: 3px; + padding-right: 3px; + margin-left: 8px; + margin-right: 8px; } @media only screen and (max-width: 767px) { .tabBar .arearef .pagination.paginationref { - max-width: calc(50%); + max-width: calc(50%); } .clearbothonsmartphone { - clear: both; - display: block !important; + clear: both; + display: block !important; } div.tabs { @@ -3910,31 +3939,31 @@ ul.noborder li:nth-child(even):not(.liste_titre) { } .boxstats, .boxstats130 { margin: 3px; - } - .boxstats130 { - text-align: <?php echo $left; ?> - } + } + .boxstats130 { + text-align: <?php echo $left; ?> + } .thumbstat { flex: 1 1 110px; margin-bottom: 8px; - min-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(160, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 150; ?>px; /* on screen < 320, we guaranty to have 2 columns */ + min-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(160, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 150; ?>px; /* on screen < 320, we guaranty to have 2 columns */ } .thumbstat150 { flex: 1 1 110px; margin-bottom: 8px; - min-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(160, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 160; ?>px; /* on screen < 320, we guaranty to have 2 columns */ - max-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(161, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 161; ?>px; /* on screen < 320, we guaranty to have 2 columns */ - /* width: ...px; If I use with, there is trouble on size of flex boxes solved with min + (max that is a little bit higer than min) */ + min-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(160, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 160; ?>px; /* on screen < 320, we guaranty to have 2 columns */ + max-width: <?php echo isset($_SESSION['dol_screenwidth']) ?min(161, round($_SESSION['dol_screenwidth'] / 2 - 20)) : 161; ?>px; /* on screen < 320, we guaranty to have 2 columns */ + /* width: ...px; If I use with, there is trouble on size of flex boxes solved with min + (max that is a little bit higer than min) */ } - .dashboardlineindicator { - float: left; - padding-left: 5px; - } - .boxstats { - width: 111px; - } - .boxstatsempty { - width: 111px; + .dashboardlineindicator { + float: left; + padding-left: 5px; + } + .boxstats { + width: 111px; + } + .boxstatsempty { + width: 111px; } } @@ -3946,8 +3975,8 @@ span.boxstatstext span:not(.fas) { opacity: 0.5; } span.boxstatstext { - line-height: 18px; - color: var(--colortext); + line-height: 18px; + color: var(--colortext); } span.boxstatstext img, a.dashboardlineindicatorlate img { border: 0; @@ -3985,42 +4014,42 @@ span.dashboardlineko { .dashboardlinelatecoin { float: right; position: relative; - text-align: right; - top: -27px; - right: 2px; - padding: 0px 5px 0px 5px; - border-radius: .25em; + text-align: right; + top: -27px; + right: 2px; + padding: 0px 5px 0px 5px; + border-radius: .25em; - background-color: #9f4705; + background-color: #9f4705; } .imglatecoin { - padding: 1px 3px 1px 1px; - margin-left: 4px; - margin-right: 2px; - background-color: #8c4446; - color: #FFFFFF ! important; - border-radius: .25em; + padding: 1px 3px 1px 1px; + margin-left: 4px; + margin-right: 2px; + background-color: #8c4446; + color: #FFFFFF ! important; + border-radius: .25em; display: inline-block; vertical-align: middle; } .boxtable { - margin-bottom: 25px !important; - border-bottom-width: 1px; + margin-bottom: 25px !important; + border-bottom-width: 1px; background: var(--colorbackbody); - border-top: <?php echo $borderwidth ?>px solid rgb(<?php echo $colortopbordertitle1 ?>); + border-top: <?php echo $borderwidth ?>px solid rgb(<?php echo $colortopbordertitle1 ?>); /* border-top: 2px solid var(--colorbackhmenu1) !important; */ } table.noborder.boxtable tr td { - height: unset; + height: unset; } .boxtablenotop { - border-top-width: 0 !important; + border-top-width: 0 !important; } .boxtablenobottom { - border-bottom-width: 0 !important; + border-bottom-width: 0 !important; } .boxtable .fichehalfright, .boxtable .fichehalfleft { - min-width: 275px; /* increasing this, make chart on box not side by side on laptops */ + min-width: 275px; /* increasing this, make chart on box not side by side on laptops */ } .tdboxstats { text-align: center; @@ -4030,23 +4059,23 @@ table.noborder.boxtable tr td { padding-right: 0px !important; } a.valignmiddle.dashboardlineindicator { - line-height: 30px; + line-height: 30px; } tr.box_titre { - height: 26px; + height: 26px; - /* TO MATCH BOOTSTRAP */ + /* TO MATCH BOOTSTRAP */ /*background: #ddd; color: #000 !important;*/ /* TO MATCH ELDY */ background: var(--colorbacktitle1); color: var(--colortexttitle); - font-family: <?php print $fontlist ?>, sans-serif; - font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - border-bottom: 1px solid #FDFFFF; - white-space: nowrap; + font-family: <?php print $fontlist ?>, sans-serif; + font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; + border-bottom: 1px solid #FDFFFF; + white-space: nowrap; } tr.box_titre td.boxclose { @@ -4070,8 +4099,8 @@ img.boxhandle, img.boxclose { margin-right: 1px; } .prod_entry_mode_free, .prod_entry_mode_predef { - height: 26px !important; - vertical-align: middle; + height: 26px !important; + vertical-align: middle; } .modulebuilderbox { @@ -4096,24 +4125,24 @@ div.ok { /* Info admin */ div.info { border-<?php print $left; ?>: solid 5px #87cfd2; - padding-top: 8px; - padding-left: 10px; - padding-right: 4px; - padding-bottom: 8px; - margin: 1em 0em 1em 0em; - background: #eff8fc; - color: #558; -} - -/* Warning message */ -div.warning { - border-<?php print $left; ?>: solid 5px #f2cf87; padding-top: 8px; padding-left: 10px; padding-right: 4px; padding-bottom: 8px; margin: 1em 0em 1em 0em; - background: #fcf8e3; + background: #eff8fc; + color: #558; +} + +/* Warning message */ +div.warning { + border-<?php print $left; ?>: solid 5px #f2cf87; + padding-top: 8px; + padding-left: 10px; + padding-right: 4px; + padding-bottom: 8px; + margin: 1em 0em 1em 0em; + background: #fcf8e3; } div.warning a, div.info a, div.error a { color: var(--colortextlink); @@ -4121,7 +4150,7 @@ div.warning a, div.info a, div.error a { /* Error message */ div.error { - border-<?php print $left; ?>: solid 5px #f28787; + border-<?php print $left; ?>: solid 5px #f28787; padding-top: 8px; padding-left: 10px; padding-right: 4px; @@ -4151,13 +4180,13 @@ a.impayee:hover { font-weight: bold; color: #550000; } */ .framecontent { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } .framecontent iframe { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } @@ -4166,11 +4195,11 @@ a.impayee:hover { font-weight: bold; color: #550000; } */ .opened-dash-board-wrap { - margin-bottom: 25px; + margin-bottom: 25px; } div.boximport { - min-height: unset; + min-height: unset; } .product_line_stock_ok { color: #002200; } @@ -4191,11 +4220,11 @@ div.dolgraph div.legend table tbody tr { height: auto; } td.legendColorBox { padding: 2px 2px 2px 0 !important; } td.legendLabel { padding: 2px 2px 2px 0 !important; } td.legendLabel { - text-align: <?php echo $left; ?>; + text-align: <?php echo $left; ?>; } label.radioprivate { - white-space: nowrap; + white-space: nowrap; } .photo { @@ -4206,7 +4235,7 @@ label.radioprivate { margin-top: 10px; } div.divphotoref > a > .photowithmargin { /* Margin right for photo not inside a div.photoref frame only */ - margin-right: 15px; + margin-right: 15px; } .photowithborder { border: 1px solid #f0f0f0; @@ -4229,33 +4258,33 @@ div.divphotoref > a > .photowithmargin { /* Margin right for photo not inside a { content:url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/nographyet.svg', 1) ?>); display: inline-block; - opacity: 0.1; - background-repeat: no-repeat; + opacity: 0.1; + background-repeat: no-repeat; } .nographyettext { - opacity: 0.5; + opacity: 0.5; } div.titre { font-size: 1.1em; text-decoration: none; padding-top: 5px; - padding-bottom: 5px; - font-weight: 400; + padding-bottom: 5px; + font-weight: 400; } div.fiche > table.table-fiche-title:first-of-type div { - color: var(--colortexttitlenotab); - font-size: 1.05em; - /* text-transform: uppercase; */ - /* font-weight: 600; */ + color: var(--colortexttitlenotab); + font-size: 1.05em; + /* text-transform: uppercase; */ + /* font-weight: 600; */ } div.titre { - color: var(--colortexttitlenotab); + color: var(--colortexttitlenotab); } .secondary { - color: var(--colortexttitlenotab); + color: var(--colortexttitlenotab); } .tertiary { color: var(--colortexttitlenotab2); @@ -4274,11 +4303,11 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot .poweredbypublicpayment { float: right; top: 8px; - right: 8px; - position: absolute; - font-size: 0.8em; - color: #222; - opacity: 0.3; + right: 8px; + position: absolute; + font-size: 0.8em; + color: #222; + opacity: 0.3; } #dolpaymenttable { min-width: 290px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } @@ -4286,7 +4315,7 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } #tablepublicpayment tr.liste_total td { border-top: none; } input#cardholder-name { - font-size: 1em; + font-size: 1em; } .divmainbodylarge { margin-left: 40px; margin-right: 40px; } @@ -4294,13 +4323,13 @@ input#cardholder-name { #tablesubscribe { width: 100%; } div#card-element { - border: 1px solid #ccc; + border: 1px solid #ccc; } div#card-errors { color: #fa755a; - text-align: center; - padding-top: 3px; - max-width: 320px; + text-align: center; + padding-top: 3px; + max-width: 320px; } @@ -4359,8 +4388,8 @@ div#card-errors { /* .ui-dialog-content.ui-widget-content > object { - max-height: none; - width: auto; margin-left: auto; margin-right: auto; display: block; + max-height: none; + width: auto; margin-left: auto; margin-right: auto; display: block; } */ @@ -4370,16 +4399,16 @@ div#card-errors { /* ============================================================================== */ table.valid { - /* border-top: solid 1px #E6E6E6; */ - border-<?php print $left; ?>: solid 5px #f2cf87; - /* border-<?php print $right; ?>: solid 1px #444444; - border-bottom: solid 1px #555555; */ + /* border-top: solid 1px #E6E6E6; */ + border-<?php print $left; ?>: solid 5px #f2cf87; + /* border-<?php print $right; ?>: solid 1px #444444; + border-bottom: solid 1px #555555; */ padding-top: 8px; padding-left: 10px; padding-right: 4px; padding-bottom: 4px; margin: 0px 0px; - background: #fcf8e3; + background: #fcf8e3; } .validtitre { @@ -4393,7 +4422,7 @@ table.valid { /* For tooltip using dialog */ .ui-dialog.highlight.ui-widget.ui-widget-content.ui-front { - z-index: 3000; + z-index: 3000; } div.ui-tooltip { @@ -4424,20 +4453,20 @@ div.ui-tooltip.mytooltip { /* ============================================================================== */ /*div.divfordateinput img.ui-datepicker-trigger { - float: left; - display: inline-block; - vertical-align: middle; - padding-top: 10px; + float: left; + display: inline-block; + vertical-align: middle; + padding-top: 10px; } .hasDatepicker { - padding-bottom: 6px; + padding-bottom: 6px; }*/ .ui-datepicker-calendar .ui-state-default, .ui-datepicker-calendar .ui-widget-content .ui-state-default, .ui-datepicker-calendar .ui-widget-header .ui-state-default, .ui-datepicker-calendar .ui-button, html .ui-datepicker-calendar .ui-button.ui-state-disabled:hover, html .ui-button.ui-state-disabled:active { - border: unset; + border: unset; } img.datecallink { padding-left: 2px !important; padding-right: 2px !important; } @@ -4457,13 +4486,13 @@ img.datecallink { padding-left: 2px !important; padding-right: 2px !important; } margin-bottom: 5px; } table.dp { - width: 180px; - background-color: var(--inputbackgroundcolor); - border-top: solid 2px #DDDDDD; - border-<?php print $left; ?>: solid 2px #DDDDDD; - border-<?php print $right; ?>: solid 1px #222222; - border-bottom: solid 1px #222222; - padding: 0px; + width: 180px; + background-color: var(--inputbackgroundcolor); + border-top: solid 2px #DDDDDD; + border-<?php print $left; ?>: solid 2px #DDDDDD; + border-<?php print $right; ?>: solid 1px #222222; + border-bottom: solid 1px #222222; + padding: 0px; border-spacing: 0px; border-collapse: collapse; } @@ -4509,14 +4538,14 @@ table.dp { /* Bouton X fermer */ .dpInvisibleButtons { - border-style:none; - background-color:transparent; - padding:0px; - font-size: 0.85em; - border-width:0px; - color:#0B63A2; - vertical-align:middle; - cursor: pointer; + border-style:none; + background-color:transparent; + padding:0px; + font-size: 0.85em; + border-width:0px; + color:#0B63A2; + vertical-align:middle; + cursor: pointer; } .datenowlink { @@ -4529,15 +4558,15 @@ table.dp { /* ============================================================================== */ div.visible { - display: block; + display: block; } div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { - display: none; + display: none; } tr.visible { - display: block; + display: block; } @@ -4546,10 +4575,10 @@ tr.visible { /* ============================================================================== */ .exampleapachesetup { - overflow-y: auto; - height: 100px; - font-size: 0.8em; - border: 1px solid #aaa; + overflow-y: auto; + height: 100px; + font-size: 0.8em; + border: 1px solid #aaa; } span[phptag] { @@ -4557,14 +4586,14 @@ span[phptag] { } .nobordertransp { - border: 0px; - background-color: transparent; - background-image: none; + border: 0px; + background-color: transparent; + background-image: none; } .bordertransp { - background-color: transparent; - background-image: none; - border: none; + background-color: transparent; + background-image: none; + border: none; font-weight: normal; } .websitebar { @@ -4581,9 +4610,9 @@ span[phptag] { { padding: 4px 5px 4px 5px !important; margin: 2px 4px 2px 4px !important; - line-height: normal; - background: #f5f5f5 !important; - border: 1px solid #ccc !important; + line-height: normal; + background: #f5f5f5 !important; + border: 1px solid #ccc !important; } .websiteselection { /* display: inline-block; */ @@ -4600,9 +4629,9 @@ span[phptag] { padding-bottom: 3px; */ } .websiteinputurl { - display: inline-block; - vertical-align: top; - line-height: 28px; + display: inline-block; + vertical-align: top; + line-height: 28px; } .websiteiframenoborder { border: 0px; @@ -4618,9 +4647,9 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im opacity: 0.2; } .websitehelp { - vertical-align: middle; - float: right; - padding-top: 8px; + vertical-align: middle; + float: right; + padding-top: 8px; } .websiteselectionsection { border-left: 1px solid #bbb; @@ -4630,11 +4659,11 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im margin-right: 5px; } .websitebar input#previewpageurl { - line-height: 1em; + line-height: 1em; } #divbodywebsite section p { - margin: unset; + margin: unset; } @@ -4644,7 +4673,7 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im /* ============================================================================== */ .dayevent .tagtr:first-of-type { - height: 24px; + height: 24px; } .agendacell { height: 60px; } @@ -4670,10 +4699,10 @@ table.cal_month td { padding-left: 1px !important; padding-right: 1px !important .cal_peruser { padding-top: 0 !important; padding-bottom: 0 !important; padding-<?php print $left; ?>: 1px !important; padding-<?php print $right; ?>: 1px !important; } .cal_impair { background: linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - /* background: -ms-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); */ + background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + /* background: -ms-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); */ } .cal_today_peruser_impair { background: #F8F8F0; } .peruser_busy { } @@ -4694,7 +4723,7 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } table.cal_month tr td table.nobordernopadding tr td { padding: 0 2px 0 2px; } table.cal_month tr.liste_titre td.tdfordaytitle { min-width: 120px; } a.dayevent-aday { - padding-left: 8px; + padding-left: 8px; } .calendarviewcontainertr { height: 100px; } @@ -4713,28 +4742,28 @@ td.cal_other_month { .ui-autocomplete-loading { background: white url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/working.gif', 1) ?>) right center no-repeat; } .ui-autocomplete { - position:absolute; - width:auto; - font-size: 1.0em; - background-color: var(--inputbackgroundcolor); - border:1px solid #888; - margin:0px; + position:absolute; + width:auto; + font-size: 1.0em; + background-color: var(--inputbackgroundcolor); + border:1px solid #888; + margin:0px; /* padding:0px; This make combo crazy */ - } + } .ui-autocomplete ul { - list-style-type:none; - margin:0px; - padding:0px; - } + list-style-type:none; + margin:0px; + padding:0px; + } .ui-autocomplete ul li.selected { background-color: var(--inputbackgroundcolor);} .ui-autocomplete ul li { - list-style-type:none; - display:block; - margin:0; - padding:2px; - height:18px; - cursor:pointer; - } + list-style-type:none; + display:block; + margin:0; + padding:2px; + height:18px; + cursor:pointer; + } /* ============================================================================== */ @@ -4910,22 +4939,22 @@ A.none, A.none:active, A.none:visited, A.none:hover { /* Style to overwrites JQuery styles */ .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { - border: 1px solid #888; - background: var(--colorbacktitle1); - color: unset; + border: 1px solid #888; + background: var(--colorbacktitle1); + color: unset; } .ui-menu .ui-menu-item a { - text-decoration:none; - display:block; - padding:.2em .4em; - line-height:1.5; - font-weight: normal; - font-family:<?php echo $fontlist; ?>; - font-size:1em; + text-decoration:none; + display:block; + padding:.2em .4em; + line-height:1.5; + font-weight: normal; + font-family:<?php echo $fontlist; ?>; + font-size:1em; } .ui-widget { - font-family:<?php echo $fontlist; ?>; + font-family:<?php echo $fontlist; ?>; } /* .ui-button { margin-left: -2px; <?php print (preg_match('/chrome/', $conf->browser->name) ? 'padding-top: 1px;' : ''); ?> } */ .ui-button { margin-left: -2px; } @@ -4933,7 +4962,7 @@ A.none, A.none:active, A.none:visited, A.none:hover { .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: 2px 0px 6px 0px; } .ui-button-text { - line-height: 1em !important; + line-height: 1em !important; } .ui-autocomplete-input { margin: 0; padding: 4px; } @@ -4943,28 +4972,28 @@ A.none, A.none:active, A.none:visited, A.none:hover { /* ============================================================================== */ body.cke_show_borders { - margin: 5px !important; + margin: 5px !important; } .cke_dialog { - border: 1px #bbb solid ! important; + border: 1px #bbb solid ! important; } /*.cke_editor table, .cke_editor tr, .cke_editor td { - border: 0px solid #FF0000 !important; + border: 0px solid #FF0000 !important; } span.cke_skin_kama { padding: 0 !important; }*/ .cke_wrapper { padding: 4px !important; } a.cke_dialog_ui_button { - font-family: <?php print $fontlist ?> !important; + font-family: <?php print $fontlist ?> !important; background-image: url(<?php echo $img_button ?>) !important; background-position: bottom !important; - border: 1px solid #C0C0C0 !important; + border: 1px solid #C0C0C0 !important; -webkit-border-radius:0px 5px 0px 5px !important; border-radius:0px 5px 0px 5px !important; - -webkit-box-shadow: 3px 3px 4px #DDD !important; - box-shadow: 3px 3px 4px #DDD !important; + -webkit-box-shadow: 3px 3px 4px #DDD !important; + box-shadow: 3px 3px 4px #DDD !important; } .cke_dialog_ui_hbox_last { @@ -4978,8 +5007,8 @@ a.cke_dialog_ui_button } */ a.cke_dialog_ui_button_ok span { - text-shadow: none !important; - color: #333 !important; + text-shadow: none !important; + color: #333 !important; } @@ -4987,28 +5016,28 @@ a.cke_dialog_ui_button_ok span { /* ACE editor */ /* ============================================================================== */ .ace_editor { - border: 1px solid #ddd; + border: 1px solid #ddd; margin: 0; } .aceeditorstatusbar { - margin: 0; - padding: 0; - padding-<?php echo $left; ?>: 10px; - left: 0; - right: 0; - bottom: 0; - background-color: #ebebeb; - height: 28px; - line-height: 2.2em; + margin: 0; + padding: 0; + padding-<?php echo $left; ?>: 10px; + left: 0; + right: 0; + bottom: 0; + background-color: #ebebeb; + height: 28px; + line-height: 2.2em; } .ace_status-indicator { - color: gray; - position: relative; - right: 0; - border-left: 1px solid; + color: gray; + position: relative; + right: 0; + border-left: 1px solid; } pre#editfilecontentaceeditorid { - margin-top: 5px; + margin-top: 5px; } @@ -5017,7 +5046,7 @@ pre#editfilecontentaceeditorid { /* ============================================================================== */ .template-upload { - height: 72px !important; + height: 72px !important; } @@ -5038,32 +5067,32 @@ pre#editfilecontentaceeditorid { /* ============================================================================== */ #types .btn { - cursor: pointer; + cursor: pointer; } #types .btn-primary { - font-weight: bold; + font-weight: bold; } #types form { - padding: 20px; + padding: 20px; } #types label { - display:inline-block; - width:100px; - margin-right: 20px; - padding: 4px; - text-align: right; - vertical-align: top; + display:inline-block; + width:100px; + margin-right: 20px; + padding: 4px; + text-align: right; + vertical-align: top; } #types input.text, #types textarea { - width: 400px; + width: 400px; } #types textarea { - height: 100px; + height: 100px; } @@ -5075,55 +5104,55 @@ pre#editfilecontentaceeditorid { box-sizing:border-box; } #comment .comment { - border-radius:7px; - margin-bottom:10px; - overflow:hidden; + border-radius:7px; + margin-bottom:10px; + overflow:hidden; } #comment .comment-table { - display:table; - height:100%; + display:table; + height:100%; } #comment .comment-cell { - display:table-cell; + display:table-cell; } #comment .comment-info { - font-size:0.8em; - border-right:1px solid #dedede; - margin-right:10px; - width:160px; - text-align:center; - background:rgba(255,255,255,0.5); - vertical-align:middle; - padding:10px 2px; + font-size:0.8em; + border-right:1px solid #dedede; + margin-right:10px; + width:160px; + text-align:center; + background:rgba(255,255,255,0.5); + vertical-align:middle; + padding:10px 2px; } #comment .comment-info a { - color:inherit; + color:inherit; } #comment .comment-right { - vertical-align:top; + vertical-align:top; } #comment .comment-description { - padding:10px; - vertical-align:top; + padding:10px; + vertical-align:top; } #comment .comment-delete { - width: 100px; - text-align:center; - vertical-align:middle; + width: 100px; + text-align:center; + vertical-align:middle; } #comment .comment-delete:hover { - background:rgba(250,20,20,0.8); + background:rgba(250,20,20,0.8); } #comment .comment-edit { - width: 100px; - text-align:center; - vertical-align:middle; + width: 100px; + text-align:center; + vertical-align:middle; } #comment .comment-edit:hover { - background:rgba(0,184,148,0.8); + background:rgba(0,184,148,0.8); } #comment textarea { - width: 100%; + width: 100%; } @@ -5137,7 +5166,7 @@ div.scroll2 { } div#GanttChartDIVglisthead, div#GanttChartDIVgcharthead { - line-height: 2; + line-height: 2; } .gtaskname div, .gtaskname, .gstartdate div, .gstartdate, .genddate div, .genddate { @@ -5150,50 +5179,50 @@ div.gantt, .gtaskheading, .gmajorheading, .gminorheading, .gminorheadingwkend { color: #000 !important; } div.gTaskInfo { - background: #f0f0f0 !important; + background: #f0f0f0 !important; } .gtaskblue { background: rgb(108,152,185) !important; } .gtaskgreen { - background: rgb(160,173,58) !important; + background: rgb(160,173,58) !important; } td.gtaskname { - overflow: hidden; - text-overflow: ellipsis; + overflow: hidden; + text-overflow: ellipsis; } td.gminorheadingwkend { - color: #888 !important; + color: #888 !important; } td.gminorheading { - color: #666 !important; + color: #666 !important; } .glistlbl, .glistgrid { width: 582px !important; } /*.gtaskname div, .gtaskname { - min-width: 250px !important; - max-width: 250px !important; - width: 250px !important; + min-width: 250px !important; + max-width: 250px !important; + width: 250px !important; }*/ .gtaskname div, .gtaskname { - min-width: 250px !important; - max-width: unset !important; - width: unset !important; + min-width: 250px !important; + max-width: unset !important; + width: unset !important; } .gpccomplete div, .gpccomplete { - min-width: 40px !important; - max-width: 40px !important; - width: 40px !important; + min-width: 40px !important; + max-width: 40px !important; + width: 40px !important; } td.gtaskheading.gstartdate, td.gtaskheading.genddate { - white-space: break-spaces; + white-space: break-spaces; } .gtasktableh tr:nth-child(2) td:nth-child(2), .gtasktableh tr:nth-child(2) td:nth-child(3), .gtasktableh tr:nth-child(2) td:nth-child(4), .gtasktableh tr:nth-child(2) td:nth-child(5), .gtasktableh tr:nth-child(2) td:nth-child(6), .gtasktableh tr:nth-child(2) td:nth-child(7) { - color: transparent !important; - border-left: none; - border-right: none; - border-top: none; + color: transparent !important; + border-left: none; + border-right: none; + border-top: none; } /* ============================================================================== */ @@ -5217,25 +5246,25 @@ td.gtaskheading.gstartdate, td.gtaskheading.genddate { } div.filedirelem { - position: relative; - display: block; - text-decoration: none; + position: relative; + display: block; + text-decoration: none; } ul.filedirelem { - padding: 2px; - margin: 0 5px 5px 5px; + padding: 2px; + margin: 0 5px 5px 5px; } ul.filedirelem li { - list-style: none; - padding: 2px; - margin: 0 10px 20px 10px; - width: 160px; - height: 120px; - text-align: center; - display: block; - float: <?php print $left; ?>; - border: solid 1px #DDDDDD; + list-style: none; + padding: 2px; + margin: 0 10px 20px 10px; + width: 160px; + height: 120px; + text-align: center; + display: block; + float: <?php print $left; ?>; + border: solid 1px #DDDDDD; } ul.ecmjqft { @@ -5266,7 +5295,7 @@ ul.ecmjqft a:active { font-weight: bold !important; } ul.ecmjqft a:hover { - text-decoration: underline; + text-decoration: underline; } div.ecmjqft { vertical-align: middle; @@ -5280,16 +5309,16 @@ div.ecmjqft { min-height: 40px; } #ecm-layout-north div.attachareaformuserfileecm { - padding-bottom: 0px; + padding-bottom: 0px; } div#ecm-layout-west { - width: 380px; - vertical-align: top; + width: 380px; + vertical-align: top; } div#ecm-layout-center { - width: calc(100% - 390px); - vertical-align: top; - float: right; + width: calc(100% - 390px); + vertical-align: top; + float: right; } .ecmjqft LI.directory { font-weight:normal; background: url(<?php echo dol_buildpath($path.'/theme/common/treemenu/folder2.png', 1); ?>) left top no-repeat; } @@ -5319,14 +5348,14 @@ div#ecm-layout-center { font-weight: normal; } .jnotify-container .jnotify-notification-warning .jnotify-close, .jnotify-container .jnotify-notification-warning .jnotify-message { - color: #a28918 !important; + color: #a28918 !important; } /* use or not ? */ div.jnotify-background { opacity : 0.95 !important; - -webkit-box-shadow: 2px 2px 4px #888 !important; - box-shadow: 2px 2px 4px #888 !important; + -webkit-box-shadow: 2px 2px 4px #888 !important; + box-shadow: 2px 2px 4px #888 !important; } /* ============================================================================== */ @@ -5389,7 +5418,7 @@ table.dataTable tr.odd td.sorting_1, table.dataTable tr.even td.sorting_1 { .paginate_button { font-weight: normal !important; - text-decoration: none !important; + text-decoration: none !important; } .paging_full_numbers { height: inherit !important; @@ -5402,7 +5431,7 @@ table.dataTable tr.odd td.sorting_1, table.dataTable tr.even td.sorting_1 { border-radius: inherit !important; } .paging_full_numbers a.paginate_button_disabled:hover, .paging_full_numbers a.disabled:hover { - background-color: var(--colorbackbody) !important; + background-color: var(--colorbackbody) !important; } .paginate_button, .paginate_active { border: 1px solid #ddd !important; @@ -5441,23 +5470,23 @@ span.select2-selection--single.flat[aria-disabled="true"] span.select2-selection } span#select2-taskid-container[title^='--'] { - opacity: 0.3; + opacity: 0.3; } .select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: rgb(<?php echo $colorbackhmenu1 ?>); - color: var(--colortextbackhmenu); + background-color: rgb(<?php echo $colorbackhmenu1 ?>); + color: var(--colortextbackhmenu); } .select2-container--default .select2-results__option--highlighted[aria-selected] span { - color: #fff !important; + color: #fff !important; } span.select2.select2-container.select2-container--default { <?php if (empty($conf->global->THEME_SHOW_BORDER_ON_INPUT)) { ?> - border-left: none; - border-top: none; - border-right: none; - <?php } ?> + border-left: none; + border-top: none; + border-right: none; + <?php } ?> } input.select2-input { border-bottom: none ! important; @@ -5477,36 +5506,36 @@ input.select2-input { border: none; } .select2-container--focus span.select2-selection.select2-selection--single { - border-bottom: 1px solid #666 !important; + border-bottom: 1px solid #666 !important; } .blockvmenusearch .select2-container--default .select2-selection--single, .blockvmenubookmarks .select2-container--default .select2-selection--single { - background-color: var(--colorbackvmenu1); + background-color: var(--colorbackvmenu1); } .select2-container--default .select2-selection--single { - background-color: var(--colorbackbody); + background-color: var(--colorbackbody); } #blockvmenusearch .select2-container--default .select2-selection--single .select2-selection__placeholder { - color: var(--colortextbackvmenu); + color: var(--colortextbackvmenu); } .select2-container--default .select2-selection--single .select2-selection__rendered { - color: var(--colortext); - /* background-color: var(--colorbackvmenu1); */ + color: var(--colortext); + /* background-color: var(--colorbackvmenu1); */ } .select2-default { - color: #999 !important; + color: #999 !important; } .select2-choice, .select2-container .select2-choice { border-bottom: solid 1px rgba(0,0,0,.4); } .select2-container .select2-choice > .select2-chosen { - margin-right: 23px; + margin-right: 23px; } .select2-container .select2-choice .select2-arrow { border-radius: 0; - background: transparent; + background: transparent; } .select2-container-multi .select2-choices { background-image: none; @@ -5533,7 +5562,7 @@ input.select2-input { box-shadow: none !important; } .select2-container--open .select2-dropdown--above { - border-bottom: solid 1px var(--inputbordercolor); + border-bottom: solid 1px var(--inputbordercolor); } .select2-drop.select2-drop-above.select2-drop-active { border-top: 1px solid #ccc; @@ -5680,36 +5709,36 @@ a span.select2-chosen } .select2-container--default .select2-results>.select2-results__options{ - max-height: 400px; + max-height: 400px; } /* Special case for the select2 add widget */ #addbox .select2-container .select2-choice > .select2-chosen, #actionbookmark .select2-container .select2-choice > .select2-chosen { - text-align: <?php echo $left; ?>; - opacity: 0.4; + text-align: <?php echo $left; ?>; + opacity: 0.4; } .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--colortext); opacity: 0.4; } span#select2-boxbookmark-container, span#select2-boxcombo-container { - text-align: <?php echo $left; ?>; + text-align: <?php echo $left; ?>; } span#select2-boxbookmark-container { - opacity: 0.4; + opacity: 0.4; } .select2-container .select2-selection--single .select2-selection__rendered { padding-left: 6px; } /* Style used before the select2 js is executed on boxcombo */ #boxbookmark.boxcombo, #boxcombo.boxcombo { - text-align: left; - opacity: 0.4; - border-bottom: solid 1px rgba(0,0,0,.4) !important; - height: 26px; - line-height: 24px; - padding: 0 0 2px 0; - vertical-align: top; + text-align: left; + opacity: 0.4; + border-bottom: solid 1px rgba(0,0,0,.4) !important; + height: 26px; + line-height: 24px; + padding: 0 0 2px 0; + vertical-align: top; } /* To emulate select 2 style */ @@ -5763,7 +5792,7 @@ span#select2-boxbookmark-container { border-radius: 5px !important; box-shadow: none; -webkit-box-shadow: none !important; - box-shadow: none !important; + box-shadow: none !important; } span.noborderoncategories a, li.noborderoncategories a { line-height: normal; @@ -5853,9 +5882,9 @@ span.noborderoncategories { } .multi-select-menuitem { - clear: both; - float: left; - padding-left: 5px + clear: both; + float: left; + padding-left: 5px } @@ -5864,52 +5893,52 @@ span.noborderoncategories { /* ============================================================================== */ ul.ulselectedfields { - z-index: 95; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ + z-index: 95; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ } dl.dropdown { - margin:0px; + margin:0px; margin-left: 2px; - margin-right: 2px; - padding:0px; - vertical-align: middle; - display: inline-block; + margin-right: 2px; + padding:0px; + vertical-align: middle; + display: inline-block; } .dropdown dd, .dropdown dt { - margin:0px; - padding:0px; + margin:0px; + padding:0px; } .dropdown ul { - margin: -1px 0 0 0; - text-align: <?php echo $left; ?>; + margin: -1px 0 0 0; + text-align: <?php echo $left; ?>; } .dropdown dd { - position:relative; + position:relative; } .dropdown dt a { - display:block; - overflow: hidden; - border:0; + display:block; + overflow: hidden; + border:0; } .dropdown dt a span, .multiSel span { - cursor:pointer; - display:inline-block; - padding: 0 3px 2px 0; + cursor:pointer; + display:inline-block; + padding: 0 3px 2px 0; } .dropdown span.value { - display:none; + display:none; } .dropdown dd ul { - background-color: var(--inputbackgroundcolor); - box-shadow: 1px 1px 10px #aaa; - display:none; - <?php echo $right; ?>:0px; /* pop is align on right */ - padding: 0 0 0 0; - position:absolute; - top:2px; - list-style:none; - max-height: 264px; - overflow: auto; - border-radius: 2px; + background-color: var(--inputbackgroundcolor); + box-shadow: 1px 1px 10px #aaa; + display:none; + <?php echo $right; ?>:0px; /* pop is align on right */ + padding: 0 0 0 0; + position:absolute; + top:2px; + list-style:none; + max-height: 264px; + overflow: auto; + border-radius: 2px; } .dropdown dd ul li { white-space: nowrap; @@ -5922,22 +5951,22 @@ dl.dropdown { background: #eee; } .dropdown dd ul li input[type="checkbox"] { - margin-<?php echo $right; ?>: 3px; + margin-<?php echo $right; ?>: 3px; } .dropdown dd ul li a, .dropdown dd ul li span { - padding: 3px; - display: block; + padding: 3px; + display: block; } .dropdown dd ul li span { color: #888; } /*.dropdown dd ul li a:hover { - background-color: var(--inputbackgroundcolor); + background-color: var(--inputbackgroundcolor); }*/ dd.dropdowndd ul li { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; } @@ -5959,11 +5988,11 @@ dd.dropdowndd ul li { /* ============================================================================== */ .searchpage .tagtr .tagtd { - padding-bottom: 3px; + padding-bottom: 3px; } .searchpage .tagtr .tagtd .button { background: unset; - border: unset; + border: unset; } li.ui-li-divider .ui-link { @@ -5999,16 +6028,16 @@ a.ui-link, a.ui-link:hover, .ui-btn:hover, span.ui-btn-text:hover, span.ui-btn-i padding-left: 30px; } .ui-select .ui-btn-icon-right .ui-icon { - right: 8px; + right: 8px; } .ui-btn-icon-left > .ui-btn-inner > .ui-icon, .ui-btn-icon-right > .ui-btn-inner > .ui-icon { - margin-top: -10px; + margin-top: -10px; } select { - /* display: inline-block; */ /* We can't set this. This disable ability to make */ - overflow:hidden; - white-space: nowrap; /* Enabling this make behaviour strange when selecting the empty value if this empty value is '' instead of '&nbsp;' */ - text-overflow: ellipsis; + /* display: inline-block; */ /* We can't set this. This disable ability to make */ + overflow:hidden; + white-space: nowrap; /* Enabling this make behaviour strange when selecting the empty value if this empty value is '' instead of '&nbsp;' */ + text-overflow: ellipsis; } .fiche .ui-controlgroup { margin: 0px; @@ -6091,40 +6120,40 @@ ul.ulmenu { /* Style for first level menu with jmobile */ .ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { - padding: 1em 15px; - display: block; + padding: 1em 15px; + display: block; } .ui-btn-up-c { font-weight: normal; } .ui-focus, .ui-btn:focus { - -webkit-box-shadow: none; - box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; } .ui-bar-b { - /*border: 1px solid #888;*/ - border: none; - background: none; - text-shadow: none; - color: var(--colortexttitlenotab) !important; + /*border: 1px solid #888;*/ + border: none; + background: none; + text-shadow: none; + color: var(--colortexttitlenotab) !important; } .ui-bar-b, .lilevel0 { - background-repeat: repeat-x; - border: none; - background: none; - text-shadow: none; - color: var(--colortexttitlenotab) !important; + background-repeat: repeat-x; + border: none; + background: none; + text-shadow: none; + color: var(--colortexttitlenotab) !important; } .alilevel0 { font-weight: normal !important; } .ui-li.ui-last-child, .ui-li.ui-field-contain.ui-last-child { - border-bottom-width: 0px !important; + border-bottom-width: 0px !important; } .alilevel0 { - color: var(--colortexttitle) !important; - background: #f8f8f8 + color: var(--colortexttitle) !important; + background: #f8f8f8 } .ulmenu { box-shadow: none !important; @@ -6152,11 +6181,11 @@ div.tabsElem a.tab { background: transparent; } .alilevel1 { - color: var(--colortexttitlenotab) !important; + color: var(--colortexttitlenotab) !important; } .lilevel1 { - border-top: 2px solid #444; - background: #fff ! important; + border-top: 2px solid #444; + background: #fff ! important; } .lilevel1 div div a { font-weight: bold !important; @@ -6164,7 +6193,7 @@ div.tabsElem a.tab { .lilevel2 { padding-left: 22px; - background: #fff ! important; + background: #fff ! important; } .lilevel3 { @@ -6174,12 +6203,12 @@ div.tabsElem a.tab { .lilevel4 { padding-left: 66px; - background: #fff ! important; + background: #fff ! important; } .lilevel5 { padding-left: 88px; - background: #fff ! important; + background: #fff ! important; } @@ -6213,14 +6242,14 @@ div.tabsElem a.tab { color: #6d3f6d; } .menu li.menu_choix1 { - padding-top: 6px; - padding-right: 10px; - padding-bottom: 2px; + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; } .menu li.menu_choix2 { - padding-top: 6px; - padding-right: 10px; - padding-bottom: 2px; + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; } @media only screen and (max-width: 767px) { @@ -6229,13 +6258,13 @@ div.tabsElem a.tab { height: 30px; padding-left: 40px; } - .menu li.menu_choix1, .menu li.menu_choix2 { - padding-left: 4px; - padding-right: 0; - } - .liste_articles { - margin-right: 0 !important; - } + .menu li.menu_choix1, .menu li.menu_choix2 { + padding-left: 4px; + padding-right: 0; + } + .liste_articles { + margin-right: 0 !important; + } } @@ -6263,7 +6292,7 @@ div.tabsElem a.tab { .ticketpublicarea { margin-left: 15%; - margin-right: 15%; + margin-right: 15%; } .publicnewticketform { /* margin-top: 25px !important; */ @@ -6301,11 +6330,11 @@ div.tabsElem a.tab { } @media only screen and (min-width: 1170px) { #cd-timeline { - margin-bottom: 3em; + margin-bottom: 3em; } #cd-timeline::before { - left: 50%; - margin-left: -2px; + left: 50%; + margin-left: -2px; } } @@ -6326,13 +6355,13 @@ div.tabsElem a.tab { } @media only screen and (min-width: 1170px) { .cd-timeline-block { - margin: 4em 0; + margin: 4em 0; } .cd-timeline-block:first-child { - margin-top: 0; + margin-top: 0; } .cd-timeline-block:last-child { - margin-bottom: 0; + margin-bottom: 0; } } @@ -6367,80 +6396,80 @@ div.tabsElem a.tab { } @media only screen and (min-width: 1170px) { .cd-timeline-img { - width: 60px; - height: 60px; - left: 50%; - margin-left: -30px; - /* Force Hardware Acceleration in WebKit */ - -webkit-transform: translateZ(0); - -webkit-backface-visibility: hidden; + width: 60px; + height: 60px; + left: 50%; + margin-left: -30px; + /* Force Hardware Acceleration in WebKit */ + -webkit-transform: translateZ(0); + -webkit-backface-visibility: hidden; } .cssanimations .cd-timeline-img.is-hidden { - visibility: hidden; + visibility: hidden; } .cssanimations .cd-timeline-img.bounce-in { - visibility: visible; - -webkit-animation: cd-bounce-1 0.6s; - -moz-animation: cd-bounce-1 0.6s; - animation: cd-bounce-1 0.6s; + visibility: visible; + -webkit-animation: cd-bounce-1 0.6s; + -moz-animation: cd-bounce-1 0.6s; + animation: cd-bounce-1 0.6s; } } @-webkit-keyframes cd-bounce-1 { 0% { - opacity: 0; - -webkit-transform: scale(0.5); + opacity: 0; + -webkit-transform: scale(0.5); } 60% { - opacity: 1; - -webkit-transform: scale(1.2); + opacity: 1; + -webkit-transform: scale(1.2); } 100% { - -webkit-transform: scale(1); + -webkit-transform: scale(1); } } @-moz-keyframes cd-bounce-1 { 0% { - opacity: 0; - -moz-transform: scale(0.5); + opacity: 0; + -moz-transform: scale(0.5); } 60% { - opacity: 1; - -moz-transform: scale(1.2); + opacity: 1; + -moz-transform: scale(1.2); } 100% { - -moz-transform: scale(1); + -moz-transform: scale(1); } } @keyframes cd-bounce-1 { 0% { - opacity: 0; - -webkit-transform: scale(0.5); - -moz-transform: scale(0.5); - -ms-transform: scale(0.5); - -o-transform: scale(0.5); - transform: scale(0.5); + opacity: 0; + -webkit-transform: scale(0.5); + -moz-transform: scale(0.5); + -ms-transform: scale(0.5); + -o-transform: scale(0.5); + transform: scale(0.5); } 60% { - opacity: 1; - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - -ms-transform: scale(1.2); - -o-transform: scale(1.2); - transform: scale(1.2); + opacity: 1; + -webkit-transform: scale(1.2); + -moz-transform: scale(1.2); + -ms-transform: scale(1.2); + -o-transform: scale(1.2); + transform: scale(1.2); } 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - -ms-transform: scale(1); - -o-transform: scale(1); - transform: scale(1); + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } .cd-timeline-content { @@ -6492,58 +6521,58 @@ div.tabsElem a.tab { } @media only screen and (min-width: 768px) { .cd-timeline-content h2 { - font-size: 20px; - font-size: 1.25rem; + font-size: 20px; + font-size: 1.25rem; } .cd-timeline-content { - font-size: 16px; - font-size: 1rem; + font-size: 16px; + font-size: 1rem; } .cd-timeline-content .cd-read-more, .cd-timeline-content .cd-date { - font-size: 14px; - font-size: 0.875rem; + font-size: 14px; + font-size: 0.875rem; } } @media only screen and (min-width: 1170px) { .cd-timeline-content { - margin-left: 0; - padding: 1.6em; - width: 43%; + margin-left: 0; + padding: 1.6em; + width: 43%; } .cd-timeline-content::before { - top: 24px; - left: 100%; - border-color: transparent; - border-left-color: white; + top: 24px; + left: 100%; + border-color: transparent; + border-left-color: white; } .cd-timeline-content .cd-read-more { - float: left; + float: left; } .cd-timeline-content .cd-date { - position: absolute; - width: 55%; - left: 115%; - top: 6px; - font-size: 16px; - font-size: 1rem; + position: absolute; + width: 55%; + left: 115%; + top: 6px; + font-size: 16px; + font-size: 1rem; } .cd-timeline-block:nth-child(even) .cd-timeline-content { - float: right; + float: right; } .cd-timeline-block:nth-child(even) .cd-timeline-content::before { - top: 24px; - left: auto; - right: 100%; - border-color: transparent; - border-right-color: white; + top: 24px; + left: auto; + right: 100%; + border-color: transparent; + border-right-color: white; } .cd-timeline-block:nth-child(even) .cd-timeline-content .cd-read-more { - float: right; + float: right; } .cd-timeline-block:nth-child(even) .cd-timeline-content .cd-date { - left: auto; - right: 115%; - text-align: right; + left: auto; + right: 115%; + text-align: right; } } @@ -6557,21 +6586,21 @@ div.phpdebugbar * { font-weight: unset; } span.phpdebugbar-tooltip.phpdebugbar-tooltip-extra-wide, span.phpdebugbar-tooltip.phpdebugbar-tooltip-wide { - width: 250px !important; + width: 250px !important; } .phpdebugbar-indicator span.phpdebugbar-tooltip { - opacity: .95 !important; + opacity: .95 !important; } a.phpdebugbar-tab.phpdebugbar-active { background-image: unset !important; } .phpdebugbar-fa-tags:before { - content: "\f121"; - font-weight: 600 !important; + content: "\f121"; + font-weight: 600 !important; } .phpdebugbar-fa-tasks:before { - content: "\f550"; - font-weight: 600 !important; + content: "\f550"; + font-weight: 600 !important; } .phpdebugbar-fa-tags, .phpdebugbar-fa-tasks, .phpdebugbar-indicator .fa { font-family: "Font Awesome 5 Free"; @@ -6600,10 +6629,10 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before /* ============================================================================== */ .dol-xaxis-vertical .flot-x-axis .flot-tick-label.tickLabel { - text-orientation: sideways; - font-weight: 400; - writing-mode: vertical-rl; - white-space: nowrap; + text-orientation: sideways; + font-weight: 400; + writing-mode: vertical-rl; + white-space: nowrap; } @@ -6637,14 +6666,14 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before width: <?php print dol_size(350, 'width'); ?>px; } - div.tabBar { - padding-left: 0px; - padding-right: 0px; - -webkit-border-radius: 0; - border-radius: 0px; - border-right: none; - border-left: none; - } + div.tabBar { + padding-left: 0px; + padding-right: 0px; + -webkit-border-radius: 0; + border-radius: 0px; + border-right: none; + border-left: none; + } } @media only screen and (max-width: 1024px) @@ -6663,27 +6692,27 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before @media only screen and (max-width: <?php echo empty($conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1) ? round($nbtopmenuentries * 90, 0) + 340 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1; ?>px) /* reduction 1 */ { div.tmenucenter { - width: <?php echo round(52); ?>px; /* size of viewport */ - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - color: var(--colortextbackhmenu); + width: <?php echo round(52); ?>px; /* size of viewport */ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: var(--colortextbackhmenu); } .mainmenuaspan { - font-size: 0.9em; - padding-right: 0; - } - .topmenuimage { - background-size: 22px auto; - margin-top: 0px; + font-size: 0.9em; + padding-right: 0; + } + .topmenuimage { + background-size: 22px auto; + margin-top: 0px; } - li.tmenu, li.tmenusel { - min-width: 36px; - } - div.mainmenu { - min-width: auto; - } + li.tmenu, li.tmenusel { + min-width: 36px; + } + div.mainmenu { + min-width: auto; + } div.tmenuleft { display: none; } @@ -6702,21 +6731,21 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before height: 23px; } div.tmenucenter { - max-width: <?php echo round(26); ?>px; /* size of viewport */ - text-overflow: clip; + max-width: <?php echo round(26); ?>px; /* size of viewport */ + text-overflow: clip; } span.mainmenuaspan { - margin-left: 1px; + margin-left: 1px; } .mainmenuaspan { - font-size: 0.9em; - padding-left: 0; - padding-right: 0; - } - .topmenuimage { - background-size: 20px auto; - margin-top: 2px; - left: 4px; + font-size: 0.9em; + padding-left: 0; + padding-right: 0; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px; + left: 4px; } .dropdown dd ul { @@ -6730,16 +6759,16 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before z-index: 200; background: var(--colorbackvmenu1); padding-top: 70px; - } + } #id-left { - z-index: 201; + z-index: 201; background: var(--colorbackvmenu1); } - .login_vertical_align { - padding-left: 20px; - padding-right: 20px; - } + .login_vertical_align { + padding-left: 20px; + padding-right: 20px; + } /* Reduce login top right info */ .help { @@ -6759,34 +6788,34 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before width: 100%; } div.login_block a { - color: unset; - } + color: unset; + } div.login_block { /* Style when phone layout or when using the menuhider */ padding-top: 10px; padding-left: 20px; - padding-right: 20px; - padding-bottom: 16px; + padding-right: 20px; + padding-bottom: 16px; top: inherit !important; left: 0 !important; text-align: center; - vertical-align: middle; + vertical-align: middle; background: var(--colorbackvmenu1); - height: 50px; + height: 50px; - z-index: 202; - min-width: 200px; /* must be width of menu + padding + padding of sidenav */ - max-width: 200px; /* must be width of menu + padding + padding of sidenav */ - width: 200px; /* must be width of menu + padding + padding of sidenav */ - } - .side-nav-vert .user-menu .dropdown-menu { - width: 234px !important; - } - div.login_block_other { - margin-right: unset; - } + z-index: 202; + min-width: 200px; /* must be width of menu + padding + padding of sidenav */ + max-width: 200px; /* must be width of menu + padding + padding of sidenav */ + width: 200px; /* must be width of menu + padding + padding of sidenav */ + } + .side-nav-vert .user-menu .dropdown-menu { + width: 234px !important; + } + div.login_block_other { + margin-right: unset; + } div.login_block_user, div.login_block_other { clear: both; } .atoplogin, .atoplogin:hover { @@ -6798,32 +6827,32 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before padding: 0 !important; height: 38px; } - li.tmenu, li.tmenusel { - min-width: 32px; - } + li.tmenu, li.tmenusel { + min-width: 32px; + } div.mainmenu { height: 23px; } div.tmenucenter { - text-overflow: clip; + text-overflow: clip; } - .topmenuimage { - background-size: 20px auto; - margin-top: 2px !important; - left: 2px; + .topmenuimage { + background-size: 20px auto; + margin-top: 2px !important; + left: 2px; } div.mainmenu { - min-width: 20px; - } + min-width: 20px; + } .titlefield { - width: auto !important; /* We want to ignore the 30%, try to use more if you can */ + width: auto !important; /* We want to ignore the 30%, try to use more if you can */ } .tableforfield>tr>td:first-child, .tableforfield>tbody>tr>td:first-child, div.tableforfield div.tagtr>div.tagtd:first-of-type { - /* max-width: 100px; */ /* but no more than 100px */ + /* max-width: 100px; */ /* but no more than 100px */ } .tableforfield>tr>td:nth-child(2), .tableforfield>tbody>tr>td:nth-child(2), div.tableforfield div.tagtr>div.tagtd:nth-child(2) { - word-break: break-word; + word-break: break-word; } .badge { min-width: auto; @@ -6865,7 +6894,9 @@ include dol_buildpath($path.'/theme/'.$theme.'/info-box.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/progress.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/timeline.inc.php', 0); -if (!empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; +if (!empty($conf->global->THEME_CUSTOM_CSS)) { + print $conf->global->THEME_CUSTOM_CSS; +} ?> diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 2da8de5cff3..04e4c035b4a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -1,5 +1,7 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ /* @@ -8,33 +10,33 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> */ .info-box-module-external span.info-box-icon-version { - background: #bbb; + background: #bbb; } .info-box { display: block; - position: relative; + position: relative; min-height: 90px; /* background: #fff; */ width: 100%; box-shadow: 1px 1px 15px rgba(192, 192, 192, 0.2); - border-radius: 2px; - border: 1px solid #e9e9e9; + border-radius: 2px; + border: 1px solid #e9e9e9; margin-bottom: 15px; } .info-box.info-box-sm { - min-height: 80px; - margin-bottom: 10px; - /* background: #fff; */ + min-height: 80px; + margin-bottom: 10px; + /* background: #fff; */ } .opened-dash-board-wrap .info-box.info-box-sm { - border-radius: 0 0 0 20px; + border-radius: 0 0 0 20px; } .info-box-more { - float: right; - top: 5px; - position: absolute; - right: 8px; + float: right; + top: 5px; + position: absolute; + right: 8px; } .info-box small { @@ -71,7 +73,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> border-bottom-right-radius: 0; border-bottom-left-radius: 2px; display: block; - overflow: hidden; + overflow: hidden; float: left; height: 90px; width: 90px; @@ -82,20 +84,20 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> } .info-box-module .info-box-icon { - padding-top: 5px; - padding-bottom: 5px; + padding-top: 5px; + padding-bottom: 5px; } .info-box-sm .info-box-icon { - height: 80px; - width: 78px; - font-size: 25px; - line-height: 92px; + height: 80px; + width: 78px; + font-size: 25px; + line-height: 92px; } .opened-dash-board-wrap .info-box-sm .info-box-icon { - border-radius: 0 0 0 20px; + border-radius: 0 0 0 20px; } .opened-dash-board-wrap .info-box-sm .info-box-icon { - line-height: 80px; + line-height: 80px; } .info-box-module .info-box-icon { height: 98px; @@ -104,75 +106,75 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> max-width: 100%; } .info-box-module .info-box-icon > img { - max-width: 60%; + max-width: 60%; } a.info-box-text.info-box-text-a { - display: table-cell; + display: table-cell; } a.info-box-text-a i.fa.fa-exclamation-triangle { - font-size: 0.9em; + font-size: 0.9em; } .info-box-icon-text{ - box-sizing: border-box; - display: block; - position: absolute; - width: 90px; - bottom: 0px; - color: #ffffff; - background-color: rgba(0,0,0,0.1); - cursor: default; + box-sizing: border-box; + display: block; + position: absolute; + width: 90px; + bottom: 0px; + color: #ffffff; + background-color: rgba(0,0,0,0.1); + cursor: default; - font-size: 10px; - line-height: 15px; - padding: 0px 3px; - text-align: center; - opacity: 0; - -webkit-transition: opacity 0.5s, visibility 0s 0.5s; - transition: opacity 0.5s, visibility 0s 0.5s; + font-size: 10px; + line-height: 15px; + padding: 0px 3px; + text-align: center; + opacity: 0; + -webkit-transition: opacity 0.5s, visibility 0s 0.5s; + transition: opacity 0.5s, visibility 0s 0.5s; } .info-box-icon-version { - box-sizing: border-box; - display: block; - position: absolute; - width: 90px; - bottom: 0px; - color: #ffffff; - background-color: rgba(0,0,0,0.1); - cursor: default; + box-sizing: border-box; + display: block; + position: absolute; + width: 90px; + bottom: 0px; + color: #ffffff; + background-color: rgba(0,0,0,0.1); + cursor: default; - font-size: 10px; - line-height: 22px; - padding: 0px 3px; - text-align: center; - opacity: 1; - -webkit-transition: opacity 0.5s, visibility 0s 0.5s; - transition: opacity 0.5s, visibility 0s 0.5s; + font-size: 10px; + line-height: 22px; + padding: 0px 3px; + text-align: center; + opacity: 1; + -webkit-transition: opacity 0.5s, visibility 0s 0.5s; + transition: opacity 0.5s, visibility 0s 0.5s; } .box-flex-item.info-box-module.info-box-module-disabled { - /* opacity: 0.6; */ + /* opacity: 0.6; */ } .info-box-actions { position: absolute; - right: 0; - bottom: 0; + right: 0; + bottom: 0; } <?php if (empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS) && !empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD)) { ?> .info-box-icon-text{ - opacity: 1; + opacity: 1; } <?php } ?> .info-box-sm .info-box-icon-text, .info-box-sm .info-box-icon-version{ - overflow: hidden; - width: 80px; + overflow: hidden; + width: 80px; } .info-box:hover .info-box-icon-text{ - opacity: 1; + opacity: 1; } .info-box-content { @@ -180,11 +182,11 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { margin-left: 84px; } .info-box-sm .info-box-content{ - margin-left: 80px; + margin-left: 80px; } .info-box-sm .info-box-module-enabled { - /* background: linear-gradient(0.35turn, #fff, #fff, #f6faf8, #e4efe8) */ - background: linear-gradient(0.4turn, #fff, #fff, #fff, #e4efe8); + /* background: linear-gradient(0.35turn, #fff, #fff, #f6faf8, #e4efe8) */ + background: linear-gradient(0.4turn, #fff, #fff, #fff, #e4efe8); } .info-box-content-warning span.font-status4 { color: #bc9526 !important; @@ -193,7 +195,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { background: #ffd7a3; }*/ /*.info-box-icon.info-box-icon-module-enabled { - background: #e4f0e4 !important; + background: #e4f0e4 !important; }*/ .info-box-number { @@ -240,20 +242,26 @@ a.info-box-text{ text-decoration: none;} include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $prefix = ''; -if (!empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; +if (!empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) { + $prefix = 'background-'; +} -if (!isset($conf->global->THEME_SATURATE_RATIO)) $conf->global->THEME_SATURATE_RATIO = 0.7; -if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +if (!isset($conf->global->THEME_SATURATE_RATIO)) { + $conf->global->THEME_SATURATE_RATIO = 0.7; +} +if (GETPOSTISSET('THEME_SATURATE_RATIO')) { + $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +} ?> .info-box-icon { <?php if ($prefix) { ?> color: #fff !important; <?php } ?> - opacity: 0.95; - <?php if (isset($conf->global->THEME_SATURATE_RATIO)) { ?> - filter: saturate(<?php echo $conf->global->THEME_SATURATE_RATIO; ?>); - <?php } ?> + opacity: 0.95; + <?php if (isset($conf->global->THEME_SATURATE_RATIO)) { ?> + filter: saturate(<?php echo $conf->global->THEME_SATURATE_RATIO; ?>); + <?php } ?> } .customer-back { @@ -435,13 +443,13 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = } .info-box-module { min-width: 350px; - max-width: 350px; + max-width: 350px; } @media only screen and (max-width: 1740px) { .info-box-module { - min-width: 315px; - max-width: 315px; + min-width: 315px; + max-width: 315px; } } @@ -463,8 +471,8 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = @media only screen and (max-width: 767px) { .box-flex-container { - margin: 0 0 0 0px !important; - width: 100% !important; + margin: 0 0 0 0px !important; + width: 100% !important; } .info-box-module { width: 100%; diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 156da9be652..14421e38db7 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -1,23 +1,25 @@ -<?php if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +<?php if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ .mainmenu::before{ - /* font part */ - font-family: "Font Awesome 5 Free"; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - line-height: 23px; + /* font part */ + font-family: "Font Awesome 5 Free"; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + line-height: 23px; font-size: <?php echo $topMenuFontSize; ?>; - -webkit-font-smoothing: antialiased; - text-align:center; + -webkit-font-smoothing: antialiased; + text-align:center; text-decoration:none; color: #<?php echo $colortextbackhmenu; ?>; } .fa-15x { - font-size: 1.5em; + font-size: 1.5em; } div.mainmenu.menu { @@ -34,116 +36,116 @@ div.mainmenu.home::before{ } div.mainmenu.billing::before { - content: "\f51e"; + content: "\f51e"; } div.mainmenu.accountancy::before { - content: "\f53d"; + content: "\f53d"; } div.mainmenu.agenda::before { - content: "\f073"; + content: "\f073"; } div.mainmenu.bank::before { - content: "\f19c"; + content: "\f19c"; } <?php if ($conf->global->MAIN_FEATURES_LEVEL == 2) { ?> /* TESTING USAGE OF SVG WITHOUT FONT */ div.mainmenu.cashdesk { - line-height: 26px; + line-height: 26px; } div.mainmenu.cashdesk .tmenuimage { - line-height: 26px; - display: inline-block; - vertical-align: middle; - height: <?php echo $topMenuFontSize; ?>; + line-height: 26px; + display: inline-block; + vertical-align: middle; + height: <?php echo $topMenuFontSize; ?>; background-color: #<?php echo $colortextbackhmenu; ?>; - width: 100%; - -webkit-mask: url(<?php echo DOL_URL_ROOT.'/theme/common/fontawesome-5/svgs/solid/cash-register.svg' ?>) no-repeat 50% 50%; /* for old webkit browser */ - mask: url(<?php echo DOL_URL_ROOT.'/theme/common/fontawesome-5/svgs/solid/cash-register.svg' ?>) no-repeat 50% 50%; + width: 100%; + -webkit-mask: url(<?php echo DOL_URL_ROOT.'/theme/common/fontawesome-5/svgs/solid/cash-register.svg' ?>) no-repeat 50% 50%; /* for old webkit browser */ + mask: url(<?php echo DOL_URL_ROOT.'/theme/common/fontawesome-5/svgs/solid/cash-register.svg' ?>) no-repeat 50% 50%; } <?php } else { ?> div.mainmenu.cashdesk::before { - content: "\f788"; + content: "\f788"; } <?php } ?> div.mainmenu.takepos::before { - content: "\f788"; + content: "\f788"; } div.mainmenu.companies::before { - content: "\f1ad"; + content: "\f1ad"; } div.mainmenu.commercial::before { - content: "\f0f2"; + content: "\f0f2"; } div.mainmenu.ecm::before { - content: "\f07c"; + content: "\f07c"; } div.mainmenu.externalsite::before { - content: "\f360"; + content: "\f360"; } div.mainmenu.ftp::before { - content: "\f362"; + content: "\f362"; } div.mainmenu.hrm::before { - content: "\f508"; + content: "\f508"; } div.mainmenu.members::before { - content: "\f007"; + content: "\f007"; } div.mainmenu.products::before { - content: "\f1b2"; + content: "\f1b2"; } div.mainmenu.mrp::before { - content: "\f1b3"; + content: "\f1b3"; } div.mainmenu.project::before { - content: "\f0e8"; + content: "\f0e8"; } div.mainmenu.ticket::before { - content: "\f3ff"; + content: "\f3ff"; } div.mainmenu.tools::before { - content: "\f0ad"; + content: "\f0ad"; } div.mainmenu.website::before { - content: "\f57d"; + content: "\f57d"; } div.mainmenu.generic1::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic2::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic3::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic4::before { - content: "\f249"; + content: "\f249"; } /* Define color of some picto */ diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index 098ceb4aaae..7d0f75614c7 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -25,16 +25,36 @@ * \brief File for The Web App */ -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '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('NOLOGIN')) define('NOLOGIN', '1'); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (!defined('NOSESSION')) define('NOSESSION', '1'); +if (!defined('NOREQUIREUSER')) { + define('NOREQUIREUSER', '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('NOLOGIN')) { + define('NOLOGIN', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); +} require_once __DIR__.'/../../main.inc.php'; @@ -45,8 +65,7 @@ if (empty($dolibarr_nocache)) { header('Cache-Control: max-age=10800, public, must-revalidate'); // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT'); -} -else { +} else { header('Cache-Control: no-cache'); } @@ -55,7 +74,9 @@ $manifest = new stdClass(); $manifest->name = constant('DOL_APPLICATION_TITLE'); -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $manifest->name = $conf->global->MAIN_APPLICATION_TITLE; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $manifest->name = $conf->global->MAIN_APPLICATION_TITLE; +} $manifest->theme_color = !empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR)?$conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR:'#F05F40'; @@ -64,21 +85,23 @@ $manifest->display = "standalone"; $manifest->splash_pages = null; $manifest->icons = array(); -if (!empty($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL)){ +if (!empty($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL)) { $icon = new stdClass(); $icon->src = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL; - if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) { $icon->sizes = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE."x".$conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE; } - else { $icon->sizes = "512x512"; } + if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) { + $icon->sizes = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE."x".$conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE; + } else { + $icon->sizes = "512x512"; + } $icon->type = "image/png"; $manifest->icons[] = $icon; -} -elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ - if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)){ +} elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)) { + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)) { $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; if (is_readable($iconPath)) { $imgSize = getimagesize($iconPath); - if ($imgSize){ + if ($imgSize) { $icon = new stdClass(); $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); $icon->sizes = $imgSize[0]."x".$imgSize[1]; @@ -88,12 +111,12 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ } } - if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)){ + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)) { $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; if (is_readable($iconPath)) { $imgSize = getimagesize($iconPath); - if ($imgSize){ + if ($imgSize) { $icon = new stdClass(); $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); $icon->sizes = $imgSize[0]."x".$imgSize[1]; @@ -103,12 +126,12 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ } } - if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)) { $iconRelativePath = 'logos/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; if (is_readable($iconPath)) { $imgSize = getimagesize($iconPath); - if ($imgSize){ + if ($imgSize) { $icon = new stdClass(); $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); $icon->sizes = $imgSize[0]."x".$imgSize[1]; @@ -120,7 +143,7 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ } // Add Dolibarr std icon -if (empty($manifest->icons)){ +if (empty($manifest->icons)) { $icon = new stdClass(); $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; $icon->sizes = "256x256"; diff --git a/htdocs/theme/eldy/progress.inc.php b/htdocs/theme/eldy/progress.inc.php index 71f25ff35ba..e74c84cf89e 100644 --- a/htdocs/theme/eldy/progress.inc.php +++ b/htdocs/theme/eldy/progress.inc.php @@ -1,5 +1,7 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ /* progress style is based on boostrap and admin lte framework @@ -12,183 +14,183 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> */ .progress * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .progress { - height: 20px; - overflow: hidden; - background-color: #f5f5f5; - background-color: rgba(128, 128, 128, 0.1); - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + height: 20px; + overflow: hidden; + background-color: #f5f5f5; + background-color: rgba(128, 128, 128, 0.1); + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); } .progress.spaced{ - margin-bottom: 20px; + margin-bottom: 20px; } .progress-bar { - float: left; - width: 0; - height: 100%; - font-size: 12px; - line-height: 20px; - color: #fff; - text-align: center; - background-color: #337ab7; - -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); - box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); - -webkit-transition: width .6s ease; - -o-transition: width .6s ease; - transition: width .6s ease; + float: left; + width: 0; + height: 100%; + font-size: 12px; + line-height: 20px; + color: #fff; + text-align: center; + background-color: #337ab7; + -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); + box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); + -webkit-transition: width .6s ease; + -o-transition: width .6s ease; + transition: width .6s ease; } .progress-group > .progress{ - clear: both; + clear: both; } .progress, .progress > .progress-bar { - -webkit-box-shadow: none; - box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; } .progress, .progress > .progress-bar, .progress .progress-bar, .progress > .progress-bar .progress-bar { - border-radius: 1px; + border-radius: 1px; } /* size variation */ .progress.sm, .progress-sm { - height: 10px; + height: 10px; } .progress.sm, .progress-sm, .progress.sm .progress-bar, .progress-sm .progress-bar { - border-radius: 1px; + border-radius: 1px; } .progress.xs, .progress-xs { - height: 7px; + height: 7px; } .progress.xs, .progress-xs, .progress.xs .progress-bar, .progress-xs .progress-bar { - border-radius: 1px; + border-radius: 1px; } .progress.xxs, .progress-xxs { - height: 3px; + height: 3px; } .progress.xxs, .progress-xxs, .progress.xxs .progress-bar, .progress-xxs .progress-bar { - border-radius: 1px; + border-radius: 1px; } /* Vertical bars */ .progress.vertical { - position: relative; - width: 30px; - height: 200px; - display: inline-block; - margin-right: 10px; + position: relative; + width: 30px; + height: 200px; + display: inline-block; + margin-right: 10px; } .progress.vertical > .progress-bar { - width: 100%; - position: absolute; - bottom: 0; + width: 100%; + position: absolute; + bottom: 0; } .progress.vertical.sm, .progress.vertical.progress-sm { - width: 20px; + width: 20px; } .progress.vertical.xs, .progress.vertical.progress-xs { - width: 10px; + width: 10px; } .progress.vertical.xxs, .progress.vertical.progress-xxs { - width: 3px; + width: 3px; } .progress-group .progress-text { - /* font-weight: 600; */ + /* font-weight: 600; */ } .progress-group .progress-number { - float: right; + float: right; } /* Remove margins from progress bars when put in a table */ .table tr > td .progress { - margin: 0; + margin: 0; } .progress-bar-light-blue, .progress-bar-primary { - background-color: #3c8dbc; + background-color: #3c8dbc; } .progress-striped .progress-bar-light-blue, .progress-striped .progress-bar-primary { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); } .progress-bar-green, .progress-bar-success { - background-color: <?php echo $badgeSuccess ?>; + background-color: <?php echo $badgeSuccess ?>; } .progress-striped .progress-bar-green, .progress-striped .progress-bar-success { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); } body[class*="colorblind-"] .progress-bar-green, body[class*="colorblind-"] .progress-bar-success { - background-color: <?php echo $colorblind_deuteranopes_badgeSuccess ?>; + background-color: <?php echo $colorblind_deuteranopes_badgeSuccess ?>; } body[class*="colorblind-"] .progress-bar-red, body[class*="colorblind-"] .progress-bar-danger { - background-color: <?php echo $colorblind_deuteranopes_badgeDanger ?>; + background-color: <?php echo $colorblind_deuteranopes_badgeDanger ?>; } .progress-bar-aqua, .progress-bar-info { - background-color: #00c0ef; + background-color: #00c0ef; } .progress-striped .progress-bar-aqua, .progress-striped .progress-bar-info { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); } .progress-bar-yellow, .progress-bar-warning { - background-color: <?php echo $badgeWarning ?>; + background-color: <?php echo $badgeWarning ?>; } .progress-striped .progress-bar-yellow, .progress-striped .progress-bar-warning { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); } .progress-bar-red, .progress-bar-danger { - background-color: <?php echo $badgeDanger ?>; + background-color: <?php echo $badgeDanger ?>; } .progress-striped .progress-bar-red, .progress-striped .progress-bar-danger { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); } .progress-bar-consumed { background-color: rgb(0, 0, 0, 0.15); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 319789b6fde..44a0a7d7b20 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -27,21 +27,35 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login. +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); // File must be accessed by logon page so without login. +} //if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We load menu manager class (note that object loaded may have wrong content because NOLOGIN is set and some values depends on login) -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} define('ISLOADEDBYSTEELSHEET', '1'); require __DIR__.'/theme_vars.inc.php'; -if (defined('THEME_ONLY_CONSTANT')) return; +if (defined('THEME_ONLY_CONSTANT')) { + return; +} session_cache_limiter('public'); @@ -51,8 +65,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) // and permission, so we can later calculate number of top menu ($nbtopmenuentries) according to user profile. -if (empty($user->id) && !empty($_SESSION['dol_login'])) -{ +if (empty($user->id) && !empty($_SESSION['dol_login'])) { $user->fetch('', $_SESSION['dol_login'], '', 1); $user->getrights(); @@ -65,12 +78,21 @@ if (empty($user->id) && !empty($_SESSION['dol_login'])) // Define css type top_httphead('text/css'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} -if (GETPOST('theme', 'alpha')) $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL -if (GETPOST('THEME_DARKMODEENABLED', 'int')) $conf->global->THEME_DARKMODEENABLED = GETPOST('THEME_DARKMODEENABLED', 'int'); // If darkmode was forced on URL +if (GETPOST('theme', 'alpha')) { + $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL +} +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL +} +if (GETPOST('THEME_DARKMODEENABLED', 'int')) { + $conf->global->THEME_DARKMODEENABLED = GETPOST('THEME_DARKMODEENABLED', 'int'); // If darkmode was forced on URL +} $langs->load("main", 0, 1); $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); @@ -78,7 +100,9 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $path = ''; // This value may be used in future for external module to overwrite theme $theme = 'eldy'; // Value of theme -if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { $path = '/'.$conf->global->MAIN_OVERWRITE_THEME_RES; $theme = $conf->global->MAIN_OVERWRITE_THEME_RES; } +if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { + $path = '/'.$conf->global->MAIN_OVERWRITE_THEME_RES; $theme = $conf->global->MAIN_OVERWRITE_THEME_RES; +} // Define image path files and other constants $fontlist = 'arial,tahoma,verdana,helvetica'; //$fontlist='helvetica, verdana, arial, sans-serif'; @@ -98,19 +122,36 @@ $useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global-> $borderwidth = 1; // Case of option always editable -if (!isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY = $colorbackbody; -if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; -if (!isset($conf->global->THEME_ELDY_VERMENU_BACK1)) $conf->global->THEME_ELDY_VERMENU_BACK1 = $colorbackvmenu1; -if (!isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1 = $colorbacktitle1; -if (!isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER = $colorbacklinepairhover; -if (!isset($conf->global->THEME_ELDY_USE_CHECKED)) $conf->global->THEME_ELDY_USE_CHECKED = $colorbacklinepairchecked; -if (!isset($conf->global->THEME_ELDY_LINEBREAK)) $conf->global->THEME_ELDY_LINEBREAK = $colorbacklinebreak; -if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB = $colortexttitlenotab; -if (!isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; +if (!isset($conf->global->THEME_ELDY_BACKBODY)) { + $conf->global->THEME_ELDY_BACKBODY = $colorbackbody; +} +if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +} +if (!isset($conf->global->THEME_ELDY_VERMENU_BACK1)) { + $conf->global->THEME_ELDY_VERMENU_BACK1 = $colorbackvmenu1; +} +if (!isset($conf->global->THEME_ELDY_BACKTITLE1)) { + $conf->global->THEME_ELDY_BACKTITLE1 = $colorbacktitle1; +} +if (!isset($conf->global->THEME_ELDY_USE_HOVER)) { + $conf->global->THEME_ELDY_USE_HOVER = $colorbacklinepairhover; +} +if (!isset($conf->global->THEME_ELDY_USE_CHECKED)) { + $conf->global->THEME_ELDY_USE_CHECKED = $colorbacklinepairchecked; +} +if (!isset($conf->global->THEME_ELDY_LINEBREAK)) { + $conf->global->THEME_ELDY_LINEBREAK = $colorbacklinebreak; +} +if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) { + $conf->global->THEME_ELDY_TEXTTITLENOTAB = $colortexttitlenotab; +} +if (!isset($conf->global->THEME_ELDY_TEXTLINK)) { + $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; +} // Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on -if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) -{ +if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) { $conf->global->THEME_ELDY_BACKTABCARD1 = '255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE = '234,234,234'; $conf->global->THEME_ELDY_TEXT = '0,0,0'; @@ -142,8 +183,7 @@ $fontsizesmaller = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (emp // Hover color $colorbacklinepairhover = ((!isset($conf->global->THEME_ELDY_USE_HOVER) || (string) $conf->global->THEME_ELDY_USE_HOVER === '255,255,255') ? '' : ($conf->global->THEME_ELDY_USE_HOVER === '1' ? 'e6edf0' : $conf->global->THEME_ELDY_USE_HOVER)); $colorbacklinepairchecked = ((!isset($conf->global->THEME_ELDY_USE_CHECKED) || (string) $conf->global->THEME_ELDY_USE_CHECKED === '255,255,255') ? '' : ($conf->global->THEME_ELDY_USE_CHECKED === '1' ? 'e6edf0' : $conf->global->THEME_ELDY_USE_CHECKED)); -if (!empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) -{ +if (!empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) { $colorbacklinepairhover = ((!isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '0') ? '' : ($user->conf->THEME_ELDY_USE_HOVER === '1' ? 'e6edf0' : $user->conf->THEME_ELDY_USE_HOVER)); $colorbacklinepairchecked = ((!isset($user->conf->THEME_ELDY_USE_CHECKED) || $user->conf->THEME_ELDY_USE_CHECKED === '0') ? '' : ($user->conf->THEME_ELDY_USE_CHECKED === '1' ? 'e6edf0' : $user->conf->THEME_ELDY_USE_CHECKED)); } @@ -153,26 +193,42 @@ if (!empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbackhmenu1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) $colortextbackhmenu = 'FFFFFF'; -else $colortextbackhmenu = '000000'; +if ($tmpval <= 460) { + $colortextbackhmenu = 'FFFFFF'; +} else { + $colortextbackhmenu = '000000'; +} $colorbackvmenu1 = join(',', colorStringToArray($colorbackvmenu1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbackvmenu1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) { $colortextbackvmenu = 'FFFFFF'; } else { $colortextbackvmenu = '000000'; } +if ($tmpval <= 460) { + $colortextbackvmenu = 'FFFFFF'; +} else { + $colortextbackvmenu = '000000'; +} $colorbacktitle1 = join(',', colorStringToArray($colorbacktitle1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktitle1); -if ($colortexttitle == '') -{ +if ($colortexttitle == '') { $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); - if ($tmpval <= 460) { $colortexttitle = 'FFFFFF'; $colorshadowtitle = '888888'; } else { $colortexttitle = '000000'; $colorshadowtitle = 'FFFFFF'; } -} else $colorshadowtitle = '888888'; + if ($tmpval <= 460) { + $colortexttitle = 'FFFFFF'; $colorshadowtitle = '888888'; + } else { + $colortexttitle = '000000'; $colorshadowtitle = 'FFFFFF'; + } +} else { + $colorshadowtitle = '888888'; +} $colorbacktabcard1 = join(',', colorStringToArray($colorbacktabcard1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktabcard1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) { $colortextbacktab = 'FFFFFF'; } else { $colortextbacktab = '000000'; } +if ($tmpval <= 460) { + $colortextbacktab = 'FFFFFF'; +} else { + $colortextbacktab = '000000'; +} // Format color value to match expected format (may be 'FFFFFF' or '255,255,255') @@ -185,8 +241,12 @@ $colorbacklineimpair1 = join(',', colorStringToArray($colorbacklineimpair1)); $colorbacklineimpair2 = join(',', colorStringToArray($colorbacklineimpair2)); $colorbacklinepair1 = join(',', colorStringToArray($colorbacklinepair1)); $colorbacklinepair2 = join(',', colorStringToArray($colorbacklinepair2)); -if ($colorbacklinepairhover != '') $colorbacklinepairhover = join(',', colorStringToArray($colorbacklinepairhover)); -if ($colorbacklinepairchecked != '') $colorbacklinepairchecked = join(',', colorStringToArray($colorbacklinepairchecked)); +if ($colorbacklinepairhover != '') { + $colorbacklinepairhover = join(',', colorStringToArray($colorbacklinepairhover)); +} +if ($colorbacklinepairchecked != '') { + $colorbacklinepairchecked = join(',', colorStringToArray($colorbacklinepairchecked)); +} $colorbackbody = join(',', colorStringToArray($colorbackbody)); $colortexttitlenotab = join(',', colorStringToArray($colortexttitlenotab)); $colortexttitle = join(',', colorStringToArray($colortexttitle)); @@ -195,7 +255,9 @@ $colortextlink = join(',', colorStringToArray($colortextlink)); $nbtopmenuentries = $menumanager->showmenu('topnb'); -if ($conf->browser->layout == 'phone') $nbtopmenuentries = max($nbtopmenuentries, 10); +if ($conf->browser->layout == 'phone') { + $nbtopmenuentries = max($nbtopmenuentries, 10); +} $minwidthtmenu = 66; /* minimum width for one top menu entry */ @@ -203,11 +265,19 @@ $heightmenu = 50; /* height of top menu, part with image */ $heightmenu2 = 49; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 180; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = $maxwidthloginblock + 50; $minwidthtmenu = 0; } +if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { + $disableimages = 1; $maxwidthloginblock = $maxwidthloginblock + 50; $minwidthtmenu = 0; +} -if (!empty($conf->global->MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN)) { $maxwidthloginblock = $maxwidthloginblock + 55; } -if (!empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) { $maxwidthloginblock = $maxwidthloginblock + 55; } -if (!empty($conf->bookmark->enabled)) { $maxwidthloginblock = $maxwidthloginblock + 55; } +if (!empty($conf->global->MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN)) { + $maxwidthloginblock = $maxwidthloginblock + 55; +} +if (!empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) { + $maxwidthloginblock = $maxwidthloginblock + 55; +} +if (!empty($conf->bookmark->enabled)) { + $maxwidthloginblock = $maxwidthloginblock + 55; +} print '/*'."\n"; @@ -247,4 +317,6 @@ print '*/'."\n"; require __DIR__.'/global.inc.php'; -if (is_object($db)) $db->close(); +if (is_object($db)) { + $db->close(); +} diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index cc73803f452..8bb2fd3bbca 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -33,12 +33,9 @@ global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; $theme_bordercolor = array(235, 235, 224); $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(80, 166, 90), array(190, 190, 100), array(91, 115, 247), array(140, 140, 220), array(190, 120, 120), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150)); -if (!defined('ISLOADEDBYSTEELSHEET')) // File is run after an include of a php page, not by the style sheet, if the constant is not defined. -{ - if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) // user is loaded by dolgraph.class.php - { - if ($conf->global->MAIN_OPTIMIZEFORCOLORBLIND == 'flashy') - { +if (!defined('ISLOADEDBYSTEELSHEET')) { // File is run after an include of a php page, not by the style sheet, if the constant is not defined. + if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) { // user is loaded by dolgraph.class.php + if ($conf->global->MAIN_OPTIMIZEFORCOLORBLIND == 'flashy') { $theme_datacolor = array(array(157, 56, 191), array(0, 147, 183), array(250, 190, 30), array(221, 75, 57), array(0, 166, 90), array(140, 140, 220), array(190, 120, 120), array(190, 190, 100), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150)); } else { // for now we use the same configuration for all types of color blind diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index d5fba863b3d..161505f77ea 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -1,6 +1,6 @@ <?php /*! - Source : + Source : * AdminLTE v2.4.8 * Author: Almsaeed Studio * Website: Almsaeed Studio <https://adminlte.io> @@ -8,7 +8,9 @@ * Please visit http://opensource.org/licenses/MIT for more information */ -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ @@ -17,68 +19,68 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> * ------------------- */ .timeline { - position: relative; - margin: 0 0 30px 0; - padding: 0; - list-style: none; + position: relative; + margin: 0 0 30px 0; + padding: 0; + list-style: none; } .timeline:before { - content: ''; - position: absolute; - top: 0; - bottom: 0; - width: 4px; - background: #ddd; - left: 31px; - margin: 0; - border-radius: 2px; + content: ''; + position: absolute; + top: 0; + bottom: 0; + width: 4px; + background: #ddd; + left: 31px; + margin: 0; + border-radius: 2px; } .timeline > li { - position: relative; - margin-right: 0; - margin-bottom: 15px; + position: relative; + margin-right: 0; + margin-bottom: 15px; } .timeline > li:before, .timeline > li:after { - content: " "; - display: table; + content: " "; + display: table; } .timeline > li:after { - clear: both; + clear: both; } .timeline > li > .timeline-item { - -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); - border:1px solid #d2d2d2; - border-radius: 3px; - margin-top: 0; - background: #fff; - color: #444; - margin-left: 60px; - margin-right: 0px; - padding: 0; - position: relative; + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border:1px solid #d2d2d2; + border-radius: 3px; + margin-top: 0; + background: #fff; + color: #444; + margin-left: 60px; + margin-right: 0px; + padding: 0; + position: relative; } .timeline > li.timeline-code-ticket_msg_private > .timeline-item { background: #fffbe5; - border-color: #d0cfc0; + border-color: #d0cfc0; } .timeline > li > .timeline-item > .time{ - color: #6f6f6f; - float: right; - padding: 10px; - font-size: 12px; + color: #6f6f6f; + float: right; + padding: 10px; + font-size: 12px; } .timeline > li > .timeline-item > .timeline-header-action{ - color: #6f6f6f; - float: right; - padding: 7px; - font-size: 12px; + color: #6f6f6f; + float: right; + padding: 7px; + font-size: 12px; } @@ -87,43 +89,43 @@ a.timeline-btn:visited, a.timeline-btn:hover, a.timeline-btn:active { - display: inline-block; - margin-bottom: 0; - font-weight: 400; - border-radius: 0; - box-shadow: none; - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - text-align: center; - white-space: nowrap; - vertical-align: middle; - touch-action: manipulation; - cursor: pointer; - user-select: none; - background-image: none; - text-decoration: none; - background-color: #f4f4f4; - color: #444; - border: 1px solid #ddd; + display: inline-block; + margin-bottom: 0; + font-weight: 400; + border-radius: 0; + box-shadow: none; + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + text-align: center; + white-space: nowrap; + vertical-align: middle; + touch-action: manipulation; + cursor: pointer; + user-select: none; + background-image: none; + text-decoration: none; + background-color: #f4f4f4; + color: #444; + border: 1px solid #ddd; } a.timeline-btn:hover { - background-color: #e7e7e7; - color: #333; - border-color: #adadad; + background-color: #e7e7e7; + color: #333; + border-color: #adadad; } .timeline > li > .timeline-item > .timeline-header { - margin: 0; - color: #333; - border-bottom: 1px solid #f4f4f4; - padding: 10px; - font-size: 14px; - font-weight: normal; - line-height: 1.1; + margin: 0; + color: #333; + border-bottom: 1px solid #f4f4f4; + padding: 10px; + font-size: 14px; + font-weight: normal; + line-height: 1.1; } .timeline > li > .timeline-item > .timeline-footer { @@ -131,74 +133,74 @@ a.timeline-btn:hover } .timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-header, .timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-footer { - border-color: #ecebda; + border-color: #ecebda; } .timeline > li > .timeline-item > .timeline-header > a { - font-weight: 600; + font-weight: 600; } .timeline > li > .timeline-item > .timeline-body, .timeline > li > .timeline-item > .timeline-footer { - padding: 10px; + padding: 10px; } .timeline > li > .fa, .timeline > li > .glyphicon, .timeline > li > .ion { - width: 30px; - height: 30px; - font-size: 15px; - line-height: 30px; - position: absolute; - color: #666; - background: #d2d6de; - border-radius: 50%; - text-align: center; - left: 18px; - top: 5px; + width: 30px; + height: 30px; + font-size: 15px; + line-height: 30px; + position: absolute; + color: #666; + background: #d2d6de; + border-radius: 50%; + text-align: center; + left: 18px; + top: 5px; } .timeline > .time-label > span { - font-weight: 600; - padding: 5px; - display: inline-block; - background-color: #fff; - border-radius: 4px; + font-weight: 600; + padding: 5px; + display: inline-block; + background-color: #fff; + border-radius: 4px; } .timeline-inverse > li > .timeline-item { - background: #f0f0f0; - border: 1px solid #ddd; - -webkit-box-shadow: none; - box-shadow: none; + background: #f0f0f0; + border: 1px solid #ddd; + -webkit-box-shadow: none; + box-shadow: none; } .timeline-inverse > li > .timeline-item > .timeline-header { - border-bottom-color: #ddd; + border-bottom-color: #ddd; } .timeline-icon-todo, .timeline-icon-in-progress, .timeline-icon-done{ - color: #fff !important; + color: #fff !important; } .timeline-icon-not-applicble{ - color: #000; - background-color: #f7f7f7; + color: #000; + background-color: #f7f7f7; } .timeline-icon-todo{ - background-color: #dd4b39 !important; + background-color: #dd4b39 !important; } .timeline-icon-in-progress{ - background-color: #00c0ef !important; + background-color: #00c0ef !important; } .timeline-icon-done{ - background-color: #00a65a !important; + background-color: #00a65a !important; } .timeline-badge-date{ - background-color: #0073b7 !important; - color: #fff !important; + background-color: #0073b7 !important; + color: #fff !important; } .timeline-documents-container{ diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index 1ce2d912669..7dd0229ae46 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -1,135 +1,137 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ /* Badge style is based on boostrap framework */ .badge { - display: inline-block; - padding: .1em .35em; - font-size: 80%; - font-weight: 700 !important; - line-height: 1; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25rem; - transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; - border-width: 2px; - border-style: solid; - border-color: rgba(255,255,255,0); - box-sizing: border-box; + display: inline-block; + padding: .1em .35em; + font-size: 80%; + font-weight: 700 !important; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: .25rem; + transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; + border-width: 2px; + border-style: solid; + border-color: rgba(255,255,255,0); + box-sizing: border-box; } .badge-status { - font-size: 1em; - padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ + font-size: 1em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ } .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status { - font-size: 1.1em; - padding: .4em .4em; + font-size: 1.1em; + padding: .4em .4em; } /* Force values for small screen 767 */ @media only screen and (max-width: 767px) { .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status { - font-size: 0.95em; - padding: .3em .2em; + font-size: 0.95em; + padding: .3em .2em; } } .badge-pill, .tabs .badge { - padding-right: .5em; - padding-left: .5em; - border-radius: 0.25rem; + padding-right: .5em; + padding-left: .5em; + border-radius: 0.25rem; } .badge-dot { - padding: 0; - border-radius: 50%; - padding: 0.45em; - vertical-align: unset; + padding: 0; + border-radius: 50%; + padding: 0.45em; + vertical-align: unset; } a.badge:focus, a.badge:hover { - text-decoration: none; + text-decoration: none; } .liste_titre .badge:not(.nochangebackground) { - background-color: <?php print $badgeSecondary; ?>; - color: #fff; + background-color: <?php print $badgeSecondary; ?>; + color: #fff; } /* PRIMARY */ .badge-primary{ - color: #fff !important; - background-color: <?php print $badgePrimary; ?>; + color: #fff !important; + background-color: <?php print $badgePrimary; ?>; } a.badge-primary.focus, a.badge-primary:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>; } a.badge-primary:focus, a.badge-primary:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgePrimary, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgePrimary, 10); ?>; } /* SECONDARY */ .badge-secondary, .tabs .badge { - color: #fff !important; - background-color: <?php print $badgeSecondary; ?>; + color: #fff !important; + background-color: <?php print $badgeSecondary; ?>; } a.badge-secondary.focus, a.badge-secondary:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>; } a.badge-secondary:focus, a.badge-secondary:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeSecondary, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeSecondary, 10); ?>; } /* SUCCESS */ .badge-success { - color: #fff !important; - background-color: <?php print $badgeSuccess; ?>; + color: #fff !important; + background-color: <?php print $badgeSuccess; ?>; } a.badge-success.focus, a.badge-success:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>; } a.badge-success:focus, a.badge-success:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeSuccess, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeSuccess, 10); ?>; } /* DANGER */ .badge-danger { - color: #fff !important; - background-color: <?php print $badgeDanger; ?>; + color: #fff !important; + background-color: <?php print $badgeDanger; ?>; } a.badge-danger.focus, a.badge-danger:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>; } a.badge-danger:focus, a.badge-danger:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeDanger, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeDanger, 10); ?>; } /* WARNING */ .badge-warning { - color: #fff !important; - background-color: <?php print $badgeWarning; ?>; + color: #fff !important; + background-color: <?php print $badgeWarning; ?>; } a.badge-warning.focus, a.badge-warning:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>; } a.badge-warning:focus, a.badge-warning:hover { - color: #212529 !important; - background-color: <?php print colorDarker($badgeWarning, 10); ?>; + color: #212529 !important; + background-color: <?php print colorDarker($badgeWarning, 10); ?>; } /* WARNING colorblind */ @@ -145,44 +147,44 @@ body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover { /* INFO */ .badge-info { - color: #fff !important; - background-color: <?php print $badgeInfo; ?>; + color: #fff !important; + background-color: <?php print $badgeInfo; ?>; } a.badge-info.focus, a.badge-info:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>; } a.badge-info:focus, a.badge-info:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeInfo, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeInfo, 10); ?>; } /* LIGHT */ .badge-light { - color: #212529 !important; - background-color: <?php print $badgeLight; ?>; + color: #212529 !important; + background-color: <?php print $badgeLight; ?>; } a.badge-light.focus, a.badge-light:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>; } a.badge-light:focus, a.badge-light:hover { - color: #212529 !important; - background-color: <?php print colorDarker($badgeLight, 10); ?>; + color: #212529 !important; + background-color: <?php print colorDarker($badgeLight, 10); ?>; } /* DARK */ .badge-dark { - color: #fff !important; - background-color: <?php print $badgeDark; ?>; + color: #fff !important; + background-color: <?php print $badgeDark; ?>; } a.badge-dark.focus, a.badge-dark:focus { - outline: 0; - box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>; + outline: 0; + box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>; } a.badge-dark:focus, a.badge-dark:hover { - color: #fff !important; - background-color: <?php print colorDarker($badgeDark, 10); ?>; + color: #fff !important; + background-color: <?php print colorDarker($badgeDark, 10); ?>; } @@ -231,8 +233,12 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL $thisBadgeBackgroundColor = "#fff"; } - if (in_array((string) $statusName, array('0', '5', '9'))) $thisBadgeTextColor = '#999999'; - if (in_array((string) $statusName, array('6'))) $thisBadgeTextColor = '#777777'; + if (in_array((string) $statusName, array('0', '5', '9'))) { + $thisBadgeTextColor = '#999999'; + } + if (in_array((string) $statusName, array('6'))) { + $thisBadgeTextColor = '#777777'; + } print $cssPrefix.".badge-status".$statusName." {\n"; print " color: ".$thisBadgeTextColor." !important;\n"; diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php index 1b27e7eeafb..8fc5fe1aacc 100644 --- a/htdocs/theme/md/btn.inc.php +++ b/htdocs/theme/md/btn.inc.php @@ -1,17 +1,19 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ :root { - --btncolortext:rgb(<?php print $colortextlink; ?>); - --btncolorbg: #fbfbfb; - --btncolorborderhover: none; - --btncolorborder: #FFF; - --butactiondeletebg: rgb(234,228,225); - /* tertiary color */ - /* --butactionbg:rgb(218, 235, 225); */ - /* --butactionbg:rgb(228, 218, 235); */ - --butactionbg:rgb(118, 145, 225); + --btncolortext:rgb(<?php print $colortextlink; ?>); + --btncolorbg: #fbfbfb; + --btncolorborderhover: none; + --btncolorborder: #FFF; + --butactiondeletebg: rgb(234,228,225); + /* tertiary color */ + /* --butactionbg:rgb(218, 235, 225); */ + /* --butactionbg:rgb(228, 218, 235); */ + --butactionbg:rgb(118, 145, 225); } <?php @@ -50,7 +52,7 @@ div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tab margin-bottom: 1.4em !important; } div.tabsActionNoBottom > a.butAction, div.tabsActionNoBottom > a.butActionRefused { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } span.butAction, span.butActionDelete { @@ -58,44 +60,44 @@ span.butAction, span.butActionDelete { } .butAction { - background: var(--butactionbg); - color: #FFF !important; - border-radius: 3px; - /* background: rgb(230, 232, 239); */ + background: var(--butactionbg); + color: #FFF !important; + border-radius: 3px; + /* background: rgb(230, 232, 239); */ } .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { - text-decoration: none; - text-transform: uppercase; - font-weight: bold; + text-decoration: none; + text-transform: uppercase; + font-weight: bold; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; - padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; - font-family: <?php print $fontlist ?>; - display: inline-block; - text-align: center; - cursor: pointer; - /* color: #fff; */ - /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ - color: #444; - /* border: 1px solid #aaa; */ - /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; + padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; + font-family: <?php print $fontlist ?>; + display: inline-block; + text-align: center; + cursor: pointer; + /* color: #fff; */ + /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ + color: #444; + /* border: 1px solid #aaa; */ + /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ - /*border-top-right-radius: 0 !important; - border-bottom-right-radius: 0 !important; - border-top-left-radius: 0 !important; - border-bottom-left-radius: 0 !important;*/ + /*border-top-right-radius: 0 !important; + border-bottom-right-radius: 0 !important; + border-top-left-radius: 0 !important; + border-bottom-left-radius: 0 !important;*/ } .butActionNew, .butActionNewRefused, .butActionNew:link, .butActionNew:visited, .butActionNew:hover, .butActionNew:active { - text-decoration: none; - text-transform: uppercase; - font-weight: normal; + text-decoration: none; + text-transform: uppercase; + font-weight: normal; - margin: 0em 0.3em 0 0.3em !important; - padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em 0.3em; - font-family: <?php print $fontlist ?>; - display: inline-block; - /* text-align: center; New button are on right of screen */ - cursor: pointer; + margin: 0em 0.3em 0 0.3em !important; + padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em 0.3em; + font-family: <?php print $fontlist ?>; + display: inline-block; + /* text-align: center; New button are on right of screen */ + cursor: pointer; } .button { @@ -211,61 +213,61 @@ span.butActionNewRefused>span.fa, span.butActionNewRefused>span.fa:hover } .butAction:hover { - -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); } .butActionNew:hover { - text-decoration: underline; - box-shadow: unset !important; + text-decoration: underline; + box-shadow: unset !important; } .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active, .buttonDelete { - background: var(--butactiondeletebg); - /* border: 1px solid #633; */ - color: #633; + background: var(--butactiondeletebg); + /* border: 1px solid #633; */ + color: #633; } .butActionDelete:hover { - -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 6px 1px rgba(50, 50, 50, 0.4), 0px 0px 0px rgba(60,60,60,0.1); } .butActionRefused { - text-decoration: none !important; - text-transform: uppercase; - font-weight: bold !important; + text-decoration: none !important; + text-transform: uppercase; + font-weight: bold !important; - white-space: nowrap !important; - cursor: not-allowed !important; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; - padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; - font-family: <?php print $fontlist ?> !important; - display: inline-block; - text-align: center; - cursor: pointer; - color: #999 !important; - border: 1px solid #ccc; - box-sizing: border-box; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; + white-space: nowrap !important; + cursor: not-allowed !important; + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em; + padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em; + font-family: <?php print $fontlist ?> !important; + display: inline-block; + text-align: center; + cursor: pointer; + color: #999 !important; + border: 1px solid #ccc; + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; } .butActionNewRefused, .butActionNewRefused:link, .butActionNewRefused:visited, .butActionNewRefused:hover, .butActionNewRefused:active { - text-decoration: none !important; - text-transform: uppercase; - font-weight: normal !important; + text-decoration: none !important; + text-transform: uppercase; + font-weight: normal !important; - white-space: nowrap !important; - cursor: not-allowed !important; - margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; - padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; - font-family: <?php print $fontlist ?> !important; - display: inline-block; - /* text-align: center; New button are on right of screen */ - cursor: pointer; - color: #999 !important; - padding-top: 0.2em; - box-shadow: none !important; - -webkit-box-shadow: none !important; + white-space: nowrap !important; + cursor: not-allowed !important; + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; + padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; + font-family: <?php print $fontlist ?> !important; + display: inline-block; + /* text-align: center; New button are on right of screen */ + cursor: pointer; + color: #999 !important; + padding-top: 0.2em; + box-shadow: none !important; + -webkit-box-shadow: none !important; } .butActionTransparent { @@ -279,41 +281,41 @@ TITLE BUTTON */ div.pagination li:first-child a.btnTitle { - margin-left: 10px; + margin-left: 10px; } .btnTitle, a.btnTitle { - display: inline-block; - padding: 6px 12px; - font-size: 14px - font-weight: 400; - line-height: 1.4; - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - box-shadow: none; - text-decoration: none; - position: relative; - margin: 0 0 0 10px; - min-width: 80px; - text-align: center; - color: rgb(<?php print $colortextlink; ?>); - border: none; - font-size: 12px; - font-weight: 300; - background-color: #fbfbfb; + display: inline-block; + padding: 6px 12px; + font-size: 14px + font-weight: 400; + line-height: 1.4; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + box-shadow: none; + text-decoration: none; + position: relative; + margin: 0 0 0 10px; + min-width: 80px; + text-align: center; + color: rgb(<?php print $colortextlink; ?>); + border: none; + font-size: 12px; + font-weight: 300; + background-color: #fbfbfb; } a.btnTitle.btnTitleSelected { - border: 1px solid #ccc; - border-radius: 3px; + border: 1px solid #ccc; + border-radius: 3px; } .btnTitle > .btnTitle-icon{ @@ -321,42 +323,42 @@ a.btnTitle.btnTitleSelected { } .btnTitle > .btnTitle-label{ - color: #666666; + color: #666666; } .btnTitle:hover, a.btnTitle:hover { - border-radius: 3px; - position: relative; - margin: 0 0 0 10px; - text-align: center; - color: #ffffff; - background-color: rgb(<?php print $colortextlink; ?>); - font-size: 12px; - text-decoration: none; - box-shadow: none; + border-radius: 3px; + position: relative; + margin: 0 0 0 10px; + text-align: center; + color: #ffffff; + background-color: rgb(<?php print $colortextlink; ?>); + font-size: 12px; + text-decoration: none; + box-shadow: none; } .btnTitle.refused, a.btnTitle.refused, .btnTitle.refused:hover, a.btnTitle.refused:hover { - color: #8a8a8a; - cursor: not-allowed; - background-color: #fbfbfb; - background: repeating-linear-gradient( 45deg, #ffffff, #f1f1f1 4px, #f1f1f1 4px, #f1f1f1 4px ); + color: #8a8a8a; + cursor: not-allowed; + background-color: #fbfbfb; + background: repeating-linear-gradient( 45deg, #ffffff, #f1f1f1 4px, #f1f1f1 4px, #f1f1f1 4px ); } .btnTitle:hover .btnTitle-label{ - color: #ffffff; + color: #ffffff; } div.pagination .btnTitle:hover .btnTitle-label{ color: rgb(<?php print $colortextlink; ?>); } .btnTitle.refused .btnTitle-label, .btnTitle.refused:hover .btnTitle-label{ - color: #8a8a8a; + color: #8a8a8a; } .btnTitle>.fa { - font-size: 20px; - display: block; + font-size: 20px; + display: block; } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @@ -366,15 +368,15 @@ div.pagination .btnTitle:hover .btnTitle-label{ font-size: 0.95em; } .btnTitle, a.btnTitle { - display: inline-block; - padding: 4px 4px 4px 4px; + display: inline-block; + padding: 4px 4px 4px 4px; min-width: unset; } } <?php if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin)) { ?> .butActionRefused, .butActionNewRefused, .btnTitle.refused { - display: none !important; + display: none !important; } <?php } ?> diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 6f7d55a285c..9b96c9b061b 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -1,5 +1,7 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > dont remove this line it's an ide hack */ /* @@ -7,15 +9,15 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> */ .bookmark-footer a.top-menu-dropdown-link { - white-space: normal; + white-space: normal; } button.dropdown-item.global-search-item { - outline: none; + outline: none; } .open>.dropdown-search, .open>.dropdown-bookmark, .open>.dropdown-menu, .dropdown dd ul.open { - display: block; + display: block; } @@ -23,9 +25,9 @@ button.dropdown-item.global-search-item { color: #fff; } div#topmenu-bookmark-dropdown { - position: fixed; - right: 20px; - top: 0px; + position: fixed; + right: 20px; + top: 0px; } #topmenu-login-dropdown .dropdown-toggle:after { @@ -33,347 +35,347 @@ div#topmenu-bookmark-dropdown { } #topmenu-bookmark-dropdown .dropdown-menu { - width: 300px; + width: 300px; } button.dropdown-item.global-search-item { - outline: none; + outline: none; } .open>.dropdown-search, .open>.dropdown-bookmark, .open>.dropdown-menu{ - display: block; + display: block; } .dropdown-search { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-bookmark { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-menu { - border-color: #eee; + border-color: #eee; - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-toggle{ - text-decoration: none !important; + text-decoration: none !important; } .dropdown-toggle::after { - /* font part */ - font-family: "Font Awesome 5 Free"; - font-size: 0.7em; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - text-align:center; - text-decoration:none; - margin: auto 3px; - display: inline-block; - content: "\f078"; + /* font part */ + font-family: "Font Awesome 5 Free"; + font-size: 0.7em; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + text-align:center; + text-decoration:none; + margin: auto 3px; + display: inline-block; + content: "\f078"; - -webkit-transition: -webkit-transform .2s ease-in-out; - -ms-transition: -ms-transform .2s ease-in-out; - transition: transform .2s ease-in-out; + -webkit-transition: -webkit-transform .2s ease-in-out; + -ms-transition: -ms-transform .2s ease-in-out; + transition: transform .2s ease-in-out; } .open>.dropdown-toggle::after { - transform: rotate(180deg); + transform: rotate(180deg); } /* * MENU Dropdown */ .login_block.usedropdown .logout-btn{ - /* display: none; */ + /* display: none; */ } .tmenu .open.dropdown, .tmenu .open.dropdown { - background: rgba(0, 0, 0, 0.1); + background: rgba(0, 0, 0, 0.1); } .tmenu .dropdown-menu, .login_block .dropdown-menu { - position: absolute; - right: 0; - <?php echo $left; ?>: auto; - line-height:1.3em; + position: absolute; + right: 0; + <?php echo $left; ?>: auto; + line-height:1.3em; } .tmenu .dropdown-menu, .login_block .dropdown-menu .user-body { - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; } .user-body { - color: #333; + color: #333; } .side-nav-vert .user-menu .dropdown-menu { - border-top-right-radius: 0; - border-top-left-radius: 0; - padding: 1px 0 0 0; - border-top-width: 0; - width: 300px; + border-top-right-radius: 0; + border-top-left-radius: 0; + padding: 1px 0 0 0; + border-top-width: 0; + width: 300px; } .side-nav-vert .user-menu .dropdown-menu { - margin-top: 0; - border-top-left-radius: 0; - border-top-right-radius: 0; + margin-top: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; } .side-nav-vert .user-menu .dropdown-menu > .user-header { - min-height: 100px; - padding: 10px; - text-align: center; - white-space: normal; + min-height: 100px; + padding: 10px; + text-align: center; + white-space: normal; } #topmenu-global-search-dropdown .dropdown-menu{ - width: 300px; - max-width: 100%; + width: 300px; + max-width: 100%; } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown { - line-height: 46px; + line-height: 46px; } a.top-menu-dropdown-link { - padding: 8px; + padding: 8px; } .dropdown-user-image { - border-radius: 50%; - vertical-align: middle; - z-index: 5; - height: 90px; - width: 90px; - border: 3px solid; - border-color: transparent; - border-color: rgba(255, 255, 255, 0.2); - max-width: 100%; - max-height :100%; + border-radius: 50%; + vertical-align: middle; + z-index: 5; + height: 90px; + width: 90px; + border: 3px solid; + border-color: transparent; + border-color: rgba(255, 255, 255, 0.2); + max-width: 100%; + max-height :100%; } .dropdown-menu > .user-header{ - background: rgb(<?php echo $colorbackhmenu1 ?>); + background: rgb(<?php echo $colorbackhmenu1 ?>); } .dropdown-menu .dropdown-header{ - padding: 8px 10px 10px 10px; + padding: 8px 10px 10px 10px; } .dropdown-menu > .user-footer { - background-color: #f9f9f9; - padding: 10px; + background-color: #f9f9f9; + padding: 10px; } .user-footer:after { - clear: both; + clear: both; } .dropdown-menu > .bookmark-footer{ - border-top: 1px solid #f0f0f0; - background-color: #f9f9f9; - padding: 10px; + border-top: 1px solid #f0f0f0; + background-color: #f9f9f9; + padding: 10px; } .dropdown-menu > .user-body, .dropdown-body{ - padding: 15px; - border-bottom: 1px solid #f4f4f4; - border-top: 1px solid #dddddd; - white-space: normal; + padding: 15px; + border-bottom: 1px solid #f4f4f4; + border-top: 1px solid #dddddd; + white-space: normal; } .dropdown-menu > .bookmark-body, .dropdown-body{ - padding: 10px 0; - overflow-y: auto; - max-height: 60vh ; /* fallback for browsers without support for calc() */ - max-height: calc(90vh - 110px) ; + padding: 10px 0; + overflow-y: auto; + max-height: 60vh ; /* fallback for browsers without support for calc() */ + max-height: calc(90vh - 110px) ; white-space: normal; } #topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ - max-height: 60vh ; /* fallback for browsers without support for calc() */ - max-height: calc(90vh - 200px) ; + max-height: 60vh ; /* fallback for browsers without support for calc() */ + max-height: calc(90vh - 200px) ; } .dropdown-body::-webkit-scrollbar { - width: 8px; - } + width: 8px; + } .dropdown-body::-webkit-scrollbar-thumb { - -webkit-border-radius: 0; - border-radius: 0; - /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ - background: #aaa; + -webkit-border-radius: 0; + border-radius: 0; + /* background: rgb(<?php echo $colorbackhmenu1 ?>); */ + background: #aaa; } .dropdown-body::-webkit-scrollbar-track { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - -webkit-border-radius: 0; - border-radius: 0; + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + -webkit-border-radius: 0; + border-radius: 0; } #topmenu-login-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown { - padding: 0 5px 0 5px; + padding: 0 5px 0 5px; } #topmenu-login-dropdown a:hover{ - text-decoration: none; + text-decoration: none; } #topmenuloginmoreinfo-btn{ - display: block; - text-aling: right; - color:#666; - cursor: pointer; + display: block; + text-aling: right; + color:#666; + cursor: pointer; } #topmenuloginmoreinfo{ - display: none; - clear: both; - font-size: 0.95em; + display: none; + clear: both; + font-size: 0.95em; } .button-top-menu-dropdown { - display: inline-block; - padding: 6px 12px; - margin-bottom: 0; - font-size: 14px; - font-weight: 400; - line-height: 1.42857143; - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-image: none; + border: 1px solid transparent; + border-radius: 4px; } .user-footer .button-top-menu-dropdown { - color: #666666; - border-radius: 0; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - border-width: 1px; - background-color: #f4f4f4; - border-color: #ddd; + color: #666666; + border-radius: 0; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + border-width: 1px; + background-color: #f4f4f4; + border-color: #ddd; } .dropdown-menu a.top-menu-dropdown-link { - color: rgb(<?php print $colortextlink; ?>) !important; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - display: block; - margin: 5px 0px; + color: rgb(<?php print $colortextlink; ?>) !important; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + display: block; + margin: 5px 0px; } .dropdown-item { - display: block !important; - box-sizing: border-box; - width: 100%; - padding: .25rem 1.5rem .25rem 1rem; - clear: both; - font-weight: 400; - color: #212529 !important; - text-align: inherit; - background-color: transparent; - border: 0; + display: block !important; + box-sizing: border-box; + width: 100%; + padding: .25rem 1.5rem .25rem 1rem; + clear: both; + font-weight: 400; + color: #212529 !important; + text-align: inherit; + background-color: transparent; + border: 0; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; } .dropdown-item::before { - /* font part */ - font-family: "Font Awesome 5 Free"; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - text-align:center; - text-decoration:none; - margin-right: 5px; - display: inline-block; - content: "\f0da"; - color: rgba(0,0,0,0.3); + /* font part */ + font-family: "Font Awesome 5 Free"; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + text-align:center; + text-decoration:none; + margin-right: 5px; + display: inline-block; + content: "\f0da"; + color: rgba(0,0,0,0.3); } .dropdown-item.active, .dropdown-item:hover, .dropdown-item:focus { - color: #<?php echo $colortextbackhmenu; ?> !important; - text-decoration: none; - background: rgb(<?php echo $colorbackhmenu1 ?>); + color: #<?php echo $colortextbackhmenu; ?> !important; + text-decoration: none; + background: rgb(<?php echo $colorbackhmenu1 ?>); } /* @@ -381,26 +383,26 @@ a.top-menu-dropdown-link { */ .dropdown-search-input { - width: 100%; - padding: 10px 35px 10px 20px; + width: 100%; + padding: 10px 35px 10px 20px; - background-color: transparent; - font-size: 14px; - line-height: 16px; - box-sizing: border-box; + background-color: transparent; + font-size: 14px; + line-height: 16px; + box-sizing: border-box; - color: #575756; - background-color: transparent; - background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-size: 16px 16px; - background-position: 95% center; - border-radius: 50px; - border: 1px solid #c4c4c2 !important; - transition: all 250ms ease-in-out; - backface-visibility: hidden; - transform-style: preserve-3d; + color: #575756; + background-color: transparent; + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-size: 16px 16px; + background-position: 95% center; + border-radius: 50px; + border: 1px solid #c4c4c2 !important; + transition: all 250ms ease-in-out; + backface-visibility: hidden; + transform-style: preserve-3d; } @@ -421,11 +423,11 @@ a.top-menu-dropdown-link { } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown { - line-height: unset; + line-height: unset; } ul.tmenu { - margin-right: 2px; + margin-right: 2px; } } @@ -450,10 +452,10 @@ a.top-menu-dropdown-link { .dropdown-search-input::placeholder { - color: color(#575756 a(0.8)); - letter-spacing: 1.5px; + color: color(#575756 a(0.8)); + letter-spacing: 1.5px; } .hidden-search-result{ - display: none !important; + display: none !important; } diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index a784a1ec7d9..1ab7dc02bf0 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -1,5 +1,7 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ @@ -12,10 +14,16 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $prefix = ''; -if (!empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; +if (!empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) { + $prefix = 'background-'; +} -if (!isset($conf->global->THEME_SATURATE_RATIO)) $conf->global->THEME_SATURATE_RATIO = 0.7; -if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +if (!isset($conf->global->THEME_SATURATE_RATIO)) { + $conf->global->THEME_SATURATE_RATIO = 0.7; +} +if (GETPOSTISSET('THEME_SATURATE_RATIO')) { + $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +} ?> @@ -112,14 +120,14 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = .info-box-module-external span.info-box-icon-version { - background: #bbb; + background: #bbb; } a.info-box-text.info-box-text-a { - display: table-cell; + display: table-cell; } a.info-box-text-a i.fa.fa-exclamation-triangle { - font-size: 0.9em; + font-size: 0.9em; } .info-box { @@ -134,14 +142,14 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { border: 1px solid #e9e9e9; } .info-box.info-box-sm{ - min-height: 80px; - margin-bottom: 10px; + min-height: 80px; + margin-bottom: 10px; } .info-box-more { - float: right; - top: 4px; - position: absolute; - right: 10px; + float: right; + top: 4px; + position: absolute; + right: 10px; } .info-box small { @@ -182,17 +190,17 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { font-size: 45px; line-height: 90px; background: #eee; - <?php if (isset($conf->global->THEME_SATURATE_RATIO)) { ?> - filter: saturate(<?php echo $conf->global->THEME_SATURATE_RATIO; ?>); - <?php } ?> + <?php if (isset($conf->global->THEME_SATURATE_RATIO)) { ?> + filter: saturate(<?php echo $conf->global->THEME_SATURATE_RATIO; ?>); + <?php } ?> } .info-box-sm .info-box-icon { - width: 80px; - font-size: 25px; - line-height: 92px; + width: 80px; + font-size: 25px; + line-height: 92px; } .opened-dash-board-wrap .info-box-sm .info-box-icon { - line-height: 80px; + line-height: 80px; } .info-box-module .info-box-icon { height: 98px; @@ -201,69 +209,69 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { max-width: 100%; } .info-box-module .info-box-icon > img { - max-width: 55%; + max-width: 55%; } .info-box-icon-text{ - box-sizing: border-box; - display: block; - position: absolute; - width: 90px; - bottom: 0px; - color: #ffffff; - background-color: rgba(0,0,0,0.1); - cursor: default; + box-sizing: border-box; + display: block; + position: absolute; + width: 90px; + bottom: 0px; + color: #ffffff; + background-color: rgba(0,0,0,0.1); + cursor: default; - font-size: 10px; - line-height: 15px; - padding: 0px 3px; - text-align: center; - opacity: 0; - -webkit-transition: opacity 0.5s, visibility 0s 0.5s; - transition: opacity 0.5s, visibility 0s 0.5s; + font-size: 10px; + line-height: 15px; + padding: 0px 3px; + text-align: center; + opacity: 0; + -webkit-transition: opacity 0.5s, visibility 0s 0.5s; + transition: opacity 0.5s, visibility 0s 0.5s; } .info-box-icon-version { - box-sizing: border-box; - display: block; - position: absolute; - width: 90px; - bottom: 0px; - color: #ffffff; - background-color: rgba(0,0,0,0.1); - cursor: default; + box-sizing: border-box; + display: block; + position: absolute; + width: 90px; + bottom: 0px; + color: #ffffff; + background-color: rgba(0,0,0,0.1); + cursor: default; - font-size: 10px; - line-height: 22px; - padding: 0px 3px; - text-align: center; - opacity: 1; - -webkit-transition: opacity 0.5s, visibility 0s 0.5s; - transition: opacity 0.5s, visibility 0s 0.5s; + font-size: 10px; + line-height: 22px; + padding: 0px 3px; + text-align: center; + opacity: 1; + -webkit-transition: opacity 0.5s, visibility 0s 0.5s; + transition: opacity 0.5s, visibility 0s 0.5s; } .box-flex-item.info-box-module.info-box-module-disabled { - /* opacity: 0.6; */ + /* opacity: 0.6; */ } .info-box-actions { position: absolute; - right: 0; - bottom: 0; + right: 0; + bottom: 0; } <?php if (empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS) && !empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD)) { ?> .info-box-icon-text{ - opacity: 1; + opacity: 1; } <?php } ?> .info-box-sm .info-box-icon-text, .info-box-sm .info-box-icon-version{ - overflow: hidden; - width: 80px; + overflow: hidden; + width: 80px; } .info-box:hover .info-box-icon-text{ - opacity: 1; + opacity: 1; } .info-box-content { @@ -291,7 +299,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { margin-bottom: 6px; } .info-box-title { - width: calc(100% - 20px); + width: calc(100% - 20px); } .info-box-text{ font-size: 0.92em; @@ -315,8 +323,12 @@ a.info-box-text{ text-decoration: none;} } <?php include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (!isset($conf->global->THEME_SATURATE_RATIO)) $conf->global->THEME_SATURATE_RATIO = 0.7; -if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +if (!isset($conf->global->THEME_SATURATE_RATIO)) { + $conf->global->THEME_SATURATE_RATIO = 0.7; +} +if (GETPOSTISSET('THEME_SATURATE_RATIO')) { + $conf->global->THEME_SATURATE_RATIO = GETPOST('THEME_SATURATE_RATIO', 'int'); +} ?> .bg-infobox-project i.fa{ color: #605ca8 !important; @@ -471,7 +483,7 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = .info-box-module { min-width: 350px; - max-width: 350px; + max-width: 350px; } .info-box-module .info-box-content { @@ -481,8 +493,8 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = @media only screen and (max-width: 1740px) { .info-box-module { - min-width: 315px; - max-width: 315px; + min-width: 315px; + max-width: 315px; } } @media only screen and (max-width: 767px) { diff --git a/htdocs/theme/md/main_menu_fa_icons.inc.php b/htdocs/theme/md/main_menu_fa_icons.inc.php index 9326cf40ffe..eec79b951eb 100644 --- a/htdocs/theme/md/main_menu_fa_icons.inc.php +++ b/htdocs/theme/md/main_menu_fa_icons.inc.php @@ -1,48 +1,50 @@ -<?php if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> +<?php if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} ?> /* <style type="text/css" > */ .mainmenu::before{ - /* font part */ - font-family: "Font Awesome 5 Free"; - font-weight: 900; - font-style: normal; - font-variant: normal; - text-rendering: auto; - line-height: 26px; + /* font part */ + font-family: "Font Awesome 5 Free"; + font-weight: 900; + font-style: normal; + font-variant: normal; + text-rendering: auto; + line-height: 26px; font-size: 1.5em; - -webkit-font-smoothing: antialiased; - text-align:center; + -webkit-font-smoothing: antialiased; + text-align:center; text-decoration:none; color: #<?php echo $colortextbackhmenu; ?>; } .fa-15x { - font-size: 1.5em; + font-size: 1.5em; } div.mainmenu.ticket::before { - content: "\f3ff"; + content: "\f3ff"; } div.mainmenu.ticket { - background-image: none !important; + background-image: none !important; } div.mainmenu.generic1::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic2::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic3::before { - content: "\f249"; + content: "\f249"; } div.mainmenu.generic4::before { - content: "\f249"; + content: "\f249"; } /* Define color of some picto */ diff --git a/htdocs/theme/md/manifest.json.php b/htdocs/theme/md/manifest.json.php index 6051ff260ef..b249e81e7df 100644 --- a/htdocs/theme/md/manifest.json.php +++ b/htdocs/theme/md/manifest.json.php @@ -25,22 +25,46 @@ * \brief File for The Web App */ -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); -if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '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('NOLOGIN')) define('NOLOGIN', '1'); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (!defined('NOSESSION')) define('NOSESSION', '1'); +if (!defined('NOREQUIREUSER')) { + define('NOREQUIREUSER', '1'); +} +if (!defined('NOREQUIREDB')) { + define('NOREQUIREDB', '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('NOLOGIN')) { + define('NOLOGIN', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); +} require_once __DIR__.'/../../main.inc.php'; $appli = constant('DOL_APPLICATION_TITLE'); -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $appli = $conf->global->MAIN_APPLICATION_TITLE; +} top_httphead('text/json'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. @@ -48,22 +72,21 @@ if (empty($dolibarr_nocache)) { header('Cache-Control: max-age=10800, public, must-revalidate'); // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT'); -} -else { +} else { header('Cache-Control: no-cache'); } ?> { - "name": "<?php echo $appli; ?>", - "icons": [ - { - "src": "<?php echo DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; ?>", - "sizes": "256x256", - "type": "image/png" - } - ], - "theme_color": "#ffffff", - "background_color": "#ffffff", - "display": "standalone" + "name": "<?php echo $appli; ?>", + "icons": [ + { + "src": "<?php echo DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; ?>", + "sizes": "256x256", + "type": "image/png" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" } \ No newline at end of file diff --git a/htdocs/theme/md/progress.inc.php b/htdocs/theme/md/progress.inc.php index 9a78141ace0..979f8b8034e 100644 --- a/htdocs/theme/md/progress.inc.php +++ b/htdocs/theme/md/progress.inc.php @@ -1,5 +1,7 @@ <?php -if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); +if (!defined('ISLOADEDBYSTEELSHEET')) { + die('Must be call by steelsheet'); +} include dol_buildpath($path.'/theme/eldy/progress.inc.php', 0); // actually md use same style as eldy theme diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 81407987c35..def22ff87de 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -28,21 +28,35 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); // File must be accessed by logon page so without login +} //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} define('ISLOADEDBYSTEELSHEET', '1'); require __DIR__.'/theme_vars.inc.php'; -if (defined('THEME_ONLY_CONSTANT')) return; +if (defined('THEME_ONLY_CONSTANT')) { + return; +} session_cache_limiter('public'); @@ -52,8 +66,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) // and permission, so we can later calculate number of top menu ($nbtopmenuentries) according to user profile. -if (empty($user->id) && !empty($_SESSION['dol_login'])) -{ +if (empty($user->id) && !empty($_SESSION['dol_login'])) { $user->fetch('', $_SESSION['dol_login'], '', 1); $user->getrights(); @@ -66,11 +79,18 @@ if (empty($user->id) && !empty($_SESSION['dol_login'])) // Define css type top_httphead('text/css'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} -if (GETPOST('theme', 'alpha')) $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL +if (GETPOST('theme', 'alpha')) { + $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL +} +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL +} $langs->load("main", 0, 1); $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); @@ -78,7 +98,9 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $path = ''; // This value may be used in future for external module to overwrite theme $theme = 'md'; // Value of theme -if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { $path = '/'.$conf->global->MAIN_OVERWRITE_THEME_RES; $theme = $conf->global->MAIN_OVERWRITE_THEME_RES; } +if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { + $path = '/'.$conf->global->MAIN_OVERWRITE_THEME_RES; $theme = $conf->global->MAIN_OVERWRITE_THEME_RES; +} // Define image path files and other constants $fontlist = 'roboto,arial,tahoma,verdana,helvetica'; //$fontlist='verdana,helvetica,arial,sans-serif'; @@ -98,19 +120,36 @@ $useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global-> $borderwidth = 2; // Case of option always editable -if (!isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY = $colorbackbody; -if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; -if (!isset($conf->global->THEME_ELDY_VERMENU_BACK1)) $conf->global->THEME_ELDY_VERMENU_BACK1 = $colorbackvmenu1; -if (!isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1 = $colorbacktitle1; -if (!isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER = $colorbacklinepairhover; -if (!isset($conf->global->THEME_ELDY_USE_CHECKED)) $conf->global->THEME_ELDY_USE_CHECKED = $colorbacklinepairchecked; -if (!isset($conf->global->THEME_ELDY_LINEBREAK)) $conf->global->THEME_ELDY_LINEBREAK = $colorbacklinebreak; -if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB = $colortexttitlenotab; -if (!isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; +if (!isset($conf->global->THEME_ELDY_BACKBODY)) { + $conf->global->THEME_ELDY_BACKBODY = $colorbackbody; +} +if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +} +if (!isset($conf->global->THEME_ELDY_VERMENU_BACK1)) { + $conf->global->THEME_ELDY_VERMENU_BACK1 = $colorbackvmenu1; +} +if (!isset($conf->global->THEME_ELDY_BACKTITLE1)) { + $conf->global->THEME_ELDY_BACKTITLE1 = $colorbacktitle1; +} +if (!isset($conf->global->THEME_ELDY_USE_HOVER)) { + $conf->global->THEME_ELDY_USE_HOVER = $colorbacklinepairhover; +} +if (!isset($conf->global->THEME_ELDY_USE_CHECKED)) { + $conf->global->THEME_ELDY_USE_CHECKED = $colorbacklinepairchecked; +} +if (!isset($conf->global->THEME_ELDY_LINEBREAK)) { + $conf->global->THEME_ELDY_LINEBREAK = $colorbacklinebreak; +} +if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) { + $conf->global->THEME_ELDY_TEXTTITLENOTAB = $colortexttitlenotab; +} +if (!isset($conf->global->THEME_ELDY_TEXTLINK)) { + $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; +} // Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on -if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) -{ +if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) { // 90A4AE, 607D8B, 455A64, 37474F $conf->global->THEME_ELDY_BACKTABCARD1 = '255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE = '234,234,234'; @@ -143,38 +182,55 @@ $fontsizesmaller = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (emp // Hover color $colorbacklinepairhover = ((!isset($conf->global->THEME_ELDY_USE_HOVER) || (string) $conf->global->THEME_ELDY_USE_HOVER === '255,255,255') ? '' : ($conf->global->THEME_ELDY_USE_HOVER === '1' ? 'edf4fb' : $conf->global->THEME_ELDY_USE_HOVER)); $colorbacklinepairchecked = ((!isset($conf->global->THEME_ELDY_USE_CHECKED) || (string) $conf->global->THEME_ELDY_USE_CHECKED === '255,255,255') ? '' : ($conf->global->THEME_ELDY_USE_CHECKED === '1' ? 'edf4fb' : $conf->global->THEME_ELDY_USE_CHECKED)); -if (!empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) -{ +if (!empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) { $colorbacklinepairhover = ((!isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '255,255,255') ? '' : ($user->conf->THEME_ELDY_USE_HOVER === '1' ? 'edf4fb' : $user->conf->THEME_ELDY_USE_HOVER)); $colorbacklinepairchecked = ((!isset($user->conf->THEME_ELDY_USE_CHECKED) || $user->conf->THEME_ELDY_USE_CHECKED === '255,255,255') ? '' : ($user->conf->THEME_ELDY_USE_CHECKED === '1' ? 'edf4fb' : $user->conf->THEME_ELDY_USE_CHECKED)); } -if (empty($colortopbordertitle1)) $colortopbordertitle1 = $colorbackhmenu1; +if (empty($colortopbordertitle1)) { + $colortopbordertitle1 = $colorbackhmenu1; +} // Set text color to black or white $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbackhmenu1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) $colortextbackhmenu = 'FFFFFF'; -else $colortextbackhmenu = '000000'; +if ($tmpval <= 460) { + $colortextbackhmenu = 'FFFFFF'; +} else { + $colortextbackhmenu = '000000'; +} $colorbackvmenu1 = join(',', colorStringToArray($colorbackvmenu1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbackvmenu1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) { $colortextbackvmenu = 'FFFFFF'; } else { $colortextbackvmenu = '000000'; } +if ($tmpval <= 460) { + $colortextbackvmenu = 'FFFFFF'; +} else { + $colortextbackvmenu = '000000'; +} $colorbacktitle1 = join(',', colorStringToArray($colorbacktitle1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktitle1); -if ($colortexttitle == '') -{ +if ($colortexttitle == '') { $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); - if ($tmpval <= 460) { $colortexttitle = 'FFFFFF'; $colorshadowtitle = '888888'; } else { $colortexttitle = '101010'; $colorshadowtitle = 'FFFFFF'; } -} else $colorshadowtitle = '888888'; + if ($tmpval <= 460) { + $colortexttitle = 'FFFFFF'; $colorshadowtitle = '888888'; + } else { + $colortexttitle = '101010'; $colorshadowtitle = 'FFFFFF'; + } +} else { + $colorshadowtitle = '888888'; +} $colorbacktabcard1 = join(',', colorStringToArray($colorbacktabcard1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktabcard1); $tmpval = (!empty($tmppart[0]) ? $tmppart[0] : 0) + (!empty($tmppart[1]) ? $tmppart[1] : 0) + (!empty($tmppart[2]) ? $tmppart[2] : 0); -if ($tmpval <= 460) { $colortextbacktab = 'FFFFFF'; } else { $colortextbacktab = '111111'; } +if ($tmpval <= 460) { + $colortextbacktab = 'FFFFFF'; +} else { + $colortextbacktab = '111111'; +} // Format color value to match expected format (may be 'FFFFFF' or '255,255,255') $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); @@ -186,8 +242,12 @@ $colorbacklineimpair1 = join(',', colorStringToArray($colorbacklineimpair1)); $colorbacklineimpair2 = join(',', colorStringToArray($colorbacklineimpair2)); $colorbacklinepair1 = join(',', colorStringToArray($colorbacklinepair1)); $colorbacklinepair2 = join(',', colorStringToArray($colorbacklinepair2)); -if ($colorbacklinepairhover != '') $colorbacklinepairhover = join(',', colorStringToArray($colorbacklinepairhover)); -if ($colorbacklinepairchecked != '') $colorbacklinepairchecked = join(',', colorStringToArray($colorbacklinepairchecked)); +if ($colorbacklinepairhover != '') { + $colorbacklinepairhover = join(',', colorStringToArray($colorbacklinepairhover)); +} +if ($colorbacklinepairchecked != '') { + $colorbacklinepairchecked = join(',', colorStringToArray($colorbacklinepairchecked)); +} $colorbackbody = join(',', colorStringToArray($colorbackbody)); $colortexttitlenotab = join(',', colorStringToArray($colortexttitlenotab)); $colortexttitle = join(',', colorStringToArray($colortexttitle)); @@ -195,7 +255,9 @@ $colortext = join(',', colorStringToArray($colortext)); $colortextlink = join(',', colorStringToArray($colortextlink)); $nbtopmenuentries = $menumanager->showmenu('topnb'); -if ($conf->browser->layout == 'phone') $nbtopmenuentries = max($nbtopmenuentries, 10); +if ($conf->browser->layout == 'phone') { + $nbtopmenuentries = max($nbtopmenuentries, 10); +} print '/*'."\n"; print 'colorbackbody='.$colorbackbody."\n"; @@ -278,11 +340,11 @@ body { font-size: <?php print is_numeric($fontsize) ? $fontsize.'px' : $fontsize; ?>; line-height: 1.3; font-family: <?php print $fontlist ?>; - margin-top: 0; - margin-bottom: 0; - margin-right: 0; - margin-left: 0; - <?php print 'direction: '.$langs->trans("DIRECTION").";\n"; ?> + margin-top: 0; + margin-bottom: 0; + margin-right: 0; + margin-left: 0; + <?php print 'direction: '.$langs->trans("DIRECTION").";\n"; ?> } .sensiblehtmlcontent * { @@ -301,14 +363,14 @@ input { font-size: unset; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { - background-color: #FDFDFD; + background-color: #FDFDFD; } select.vmenusearchselectcombo { background-color: unset; } textarea:focus, button:focus { - /* v6 box-shadow: 0 0 4px #8091BF; */ + /* v6 box-shadow: 0 0 4px #8091BF; */ border: 1px solid #aaa !important; } input:focus, textarea:focus, button:focus, select:focus { @@ -321,10 +383,10 @@ textarea.cke_source:focus } th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), td.wrapcolumntitle.liste_titre:not(.maxwidthsearch) { - overflow: hidden; - white-space: nowrap; - max-width: 120px; - text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + max-width: 120px; + text-overflow: ellipsis; } .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], @@ -344,14 +406,14 @@ select#date_startday, select#date_startmonth, select#date_endday, select#date_en } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { font-family: <?php print $fontlist ?>; - border: none; - border<?php echo empty($conf->global->THEME_HIDE_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px rgba(0,0,0,.2); - outline: none; - margin: 0px 0px 0px 0px; + border: none; + border<?php echo empty($conf->global->THEME_HIDE_BORDER_ON_INPUT) ? '-bottom' : ''; ?>: solid 1px rgba(0,0,0,.2); + outline: none; + margin: 0px 0px 0px 0px; } input { - line-height: 17px; + line-height: 17px; padding: 4px; padding-left: 5px; } @@ -367,7 +429,7 @@ input, select { margin-top:1px; } input.button.massactionconfirmed { - margin: 4px; + margin: 4px; } textarea { @@ -399,8 +461,8 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment { min-width: 290px; margin-bottom: 15px; margin-top: 15px; - margin-left: 5px; - margin-right: 5px; + margin-left: 5px; + margin-right: 5px; background-image: none; line-height: 24px; padding: 8px; @@ -412,15 +474,15 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment { color: #888 !important; } div.buttonpayment input { - background-color: unset; - border-bottom: unset; - font-weight: bold; - text-transform: uppercase; + background-color: unset; + border-bottom: unset; + font-weight: bold; + text-transform: uppercase; color: #333; cursor: pointer; } div.buttonpayment input:focus { - color: #008; + color: #008; } input.buttonpaymentcb { background-image: url(<?php echo dol_buildpath($path.'/theme/common/credit_card.png', 1) ?>); @@ -466,16 +528,16 @@ a.butStatus { padding-left: 5px; padding-right: 5px; background-color: transparent; - color: var(--colortext) !important; - border: 2px solid var( --butactionbg); - margin: 0 0.45em !important; + color: var(--colortext) !important; + border: 2px solid var( --butactionbg); + margin: 0 0.45em !important; } /* Used by timesheets */ span.timesheetalreadyrecorded input { - border: none; - border-bottom: solid 1px rgba(0,0,0,0.1); - margin-right: 1px !important; + border: none; + border-bottom: solid 1px rgba(0,0,0,0.1); + margin-right: 1px !important; } td.onholidaymorning, td.onholidayafternoon { background-color: #fdf6f2; @@ -494,7 +556,7 @@ td.rightborder { } td.actionbuttons a { - padding-left: 6px; + padding-left: 6px; } select.flat, form.flat select, .pageplusone { font-weight: normal; @@ -502,8 +564,8 @@ select.flat, form.flat select, .pageplusone { height: 2em; } input.pageplusone { - padding-bottom: 4px; - padding-top: 4px; + padding-bottom: 4px; + padding-top: 4px; } .saturatemedium { @@ -536,10 +598,10 @@ input.pageplusone { } .vmirror { - transform: scale(1, -1); + transform: scale(1, -1); } .hmirror { - transform: scale(-1, 1); + transform: scale(-1, 1); } select:invalid { @@ -588,7 +650,7 @@ input#onlinepaymenturl, input#directdownloadlink { } div#moretabsList, div#moretabsListaction { - z-index: 5; + z-index: 5; } hr { border: 0; border-top: 1px solid #ccc; } @@ -600,7 +662,7 @@ hr { border: 0; border-top: 1px solid #ccc; } padding: 4px 14px; margin-bottom: 0; margin-top: 0; - font-family: <?php print $fontlist ?>; + font-family: <?php print $fontlist ?>; text-align: center; cursor: pointer; color: #333333 !important; @@ -632,35 +694,35 @@ hr { border: 0; border-top: 1px solid #ccc; } } .button:disabled, .buttonDelete:disabled, .button.disabled, .buttonDelete.disabled { opacity: 0.4; - box-shadow: none; - -webkit-box-shadow: none; - cursor: auto; + box-shadow: none; + -webkit-box-shadow: none; + cursor: auto; } .buttonRefused { pointer-events: none; - cursor: default; + cursor: default; opacity: 0.4; - box-shadow: none; - -webkit-box-shadow: none; + box-shadow: none; + -webkit-box-shadow: none; } .button_search, .button_removefilter { - border: unset; - background: unset; + border: unset; + background: unset; } .button_search:hover, .button_removefilter:hover { - cursor: pointer; + cursor: pointer; } form { - padding:0px; - margin:0px; + padding:0px; + margin:0px; } div.float, span.floatleft { - float:<?php print $left; ?>; + float:<?php print $left; ?>; } div.floatright { - float:<?php print $right; ?>; + float:<?php print $right; ?>; } .block { @@ -671,12 +733,12 @@ div.floatright display:inline-block; } .largenumber { - font-size: 1.4em; + font-size: 1.4em; } th .button { - -webkit-box-shadow: none !important; - box-shadow: none !important; + -webkit-box-shadow: none !important; + box-shadow: none !important; -webkit-border-radius:0px !important; border-radius:0px !important; } @@ -713,21 +775,21 @@ textarea.centpercent { width: 96%; } .small, small { - font-size: 85%; + font-size: 85%; } .h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small { - font-size: 65%; + font-size: 65%; } .h1 .small, .h1 small, .h2 .small, .h2 small, .h3 .small, .h3 small, .h4 .small, .h4 small, .h5 .small, .h5 small, .h6 .small, .h6 small, h1 .small, h1 small, h2 .small, h2 small, h3 .small, h3 small, h4 .small, h4 small, h5 .small, h5 small, h6 .small, h6 small { - font-weight: 400; - line-height: 1; - color: #777; + font-weight: 400; + line-height: 1; + color: #777; } .center { - text-align: center; - margin: 0px auto; + text-align: center; + margin: 0px auto; } .left { text-align: <?php print $left; ?>; @@ -739,10 +801,10 @@ textarea.centpercent { text-align: justify; } .pull-left { - float: left!important; + float: left!important; } .pull-right { - float: right!important; + float: right!important; } .nowrap { white-space: <?php print ($dol_optimize_smallscreen ? 'normal' : 'nowrap'); ?>; @@ -775,7 +837,7 @@ textarea.centpercent { font-weight: normal !important; } .nounderline { - text-decoration: none; + text-decoration: none; } .nopadding { padding: 0; @@ -817,43 +879,43 @@ textarea.centpercent { cursor: not-allowed; } .backgroundblank { - background-color: #fff; + background-color: #fff; } .nobackground, .nobackground tr { background: unset !important; } .checkboxattachfilelabel { - font-size: 0.85em; - opacity: 0.7; + font-size: 0.85em; + opacity: 0.7; } .longmessagecut { - max-height: 250px; - max-width: 100%; - overflow-y: auto; + max-height: 250px; + max-width: 100%; + overflow-y: auto; } .text-warning{ - color : <?php print $textWarning; ?> + color : <?php print $textWarning; ?> } body[class*="colorblind-"] .text-warning{ - color : <?php print $colorblind_deuteranopes_textWarning; ?> + color : <?php print $colorblind_deuteranopes_textWarning; ?> } .text-success{ - color : <?php print $textSuccess; ?> + color : <?php print $textSuccess; ?> } body[class*="colorblind-"] .text-success{ - color : <?php print $colorblind_deuteranopes_textSuccess; ?> + color : <?php print $colorblind_deuteranopes_textSuccess; ?> } .text-danger{ - color : <?php print $textDanger; ?> + color : <?php print $textDanger; ?> } .editfielda span.fa-pencil-alt, .editfielda span.fa-trash { - color: #ccc !important; + color: #ccc !important; } .editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { - color: rgb(<?php echo $colortexttitle; ?>) !important; + color: rgb(<?php echo $colortexttitle; ?>) !important; } .size15x { font-size: 1.5em !important; } @@ -891,32 +953,32 @@ body[class*="colorblind-"] .text-success{ vertical-align: middle; } .divsocialnetwork:not(:first-child) { - padding-left: 20px; + padding-left: 20px; } div.divsearchfield { float: <?php print $left; ?>; margin-<?php print $right; ?>: 12px; margin-<?php print $left; ?>: 2px; margin-top: 4px; - margin-bottom: 4px; - padding-left: 2px; + margin-bottom: 4px; + padding-left: 2px; } .divsearchfieldfilter { - text-overflow: clip; - overflow: auto; - white-space: nowrap; - padding-bottom: 5px; - opacity: 0.6; + text-overflow: clip; + overflow: auto; + white-space: nowrap; + padding-bottom: 5px; + opacity: 0.6; } .divadvancedsearchfield:first-child { - margin-top: 3px; + margin-top: 3px; } .divadvancedsearchfield { - float: left; - padding-left: 15px; - padding-right: 15px; - padding-bottom: 2px; - padding-top: 2px; + float: left; + padding-left: 15px; + padding-right: 15px; + padding-bottom: 2px; + padding-top: 2px; } .divadvancedsearchfield span.select2.select2-container.select2-container--default { padding-bottom: 4px; @@ -926,22 +988,22 @@ div.divsearchfield { if ($conf->browser->layout == 'phone') { ?> .divsearchfieldfilter { - white-space: nowrap; + white-space: nowrap; } <?php } ?> .a-filter, .a-mesure { - border-radius: 50px; - background: var(--colortexttitlenotab); - color: #fff; - padding: 8px 10px 8px 6px; + border-radius: 50px; + background: var(--colortexttitlenotab); + color: #fff; + padding: 8px 10px 8px 6px; } .a-filter:before { - content: "\f0b0"; + content: "\f0b0"; } .a-mesure:before { - content: "\f080"; + content: "\f080"; } .a-filter:before, .a-mesure:before { font-family: "Font Awesome 5 Free"; @@ -950,10 +1012,10 @@ if ($conf->browser->layout == 'phone') { padding-left: 5px; } .a-filter-disabled, .a-mesure-disabled { - border-radius: 50px; - background: var(--colorbacktitle1); - padding: 8px; - opacity: 0.6; + border-radius: 50px; + background: var(--colorbacktitle1); + padding: 8px; + opacity: 0.6; } @@ -982,12 +1044,12 @@ input > ul.attendees { padding-bottom: 10px; } .checkallactions { - margin-left: 2px; /* left must be same than right to keep checkbox centered */ - margin-right: 2px; /* left must be same than right to keep checkbox centered */ - vertical-align: middle; + margin-left: 2px; /* left must be same than right to keep checkbox centered */ + margin-right: 2px; /* left must be same than right to keep checkbox centered */ + vertical-align: middle; } select.flat.selectlimit { - max-width: 62px; + max-width: 62px; } .selectlimit, .marginrightonly { margin-right: 10px !important; @@ -1008,17 +1070,17 @@ select.flat.selectlimit { margin-bottom: 10px !important; } .nomargintop { - margin-top: 0 !important; + margin-top: 0 !important; } .nomarginbottom { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } .selectlimit, .selectlimit:focus { - border-left: none !important; - border-top: none !important; - border-right: none !important; - outline: none; + border-left: none !important; + border-top: none !important; + border-right: none !important; + outline: none; } .strikefordisabled { text-decoration: line-through; @@ -1028,69 +1090,69 @@ select.flat.selectlimit { } /* using a tdoverflowxxx make the min-width not working */ .tdoverflow { - max-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax50 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 50px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 50px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax100 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax100imp { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px !important; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 100px !important; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax125 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 125px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 125px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax150 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 150px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 150px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax200 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 200px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 200px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowmax300 { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 300px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + max-width: 300px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .tdoverflowauto { - max-width: 0; - overflow: auto; + max-width: 0; + overflow: auto; } .divintodwithtwolinesmax { - width: 75px; - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; + width: 75px; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; } .twolinesmax { - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; } .tablelistofcalendars { @@ -1118,19 +1180,19 @@ select.flat.selectlimit { margin-bottom: 12px; } #builddoc_form ~ .showlinkedobjectblock { - margin-top: 20px; + margin-top: 20px; } /* For the long description of module */ .moduledesclong p img,.moduledesclong p a img { - max-width: 90% !important; - height: auto !important; + max-width: 90% !important; + height: auto !important; } .imgdoc { - margin: 18px; - border: 1px solid #ccc; - box-shadow: 1px 1px 25px #aaa; - max-width: calc(100% - 56px); + margin: 18px; + border: 1px solid #ccc; + box-shadow: 1px 1px 25px #aaa; + max-width: calc(100% - 56px); } .fa-file-text-o, .fa-file-code-o, .fa-file-powerpoint-o, .fa-file-excel-o, .fa-file-word-o, .fa-file-o, .fa-file-image-o, .fa-file-video-o, .fa-file-audio-o, .fa-file-archive-o, .fa-file-pdf-o { color: #505; @@ -1142,34 +1204,36 @@ select.flat.selectlimit { /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { - width: calc(100% - 330px); - margin-bottom: 15px; - overflow-y: hidden; - -ms-overflow-style: -ms-autohiding-scrollbar; + width: calc(100% - 330px); + margin-bottom: 15px; + overflow-y: hidden; + -ms-overflow-style: -ms-autohiding-scrollbar; }*/ /* Style used for most tables */ div.fiche>div.tabBar>form>div.div-table-responsive { - min-height: 392px; + min-height: 392px; } .div-table-responsive, .div-table-responsive-no-min { - overflow-x: auto; - min-height: 0.01%; + overflow-x: auto; + min-height: 0.01%; } .div-table-responsive { - line-height: 120%; + line-height: 120%; } /* Style used for full page tables with field selector and no content after table (priority before previous for such tables) */ div.fiche>form>div.div-table-responsive, div.fiche>form>div.div-table-responsive-no-min { - overflow-x: auto; + overflow-x: auto; } div.fiche>form>div.div-table-responsive { - min-height: 392px; + min-height: 392px; } .flexcontainer { - <?php if (in_array($conf->browser->name, array('chrome', 'firefox'))) echo 'display: inline-flex;' ?> - flex-flow: row wrap; - justify-content: flex-start; + <?php if (in_array($conf->browser->name, array('chrome', 'firefox'))) { + echo 'display: inline-flex;'; + } ?> + flex-flow: row wrap; + justify-content: flex-start; } .thumbstat { flex: 1 1 116px; @@ -1178,13 +1242,13 @@ div.fiche>form>div.div-table-responsive { flex: 1 1 150px; } .thumbstat, .thumbstat150 { - flex-grow: 1; - flex-shrink: 1; - /* flex-basis: 140px; */ - /* min-width: 150px; */ - width: 158px; - justify-content: flex-start; - align-self: flex-start; + flex-grow: 1; + flex-shrink: 1; + /* flex-basis: 140px; */ + /* min-width: 150px; */ + width: 158px; + justify-content: flex-start; + align-self: flex-start; } select.selectarrowonleft { @@ -1195,7 +1259,7 @@ select.selectarrowonleft option { } table[summary="list_of_modules"] .fa-cog { - font-size: 1.5em; + font-size: 1.5em; } .linkedcol-element { @@ -1221,10 +1285,10 @@ table[summary="list_of_modules"] .fa-cog { { .width20 { width: 20px; } .width25 { width: 25px; } - .width50 { width: 50px; } - .width75 { width: 75px; } - .width100 { width: 100px; } - .width200 { width: 200px; } + .width50 { width: 50px; } + .width75 { width: 75px; } + .width100 { width: 100px; } + .width200 { width: 200px; } .minwidth100 { min-width: 100px; } .minwidth150 { min-width: 150px; } .minwidth200 { min-width: 200px; } @@ -1232,10 +1296,10 @@ table[summary="list_of_modules"] .fa-cog { .minwidth400 { min-width: 400px; } .minwidth500 { min-width: 500px; } .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 75px !important; } + .minwidth75imp { min-width: 75px !important; } .minwidth100imp { min-width: 100px !important; } .minwidth200imp { min-width: 200px !important; } - .minwidth250imp { min-width: 250px !important; } + .minwidth250imp { min-width: 250px !important; } .minwidth300imp { min-width: 300px !important; } .minwidth400imp { min-width: 400px !important; } .minwidth500imp { min-width: 500px !important; } @@ -1287,16 +1351,16 @@ table[summary="list_of_modules"] .fa-cog { .titlefield { /* width: 30% !important; */ } .titlefieldcreate { width: 30% !important; } .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 150px !important; } - .minwidth200imp { min-width: 200px !important; } - .minwidth250imp { min-width: 250px !important; } - .minwidth300imp { min-width: 300px !important; } - .minwidth400imp { min-width: 300px !important; } - .minwidth500imp { min-width: 300px !important; } + .minwidth75imp { min-width: 75px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 150px !important; } + .minwidth200imp { min-width: 200px !important; } + .minwidth250imp { min-width: 250px !important; } + .minwidth300imp { min-width: 300px !important; } + .minwidth400imp { min-width: 300px !important; } + .minwidth500imp { min-width: 300px !important; } - .linkedcol-element { + .linkedcol-element { min-width: unset; } } @@ -1304,16 +1368,16 @@ table[summary="list_of_modules"] .fa-cog { /* Force values for small screen 1000 */ @media only screen and (max-width: 1000px) { - .maxwidthonsmartphone { max-width: 100px; } + .maxwidthonsmartphone { max-width: 100px; } .minwidth50imp { min-width: 50px !important; } - .minwidth75imp { min-width: 70px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 110px !important; } - .minwidth200imp { min-width: 110px !important; } - .minwidth250imp { min-width: 115px !important; } - .minwidth300imp { min-width: 120px !important; } - .minwidth400imp { min-width: 150px !important; } - .minwidth500imp { min-width: 250px !important; } + .minwidth75imp { min-width: 70px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 110px !important; } + .minwidth200imp { min-width: 110px !important; } + .minwidth250imp { min-width: 115px !important; } + .minwidth300imp { min-width: 120px !important; } + .minwidth400imp { min-width: 150px !important; } + .minwidth500imp { min-width: 250px !important; } } /* Set a width. Note: add also a max-width, for example maxwidth500, that will be used in priority */ @@ -1337,7 +1401,7 @@ table[summary="list_of_modules"] .fa-cog { } div.divphotoref { - padding-right: 10px !important; + padding-right: 10px !important; } } @@ -1353,51 +1417,51 @@ table[summary="list_of_modules"] .fa-cog { } .login_vertical_align { - padding-left: 0; - } - .login_table input#username, .login_table input#password, .login_table input#securitycode { + padding-left: 0; + } + .login_table input#username, .login_table input#password, .login_table input#securitycode { margin-left: 5px !important; - } + } div#login_left, div#login_right { - min-width: 150px !important; - padding-left: 5px !important; - padding-right: 5px !important; - } - .login_table div#login_right .tdinputlogin, .login_table div#login_right .tdinputlogin input { - min-width: 150px !important; - } + min-width: 150px !important; + padding-left: 5px !important; + padding-right: 5px !important; + } + .login_table div#login_right .tdinputlogin, .login_table div#login_right .tdinputlogin input { + min-width: 150px !important; + } .divmainbodylarge { margin-left: 20px; margin-right: 20px; } - .tdoverflowonsmartphone { - max-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - .tdoverflowmax100onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + .tdoverflowonsmartphone { + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } - .tdoverflowmax150onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + .tdoverflowmax100onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .tdoverflowmax150onsmartphone { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } div.fiche { - margin-top: <?php print ($dol_hide_topmenu ? '12' : '6'); ?>px !important; + margin-top: <?php print ($dol_hide_topmenu ? '12' : '6'); ?>px !important; + } + .border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col { + height: 40px !important; } - .border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col { - height: 40px !important; - } - .quatrevingtpercent, .inputsearch { - width: 95%; - } + .quatrevingtpercent, .inputsearch { + width: 95%; + } select { padding-top: 4px; @@ -1409,34 +1473,34 @@ table[summary="list_of_modules"] .fa-cog { } input, input[type=text], input[type=password], select, textarea { min-width: 20px; - min-height: 1.4em; - line-height: 1.4em; - } + min-height: 1.4em; + line-height: 1.4em; + } - .hideonsmartphone { display: none; } - .hideonsmartphoneimp { display: none !important; } - .noenlargeonsmartphone { width : 50px !important; display: inline !important; } - .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } - .maxwidth50onsmartphone { max-width: 40px; } - .maxwidth75onsmartphone { max-width: 50px; } - .maxwidth100onsmartphone { max-width: 70px; } - .maxwidth150onsmartphone { max-width: 120px; } - .maxwidth150onsmartphoneimp { max-width: 120px !important; } - .maxwidth200onsmartphone { max-width: 200px; } - .maxwidth250onsmartphone { max-width: 250px; } - .maxwidth300onsmartphone { max-width: 300px; } - .maxwidth400onsmartphone { max-width: 400px; } + .hideonsmartphone { display: none; } + .hideonsmartphoneimp { display: none !important; } + .noenlargeonsmartphone { width : 50px !important; display: inline !important; } + .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } + .maxwidth50onsmartphone { max-width: 40px; } + .maxwidth75onsmartphone { max-width: 50px; } + .maxwidth100onsmartphone { max-width: 70px; } + .maxwidth150onsmartphone { max-width: 120px; } + .maxwidth150onsmartphoneimp { max-width: 120px !important; } + .maxwidth200onsmartphone { max-width: 200px; } + .maxwidth250onsmartphone { max-width: 250px; } + .maxwidth300onsmartphone { max-width: 300px; } + .maxwidth400onsmartphone { max-width: 400px; } .minwidth50imp { min-width: 50px !important; } .minwidth75imp { min-width: 75px !important; } - .minwidth100imp { min-width: 100px !important; } - .minwidth150imp { min-width: 110px !important; } - .minwidth200imp { min-width: 110px !important; } - .minwidth250imp { min-width: 115px !important; } - .minwidth300imp { min-width: 120px !important; } - .minwidth400imp { min-width: 150px !important; } - .minwidth500imp { min-width: 250px !important; } - .titlefield { width: auto; } - .titlefieldcreate { width: auto; } + .minwidth100imp { min-width: 100px !important; } + .minwidth150imp { min-width: 110px !important; } + .minwidth200imp { min-width: 110px !important; } + .minwidth250imp { min-width: 115px !important; } + .minwidth300imp { min-width: 120px !important; } + .minwidth400imp { min-width: 150px !important; } + .minwidth500imp { min-width: 250px !important; } + .titlefield { width: auto; } + .titlefieldcreate { width: auto; } #tooltip { position: absolute; @@ -1451,31 +1515,31 @@ table[summary="list_of_modules"] .fa-cog { div.divphotoref { padding-<?php echo $right; ?>: 5px; - padding-bottom: 5px; + padding-bottom: 5px; + } + img.photoref, div.photoref { + border: none; + -webkit-box-shadow: none; + box-shadow: none; + padding: 4px; + height: 20px; + width: 20px; + object-fit: contain; } - img.photoref, div.photoref { - border: none; - -webkit-box-shadow: none; - box-shadow: none; - padding: 4px; - height: 20px; - width: 20px; - object-fit: contain; - } div.statusref { - padding-right: 10px; - } + padding-right: 10px; + } div.statusref img { - padding-right: 3px !important; - } + padding-right: 3px !important; + } div.statusrefbis { - padding-right: 3px !important; - } + padding-right: 3px !important; + } - input.buttonpayment { + input.buttonpayment { min-width: 300px; - } + } } .linkobject { cursor: pointer; } @@ -1690,7 +1754,7 @@ div.login_block { color: #333 !important; } .login_block_elem a span.atoplogin, .login_block_elem span.atoplogin { - vertical-align: middle; + vertical-align: middle; } @@ -1718,7 +1782,9 @@ div.fiche { div.fiche { margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : (empty($conf->dol_optimize_smallscreen) ? '24' : '6')); ?>px; margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : (empty($conf->dol_optimize_smallscreen) ? '22' : '6')); ?>px; - <?php if (!empty($dol_hide_leftmenu) && !empty($dol_hide_topmenu)) print 'margin-top: 12px;'; ?> + <?php if (!empty($dol_hide_leftmenu) && !empty($dol_hide_topmenu)) { + print 'margin-top: 12px;'; + } ?> margin-bottom: 15px; } body.onlinepaymentbody div.fiche { /* For online payment page */ @@ -1735,28 +1801,50 @@ div.fichecenterbis { margin-top: 8px; } div.fichethirdleft { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?> - <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px;\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$left.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: 50%;\n"; + } ?> + <?php if ($conf->browser->layout == 'phone') { + print "padding-bottom: 6px;\n"; + } ?> } div.fichetwothirdright { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: 50%;\n"; } ?> - <?php if ($conf->browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$right.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: 50%;\n"; + } ?> + <?php if ($conf->browser->layout == 'phone') { + print "padding-bottom: 6px\n"; + } ?> } div.fichetwothirdright div.ficheaddleft { - padding-left: 20px; + padding-left: 20px; } div.fichehalfleft { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: calc(50% - 10px);\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$left.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: calc(50% - 10px);\n"; + } ?> } div.fichehalfright { - <?php if ($conf->browser->layout != 'phone') { print "float: ".$right.";\n"; } ?> - <?php if ($conf->browser->layout != 'phone') { print "width: calc(50% - 10px);\n"; } ?> + <?php if ($conf->browser->layout != 'phone') { + print "float: ".$right.";\n"; + } ?> + <?php if ($conf->browser->layout != 'phone') { + print "width: calc(50% - 10px);\n"; + } ?> } div.fichehalfright { - <?php if ($conf->browser->layout == 'phone') { print "margin-top: 10px;\n"; } ?> + <?php if ($conf->browser->layout == 'phone') { + print "margin-top: 10px;\n"; + } ?> } div.firstcolumn div.box { padding-right: 10px; @@ -1767,44 +1855,46 @@ div.secondcolumn div.box { /* Force values on one colum for small screen */ @media only screen and (max-width: 900px) { - div.fiche { - margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : ($dol_hide_leftmenu ? '4' : '20')); ?>px; - margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 8 : 16); ?>px; - <?php if (!empty($conf->dol_hide_leftmenu) && !empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> - margin-bottom: 15px; - } - div.fichecenter { - width: 100%; - clear: both; /* This is to have div fichecenter that are true rectangles */ - } - div.fichecenterbis { - margin-top: 8px; - } - div.fichethirdleft { - float: none; - width: auto; - padding-bottom: 6px; - } - div.fichetwothirdright { - float: none; - width: auto; - padding-bottom: 6px; - } - div.fichetwothirdright div.ficheaddleft { - padding-left: 0; + div.fiche { + margin-<?php print $left; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 6 : ($dol_hide_leftmenu ? '4' : '20')); ?>px; + margin-<?php print $right; ?>: <?php print (GETPOST('optioncss', 'aZ09') == 'print' ? 8 : 16); ?>px; + <?php if (!empty($conf->dol_hide_leftmenu) && !empty($conf->dol_hide_topmenu)) { + print 'margin-top: 4px;'; + } ?> + margin-bottom: 15px; } - div.fichehalfleft { - float: none; - width: auto; - } - div.fichehalfright { - float: none; - width: auto; - } - div.fichehalfright { - margin-top: 10px; - } - div.firstcolumn div.box { + div.fichecenter { + width: 100%; + clear: both; /* This is to have div fichecenter that are true rectangles */ + } + div.fichecenterbis { + margin-top: 8px; + } + div.fichethirdleft { + float: none; + width: auto; + padding-bottom: 6px; + } + div.fichetwothirdright { + float: none; + width: auto; + padding-bottom: 6px; + } + div.fichetwothirdright div.ficheaddleft { + padding-left: 0; + } + div.fichehalfleft { + float: none; + width: auto; + } + div.fichehalfright { + float: none; + width: auto; + } + div.fichehalfright { + margin-top: 10px; + } + div.firstcolumn div.box { padding-right: 0px; } div.secondcolumn div.box { @@ -1814,7 +1904,7 @@ div.secondcolumn div.box { /* For table into table into card */ div.fichehalfright tr.liste_titre:first-child td table.nobordernopadding td { - padding: 0 0 0 0; + padding: 0 0 0 0; } div.nopadding { padding: 0 !important; @@ -1833,17 +1923,17 @@ div.nopadding { width: 14px; } .table-list-of-attached-files .col-picto, .table-list-of-links .col-picto { - opacity: 0.7 !important; - font-size: 1em; - width: 20px; + opacity: 0.7 !important; + font-size: 1em; + width: 20px; } .table-list-of-attached-files .col-picto .widthpictotitle, .table-list-of-links .col-picto .widthpictotitle { width: unset; - color: #999; + color: #999; } .pictosubstatus { - padding-left: 2px; - padding-right: 2px; + padding-left: 2px; + padding-right: 2px; } .pictostatus { width: 15px; @@ -1851,14 +1941,14 @@ div.nopadding { margin-top: -3px } .pictowarning, .pictoerror, .pictopreview { - padding-<?php echo $left; ?>: 3px; + padding-<?php echo $left; ?>: 3px; } .pictowarning { - /* vertical-align: text-bottom; */ - color: <?php echo $badgeWarning; ?>; + /* vertical-align: text-bottom; */ + color: <?php echo $badgeWarning; ?>; } .pictoerror { - color: <?php echo $badgeDanger ?>; + color: <?php echo $badgeDanger ?>; } .pictomodule { width: 14px; @@ -1866,14 +1956,14 @@ div.nopadding { .fiche .arearef img.pictoedit, .fiche .arearef span.pictoedit, .fiche .fichecenter img.pictoedit, .fiche .fichecenter span.pictoedit, .tagtdnote span.pictoedit { - opacity: 0.6; + opacity: 0.6; } img.hideonsmartphone.pictoactionview { - vertical-align: bottom; + vertical-align: bottom; } .pictofixedwidth { - text-align: left; - width: 16px; + text-align: left; + width: 16px; } .colorthumb { @@ -1918,32 +2008,32 @@ div.statusref { clear: both; } div.statusref img { - padding-left: 8px; - padding-right: 9px; - vertical-align: text-bottom; - width: 18px; + padding-left: 8px; + padding-right: 9px; + vertical-align: text-bottom; + width: 18px; } div.statusrefbis { - padding-left: 8px; - padding-right: 9px; - vertical-align: text-bottom; + padding-left: 8px; + padding-right: 9px; + vertical-align: text-bottom; } img.photoref, div.photoref { border: 1px solid #CCC; - -webkit-box-shadow: 3px 3px 4px #DDD; - box-shadow: 3px 3px 4px #DDD; - padding: 4px; + -webkit-box-shadow: 3px 3px 4px #DDD; + box-shadow: 3px 3px 4px #DDD; + padding: 4px; height: 80px; width: 80px; - object-fit: contain; + object-fit: contain; } div.photoref .fa, div.photoref .fas, div.photoref .far { - font-size: 2.5em; + font-size: 2.5em; } img.fitcontain { - object-fit: contain; + object-fit: contain; } div.photoref { display:table-cell; @@ -1951,12 +2041,12 @@ div.photoref { text-align:center; } img.photorefnoborder { - padding: 2px; + padding: 2px; height: 48px; width: 48px; - object-fit: contain; - border: 1px solid #AAA; - border-radius: 100px; + object-fit: contain; + border: 1px solid #AAA; + border-radius: 100px; } .underrefbanner { } @@ -1965,7 +2055,7 @@ img.photorefnoborder { } .trextrafieldseparator td, .trextrafields_collapse_last td { - border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>) !important; + border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>) !important; } .tdhrthin { margin: 0; @@ -1987,7 +2077,9 @@ $heightmenu = 48; /* height of top menu, part with image */ $heightmenu2 = 48; /* height of top menu, ârt with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { $heightmenu = 30; $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu = 0; } +if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { + $heightmenu = 30; $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu = 0; +} ?> div#tmenu_tooltip { @@ -2024,25 +2116,25 @@ div.tmenudiv { <?php if (GETPOST('optioncss', 'aZ09') == 'print') { ?> display:none; <?php } else { ?> - position: relative; - display: block; - white-space: nowrap; - border-top: 0px; - border-<?php print $left; ?>: 0px; - border-<?php print $right; ?>: 0px; - padding: 0px 0px 0px 0px; /* t r b l */ - margin: 0px 0px 0px 0px; /* t r b l */ + position: relative; + display: block; + white-space: nowrap; + border-top: 0px; + border-<?php print $left; ?>: 0px; + border-<?php print $right; ?>: 0px; + padding: 0px 0px 0px 0px; /* t r b l */ + margin: 0px 0px 0px 0px; /* t r b l */ font-size: 13px; - font-weight: normal; + font-weight: normal; color: #000000; - text-decoration: none; + text-decoration: none; <?php } ?> } div.tmenudisabled, a.tmenudisabled { opacity: 0.6; } a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudisabled:active { - font-weight: normal; + font-weight: normal; padding: 0px 5px 0px 5px; white-space: nowrap; color: #<?php echo $colortextbackhmenu; ?>; @@ -2051,12 +2143,12 @@ a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudis } a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { - font-weight: normal; + font-weight: normal; padding: 0px 5px 0px 5px; white-space: nowrap; /* text-shadow: 1px 1px 1px #000000; */ color: #<?php echo $colortextbackhmenu; ?>; - text-decoration: none; + text-decoration: none; } a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active { font-weight: normal; @@ -2069,12 +2161,12 @@ a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active { ul.tmenu { /* t r b l */ - padding: 0px 0px 0px 0px; - margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; list-style: none; display: table; - margin-right: 65px; /* to keep space for bookmark */ - padding-left: 5px; + margin-right: 65px; /* to keep space for bookmark */ + padding-left: 5px; } ul.tmenu li { background: rgb(<?php echo $colorbackhmenu1 ?>); @@ -2093,12 +2185,13 @@ li.tmenu, li.tmenusel { vertical-align: bottom; <?php if (empty($conf->global->MAIN_MENU_INVERT)) { ?> float: <?php print $left; ?>; - <?php if (!$disableimages) { ?> - height: <?php print $heightmenu; ?>px; + <?php if (!$disableimages) { ?> + height: <?php print $heightmenu; ?>px; padding: 0px 0px 2px 0px; - <?php } else { ?> - padding: 0px 0px 0px 0px; - <?php } } ?> + <?php } else { ?> + padding: 0px 0px 0px 0px; + <?php } + } ?> position:relative; display: block; margin: 0px 0px 0px 0px; @@ -2133,14 +2226,14 @@ div.tmenucenter height: 26px; <?php } else { ?> padding-top: 2px; - height: <?php print $heightmenu; ?>px; + height: <?php print $heightmenu; ?>px; <?php } ?> - width: 100%; + width: 100%; } div.menu_titre { padding-bottom: 2px; overflow: hidden; - text-overflow: ellipsis; + text-overflow: ellipsis; } .mainmenuaspan { @@ -2157,14 +2250,14 @@ div.mainmenu { min-width: 40px; } a.tmenuimage:focus, .mainmenu.topmenuimage:focus { - outline: none; + outline: none; } /* Do not load menu img if hidden to save bandwidth */ <?php if (empty($dol_hide_topmenu)) { ?> - <?php if (!defined('DISABLE_FONT_AWSOME')) { ?> - <?php include dol_buildpath($path.'/theme/'.$theme.'/main_menu_fa_icons.inc.php', 0); ?> - <?php } ?> + <?php if (!defined('DISABLE_FONT_AWSOME')) { ?> + <?php include dol_buildpath($path.'/theme/'.$theme.'/main_menu_fa_icons.inc.php', 0); ?> + <?php } ?> div.mainmenu.home{ background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/home.png', 1) ?>); @@ -2184,7 +2277,7 @@ div.mainmenu.agenda { } div.mainmenu.bank { - background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/bank.png', 1) ?>); + background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/bank.png', 1) ?>); } div.mainmenu.cashdesk { @@ -2212,7 +2305,7 @@ div.mainmenu.externalsite { } div.mainmenu.ftp { - background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png', 1) ?>); + background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png', 1) ?>); } div.mainmenu.hrm { @@ -2265,8 +2358,7 @@ div.mainmenu.website { 'barcode'=>'', 'fckeditor'=>'', 'categorie'=>'', ); $mainmenuused = 'home'; - foreach ($conf->modules as $val) - { + foreach ($conf->modules as $val) { $mainmenuused .= ','.(isset($moduletomainmenu[$val]) ? $moduletomainmenu[$val] : $val); } $mainmenuusedarray = array_unique(explode(',', $mainmenuused)); @@ -2276,26 +2368,26 @@ div.mainmenu.website { $divalreadydefined = array('home', 'companies', 'products', 'mrp', 'commercial', 'externalsite', 'accountancy', 'project', 'tools', 'members', 'agenda', 'ftp', 'holiday', 'hrm', 'bookmark', 'cashdesk', 'takepos', 'ecm', 'geoipmaxmind', 'gravatar', 'clicktodial', 'paypal', 'stripe', 'webservices', 'website'); // Put here list of menu entries we are sure we don't want $divnotrequired = array('multicurrency', 'salaries', 'ticket', 'margin', 'opensurvey', 'paybox', 'expensereport', 'incoterm', 'prelevement', 'propal', 'workflow', 'notification', 'supplier_proposal', 'cron', 'product', 'productbatch', 'expedition'); - foreach ($mainmenuusedarray as $val) - { - if (empty($val) || in_array($val, $divalreadydefined)) continue; - if (in_array($val, $divnotrequired)) continue; + foreach ($mainmenuusedarray as $val) { + if (empty($val) || in_array($val, $divalreadydefined)) { + continue; + } + if (in_array($val, $divnotrequired)) { + continue; + } //print "XXX".$val; // Search img file in module dir $found = 0; $url = ''; - foreach ($conf->file->dol_document_root as $dirroot) - { - if (file_exists($dirroot."/".$val."/img/".$val.".png")) - { + foreach ($conf->file->dol_document_root as $dirroot) { + if (file_exists($dirroot."/".$val."/img/".$val.".png")) { $url = dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); $found = 1; break; } } // Img file not found - if (!$found) - { + if (!$found) { if (!defined('DISABLE_FONT_AWSOME')) { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; print 'div.mainmenu.'.$val.'::before { @@ -2320,22 +2412,22 @@ div.mainmenu.website { } // End test if $dol_hide_topmenu ?> .tmenuimage { - padding:0 0 0 0 !important; - margin:0 0px 0 0 !important; - <?php if ($disableimages) { ?> - display: none; - <?php } ?> + padding:0 0 0 0 !important; + margin:0 0px 0 0 !important; + <?php if ($disableimages) { ?> + display: none; + <?php } ?> } .topmenuimage { <?php if ($disableimages) { ?> - display: none; - <?php } ?> + display: none; + <?php } ?> } a.tmenuimage { - display: block; + display: block; } a.tmenuimage:focus { - outline: none; + outline: none; } @@ -2345,13 +2437,13 @@ a.tmenuimage:focus { { background: #f0f0f0; display: table; - position: absolute; - height: 100%; - width: 100%; + position: absolute; + height: 100%; + width: 100%; } .login_center { display: table-cell; - vertical-align: middle; + vertical-align: middle; } .login_vertical_align { padding: 10px; @@ -2404,9 +2496,9 @@ form#login { margin: 8px; } .login_table .tdinputlogin { - background-color: #fff; - min-width: 220px; - border-radius: 2px; + background-color: #fff; + min-width: 220px; + border-radius: 2px; } .login_table .tdinputlogin { border-bottom: 1px solid #ccc; @@ -2417,7 +2509,7 @@ form#login { } .login_main_home { - word-break: break-word; + word-break: break-word; } .login_main_message { text-align: center; @@ -2438,7 +2530,7 @@ div#login_left, div#login_right { vertical-align: middle; } div#login_right select#entity { - margin-top: 10px; + margin-top: 10px; } table.login_table tr td table.none tr td { padding: 2px; @@ -2468,8 +2560,8 @@ table.login_table_securitycode tr td { div.login_block { border-right: 1px solid rgba(0,0,0,0.3); - padding-top: 3px; - padding-bottom: 3px; + padding-top: 3px; + padding-bottom: 3px; <?php print $left; ?>: 0; top: 0px; <?php if (in_array($conf->browser->layout, array('phone', 'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> @@ -2507,13 +2599,13 @@ div.login_block_other { padding-top: 3px; } .topnav div.login_block_user { display: inline-block; - vertical-align: middle; + vertical-align: middle; line-height: <?php echo $disableimages ? '25' : '50'; ?>px; height: <?php echo $disableimages ? '25' : '50'; ?>px; } .topnav div.login_block_other { display: inline-block; - vertical-align: middle; + vertical-align: middle; clear: <?php echo $disableimages ? 'none' : 'both'; ?>; padding-top: 0; text-align: right; @@ -2531,11 +2623,11 @@ div.login_block_other { padding-top: 3px; } margin-top: 1px; } a.aversion { - white-space: nowrap; - width: 48px; - overflow: hidden; - text-overflow: ellipsis; - display: block; + white-space: nowrap; + width: 48px; + overflow: hidden; + text-overflow: ellipsis; + display: block; } .atoplogin, .atoplogin:hover { @@ -2550,8 +2642,8 @@ a.aversion { text-decoration:underline !important; } span.fa.atoplogin, span.fa.atoplogin:hover { - font-size: 16px; - text-decoration: none !important; + font-size: 16px; + text-decoration: none !important; } img.login, img.printer, img.entity { /* padding: 0px 0px 0px 4px; */ @@ -2564,29 +2656,29 @@ img.login, img.printer, img.entity { border-radius: 8px; width: 16px; height: 16px; - background-size: contain; + background-size: contain; vertical-align: text-bottom; background-color: #FFF; } img.userphoto { /* size for user photo in lists */ - border-radius: 0.75em; - width: 1.5em; - height: 1.5em; - background-size: contain; - vertical-align: middle; + border-radius: 0.75em; + width: 1.5em; + height: 1.5em; + background-size: contain; + vertical-align: middle; } img.userphotosmall { /* size for user photo in lists */ border-radius: 0.6em; width: 1.2em; - height: 1.2em; - background-size: contain; - vertical-align: middle; + height: 1.2em; + background-size: contain; + vertical-align: middle; } img.userphoto[alt="Gravatar avatar"] { - background: #fff; + background: #fff; } form[name="addtime"] img.userphoto { - border: 1px solid #444; + border: 1px solid #444; } .span-icon-user { background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/object_user.png', 1); ?>); @@ -2602,19 +2694,19 @@ form[name="addtime"] img.userphoto { /* ============================================================================== */ div.vmenu, td.vmenu { - margin-<?php print $right; ?>: 2px; - position: relative; - float: left; - padding: 0px; - padding-bottom: 0px; - padding-top: 0px; - width: 222px; + margin-<?php print $right; ?>: 2px; + position: relative; + float: left; + padding: 0px; + padding-bottom: 0px; + padding-top: 0px; + width: 222px; } .vmenu { margin-left: 4px; <?php if (GETPOST('optioncss', 'aZ09') == 'print') { ?> - display: none; + display: none; <?php } ?> } @@ -2626,7 +2718,7 @@ div.vmenu, td.vmenu { padding-top: 4px; padding-bottom: 3px; overflow: hidden; - text-overflow: ellipsis; + text-overflow: ellipsis; } #menu_contenu_logo { padding-right: 4px; } .companylogo { padding-top: 4px; } @@ -2644,14 +2736,14 @@ font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: <?php print $left; ?>; font-weight: normal; color: #999; text-decoration: none; } .helppresentcircle { - color: var(--colorbackhmenu1); - filter: invert(0.5); - margin-left: -7px; - display: inline-block; - margin-top: -10px; - font-size: x-small; - vertical-align: super; - opacity: 0.95; + color: var(--colorbackhmenu1); + filter: invert(0.5); + margin-left: -7px; + display: inline-block; + margin-top: -10px; + font-size: x-small; + vertical-align: super; + opacity: 0.95; } div.blockvmenulogo @@ -2659,23 +2751,23 @@ div.blockvmenulogo border-bottom: 0 !important; } .menulogocontainer { - margin: <?php echo $disableimages ? '0' : '6'; ?>px; - margin-left: 12px; - margin-right: 6px; - padding: 0; - height: <?php echo $disableimages ? '20' : '32'; ?>px; - /* width: 100px; */ - max-width: 100px; - vertical-align: middle; + margin: <?php echo $disableimages ? '0' : '6'; ?>px; + margin-left: 12px; + margin-right: 6px; + padding: 0; + height: <?php echo $disableimages ? '20' : '32'; ?>px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; } .backgroundforcompanylogo { background-color: rgba(255,255,255,0.7); border-radius: 5px; } .menulogocontainer img.mycompany { - object-fit: contain; - width: inherit; - height: inherit; + object-fit: contain; + width: inherit; + height: inherit; } #mainmenutd_companylogo::after { content: unset; @@ -2701,14 +2793,14 @@ div.blockvmenupair, div.blockvmenuimpair color: #000000; text-align: <?php print $left; ?>; text-decoration: none; - padding-left: 5px; - padding-right: 1px; - padding-top: 3px; - padding-bottom: 3px; - margin: 1px 0px 8px 0px; + padding-left: 5px; + padding-right: 1px; + padding-top: 3px; + padding-bottom: 3px; + margin: 1px 0px 8px 0px; - padding-bottom: 10px; - border-bottom: 1px solid #e0e0e0; + padding-bottom: 10px; + border-bottom: 1px solid #e0e0e0; } div.blockvmenubookmarks { @@ -2719,7 +2811,7 @@ div.blockvmenuend { padding-left: 0 !important; } a.vsmenu.addbookmarkpicto { - padding-right: 10px; + padding-right: 10px; } div.blockvmenufirst { padding-top: 10px; @@ -2731,14 +2823,14 @@ div.blockvmenusearch, div.blockvmenubookmarks color: #000000; text-align: <?php print $left; ?>; text-decoration: none; - padding-left: 5px; - padding-right: 1px; - padding-top: 3px; - padding-bottom: 3px; - margin: 1px 0px 2px 0px; + padding-left: 5px; + padding-right: 1px; + padding-top: 3px; + padding-bottom: 3px; + margin: 1px 0px 2px 0px; - padding-bottom: 10px; - /* border-bottom: 1px solid #f4f4f4; */ + padding-bottom: 10px; + /* border-bottom: 1px solid #f4f4f4; */ } div.blockvmenusearchphone { @@ -2753,13 +2845,13 @@ div.blockvmenuhelp color: #000000; text-align: center; text-decoration: none; - padding-left: 0px; - padding-right: 8px; - padding-top: 3px; - padding-bottom: 3px; - margin: 4px 0px 0px 0px; + padding-left: 0px; + padding-right: 8px; + padding-top: 3px; + padding-bottom: 3px; + margin: 4px 0px 0px 0px; <?php } else { ?> - display: none; + display: none; <?php } ?> } @@ -2782,7 +2874,7 @@ td.barre_select { td.photo { background: #F4F4F4; color: #000000; - border: 1px solid #bbb; + border: 1px solid #bbb; } /* ============================================================================== */ @@ -2794,14 +2886,14 @@ td.photo { */ #mainContent, #leftContent .ui-layout-pane { - padding: 0px; - overflow: auto; + padding: 0px; + overflow: auto; } #mainContent, #leftContent .ui-layout-center { padding: 0px; position: relative; /* contain floated or positioned elements */ - overflow: auto; /* add scrolling to content-div */ + overflow: auto; /* add scrolling to content-div */ } @@ -2810,29 +2902,29 @@ td.photo { /* ============================================================================== */ td.ecmroot { - padding-bottom: 0 !important; + padding-bottom: 0 !important; } .largebutton { /* border-top: 1px solid #CCC !important; */ - padding: 0px 4px 14px 4px !important; - min-height: 32px; + padding: 0px 4px 14px 4px !important; + min-height: 32px; } a.toolbarbutton { - margin-top: 0px; - margin-left: 4px; - margin-right: 4px; - height: 30px; + margin-top: 0px; + margin-left: 4px; + margin-right: 4px; + height: 30px; } img.toolbarbutton { margin-top: 1px; - height: 30px; + height: 30px; } li.expanded > a.fmdirlia.jqft.ecmjqft { - font-weight: bold !important; + font-weight: bold !important; } @@ -2840,30 +2932,30 @@ li.expanded > a.fmdirlia.jqft.ecmjqft { /* Onglets */ /* ============================================================================== */ div.tabs { - text-align: <?php print $left; ?>; - margin-left: 6px !important; - margin-right: 6px !important; - clear:both; + text-align: <?php print $left; ?>; + margin-left: 6px !important; + margin-right: 6px !important; + clear:both; height:100%; } div.tabsElem { margin-top: 6px; } /* To avoid overlap of tabs when not browser */ div.tabsElem a { - font-weight: normal !important; + font-weight: normal !important; } div.tabBar { - color: #<?php echo $colortextbacktab; ?>; - padding-top: 16px; - padding-left: 16px; - padding-right: 16px; + color: #<?php echo $colortextbacktab; ?>; + padding-top: 16px; + padding-left: 16px; + padding-right: 16px; padding-bottom: 16px; - margin: 0px 0px 16px 0px; - -webkit-border-radius: 3px; + margin: 0px 0px 16px 0px; + -webkit-border-radius: 3px; border-radius: 3px; - border-right: 1px solid #BBB; - border-left: 1px solid #BBB; - border-top: 1px solid #CCC; + border-right: 1px solid #BBB; + border-left: 1px solid #BBB; + border-top: 1px solid #CCC; width: auto; background: rgb(<?php echo $colorbacktabcard1; ?>); border-bottom: 1px solid #aaa; @@ -2875,8 +2967,8 @@ div.tabBar tr.titre td { /* div.tabBar.tabBarNoTop { - padding-top: 0; - border-top: 0; + padding-top: 0; + border-top: 0; } */ @@ -2886,7 +2978,7 @@ div.tabBarWithBottom { border-bottom: 1px solid #aaa; } div.tabBar table.tableforservicepart2:last-child { - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } .tableforservicepart1 .tdhrthin { height: unset; @@ -2904,12 +2996,12 @@ div.divButAction { margin-bottom: 1.4em; } div.tabsAction { - margin: 20px 0em 20px 0em; - padding: 0em 0em; - text-align: right; + margin: 20px 0em 20px 0em; + padding: 0em 0em; + text-align: right; } div.tabsActionNoBottom { - margin-bottom: 0px; + margin-bottom: 0px; } div.tabsAction > a { margin-bottom: 16px !important; @@ -2928,15 +3020,15 @@ div.popuptab { } a.tabTitle { - color:rgba(0,0,0,.5); - margin-<?php print $right; ?>: 10px; - text-shadow:1px 1px 1px #ffffff; + color:rgba(0,0,0,.5); + margin-<?php print $right; ?>: 10px; + text-shadow:1px 1px 1px #ffffff; font-family: <?php print $fontlist ?>; font-weight: normal; - padding: 4px 6px 2px 6px; - margin: 0px 6px; - text-decoration: none; - white-space: nowrap; + padding: 4px 6px 2px 6px; + margin: 0px 6px; + text-decoration: none; + white-space: nowrap; } .tabTitleText { display: none; @@ -2945,22 +3037,22 @@ a.tabTitle { max-height: 14px; } div.tabs div.tabsElem:first-of-type a.tab { - margin-left: 0px !important; + margin-left: 0px !important; } a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { font-family: <?php print $fontlist ?>; padding: 12px 13px 12px; - margin: 0em 0.2em; - text-decoration: none; - white-space: nowrap; + margin: 0em 0.2em; + text-decoration: none; + white-space: nowrap; background-image: none !important; } .tabunactive { /* We add some border on tabunactive to avoid change of position of title when switching tabs (border of tabunactive = border of tabactive) */ - border-right: 1px solid rgb(<?php echo $colorbackbody; ?>); - border-left: 1px solid rgb(<?php echo $colorbackbody; ?>); + border-right: 1px solid rgb(<?php echo $colorbackbody; ?>); + border-left: 1px solid rgb(<?php echo $colorbackbody; ?>); } .tabactive, a.tab#active { @@ -2980,30 +3072,30 @@ a.tab:hover text-decoration: underline; } a.tabimage { - color: #434956; + color: #434956; font-family: <?php print $fontlist ?>; - text-decoration: none; - white-space: nowrap; + text-decoration: none; + white-space: nowrap; } td.tab { - background: #dee7ec; + background: #dee7ec; } span.tabspan { - background: #dee7ec; - color: #434956; + background: #dee7ec; + color: #434956; font-family: <?php print $fontlist ?>; - padding: 0px 6px; - margin: 0em 0.2em; - text-decoration: none; - white-space: nowrap; + padding: 0px 6px; + margin: 0em 0.2em; + text-decoration: none; + white-space: nowrap; -webkit-border-radius:3px 3px 0px 0px; border-radius:3px 3px 0px 0px; - border-<?php print $right; ?>: 1px solid #555555; - border-<?php print $left; ?>: 1px solid #D8D8D8; - border-top: 1px solid #D8D8D8; + border-<?php print $right; ?>: 1px solid #555555; + border-<?php print $left; ?>: 1px solid #D8D8D8; + border-top: 1px solid #D8D8D8; } /* ============================================================================== */ @@ -3051,7 +3143,7 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd } .smallpaddingimp { - padding: 4px !important; + padding: 4px !important; } .nopaddingleft { padding-<?php print $left; ?>: 0px; @@ -3085,8 +3177,8 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd } table.tableforemailform tr td { - padding-top: 3px; - padding-bottom: 3px; + padding-top: 3px; + padding-bottom: 3px; } table.border, table.bordernooddeven, table.dataTable, .table-border, .table-border-col, .table-key-border-col, .table-val-border-col, div.border { @@ -3102,7 +3194,7 @@ table.borderplus { height: 26px; } tr.liste_titre.box_titre td table td, .bordernooddeven tr td { - height: 26px; + height: 26px; } table.border td, table.bordernooddeven td, div.border div div.tagtd { @@ -3129,10 +3221,10 @@ td.border, div.tagtable div div.border { /* Main boxes */ .nobordertop, .nobordertop tr:first-of-type td { - border-top: none !important; + border-top: none !important; } .noborderbottom, .noborderbottom tr:last-of-type td { - border-bottom: none !important; + border-bottom: none !important; } .bordertop { border-top: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); @@ -3151,8 +3243,8 @@ div.colorback margin-top: 5px; } .liste_titre_bydiv { - border-right: 1px solid #ccc; - border-left: 1px solid #ccc; + border-right: 1px solid #ccc; + border-left: 1px solid #ccc; } table.liste, table.noborder, table.formdoc, div.noborder { width: calc(100% - 1px); /* -1 to fix a bug. Without, a scroll appears due to overflow-x: auto; of div-table-responsive */ @@ -3168,8 +3260,8 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-bottom-color: #BBB; border-bottom-style: solid; - border-right: 1px solid #ccc; - border-left: 1px solid #ccc; + border-right: 1px solid #ccc; + border-left: 1px solid #ccc; margin: 0px 0px 8px 0px; @@ -3202,21 +3294,21 @@ tr.liste_titre_filter td.liste_titre { } .liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd { - /*border-top-width: 1px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid;*/ + /*border-top-width: 1px; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid;*/ } .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd { - border-top-width: 2px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-width: 2px; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } .liste_titre_add td, .liste_titre_add .tagtd { - border-top-width: 1px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-width: 1px; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } table.liste th, table.noborder th, table.noborder tr.liste_titre td { @@ -3227,7 +3319,7 @@ table.noborder td, div.noborder form, div.noborder form div, table.tableforservi } form.tagtable { padding: unset !important; - border: unset !important; + border: unset !important; } table.liste td, table.noborder td, div.noborder form div { @@ -3254,13 +3346,13 @@ table.border tr td table.nobordernopadding tr td { padding-bottom: 0; } td.borderright { - border: none; /* to erase value for table.nobordernopadding td */ + border: none; /* to erase value for table.nobordernopadding td */ border-right-width: 1px !important; border-right-color: #BBB !important; border-right-style: solid !important; } td.borderleft { - border: none; /* to erase value for table.nobordernopadding td */ + border: none; /* to erase value for table.nobordernopadding td */ border-left-width: 1px !important; border-left-color: #BBB !important; border-left-style: solid !important; @@ -3284,17 +3376,17 @@ div.refidpadding { div.refid { font-weight: bold; color: rgb(<?php print $colortexttitlenotab; ?>); - font-size: 160%; + font-size: 160%; } div.refidno { padding-top: 8px; font-weight: normal; - color: #444; - font-size: <?php print $fontsize ?>px; - line-height: 21px; + color: #444; + font-size: <?php print $fontsize ?>px; + line-height: 21px; } div.refidno form { - display: inline-block; + display: inline-block; } div.pagination { @@ -3362,10 +3454,10 @@ div.pagination li a:hover, div.pagination li span:hover, div.pagination li a:focus, div.pagination li span:focus { - color: #000; - background-color: #eee; - border-color: #ddd; - /* padding-top: 8px; */ + color: #000; + background-color: #eee; + border-color: #ddd; + /* padding-top: 8px; */ } div.pagination li .active a, div.pagination li .active span, @@ -3410,12 +3502,12 @@ table.hidepaginationnext .paginationnext { display: none; } .paginationafterarrows a.btnTitlePlus { - border: 1px solid var(--btncolorborder); + border: 1px solid var(--btncolorborder); } .paginationafterarrows a.btnTitlePlus:hover span:before { - /* text-shadow: 0px 0px 5px #ccc; */ - /* filter: invert(0.3); */ - font-size: 1.03em; + /* text-shadow: 0px 0px 5px #ccc; */ + /* filter: invert(0.3); */ + font-size: 1.03em; } @@ -3527,25 +3619,25 @@ td.evenodd, tr.nohoverpair td, #trlinefordates td { } .trforbreak td { font-weight: bold; - border-bottom: 1pt solid black !important; + border-bottom: 1pt solid black !important; background-color: var(--colorbacklinebreak) !important; } table.dataTable td { - padding: 5px 2px 5px 3px !important; + padding: 5px 2px 5px 3px !important; } tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd { - padding: 5px 2px 5px 3px; - border-bottom: 1px solid #eee; + padding: 5px 2px 5px 3px; + border-bottom: 1px solid #eee; } form.pair, form.impair { font-weight: normal; } tr.pair:last-of-type td, tr.impair:last-of-type td { - border-bottom: 0px !important; + border-bottom: 0px !important; } tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { - border-bottom: 0px !important; + border-bottom: 0px !important; } /* table.nobottomiftotal tr.liste_total td { @@ -3576,8 +3668,8 @@ div.liste_titre { } div.liste_titre_bydiv { border-top-width: <?php echo $borderwidth ?>px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; box-shadow: none; border-collapse: collapse; @@ -3593,11 +3685,11 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se { background: rgb(<?php echo $colorbacktitle1; ?>); font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - border-bottom: 1px solid #FDFFFF; + border-bottom: 1px solid #FDFFFF; - color: rgb(<?php echo $colortexttitle; ?>); - font-family: <?php print $fontlist ?>; - text-align: <?php echo $left; ?>; + color: rgb(<?php echo $colortexttitle; ?>); + font-family: <?php print $fontlist ?>; + text-align: <?php echo $left; ?>; } tr.liste_titre th, tr.liste_titre td, th.liste_titre { @@ -3605,14 +3697,14 @@ tr.liste_titre th, tr.liste_titre td, th.liste_titre } /* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ tr:first-child th.liste_titre, tr:first-child th.liste_titre_sel { - border-bottom: 1px solid #FFF ! important; + border-bottom: 1px solid #FFF ! important; } tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste_titre div, div.liste_titre { - font-family: <?php print $fontlist ?>; - font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - vertical-align: middle; - height: 24px; + font-family: <?php print $fontlist ?>; + font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; + vertical-align: middle; + height: 24px; } tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a { text-shadow: none !important; @@ -3620,8 +3712,8 @@ tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, fo } tr.liste_titre_topborder td { border-top-width: <?php echo $borderwidth; ?>px; - border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); - border-top-style: solid; + border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); + border-top-style: solid; } .liste_titre td a { text-shadow: none !important; @@ -3634,7 +3726,7 @@ tr.liste_titre_topborder td { background: transparent; } tr.liste_titre:last-child th.liste_titre, tr.liste_titre:last-child th.liste_titre_sel, tr.liste_titre td.liste_titre, tr.liste_titre td.liste_titre_sel, form.liste_titre div.tagtd { /* For last line of table headers only */ - border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); + border-bottom: 1px solid rgb(<?php echo $colortopbordertitle1 ?>); } div.liste_titre { @@ -3642,23 +3734,23 @@ div.liste_titre { } tr.liste_titre_sel th, th.liste_titre_sel, tr.liste_titre_sel td, td.liste_titre_sel, form.liste_titre_sel div { - font-family: <?php print $fontlist ?>; - font-weight: normal; - border-bottom: 1px solid #FDFFFF; - text-decoration: underline; + font-family: <?php print $fontlist ?>; + font-weight: normal; + border-bottom: 1px solid #FDFFFF; + text-decoration: underline; } input.liste_titre { - background: transparent; - border: 0px; + background: transparent; + border: 0px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div, .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { - color: #332266; - /* padding: 4px; */ + color: #332266; + /* padding: 4px; */ } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { - white-space: nowrap; - line-height: 1.5em; + white-space: nowrap; + line-height: 1.5em; } } .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { @@ -3706,7 +3798,7 @@ div.tabBar .noborder { box-shadow: 0px 0px 0px #f4f4f4 !important; } div .tdtop { - vertical-align: top !important; + vertical-align: top !important; padding-top: 5px !important; padding-bottom: 0px !important; } @@ -3715,7 +3807,7 @@ div .tdtop { border-bottom: 1px solid #AAA !important; } #tablelines tr td { - height: unset; + height: unset; } @@ -3763,50 +3855,50 @@ ul.noborder li:nth-child(even):not(.liste_titre) { */ .box { - overflow-x: auto; - min-height: 40px; - padding-right: 0px; - padding-left: 0px; - padding-bottom: 12px; + overflow-x: auto; + min-height: 40px; + padding-right: 0px; + padding-left: 0px; + padding-bottom: 12px; } .ficheaddleft div.boxstats, .ficheaddright div.boxstats { - border: none; + border: none; } .boxstatsborder { - /* border: 1px solid #CCC !important; */ + /* border: 1px solid #CCC !important; */ } .boxstats, .boxstats130 { - display: inline-block; - margin: 8px; - /* border: 1px solid #CCC; */ - text-align: center; - border-radius: 2px; - background: #eee; + display: inline-block; + margin: 8px; + /* border: 1px solid #CCC; */ + text-align: center; + border-radius: 2px; + background: #eee; } .boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; + text-overflow: ellipsis; } .boxstats { - padding: 3px; - width: 100px; - min-height: 40px; + padding: 3px; + width: 100px; + min-height: 40px; } .boxstats130 { - width: 135px; - height: 54px; - padding: 3px; + width: 135px; + height: 54px; + padding: 3px; } @media only screen and (max-width: 767px) { .tabBar .arearef .pagination.paginationref { - max-width: calc(50%); + max-width: calc(50%); } .clearbothonsmartphone { - clear: both; - display: block !important; + clear: both; + display: block !important; } div.tabs { @@ -3817,34 +3909,34 @@ ul.noborder li:nth-child(even):not(.liste_titre) { .boxstats, .boxstats130 { margin: 3px; - border: 1px solid #ddd; - box-shadow: none; - background: #eee; - } + border: 1px solid #ddd; + box-shadow: none; + background: #eee; + } .thumbstat { flex: 1 1 110px; } .thumbstat150 { flex: 1 1 110px; } - .dashboardlineindicator { - float: left; - padding-left: 5px; - } - .boxstats130 { - width: 148px; - } - .boxstats { - width: 100px; - } + .dashboardlineindicator { + float: left; + padding-left: 5px; + } + .boxstats130 { + width: 148px; + } + .boxstats { + width: 100px; + } } .boxstats:hover { box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.20); } span.boxstatstext { - /* opacity: 0.7; */ /* a bug if browser make z-index infintie when opacity is set so we disable it */ - line-height: 18px; - color: #000; + /* opacity: 0.7; */ /* a bug if browser make z-index infintie when opacity is set so we disable it */ + line-height: 18px; + color: #000; } .boxstatsindicator.thumbstat150 { /* If we remove this, box position is ko on ipad */ display: inline-flex; @@ -3874,29 +3966,29 @@ span.dashboardlineko { .dashboardlinelatecoin { float: right; position: relative; - text-align: right; - top: -24px; - padding: 1px 6px 1px 6px; - background-color: #8c4446; - color: #FFFFFF ! important; - border-radius: .25em; + text-align: right; + top: -24px; + padding: 1px 6px 1px 6px; + background-color: #8c4446; + color: #FFFFFF ! important; + border-radius: .25em; } .boxtable { - margin-bottom: 8px !important; - border-bottom-width: 1px; + margin-bottom: 8px !important; + border-bottom-width: 1px; } .boxtable { - margin-bottom: 8px !important; - border-bottom-width: 1px; + margin-bottom: 8px !important; + border-bottom-width: 1px; } .boxtablenotop { - /* border-top-width: 0 !important; */ + /* border-top-width: 0 !important; */ } .boxtablenobottom { - /* border-bottom-width: 0 !important; */ + /* border-bottom-width: 0 !important; */ } .boxtable .fichehalfright, .boxtable .fichehalfleft { - min-width: 275px; + min-width: 275px; } .tdboxstats { text-align: center; @@ -3906,25 +3998,25 @@ span.dashboardlineko { padding-right: 1px !important; } a.valignmiddle.dashboardlineindicator { - line-height: 30px; + line-height: 30px; } tr.box_titre { - height: 26px !important; + height: 26px !important; - /* TO MATCH BOOTSTRAP */ + /* TO MATCH BOOTSTRAP */ /*background: #ddd; color: #000 !important; */ /* TO MATCH ELDY */ background: rgb(<?php echo $colorbacktitle1; ?>); - background-repeat: repeat-x; - color: rgb(<?php echo $colortexttitle; ?>); - font-family: <?php print $fontlist ?>, sans-serif; - font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; - border-bottom: 1px solid #FDFFFF; - white-space: nowrap; + background-repeat: repeat-x; + color: rgb(<?php echo $colortexttitle; ?>); + font-family: <?php print $fontlist ?>, sans-serif; + font-weight: <?php echo $useboldtitle ? 'bold' : 'normal'; ?>; + border-bottom: 1px solid #FDFFFF; + white-space: nowrap; } tr.box_titre td.boxclose { @@ -3949,8 +4041,8 @@ img.boxhandle, img.boxclose { } .prod_entry_mode_free, .prod_entry_mode_predef { - height: 26px !important; - vertical-align: middle; + height: 26px !important; + vertical-align: middle; } .modulebuilderbox { @@ -3975,23 +4067,23 @@ div.ok { /* Info admin */ div.info { border-<?php print $left; ?>: solid 5px #87cfd2; - padding-top: 8px; - padding-left: 10px; - padding-right: 4px; - padding-bottom: 8px; - margin: 0.5em 0em 0.5em 0em; - background: #eff8fc; -} - -/* Warning message */ -div.warning { - border-<?php print $left; ?>: solid 5px #f2cf87; padding-top: 8px; padding-left: 10px; padding-right: 4px; padding-bottom: 8px; margin: 0.5em 0em 0.5em 0em; - background: #fcf8e3; + background: #eff8fc; +} + +/* Warning message */ +div.warning { + border-<?php print $left; ?>: solid 5px #f2cf87; + padding-top: 8px; + padding-left: 10px; + padding-right: 4px; + padding-bottom: 8px; + margin: 0.5em 0em 0.5em 0em; + background: #fcf8e3; } div.warning a, div.info a, div.error a { color: rgb(<?php echo $colortextlink; ?>); @@ -3999,7 +4091,7 @@ div.warning a, div.info a, div.error a { /* Error message */ div.error { - border-<?php print $left; ?>: solid 5px #f28787; + border-<?php print $left; ?>: solid 5px #f28787; padding-top: 8px; padding-left: 10px; padding-right: 4px; @@ -4030,13 +4122,13 @@ a.impayee:hover { font-weight: bold; color: #550000; } */ .framecontent { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } .framecontent iframe { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } @@ -4046,11 +4138,11 @@ a.impayee:hover { font-weight: bold; color: #550000; } */ .opened-dash-board-wrap { - margin-bottom: 25px; + margin-bottom: 25px; } div.boximport { - min-height: unset; + min-height: unset; } .product_line_stock_ok { color: #002200; } @@ -4070,11 +4162,11 @@ div.dolgraph div.legend table tbody tr { height: auto; } td.legendColorBox { padding: 2px 2px 2px 0 !important; } td.legendLabel { padding: 2px 2px 2px 0 !important; } td.legendLabel { - text-align: <?php echo $left; ?>; + text-align: <?php echo $left; ?>; } label.radioprivate { - white-space: nowrap; + white-space: nowrap; } .photo { @@ -4085,7 +4177,7 @@ label.radioprivate { margin-top: 2px; } div.divphotoref > a > .photowithmargin { /* Margin right for photo not inside a div.photoref frame only */ - margin-right: 15px; + margin-right: 15px; } .photowithborder { border: 1px solid #f0f0f0; @@ -4108,20 +4200,20 @@ div.divphotoref > a > .photowithmargin { /* Margin right for photo not inside a { content:url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/nographyet.svg', 1) ?>); display: inline-block; - opacity: 0.1; - background-repeat: no-repeat; + opacity: 0.1; + background-repeat: no-repeat; } .nographyettext { - opacity: 0.5; + opacity: 0.5; } div.titre { font-size: 14px; text-decoration: none; padding-top: 5px; - padding-bottom: 5px; - text-transform: uppercase; + padding-bottom: 5px; + text-transform: uppercase; /* text-shadow: 1px 1px 2px #FFFFFF; */ } div.titre { @@ -4146,14 +4238,14 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot .poweredbypublicpayment { float: right; top: 8px; - right: 8px; - position: absolute; - font-size: 0.8em; - color: #222; - opacity: 0.3; + right: 8px; + position: absolute; + font-size: 0.8em; + color: #222; + opacity: 0.3; } span.buttonpaymentsmall { - text-shadow: none; + text-shadow: none; } #dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } @@ -4166,13 +4258,13 @@ span.buttonpaymentsmall { #tablesubscribe { width: 100%; } div#card-element { - border: 1px solid #ccc; + border: 1px solid #ccc; } div#card-errors { color: #fa755a; - text-align: center; - padding-top: 3px; - max-width: 320px; + text-align: center; + padding-top: 3px; + max-width: 320px; } @@ -4224,7 +4316,7 @@ div#card-errors { .ui-dialog-titlebar { } .ui-dialog-content { - font-size: <?php print $fontsize; ?>px !important; + font-size: <?php print $fontsize; ?>px !important; } @@ -4234,8 +4326,8 @@ div#card-errors { /* .ui-dialog-content.ui-widget-content > object { - max-height: none; - width: auto; margin-left: auto; margin-right: auto; display: block; + max-height: none; + width: auto; margin-left: auto; margin-right: auto; display: block; } */ @@ -4245,16 +4337,16 @@ div#card-errors { /* ============================================================================== */ table.valid { - /* border-top: solid 1px #E6E6E6; */ - border-<?php print $left; ?>: solid 5px #f2cf87; - /* border-<?php print $right; ?>: solid 1px #444444; - border-bottom: solid 1px #555555; */ + /* border-top: solid 1px #E6E6E6; */ + border-<?php print $left; ?>: solid 5px #f2cf87; + /* border-<?php print $right; ?>: solid 1px #444444; + border-bottom: solid 1px #555555; */ padding-top: 8px; padding-left: 10px; padding-right: 4px; padding-bottom: 4px; margin: 0px 0px; - background: #fcf8e3; + background: #fcf8e3; } .validtitre { @@ -4268,7 +4360,7 @@ table.valid { /* For tooltip using dialog */ .ui-dialog.highlight.ui-widget.ui-widget-content.ui-front { - z-index: 3000; + z-index: 3000; } div.ui-tooltip { @@ -4300,7 +4392,7 @@ div.ui-tooltip.mytooltip { .ui-datepicker-calendar .ui-widget-header .ui-state-default, .ui-datepicker-calendar .ui-button, html .ui-datepicker-calendar .ui-button.ui-state-disabled:hover, html .ui-button.ui-state-disabled:active { - border: unset; + border: unset; } img.datecallink { padding-left: 2px !important; padding-right: 2px !important; } @@ -4320,13 +4412,13 @@ img.datecallink { padding-left: 2px !important; padding-right: 2px !important; } margin-bottom: 5px; } table.dp { - width: 180px; - background-color: #FFFFFF; - /*border-top: solid 2px #f4f4f4; - border-<?php print $left; ?>: solid 2px #f4f4f4; - border-<?php print $right; ?>: solid 1px #222222; - border-bottom: solid 1px #222222; */ - padding: 0px; + width: 180px; + background-color: #FFFFFF; + /*border-top: solid 2px #f4f4f4; + border-<?php print $left; ?>: solid 2px #f4f4f4; + border-<?php print $right; ?>: solid 1px #222222; + border-bottom: solid 1px #222222; */ + padding: 0px; border-spacing: 0px; border-collapse: collapse; } @@ -4372,14 +4464,14 @@ table.dp { /* Bouton X fermer */ .dpInvisibleButtons { - border-style:none; - background-color:transparent; - padding:0px; - font-size: 0.85em; - border-width:0px; - color: #eee; - vertical-align:middle; - cursor: pointer; + border-style:none; + background-color:transparent; + padding:0px; + font-size: 0.85em; + border-width:0px; + color: #eee; + vertical-align:middle; + cursor: pointer; } .datenowlink { @@ -4399,15 +4491,15 @@ table.dp { /* ============================================================================== */ div.visible { - display: block; + display: block; } div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { - display: none; + display: none; } tr.visible { - display: block; + display: block; } @@ -4416,10 +4508,10 @@ tr.visible { /* ============================================================================== */ .exampleapachesetup { - overflow-y: auto; - max-height: 100px; - font-size: 0.8em; - border: 1px solid #aaa; + overflow-y: auto; + max-height: 100px; + font-size: 0.8em; + border: 1px solid #aaa; } span[phptag] { @@ -4427,16 +4519,16 @@ span[phptag] { } .nobordertransp { - border: 0px; - background-color: transparent; - background-image: none; - color: #000 !important; - text-shadow: none; + border: 0px; + background-color: transparent; + background-image: none; + color: #000 !important; + text-shadow: none; } .bordertransp { - background-color: transparent; - background-image: none; - border: 1px solid #aaa; + background-color: transparent; + background-image: none; + border: 1px solid #aaa; font-weight: normal; color: #444 !important; } @@ -4444,7 +4536,7 @@ span[phptag] { border-bottom: 1px solid #ccc; background: #eee; display: inline-block; - padding: 4px 0 4px 0; + padding: 4px 0 4px 0; } .websitebar .buttonDelete, .websitebar .button { text-shadow: none; @@ -4453,11 +4545,11 @@ span[phptag] { { padding: 2px 4px 2px 4px !important; margin: 2px 4px 2px 4px !important; - line-height: normal; + line-height: normal; } .websitebar input.button.bordertransp, .websitebar input.buttonDelete.bordertransp { - color: #444 !important; - text-shadow: none; + color: #444 !important; + text-shadow: none; } .websiteselection { /* display: inline-block; */ @@ -4473,9 +4565,9 @@ span[phptag] { padding-bottom: 3px; */ } .websiteinputurl { - display: inline-block; - vertical-align: top; - line-height: 28px; + display: inline-block; + vertical-align: top; + line-height: 28px; } .websiteiframenoborder { border: 0px; @@ -4494,9 +4586,9 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im border: 0px; } .websitehelp { - vertical-align: middle; - float: right; - padding-top: 8px; + vertical-align: middle; + float: right; + padding-top: 8px; } .websiteselectionsection { border-left: 1px solid #bbb; @@ -4506,11 +4598,11 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im margin-right: 5px; } .websitebar input#previewpageurl { - line-height: 1em; + line-height: 1em; } #divbodywebsite section p { - margin: unset; + margin: unset; } @@ -4519,7 +4611,7 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im /* ============================================================================== */ .dayevent .tagtr:first-of-type { - height: 24px; + height: 24px; } .agendacell { height: 60px; } table.cal_month { border-spacing: 0px; } @@ -4577,28 +4669,28 @@ td.cal_other_month { .ui-autocomplete-loading { background: white url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/working.gif', 1) ?>) right center no-repeat; } .ui-autocomplete { - position:absolute; - width:auto; - font-size: 1.0em; - background-color:white; - border:1px solid #888; - margin:0px; + position:absolute; + width:auto; + font-size: 1.0em; + background-color:white; + border:1px solid #888; + margin:0px; /* padding:0px; This make combo crazy */ - } + } .ui-autocomplete ul { - list-style-type:none; - margin:0px; - padding:0px; - } + list-style-type:none; + margin:0px; + padding:0px; + } .ui-autocomplete ul li.selected { background-color: #D3E5EC;} .ui-autocomplete ul li { - list-style-type:none; - display:block; - margin:0; - padding:2px; - height:18px; - cursor:pointer; - } + list-style-type:none; + display:block; + margin:0; + padding:2px; + height:18px; + cursor:pointer; + } /* ============================================================================== */ @@ -4606,8 +4698,8 @@ td.cal_other_month { /* ============================================================================== */ td.gtaskname { - overflow: hidden; - text-overflow: ellipsis; + overflow: hidden; + text-overflow: ellipsis; } @@ -4783,29 +4875,29 @@ A.none, A.none:active, A.none:visited, A.none:hover { /* Style to overwrites JQuery styles */ .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { - border: 1px solid #888; - background: rgb(<?php echo $colorbacktitle1; ?>); - color: unset; + border: 1px solid #888; + background: rgb(<?php echo $colorbacktitle1; ?>); + color: unset; } .ui-menu .ui-menu-item a { - text-decoration:none; - display:block; - padding:.2em .4em; - line-height:1.5; - font-weight: normal; - font-family:<?php echo $fontlist; ?>; - font-size:1em; + text-decoration:none; + display:block; + padding:.2em .4em; + line-height:1.5; + font-weight: normal; + font-family:<?php echo $fontlist; ?>; + font-size:1em; } .ui-widget { - font-family:<?php echo $fontlist; ?>; + font-family:<?php echo $fontlist; ?>; } .ui-button { margin-left: -2px; <?php print (preg_match('/chrome/', $conf->browser->name) ? 'padding-top: 1px;' : ''); ?> } .ui-button-icon-only .ui-button-text { height: 8px; } .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: 2px 0px 6px 0px; } .ui-button-text { - line-height: 1em !important; + line-height: 1em !important; } .ui-autocomplete-input { margin: 0; padding: 4px; } @@ -4815,28 +4907,28 @@ A.none, A.none:active, A.none:visited, A.none:hover { /* ============================================================================== */ body.cke_show_borders { - margin: 5px !important; + margin: 5px !important; } .cke_dialog { - border: 1px #bbb solid ! important; + border: 1px #bbb solid ! important; } /*.cke_editor table, .cke_editor tr, .cke_editor td { - border: 0px solid #FF0000 !important; + border: 0px solid #FF0000 !important; } span.cke_skin_kama { padding: 0 !important; }*/ .cke_wrapper { padding: 4px !important; } a.cke_dialog_ui_button { - font-family: <?php print $fontlist ?> !important; + font-family: <?php print $fontlist ?> !important; background-image: url(<?php echo $img_button ?>) !important; background-position: bottom !important; - border: 1px solid #C0C0C0 !important; + border: 1px solid #C0C0C0 !important; -webkit-border-radius:0px 2px 0px 2px !important; border-radius:0px 2px 0px 2px !important; - -webkit-box-shadow: 3px 3px 4px #f4f4f4 !important; - box-shadow: 3px 3px 4px #f4f4f4 !important; + -webkit-box-shadow: 3px 3px 4px #f4f4f4 !important; + box-shadow: 3px 3px 4px #f4f4f4 !important; } .cke_dialog_ui_hbox_last { @@ -4850,8 +4942,8 @@ a.cke_dialog_ui_button } */ a.cke_dialog_ui_button_ok span { - text-shadow: none !important; - color: #333 !important; + text-shadow: none !important; + color: #333 !important; } @@ -4859,28 +4951,28 @@ a.cke_dialog_ui_button_ok span { /* ACE editor */ /* ============================================================================== */ .ace_editor { - border: 1px solid #ddd; + border: 1px solid #ddd; margin: 0; } .aceeditorstatusbar { - margin: 0; - padding: 0; - padding-<?php echo $left; ?>: 10px; - left: 0; - right: 0; - bottom: 0; - color: #666; - height: 28px; - line-height: 2.2em; + margin: 0; + padding: 0; + padding-<?php echo $left; ?>: 10px; + left: 0; + right: 0; + bottom: 0; + color: #666; + height: 28px; + line-height: 2.2em; } .ace_status-indicator { - color: gray; - position: relative; - right: 0; - border-left: 1px solid; + color: gray; + position: relative; + right: 0; + border-left: 1px solid; } pre#editfilecontentaceeditorid { - margin-top: 5px; + margin-top: 5px; } @@ -4889,7 +4981,7 @@ pre#editfilecontentaceeditorid { /* ============================================================================== */ .template-upload { - height: 72px !important; + height: 72px !important; } @@ -4910,32 +5002,32 @@ pre#editfilecontentaceeditorid { /* ============================================================================== */ #types .btn { - cursor: pointer; + cursor: pointer; } #types .btn-primary { - font-weight: bold; + font-weight: bold; } #types form { - padding: 20px; + padding: 20px; } #types label { - display:inline-block; - width:100px; - margin-right: 20px; - padding: 4px; - text-align: right; - vertical-align: top; + display:inline-block; + width:100px; + margin-right: 20px; + padding: 4px; + text-align: right; + vertical-align: top; } #types input.text, #types textarea { - width: 400px; + width: 400px; } #types textarea { - height: 100px; + height: 100px; } @@ -4947,55 +5039,55 @@ pre#editfilecontentaceeditorid { box-sizing:border-box; } #comment .comment { - border-radius:7px; - margin-bottom:10px; - overflow:hidden; + border-radius:7px; + margin-bottom:10px; + overflow:hidden; } #comment .comment-table { - display:table; - height:100%; + display:table; + height:100%; } #comment .comment-cell { - display:table-cell; + display:table-cell; } #comment .comment-info { - font-size:0.8em; - border-right:1px solid #dedede; - margin-right:10px; - width:160px; - text-align:center; - background:rgba(255,255,255,0.5); - vertical-align:middle; - padding:10px 2px; + font-size:0.8em; + border-right:1px solid #dedede; + margin-right:10px; + width:160px; + text-align:center; + background:rgba(255,255,255,0.5); + vertical-align:middle; + padding:10px 2px; } #comment .comment-info a { - color:inherit; + color:inherit; } #comment .comment-right { - vertical-align:top; + vertical-align:top; } #comment .comment-description { - padding:10px; - vertical-align:top; + padding:10px; + vertical-align:top; } #comment .comment-delete { - width: 100px; - text-align:center; - vertical-align:middle; + width: 100px; + text-align:center; + vertical-align:middle; } #comment .comment-delete:hover { - background:rgba(250,20,20,0.8); + background:rgba(250,20,20,0.8); } #comment .comment-edit { - width: 100px; - text-align:center; - vertical-align:middle; + width: 100px; + text-align:center; + vertical-align:middle; } #comment .comment-edit:hover { - background:rgba(0,184,148,0.8); + background:rgba(0,184,148,0.8); } #comment textarea { - width: 100%; + width: 100%; } @@ -5008,7 +5100,7 @@ div.scroll2 { } div#GanttChartDIVglisthead, div#GanttChartDIVgcharthead { - line-height: 2; + line-height: 2; } .gtaskname div, .gtaskname, .gstartdate div, .gstartdate, .genddate div, .genddate { @@ -5021,45 +5113,45 @@ div.gantt, .gtaskheading, .gmajorheading, .gminorheading, .gminorheadingwkend { color: #000 !important; } div.gTaskInfo { - background: #f0f0f0 !important; + background: #f0f0f0 !important; } .gtaskblue { background: rgb(108,152,185) !important; } .gtaskgreen { - background: rgb(160,173,58) !important; + background: rgb(160,173,58) !important; } td.gtaskname { - overflow: hidden; - text-overflow: ellipsis; + overflow: hidden; + text-overflow: ellipsis; } td.gminorheadingwkend { - color: #888 !important; + color: #888 !important; } td.gminorheading { - color: #666 !important; + color: #666 !important; } .glistlbl, .glistgrid { width: 582px !important; } .gtaskname div, .gtaskname { - min-width: 250px !important; - max-width: 250px !important; - width: 250px !important; + min-width: 250px !important; + max-width: 250px !important; + width: 250px !important; } .gpccomplete div, .gpccomplete { - min-width: 40px !important; - max-width: 40px !important; - width: 40px !important; + min-width: 40px !important; + max-width: 40px !important; + width: 40px !important; } td.gtaskheading.gstartdate, td.gtaskheading.genddate { - white-space: break-spaces; + white-space: break-spaces; } .gtasktableh tr:nth-child(2) td:nth-child(2), .gtasktableh tr:nth-child(2) td:nth-child(3), .gtasktableh tr:nth-child(2) td:nth-child(4), .gtasktableh tr:nth-child(2) td:nth-child(5), .gtasktableh tr:nth-child(2) td:nth-child(6), .gtasktableh tr:nth-child(2) td:nth-child(7) { - color: transparent !important; - border-left: none; - border-right: none; - border-top: none; + color: transparent !important; + border-left: none; + border-right: none; + border-top: none; } @@ -5084,25 +5176,25 @@ td.gtaskheading.gstartdate, td.gtaskheading.genddate { } div.filedirelem { - position: relative; - display: block; - text-decoration: none; + position: relative; + display: block; + text-decoration: none; } ul.filedirelem { - padding: 2px; - margin: 0 5px 5px 5px; + padding: 2px; + margin: 0 5px 5px 5px; } ul.filedirelem li { - list-style: none; - padding: 2px; - margin: 0 10px 20px 10px; - width: 160px; - height: 120px; - text-align: center; - display: block; - float: <?php print $left; ?>; - border: solid 1px #f4f4f4; + list-style: none; + padding: 2px; + margin: 0 10px 20px 10px; + width: 160px; + height: 120px; + text-align: center; + display: block; + float: <?php print $left; ?>; + border: solid 1px #f4f4f4; } ul.ecmjqft { @@ -5132,7 +5224,7 @@ ul.ecmjqft a:active { font-weight: bold !important; } ul.ecmjqft a:hover { - text-decoration: underline; + text-decoration: underline; } div.ecmjqft { @@ -5144,13 +5236,13 @@ div.ecmjqft { clear: both; } div#ecm-layout-west { - width: 380px; - vertical-align: top; + width: 380px; + vertical-align: top; } div#ecm-layout-center { - width: calc(100% - 390px); - vertical-align: top; - float: right; + width: calc(100% - 390px); + vertical-align: top; + float: right; } .ecmjqft LI.directory { font-weight:normal; background: url(<?php echo dol_buildpath($path.'/theme/common/treemenu/folder2.png', 1); ?>) left top no-repeat; } @@ -5180,14 +5272,14 @@ div#ecm-layout-center { font-weight: normal; } .jnotify-container .jnotify-notification-warning .jnotify-close, .jnotify-container .jnotify-notification-warning .jnotify-message { - color: #a28918 !important; + color: #a28918 !important; } /* use or not ? */ div.jnotify-background { opacity : 0.95 !important; - -webkit-box-shadow: 2px 2px 4px #888 !important; - box-shadow: 2px 2px 4px #888 !important; + -webkit-box-shadow: 2px 2px 4px #888 !important; + box-shadow: 2px 2px 4px #888 !important; } /* ============================================================================== */ @@ -5250,7 +5342,7 @@ table.dataTable tr.odd td.sorting_1, table.dataTable tr.even td.sorting_1 { .paginate_button { font-weight: normal !important; - text-decoration: none !important; + text-decoration: none !important; } .paging_full_numbers { height: inherit !important; @@ -5263,7 +5355,7 @@ table.dataTable tr.odd td.sorting_1, table.dataTable tr.even td.sorting_1 { border-radius: inherit !important; } .paging_full_numbers a.paginate_button_disabled:hover, .paging_full_numbers a.disabled:hover { - background-color: #FFF !important; + background-color: #FFF !important; } .paginate_button, .paginate_active { border: 1px solid #ddd !important; @@ -5299,7 +5391,7 @@ div.dataTables_length select { /* ============================================================================== */ span#select2-taskid-container[title^='--'] { - opacity: 0.3; + opacity: 0.3; } input.select2-input { @@ -5316,16 +5408,16 @@ input.select2-input { .blockvmenusearch .select2-container--default .select2-selection--single, .blockvmenubookmarks .select2-container--default .select2-selection--single { - background-color: unset; + background-color: unset; } .select2-container--default .select2-selection--single .select2-selection__rendered { - color: unset; + color: unset; } .select2-container .select2-choice { border-bottom: 1px solid #ccc; } .select2-container .select2-choice > .select2-chosen { - margin-right: 23px; + margin-right: 23px; } .select2-container .select2-choice .select2-arrow { border-radius: 0; @@ -5357,7 +5449,7 @@ input.select2-input { box-shadow: none !important; } .select2-container--open .select2-dropdown--above { - border-bottom: solid 1px rgba(0,0,0,.2); + border-bottom: solid 1px rgba(0,0,0,.2); } .select2-drop.select2-drop-above.select2-drop-active { border-top: 1px solid #ccc; @@ -5486,34 +5578,34 @@ a span.select2-chosen border-left: 1px solid #ddd; } .select2-container--default .select2-results>.select2-results__options{ - max-height: 400px; + max-height: 400px; } /* Special case for the select2 add widget */ #addbox .select2-container .select2-choice > .select2-chosen, #actionbookmark .select2-container .select2-choice > .select2-chosen { - text-align: <?php echo $left; ?>; - opacity: 0.3; + text-align: <?php echo $left; ?>; + opacity: 0.3; } .select2-container--default .select2-selection--single .select2-selection__placeholder { color: unset; opacity: 0.5; } span#select2-boxbookmark-container, span#select2-boxcombo-container { - text-align: <?php echo $left; ?>; - opacity: 0.5; + text-align: <?php echo $left; ?>; + opacity: 0.5; } .select2-container .select2-selection--single .select2-selection__rendered { padding-left: 6px; } /* Style used before the select2 js is executed on boxcombo */ #boxbookmark.boxcombo, #boxcombo.boxcombo { - text-align: left; - opacity: 0.3; - border-bottom: solid 1px rgba(0,0,0,.4) !important; - height: 26px; - line-height: 24px; - padding: 0 0 5px 5px; - vertical-align: top; + text-align: left; + opacity: 0.3; + border-bottom: solid 1px rgba(0,0,0,.4) !important; + height: 26px; + line-height: 24px; + padding: 0 0 5px 5px; + vertical-align: top; } /* To emulate select 2 style */ @@ -5567,7 +5659,7 @@ span#select2-boxbookmark-container, span#select2-boxcombo-container { border-radius: 5px !important; box-shadow: none; -webkit-box-shadow: none !important; - box-shadow: none !important; + box-shadow: none !important; } span.noborderoncategories a, li.noborderoncategories a { line-height: normal; @@ -5655,9 +5747,9 @@ span.noborderoncategories { } .multi-select-menuitem { - clear: both; - float: left; - padding-left: 5px + clear: both; + float: left; + padding-left: 5px } @@ -5666,51 +5758,51 @@ span.noborderoncategories { /* ============================================================================== */ ul.ulselectedfields { - z-index: 90; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ + z-index: 90; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ } dl.dropdown { - margin:0px; - padding:0px; + margin:0px; + padding:0px; margin-left: 2px; - margin-right: 2px; - vertical-align: middle; - display: inline-block; + margin-right: 2px; + vertical-align: middle; + display: inline-block; } .dropdown dd, .dropdown dt { - margin:0px; - padding:0px; + margin:0px; + padding:0px; } .dropdown ul { - margin: -1px 0 0 0; - text-align: <?php echo $left; ?>; + margin: -1px 0 0 0; + text-align: <?php echo $left; ?>; } .dropdown dd { - position:relative; + position:relative; } .dropdown dt a { - display:block; - overflow: hidden; - border:0; + display:block; + overflow: hidden; + border:0; } .dropdown dt a span, .multiSel span { - cursor:pointer; - display:inline-block; - padding: 0 3px 2px 0; + cursor:pointer; + display:inline-block; + padding: 0 3px 2px 0; } .dropdown span.value { - display:none; + display:none; } .dropdown dd ul { - background-color: #FFF; - box-shadow: 1px 1px 10px #aaa; - display:none; - <?php echo $right; ?>:0px; /* pop is align on right */ - padding: 0 0 0 0; - position:absolute; - top:2px; - list-style:none; - max-height: 264px; - overflow: auto; + background-color: #FFF; + box-shadow: 1px 1px 10px #aaa; + display:none; + <?php echo $right; ?>:0px; /* pop is align on right */ + padding: 0 0 0 0; + position:absolute; + top:2px; + list-style:none; + max-height: 264px; + overflow: auto; } .dropdown dd ul li { white-space: nowrap; @@ -5723,23 +5815,23 @@ dl.dropdown { background: #eee; } .dropdown dd ul li input[type="checkbox"] { - margin-<?php echo $right; ?>: 3px; + margin-<?php echo $right; ?>: 3px; } .dropdown dd ul li a, .dropdown dd ul li span { - padding: 3px; - display: block; + padding: 3px; + display: block; } .dropdown dd ul li span { color: #888; } .dropdown dd ul li a:hover { - background-color: #eee; + background-color: #eee; } dd.dropdowndd ul li { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; } @@ -5761,11 +5853,11 @@ dd.dropdowndd ul li { /* ============================================================================== */ .searchpage .tagtr .tagtd { - padding-bottom: 3px; + padding-bottom: 3px; } .searchpage .tagtr .tagtd .button { background: unset; - border: unset; + border: unset; } li.ui-li-divider .ui-link { @@ -5801,16 +5893,16 @@ a.ui-link, a.ui-link:hover, .ui-btn:hover, span.ui-btn-text:hover, span.ui-btn-i padding-left: 30px; } .ui-select .ui-btn-icon-right .ui-icon { - right: 8px; + right: 8px; } .ui-btn-icon-left > .ui-btn-inner > .ui-icon, .ui-btn-icon-right > .ui-btn-inner > .ui-icon { - margin-top: -10px; + margin-top: -10px; } select { - /* display: inline-block; */ /* We can't set this. This disable ability to make */ - overflow:hidden; - white-space: nowrap; /* Enabling this make behaviour strange when selecting the empty value if this empty value is '' instead of '&nbsp;' */ - text-overflow: ellipsis; + /* display: inline-block; */ /* We can't set this. This disable ability to make */ + overflow:hidden; + white-space: nowrap; /* Enabling this make behaviour strange when selecting the empty value if this empty value is '' instead of '&nbsp;' */ + text-overflow: ellipsis; } .fiche .ui-controlgroup { margin: 0px; @@ -5893,39 +5985,39 @@ ul.ulmenu { /* Style for first level menu with jmobile */ .ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { - padding: 1em 15px; - display: block; + padding: 1em 15px; + display: block; } .ui-btn-up-c { font-weight: normal; } .ui-focus, .ui-btn:focus { - -webkit-box-shadow: none; - box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; } .ui-bar-b { - /*border: 1px solid #888;*/ - border: none; - background: none; - text-shadow: none; - color: rgb(<?php print $colortexttitlenotab; ?>) !important; + /*border: 1px solid #888;*/ + border: none; + background: none; + text-shadow: none; + color: rgb(<?php print $colortexttitlenotab; ?>) !important; } .ui-bar-b, .lilevel0 { - background-repeat: repeat-x; - border: none; - background: none; - text-shadow: none; - color: rgb(<?php print $colortexttitlenotab; ?>) !important; + background-repeat: repeat-x; + border: none; + background: none; + text-shadow: none; + color: rgb(<?php print $colortexttitlenotab; ?>) !important; } .alilevel0 { font-weight: normal !important; } .ui-li.ui-last-child, .ui-li.ui-field-contain.ui-last-child { - border-bottom-width: 0px !important; + border-bottom-width: 0px !important; } .alilevel0 { - color: rgb(<?php echo $colortexttitle; ?>) !important; + color: rgb(<?php echo $colortexttitle; ?>) !important; } .ulmenu { box-shadow: none !important; @@ -5968,11 +6060,11 @@ border-top-right-radius: 6px; }*/ .alilevel1 { - color: rgb(<?php print $colortexttitlenotab; ?>) !important; + color: rgb(<?php print $colortexttitlenotab; ?>) !important; } .lilevel1 { - border-top: 2px solid #444; - background: #fff ! important; + border-top: 2px solid #444; + background: #fff ! important; } .lilevel1 div div a { font-weight: bold !important; @@ -5980,22 +6072,22 @@ border-top-right-radius: 6px; .lilevel2 { padding-left: 22px; - background: #fff ! important; + background: #fff ! important; } .lilevel3 { padding-left: 44px; - background: #fff ! important; + background: #fff ! important; } .lilevel4 { padding-left: 66px; - background: #fff ! important; + background: #fff ! important; } .lilevel5 { padding-left: 88px; - background: #fff ! important; + background: #fff ! important; } @@ -6032,14 +6124,14 @@ border-top-right-radius: 6px; color: #6d3f6d; } .menu li.menu_choix1 { - padding-top: 6px; - padding-right: 10px; - padding-bottom: 2px; + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; } .menu li.menu_choix2 { - padding-top: 6px; - padding-right: 10px; - padding-bottom: 2px; + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; } @media only screen and (max-width: 767px) { @@ -6048,13 +6140,13 @@ border-top-right-radius: 6px; background-position-y: 6px; padding-left: 40px; } - .menu li.menu_choix1, .menu li.menu_choix2 { - padding-left: 4px; - padding-right: 0; - } - .liste_articles { - margin-right: 0 !important; - } + .menu li.menu_choix1, .menu li.menu_choix2 { + padding-left: 4px; + padding-right: 0; + } + .liste_articles { + margin-right: 0 !important; + } } @@ -6077,7 +6169,7 @@ border-top-right-radius: 6px; .ticketpublicarea { margin-left: 15%; - margin-right: 15%; + margin-right: 15%; } .publicnewticketform { /* margin-top: 25px !important; */ @@ -6115,11 +6207,11 @@ border-top-right-radius: 6px; } @media only screen and (min-width: 1170px) { #cd-timeline { - margin-bottom: 3em; + margin-bottom: 3em; } #cd-timeline::before { - left: 50%; - margin-left: -2px; + left: 50%; + margin-left: -2px; } } @@ -6140,13 +6232,13 @@ border-top-right-radius: 6px; } @media only screen and (min-width: 1170px) { .cd-timeline-block { - margin: 4em 0; + margin: 4em 0; } .cd-timeline-block:first-child { - margin-top: 0; + margin-top: 0; } .cd-timeline-block:last-child { - margin-bottom: 0; + margin-bottom: 0; } } @@ -6181,80 +6273,80 @@ border-top-right-radius: 6px; } @media only screen and (min-width: 1170px) { .cd-timeline-img { - width: 60px; - height: 60px; - left: 50%; - margin-left: -30px; - /* Force Hardware Acceleration in WebKit */ - -webkit-transform: translateZ(0); - -webkit-backface-visibility: hidden; + width: 60px; + height: 60px; + left: 50%; + margin-left: -30px; + /* Force Hardware Acceleration in WebKit */ + -webkit-transform: translateZ(0); + -webkit-backface-visibility: hidden; } .cssanimations .cd-timeline-img.is-hidden { - visibility: hidden; + visibility: hidden; } .cssanimations .cd-timeline-img.bounce-in { - visibility: visible; - -webkit-animation: cd-bounce-1 0.6s; - -moz-animation: cd-bounce-1 0.6s; - animation: cd-bounce-1 0.6s; + visibility: visible; + -webkit-animation: cd-bounce-1 0.6s; + -moz-animation: cd-bounce-1 0.6s; + animation: cd-bounce-1 0.6s; } } @-webkit-keyframes cd-bounce-1 { 0% { - opacity: 0; - -webkit-transform: scale(0.5); + opacity: 0; + -webkit-transform: scale(0.5); } 60% { - opacity: 1; - -webkit-transform: scale(1.2); + opacity: 1; + -webkit-transform: scale(1.2); } 100% { - -webkit-transform: scale(1); + -webkit-transform: scale(1); } } @-moz-keyframes cd-bounce-1 { 0% { - opacity: 0; - -moz-transform: scale(0.5); + opacity: 0; + -moz-transform: scale(0.5); } 60% { - opacity: 1; - -moz-transform: scale(1.2); + opacity: 1; + -moz-transform: scale(1.2); } 100% { - -moz-transform: scale(1); + -moz-transform: scale(1); } } @keyframes cd-bounce-1 { 0% { - opacity: 0; - -webkit-transform: scale(0.5); - -moz-transform: scale(0.5); - -ms-transform: scale(0.5); - -o-transform: scale(0.5); - transform: scale(0.5); + opacity: 0; + -webkit-transform: scale(0.5); + -moz-transform: scale(0.5); + -ms-transform: scale(0.5); + -o-transform: scale(0.5); + transform: scale(0.5); } 60% { - opacity: 1; - -webkit-transform: scale(1.2); - -moz-transform: scale(1.2); - -ms-transform: scale(1.2); - -o-transform: scale(1.2); - transform: scale(1.2); + opacity: 1; + -webkit-transform: scale(1.2); + -moz-transform: scale(1.2); + -ms-transform: scale(1.2); + -o-transform: scale(1.2); + transform: scale(1.2); } 100% { - -webkit-transform: scale(1); - -moz-transform: scale(1); - -ms-transform: scale(1); - -o-transform: scale(1); - transform: scale(1); + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } .cd-timeline-content { @@ -6306,58 +6398,58 @@ border-top-right-radius: 6px; } @media only screen and (min-width: 768px) { .cd-timeline-content h2 { - font-size: 20px; - font-size: 1.25rem; + font-size: 20px; + font-size: 1.25rem; } .cd-timeline-content { - font-size: 16px; - font-size: 1rem; + font-size: 16px; + font-size: 1rem; } .cd-timeline-content .cd-read-more, .cd-timeline-content .cd-date { - font-size: 14px; - font-size: 0.875rem; + font-size: 14px; + font-size: 0.875rem; } } @media only screen and (min-width: 1170px) { .cd-timeline-content { - margin-left: 0; - padding: 1.6em; - width: 43%; + margin-left: 0; + padding: 1.6em; + width: 43%; } .cd-timeline-content::before { - top: 24px; - left: 100%; - border-color: transparent; - border-left-color: white; + top: 24px; + left: 100%; + border-color: transparent; + border-left-color: white; } .cd-timeline-content .cd-read-more { - float: left; + float: left; } .cd-timeline-content .cd-date { - position: absolute; - width: 55%; - left: 115%; - top: 6px; - font-size: 16px; - font-size: 1rem; + position: absolute; + width: 55%; + left: 115%; + top: 6px; + font-size: 16px; + font-size: 1rem; } .cd-timeline-block:nth-child(even) .cd-timeline-content { - float: right; + float: right; } .cd-timeline-block:nth-child(even) .cd-timeline-content::before { - top: 24px; - left: auto; - right: 100%; - border-color: transparent; - border-right-color: white; + top: 24px; + left: auto; + right: 100%; + border-color: transparent; + border-right-color: white; } .cd-timeline-block:nth-child(even) .cd-timeline-content .cd-read-more { - float: right; + float: right; } .cd-timeline-block:nth-child(even) .cd-timeline-content .cd-date { - left: auto; - right: 115%; - text-align: right; + left: auto; + right: 115%; + text-align: right; } } @@ -6368,10 +6460,10 @@ border-top-right-radius: 6px; /* ============================================================================== */ span.phpdebugbar-tooltip.phpdebugbar-tooltip-extra-wide, span.phpdebugbar-tooltip.phpdebugbar-tooltip-wide { - width: 250px !important; + width: 250px !important; } .phpdebugbar-indicator span.phpdebugbar-tooltip { - opacity: .95 !important; + opacity: .95 !important; } a.phpdebugbar-tab.phpdebugbar-active { background-image: unset !important; @@ -6403,10 +6495,10 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before /* ============================================================================== */ .dol-xaxis-vertical .flot-x-axis .flot-tick-label.tickLabel { - text-orientation: sideways; - font-weight: 400; - writing-mode: vertical-rl; - white-space: nowrap; + text-orientation: sideways; + font-weight: 400; + writing-mode: vertical-rl; + white-space: nowrap; } @@ -6427,17 +6519,17 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before width: <?php print dol_size(350, 'width'); ?>px; } - div.tabBar { - padding-left: 8px; - padding-right: 8px; - -webkit-border-radius: 0; - border-radius: 0px; - border-right: none; - border-left: none; - } + div.tabBar { + padding-left: 8px; + padding-right: 8px; + -webkit-border-radius: 0; + border-radius: 0px; + border-right: none; + border-left: none; + } .box-flex-container { - margin: 0 0 0 -8px !important; + margin: 0 0 0 -8px !important; } } @@ -6463,26 +6555,26 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before @media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 7, 0) + 300; ?>px) { div.tmenucenter { - max-width: <?php echo round($fontsize * 4); ?>px; /* size of viewport */ - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - color: #<?php echo $colortextbackhmenu; ?>; + max-width: <?php echo round($fontsize * 4); ?>px; /* size of viewport */ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #<?php echo $colortextbackhmenu; ?>; } .mainmenuaspan { - font-size: 0.9em; - /* font-weight: 300; */ - } - .topmenuimage { - background-size: 24px auto; - margin-top: 0px; + font-size: 0.9em; + /* font-weight: 300; */ + } + .topmenuimage { + background-size: 24px auto; + margin-top: 0px; + } + li.tmenu, li.tmenusel { + min-width: 34px; + } + div.mainmenu { + min-width: auto; } - li.tmenu, li.tmenusel { - min-width: 34px; - } - div.mainmenu { - min-width: auto; - } div.tmenuleft { display: none; } @@ -6495,17 +6587,17 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before } div.tmenucenter { - max-width: <?php echo round($fontsize * 2); ?>px; /* size of viewport */ - text-overflow: clip; + max-width: <?php echo round($fontsize * 2); ?>px; /* size of viewport */ + text-overflow: clip; } .mainmenuaspan { - font-size: 10px; - padding-left: 0; - padding-right: 0; - } - .topmenuimage { - background-size: 20px auto; - margin-top: 2px; + font-size: 10px; + padding-left: 0; + padding-right: 0; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px; } } /* rule to reduce top menu - 3rd reduction */ @@ -6518,20 +6610,20 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before /* padding-<?php echo $right; ?>: 78px; */ <?php } ?> } - li.tmenu, li.tmenusel { - min-width: 30px; - } + li.tmenu, li.tmenusel { + min-width: 30px; + } div.tmenucenter { - text-overflow: clip; + text-overflow: clip; } - .topmenuimage { - background-size: 20px auto; - margin-top: 2px !important; + .topmenuimage { + background-size: 20px auto; + margin-top: 2px !important; } div.mainmenu { - min-width: 20px; - } + min-width: 20px; + } #tooltip { position: absolute; @@ -6544,22 +6636,22 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before div.divphotoref { padding-right: 5px; } - img.photoref, div.photoref { - border: 1px solid rgba(0, 0, 0, 0.2); - -webkit-box-shadow: none; - box-shadow: none; - padding: 4px; - object-fit: contain; - } + img.photoref, div.photoref { + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-box-shadow: none; + box-shadow: none; + padding: 4px; + object-fit: contain; + } .titlefield { width: auto !important; /* We want to ignore the 30%, try to use more if you can */ } .tableforfield>tr>td:first-child, .tableforfield>tbody>tr>td:first-child, div.tableforfield div.tagtr>div.tagtd:first-of-type { - /* max-width: 100px; */ /* but no more than 100px */ + /* max-width: 100px; */ /* but no more than 100px */ } .tableforfield>tr>td:nth-child(2), .tableforfield>tbody>tr>td:nth-child(2), div.tableforfield div.tagtr>div.tagtd:nth-child(2) { - word-break: break-word; + word-break: break-word; } table.table-fiche-title .col-title div.titre{ @@ -6578,9 +6670,13 @@ include dol_buildpath($path.'/theme/'.$theme.'/info-box.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/progress.inc.php', 0); include dol_buildpath($path.'/theme/eldy/timeline.inc.php', 0); // actually md use same style as eldy theme -if (!empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; +if (!empty($conf->global->THEME_CUSTOM_CSS)) { + print $conf->global->THEME_CUSTOM_CSS; +} -if (is_object($db)) $db->close(); +if (is_object($db)) { + $db->close(); +} ?> /* This must be at end */ diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index e74c206ad20..23b34119cf0 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -29,12 +29,9 @@ global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; $theme_bordercolor = array(235, 235, 224); $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(191, 75, 57), array(80, 166, 90), array(140, 140, 220), array(190, 120, 120), array(190, 190, 100), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150)); -if (!defined('ISLOADEDBYSTEELSHEET')) // File is run after an include of a php page, not by the style sheet, if the constant is not defined. -{ - if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) // user is loaded by dolgraph.class.php - { - if ($conf->global->MAIN_OPTIMIZEFORCOLORBLIND == 'flashy') - { +if (!defined('ISLOADEDBYSTEELSHEET')) { // File is run after an include of a php page, not by the style sheet, if the constant is not defined. + if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) { // user is loaded by dolgraph.class.php + if ($conf->global->MAIN_OPTIMIZEFORCOLORBLIND == 'flashy') { $theme_datacolor = array(array(157, 56, 191), array(0, 147, 183), array(250, 190, 30), array(221, 75, 57), array(0, 166, 90), array(140, 140, 220), array(190, 120, 120), array(190, 190, 100), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150)); } else { // for now we use the same configuration for all types of color blind From 29467e983a14745fdcab5d23eeff8f40b73029d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 13:50:54 +0100 Subject: [PATCH 138/173] Code comment --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7daade7ae2a..951c4297f0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ Following changes may create regressions for some external modules, but were nec * API /setup/shipment_methods has been replaced with API /setup/shipping_methods * Field "tva" renamed into "total_tva" in llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency * Field "total" renamed into "total_ttc" in llx_propal, llx_supplier_proposal for better field name consistency +* If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT) +* If your database is MySql or MariaDB, you need at least version 5.1 ***** ChangeLog for 13.0.1 compared to 13.0.0 ***** From fa7cd70052fec8165f3b7a3261c30a730df49597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 14:25:17 +0100 Subject: [PATCH 139/173] code syntax product directory --- htdocs/product/admin/dynamic_prices.php | 23 +- htdocs/product/admin/price_rules.php | 5 +- htdocs/product/admin/product.php | 267 ++--- htdocs/product/admin/product_extrafields.php | 23 +- .../product/admin/product_lot_extrafields.php | 17 +- .../admin/product_supplier_extrafields.php | 23 +- htdocs/product/admin/product_tools.php | 134 ++- htdocs/product/admin/stock_extrafields.php | 17 +- htdocs/product/agenda.php | 76 +- htdocs/product/ajax/products.php | 51 +- .../product/actions_card_product.class.php | 130 +-- .../canvas/product/tpl/card_create.tpl.php | 7 +- .../canvas/product/tpl/card_edit.tpl.php | 3 +- .../canvas/product/tpl/card_view.tpl.php | 7 +- .../service/actions_card_service.class.php | 92 +- .../canvas/service/tpl/card_create.tpl.php | 7 +- .../canvas/service/tpl/card_edit.tpl.php | 3 +- .../canvas/service/tpl/card_view.tpl.php | 7 +- htdocs/product/card.php | 948 +++++++-------- htdocs/product/class/api_products.class.php | 63 +- .../product/class/html.formproduct.class.php | 220 ++-- htdocs/product/class/product.class.php | 495 ++++---- htdocs/product/class/productbatch.class.php | 106 +- .../class/productcustomerprice.class.php | 124 +- .../class/propalmergepdfproduct.class.php | 141 +-- htdocs/product/composition/card.php | 184 +-- htdocs/product/document.php | 102 +- .../class/price_expression.class.php | 73 +- .../class/price_global_variable.class.php | 69 +- .../price_global_variable_updater.class.php | 104 +- .../class/price_parser.class.php | 104 +- htdocs/product/dynamic_price/editor.php | 48 +- htdocs/product/fournisseurs.php | 368 +++--- htdocs/product/index.php | 208 ++-- .../product/inventory/ajax/ajax.inventory.php | 17 +- htdocs/product/inventory/card.php | 166 +-- .../inventory/class/inventory.class.php | 66 +- htdocs/product/inventory/inventory.php | 164 +-- htdocs/product/inventory/list.php | 313 +++-- htdocs/product/list.php | 1036 ++++++++++------- htdocs/product/note.php | 37 +- htdocs/product/popuprop.php | 68 +- htdocs/product/price.php | 570 ++++----- htdocs/product/reassort.php | 276 +++-- htdocs/product/reassortlot.php | 232 ++-- htdocs/product/stats/bom.php | 69 +- htdocs/product/stats/card.php | 146 ++- htdocs/product/stats/commande.php | 110 +- htdocs/product/stats/commande_fournisseur.php | 90 +- htdocs/product/stats/contrat.php | 84 +- htdocs/product/stats/facture.php | 117 +- htdocs/product/stats/facture_fournisseur.php | 105 +- htdocs/product/stats/mo.php | 76 +- htdocs/product/stats/propal.php | 100 +- htdocs/product/stats/supplier_proposal.php | 100 +- htdocs/product/stock/card.php | 174 +-- .../stock/class/api_stockmovements.class.php | 136 ++- .../stock/class/api_warehouses.class.php | 27 +- htdocs/product/stock/class/entrepot.class.php | 160 ++- .../stock/class/mouvementstock.class.php | 80 +- .../product/stock/class/productlot.class.php | 52 +- .../class/productstockentrepot.class.php | 143 ++- htdocs/product/stock/fiche-valo.php | 16 +- htdocs/product/stock/index.php | 29 +- htdocs/product/stock/info.php | 4 +- .../product/stock/lib/replenishment.lib.php | 41 +- htdocs/product/stock/list.php | 353 +++--- htdocs/product/stock/massstockmove.php | 118 +- htdocs/product/stock/movement_card.php | 515 ++++---- htdocs/product/stock/movement_list.php | 543 +++++---- htdocs/product/stock/product.php | 309 ++--- htdocs/product/stock/productlot_card.php | 38 +- htdocs/product/stock/productlot_document.php | 47 +- htdocs/product/stock/productlot_list.php | 302 +++-- htdocs/product/stock/replenish.php | 196 ++-- htdocs/product/stock/replenishorders.php | 92 +- htdocs/product/stock/stockatdate.php | 95 +- .../product/stock/tpl/stockcorrection.tpl.php | 18 +- .../product/stock/tpl/stocktransfer.tpl.php | 23 +- htdocs/product/stock/valo.php | 48 +- htdocs/product/traduction.php | 91 +- 81 files changed, 6616 insertions(+), 5225 deletions(-) diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 4d2307d17ac..7a92d9a651b 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -37,7 +37,9 @@ $cancel = GETPOST('cancel', 'alpha'); $selection = GETPOST('selection', 'int'); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} //Objects $price_globals = new PriceGlobalVariable($db); @@ -157,8 +159,7 @@ print '<span class="opacitymedium">'.$langs->trans("DynamicPriceDesc").'</span>< print '<br>'; //Global variables table -if ($action != 'create_updater' && $action != 'edit_updater') -{ +if ($action != 'create_updater' && $action != 'edit_updater') { print load_fiche_titre($langs->trans("GlobalVariables"), '', ''); print '<table summary="listofattributes" class="noborder centpercent">'; @@ -171,7 +172,7 @@ if ($action != 'create_updater' && $action != 'edit_updater') $arrayglobalvars = $price_globals->listGlobalVariables(); if (!empty($arrayglobalvars)) { - foreach ($arrayglobalvars as $i=>$entry) { + foreach ($arrayglobalvars as $i => $entry) { print '<tr class="oddeven">'; print '<td>'.$entry->code.'</td>'; print '<td>'.$entry->description.'</td>'; @@ -187,8 +188,7 @@ if ($action != 'create_updater' && $action != 'edit_updater') } print '</table>'; - if (empty($action)) - { + if (empty($action)) { //Action Buttons print '<div class="tabsAction">'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_variable">'.$langs->trans("AddVariable").'</a>'; @@ -234,8 +234,7 @@ if ($action == 'create_variable' || $action == 'edit_variable') { } // Updaters table -if ($action != 'create_variable' && $action != 'edit_variable') -{ +if ($action != 'create_variable' && $action != 'edit_variable') { print load_fiche_titre($langs->trans("GlobalVariableUpdaters"), '', ''); print '<table summary="listofattributes" class="noborder centpercent">'; @@ -250,9 +249,8 @@ if ($action != 'create_variable' && $action != 'edit_variable') print '</tr>'; $arraypriceupdaters = $price_updaters->listUpdaters(); - if (!empty($arraypriceupdaters)) - { - foreach ($arraypriceupdaters as $i=>$entry) { + if (!empty($arraypriceupdaters)) { + foreach ($arraypriceupdaters as $i => $entry) { $code = ""; if ($entry->fk_variable > 0) { $res = $price_globals->fetch($entry->fk_variable); @@ -278,8 +276,7 @@ if ($action != 'create_variable' && $action != 'edit_variable') } print '</table>'; - if (empty($action)) - { + if (empty($action)) { //Action Buttons print '<div class="tabsAction">'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_updater&token='.newToken().'">'.$langs->trans("AddUpdater").'</a>'; diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index a38245d32c7..fada766f065 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -29,8 +29,9 @@ $langs->loadLangs(array('admin', 'products')); $action = GETPOST('action', 'aZ09'); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) +if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { accessforbidden(); +} $error = 0; @@ -158,7 +159,7 @@ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { <td></td> <td style="text-align: center"><input type="text" style="text-align: right" name="var_min_percent[1]" size="5" value="<?php echo price(isset($rules[1]) ? $rules[1]->var_min_percent : 0, 2) ?>"> <?php echo $langs->trans('PercentDiscountOver', $langs->trans('SellingPrice').' 1') ?></td> </tr> - <?php for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++): ?> + <?php for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) : ?> <tr> <td class="fieldrequired" style="text-align: center"><?php echo $langs->trans('SellingPrice').' '.$i; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index f268003e1bb..0aa39a53bb3 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -40,8 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $langs->loadLangs(array("admin", "products")); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) +if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -56,9 +57,13 @@ $select_pricing_rules = array( 'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer ); $keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; -if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || !empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice +if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || !empty($conf->global->$keyforparam)) { + $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice +} $keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility').'+'.$langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; +if ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->$keyforparam)) { + $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility').'+'.$langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; +} // Clean param if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) { @@ -75,10 +80,8 @@ $error = 0; $nomessageinsetmoduleoptions = 1; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'setcodeproduct') -{ - if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'setcodeproduct') { + if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -86,33 +89,30 @@ if ($action == 'setcodeproduct') } } -if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) -{ +if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } -if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) -{ +if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) { $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", GETPOST('value_PRODUIT_MULTIPRICES_LIMIT'), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } -if ($action == 'other') -{ +if ($action == 'other') { $princingrules = GETPOST('princingrule', 'alpha'); - foreach ($select_pricing_rules as $rule => $label) // Loop on each possible mode - { - if ($rule == $princingrules) // We are on selected rule, we enable it - { - if ($princingrules == 'PRODUCT_PRICE_UNIQ') // For this case, we disable entries manually - { + foreach ($select_pricing_rules as $rule => $label) { // Loop on each possible mode + if ($rule == $princingrules) { // We are on selected rule, we enable it + if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'PRODUCT_PRICE_UNIQ', 1, 'chaine', 0, '', $conf->entity); } else { $multirule = explode('&', $princingrules); - foreach ($multirule as $rulesselected) - { + foreach ($multirule as $rulesselected) { $res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity); } } @@ -151,8 +151,7 @@ if ($action == 'other') if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); - if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it - { + if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') { // if the field does not exist, we create it $sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN desc_fourn text"; $resql_new = $db->query($sql_new); } @@ -163,16 +162,14 @@ if ($action == 'other') if ($value) { $sql_test = "SELECT count(packaging) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); - if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it - { + if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') { // if the field does not exist, we create it $sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN packaging double(24,8) DEFAULT 1"; $resql_new = $db->query($sql_new); } } } -if ($action == 'specimen') // For products -{ +if ($action == 'specimen') { // For products $modele = GETPOST('module', 'alpha'); $product = new Product($db); @@ -181,25 +178,21 @@ if ($action == 'specimen') // For products // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($product, $langs, '') > 0) - { + if ($module->write_file($product, $langs, '') > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=product&file=SPECIMEN.pdf"); return; } else { @@ -213,25 +206,22 @@ if ($action == 'specimen') // For products } // Activate a model -if ($action == 'set') -{ +if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') -{ +if ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->PRODUCT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PRODUCT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->PRODUCT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'PRODUCT_ADDON_PDF', $conf->entity); + } } } // Set default model -if ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +if ($action == 'setdoc') { + if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->PRODUCT_ADDON_PDF = $value; @@ -239,20 +229,23 @@ if ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } -if ($action == 'set') -{ +if ($action == 'set') { $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe', 'alpha')); $value = GETPOST('value'); - if (GETPOST('value', 'alpha')) $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity); - else $res = dolibarr_del_const($db, $const, $conf->entity); - if (!($res > 0)) $error++; + if (GETPOST('value', 'alpha')) { + $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_del_const($db, $const, $conf->entity); + } + if (!($res > 0)) { + $error++; + } } //if ($action == 'other') @@ -262,10 +255,8 @@ if ($action == 'set') // if (! $res > 0) $error++; //} -if ($action) -{ - if (!$error) - { +if ($action) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("SetupNotError"), null, 'errors'); @@ -280,12 +271,10 @@ $formbarcode = new FormBarCode($db); $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) -{ +if (empty($conf->product->enabled)) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) -{ +} elseif (empty($conf->service->enabled)) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } @@ -315,50 +304,53 @@ print ' <td class="center" width="80">'.$langs->trans("Status").'</td>'; print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>'; print "</tr>\n"; -foreach ($dirproduct as $dirroot) -{ +foreach ($dirproduct as $dirroot) { $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { + if (is_resource($handle)) { // Loop on each module find in opened directory - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') - { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } $modCodeProduct = new $file; // Show modules according to features level - if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($modCodeProduct->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($modCodeProduct->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } print '<tr class="oddeven">'."\n"; print '<td width="140">'.$modCodeProduct->name.'</td>'."\n"; print '<td>'.$modCodeProduct->info($langs).'</td>'."\n"; print '<td class="nowrap">'.$modCodeProduct->getExample($langs).'</td>'."\n"; - if (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) - { + if (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) { print '<td class="center">'."\n"; print img_picto($langs->trans("Activated"), 'switch_on'); print "</td>\n"; } else { $disabled = false; - if (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); + if (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true) { + } print '<td class="center">'; - if (!$disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.$file.'">'; + if (!$disabled) { + print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.$file.'">'; + } print img_picto($langs->trans("Disabled"), 'switch_off'); - if (!$disabled) print '</a>'; + if (!$disabled) { + print '</a>'; + } print '</td>'; } @@ -382,12 +374,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -412,29 +402,21 @@ print "</tr>\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/product".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -442,21 +424,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print '<tr class="oddeven"><td width="100">'; print (empty($module->name) ? $name : $module->name); print "</td><td>\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print '</td>'; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '<td class="center">'."\n"; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -470,8 +457,7 @@ foreach ($dirmodels as $reldir) // Defaut print '<td class="center">'; - if ($conf->global->PRODUCT_ADDON_PDF == $name) - { + if ($conf->global->PRODUCT_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; @@ -481,8 +467,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; @@ -496,8 +481,7 @@ foreach ($dirmodels as $reldir) // Preview print '<td class="center">'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>'; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -568,26 +552,32 @@ print '</tr>'; // Rule for price print '<tr class="oddeven">'; -if (empty($conf->multicompany->enabled)) -{ +if (empty($conf->multicompany->enabled)) { print '<td>'.$langs->trans("PricingRule").'</td>'; } else { print '<td>'.$form->textwithpicto($langs->trans("PricingRule"), $langs->trans("SamePriceAlsoForSharedCompanies"), 1).'</td>'; } print '<td class="right">'; $current_rule = 'PRODUCT_PRICE_UNIQ'; -if (!empty($conf->global->PRODUIT_MULTIPRICES)) $current_rule = 'PRODUIT_MULTIPRICES'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; +if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $current_rule = 'PRODUIT_MULTIPRICES'; +} +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; +} +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + $current_rule = 'PRODUIT_CUSTOMER_PRICES'; +} +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; +} print $form->selectarray("princingrule", $select_pricing_rules, $current_rule, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1); print '</td>'; print '</tr>'; // multiprix nombre de prix a proposer -if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) -{ +if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print '<tr class="oddeven">'; print '<td>'.$langs->trans("MultiPricesNumPrices").'</td>'; print '<td class="right"><input size="3" type="text" class="flat" name="value_PRODUIT_MULTIPRICES_LIMIT" value="'.$conf->global->PRODUIT_MULTIPRICES_LIMIT.'"></td>'; @@ -606,8 +596,7 @@ print '</tr>'; print '<tr class="oddeven">'; print '<td>'.$form->textwithpicto($langs->trans("UseSearchToSelectProduct"), $langs->trans('UseSearchToSelectProductTooltip'), 1).'</td>'; -if (empty($conf->use_javascript_ajax)) -{ +if (empty($conf->use_javascript_ajax)) { print '<td class="nowrap right">'; print $langs->trans("NotAvailableWhenAjaxDisabled"); print '</td>'; @@ -624,8 +613,7 @@ if (empty($conf->use_javascript_ajax)) } print '</tr>'; -if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) -{ +if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { print '<tr class="oddeven">'; print '<td>'.$langs->trans("NumberOfProductShowInSelect").'</td>'; print '<td class="right"><input size="3" type="text" class="flat" name="value_PRODUIT_LIMIT_SIZE" value="'.$conf->global->PRODUIT_LIMIT_SIZE.'"></td>'; @@ -685,8 +673,7 @@ print '</tr>'; */ // View product description in thirdparty language -if (!empty($conf->global->MAIN_MULTILANGS)) -{ +if (!empty($conf->global->MAIN_MULTILANGS)) { print '<tr class="oddeven">'; print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>'; print '<td class="right">'; @@ -695,8 +682,7 @@ if (!empty($conf->global->MAIN_MULTILANGS)) print '</tr>'; } -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)) { print '<tr class="oddeven">'; print '<td>'.$langs->trans("UseProductFournDesc").'</td>'; print '<td class="right">'; @@ -713,8 +699,7 @@ if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUP } -if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) -{ +if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature $dir = DOL_DOCUMENT_ROOT."/product/canvas/"; @@ -723,17 +708,13 @@ if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) print '<td class="right">'.$langs->trans("Value").'</td>'."\n"; print '</tr>'."\n"; - if (is_dir($dir)) - { + if (is_dir($dir)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (file_exists($dir.$file.'/product.'.$file.'.class.php')) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (file_exists($dir.$file.'/product.'.$file.'.class.php')) { $classfile = $dir.$file.'/product.'.$file.'.class.php'; $classname = 'Product'.ucfirst($file); @@ -742,8 +723,7 @@ if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) $module = $object->module; - if ($conf->$module->enabled) - { + if ($conf->$module->enabled) { print '<tr class="oddeven"><td>'; print $object->description; @@ -752,8 +732,7 @@ if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) $const = "PRODUCT_SPECIAL_".strtoupper($file); - if ($conf->global->$const) - { + if ($conf->global->$const) { print img_picto($langs->trans("Active"), 'tick'); print '</td><td class="right">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;spe='.urlencode($file).'&amp;value=0">'.$langs->trans("Disable").'</a>'; diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index d82d175a9a7..0962d1ddf44 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -38,13 +38,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'product'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -61,12 +65,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) -{ +if (empty($conf->product->enabled)) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) -{ +} elseif (empty($conf->service->enabled)) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } @@ -90,8 +92,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -104,8 +105,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -117,8 +117,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/product/admin/product_lot_extrafields.php b/htdocs/product/admin/product_lot_extrafields.php index e89e5741cce..91e19ee1fa7 100644 --- a/htdocs/product/admin/product_lot_extrafields.php +++ b/htdocs/product/admin/product_lot_extrafields.php @@ -38,13 +38,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'product_lot'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -81,8 +85,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -95,8 +98,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -108,8 +110,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/product/admin/product_supplier_extrafields.php b/htdocs/product/admin/product_supplier_extrafields.php index 54d56ad9dd5..8c3a10a4b74 100644 --- a/htdocs/product/admin/product_supplier_extrafields.php +++ b/htdocs/product/admin/product_supplier_extrafields.php @@ -39,13 +39,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'product_fournisseur_price'; //Must be the $element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -62,12 +66,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) -{ +if (empty($conf->product->enabled)) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) -{ +} elseif (empty($conf->service->enabled)) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } @@ -91,8 +93,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "</div>"; @@ -105,8 +106,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '<br><div id="newattrib"></div>'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -118,8 +118,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 3bf85bdff4f..674e90f3614 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -35,7 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $langs->loadLangs(array('admin', 'products')); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $oldvatrate = GETPOST('oldvatrate', 'alpha'); @@ -48,19 +50,16 @@ $newvatrate = GETPOST('newvatrate', 'alpha'); * Actions */ -if ($action == 'convert') -{ +if ($action == 'convert') { $error = 0; - if ($oldvatrate == $newvatrate) - { + if ($oldvatrate == $newvatrate) { $langs->load("errors"); setEventMessages($langs->trans("ErrorNewValueCantMatchOldValue"), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $country_id = $mysoc->country_id; // TODO Allow to choose country into form $nbrecordsmodified = 0; @@ -69,62 +68,65 @@ if ($action == 'convert') // Clean vat code old $vat_src_code_old = ''; - if (preg_match('/\((.*)\)/', $oldvatrate, $reg)) - { + if (preg_match('/\((.*)\)/', $oldvatrate, $reg)) { $vat_src_code_old = $reg[1]; $oldvatrateclean = preg_replace('/\s*\(.*\)/', '', $oldvatrate); // Remove code into vatrate. - } else $oldvatrateclean = $oldvatrate; + } else { + $oldvatrateclean = $oldvatrate; + } // Clean vat code new $vat_src_code_new = ''; - if (preg_match('/\((.*)\)/', $newvatrate, $reg)) - { + if (preg_match('/\((.*)\)/', $newvatrate, $reg)) { $vat_src_code_new = $reg[1]; $newvatrateclean = preg_replace('/\s*\(.*\)/', '', $newvatrate); // Remove code into vatrate. - } else $newvatrateclean = $newvatrate; + } else { + $newvatrateclean = $newvatrate; + } // If country to edit is my country, so we change customer prices - if ($country_id == $mysoc->country_id) - { + if ($country_id == $mysoc->country_id) { $sql = 'SELECT rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; $sql .= " AND tva_tx = '".$db->escape($oldvatrateclean)."'"; - if ($vat_src_code_old) $sql .= " AND default_vat_code = '".$db->escape($vat_src_code_old)."'"; - else " AND default_vat_code = IS NULL"; + if ($vat_src_code_old) { + $sql .= " AND default_vat_code = '".$db->escape($vat_src_code_old)."'"; + } else { + " AND default_vat_code = IS NULL"; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $objectstatic = new Product($db); // Object init must be into loop to avoid to get value of previous step $ret = $objectstatic->fetch($obj->rowid); - if ($ret > 0) - { + if ($ret > 0) { $ret = 0; $retm = 0; $updatelevel1 = false; // Update multiprice $listofmulti = array_reverse($objectstatic->multiprices, true); // To finish with level 1 - foreach ($listofmulti as $level => $multiprices) - { + foreach ($listofmulti as $level => $multiprices) { $price_base_type = $objectstatic->multiprices_base_type[$level]; // Get price_base_type of product/service to keep the same for update - if (empty($price_base_type)) continue; // Discard not defined price levels + if (empty($price_base_type)) { + continue; // Discard not defined price levels + } - if ($price_base_type == 'TTC') - { + if ($price_base_type == 'TTC') { $newprice = price2num($objectstatic->multiprices_ttc[$level], 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) $newminprice = $objectstatic->multiprices_min_ttc[$level]; } else { $newprice = price2num($objectstatic->multiprices[$level], 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) $newminprice = $objectstatic->multiprices_min[$level]; } - if ($newminprice > $newprice) $newminprice = $newprice; + if ($newminprice > $newprice) { + $newminprice = $newprice; + } $newvat = str_replace('*', '', $newvatrate); $localtaxes_type = getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc); @@ -134,45 +136,51 @@ if ($action == 'convert') //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n"; $retm = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode); - if ($retm < 0) - { + if ($retm < 0) { $error++; break; } - if ($newlevel == 1) $updatelevel1 = true; + if ($newlevel == 1) { + $updatelevel1 = true; + } } // Update single price $price_base_type = $objectstatic->price_base_type; // Get price_base_type of product/service to keep the same for update - if ($price_base_type == 'TTC') - { + if ($price_base_type == 'TTC') { $newprice = price2num($objectstatic->price_ttc, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) $newminprice = $objectstatic->price_min_ttc; } else { $newprice = price2num($objectstatic->price, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) $newminprice = $objectstatic->price_min; } - if ($newminprice > $newprice) $newminprice = $newprice; + if ($newminprice > $newprice) { + $newminprice = $newprice; + } $newvat = str_replace('*', '', $newvatrate); $localtaxes_type = getLocalTaxesFromRate($newvat, 0, $mysoc, $mysoc); $newnpr = $objectstatic->recuperableonly; $newdefaultvatcode = $vat_src_code_new; $newlevel = 0; - if (!empty($price_base_type) && !$updatelevel1) - { + if (!empty($price_base_type) && !$updatelevel1) { //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n"; $ret = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode); } - if ($ret < 0 || $retm < 0) $error++; - else $nbrecordsmodified++; + if ($ret < 0 || $retm < 0) { + $error++; + } else { + $nbrecordsmodified++; + } } unset($objectstatic); $i++; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } $fourn = new Fournisseur($db); @@ -182,24 +190,24 @@ if ($action == 'convert') $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'societe as s'; $sql .= ' WHERE pfp.fk_soc = s.rowid AND pfp.entity IN ('.getEntity('product').')'; $sql .= " AND tva_tx = '".$db->escape($oldvatrate)."'"; - if ($vat_src_code_old) $sql .= " AND default_vat_code = '".$db->escape($vat_src_code_old)."'"; - else " AND default_vat_code = IS NULL"; + if ($vat_src_code_old) { + $sql .= " AND default_vat_code = '".$db->escape($vat_src_code_old)."'"; + } else { + " AND default_vat_code = IS NULL"; + } $sql .= " AND s.fk_pays = ".((int) $country_id); //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $objectstatic2 = new ProductFournisseur($db); // Object init must be into loop to avoid to get value of previous step $ret = $objectstatic2->fetch_product_fournisseur_price($obj->rowid); - if ($ret > 0) - { + if ($ret > 0) { $ret = 0; $retm = 0; $updatelevel1 = false; $price_base_type = 'HT'; @@ -226,34 +234,39 @@ if ($action == 'convert') $newsupplierreputation = $objectstatic2->supplier_reputation; $newlevel = 0; - if (!empty($price_base_type) && !$updatelevel1) - { + if (!empty($price_base_type) && !$updatelevel1) { //print "$objectstatic2->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n"; $fourn->id = $obj->fk_soc; $ret = $objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode); } - if ($ret < 0 || $retm < 0) $error++; - else $nbrecordsmodified++; + if ($ret < 0 || $retm < 0) { + $error++; + } else { + $nbrecordsmodified++; + } } unset($objectstatic2); $i++; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); } // Output result - if (!$error) - { - if ($nbrecordsmodified > 0) setEventMessages($langs->trans("RecordsModified", $nbrecordsmodified), null, 'mesgs'); - else setEventMessages($langs->trans("NoRecordFound"), null, 'warnings'); + if (!$error) { + if ($nbrecordsmodified > 0) { + setEventMessages($langs->trans("RecordsModified", $nbrecordsmodified), null, 'mesgs'); + } else { + setEventMessages($langs->trans("NoRecordFound"), null, 'warnings'); + } } else { setEventMessages($langs->trans("Error"), null, 'errors'); } @@ -274,8 +287,7 @@ print load_fiche_titre($title, '', 'title_setup'); print $langs->trans("ProductVatMassChangeDesc").'<br><br>'; -if (empty($mysoc->country_code)) -{ +if (empty($mysoc->country_code)) { $langs->load("errors"); $warnpicto = img_error($langs->trans("WarningMandatorySetupNotComplete")); print '<br><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a>'; diff --git a/htdocs/product/admin/stock_extrafields.php b/htdocs/product/admin/stock_extrafields.php index 9b5a0f23f07..3f860564b48 100644 --- a/htdocs/product/admin/stock_extrafields.php +++ b/htdocs/product/admin/stock_extrafields.php @@ -37,13 +37,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'entrepot'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -76,8 +80,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>'; print "</div>"; @@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "<br>"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -103,8 +105,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 8a7ddf385d9..bf25675865f 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -36,10 +36,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; // Load translation files required by the page $langs->load("companies"); -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -48,19 +49,27 @@ $search_agenda_label = GETPOST('search_agenda_label'); // Security check $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -if ($user->socid) $id = $user->socid; +if ($user->socid) { + $id = $user->socid; +} $result = restrictedArea($user, 'produit|service', $id, 'product&product'); $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); @@ -72,20 +81,19 @@ $hookmanager->initHooks(array('agendathirdparty')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // 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 $actioncode = ''; $search_agenda_label = ''; } @@ -101,8 +109,7 @@ $contactstatic = new Contact($db); $form = new Form($db); -if ($id > 0 || $ref) -{ +if ($id > 0 || $ref) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -113,12 +120,18 @@ if ($id > 0 || $ref) $result = $object->fetch($id, $ref); $title = $langs->trans("Agenda"); - if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $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"); + } $type = $langs->trans('Product'); - if ($object->isService()) $type = $langs->trans('Service'); + if ($object->isService()) { + $type = $langs->trans('Service'); + } $head = product_prepare_head($object); @@ -130,7 +143,9 @@ if ($id > 0 || $ref) $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -154,10 +169,11 @@ if ($id > 0 || $ref) $out = ''; $permok = $user->rights->agenda->myactions->create; - if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) - { + if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; - if (get_class($objproduct) == 'Product') $out .= '&amp;prodid='.$objproduct->id.'&origin=product&originid='.$id; + if (get_class($objproduct) == 'Product') { + $out .= '&amp;prodid='.$objproduct->id.'&origin=product&originid='.$id; + } $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); @@ -170,19 +186,21 @@ if ($id > 0 || $ref) $morehtmlcenter = ''; - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { $linktocreatetimeBtnStatus = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); $morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus); } - 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 '<br>'; $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } print_barre_liste($langs->trans("ActionsOnProduct"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 198d49defaf..9dacb4e547d 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -23,13 +23,27 @@ * \brief File to return Ajax response on product 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 (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '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'); +} +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} require '../../main.inc.php'; @@ -58,8 +72,7 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); dol_syslog(join(',', $_GET)); // print_r($_GET); -if (!empty($action) && $action == 'fetch' && !empty($id)) -{ +if (!empty($action) && $action == 'fetch' && !empty($id)) { // action='fetch' is used to get product information on a product. So when action='fetch', id must be the product id. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -68,8 +81,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) $object = new Product($db); $ret = $object->fetch($id); - if ($ret > 0) - { + if ($ret > 0) { $outref = $object->ref; $outlabel = $object->label; $outlabel_trans =''; @@ -82,7 +94,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) $found = false; $price_level = 1; - if ($socid > 0 ) { + if ($socid > 0) { $thirdpartytemp = new Societe($db); $thirdpartytemp->fetch($socid); @@ -107,8 +119,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) } // Price by qty - if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) // If we need a particular price related to qty - { + if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { // If we need a particular price related to qty $sql = "SELECT price, unitprice, quantity, remise_percent"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty "; $sql .= " WHERE rowid=".$price_by_qty_rowid.""; @@ -129,8 +140,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) } // Multiprice - if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) // If we need a particular price level (from 1 to 6) - { + if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { // If we need a particular price level (from 1 to 6) $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; $sql .= " WHERE fk_product = '".$id."'"; @@ -203,8 +213,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) top_httphead(); - if (empty($htmlname)) - { + if (empty($htmlname)) { print json_encode(array()); return; } @@ -214,8 +223,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) $idprod = (!empty($match[0]) ? $match[0] : ''); - if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) - { + if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); return; } @@ -233,6 +241,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) $db->close(); - if ($outjson) + if ($outjson) { print json_encode($arrayresult); + } } diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index e7e3c7ea4b3..55a8977a4bd 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -80,8 +80,10 @@ class ActionsCardProduct global $conf, $langs, $user, $mysoc, $canvas; global $form, $formproduct; - $tmpobject = new Product($this->db); - if (!empty($id) || !empty($ref)) $tmpobject->fetch($id, $ref); + $tmpobject = new Product($this->db); + if (!empty($id) || !empty($ref)) { + $tmpobject->fetch($id, $ref); + } $this->object = $tmpobject; //parent::assign_values($action); @@ -113,8 +115,7 @@ class ActionsCardProduct // Note $this->tpl['note'] = nl2br($this->note); - if ($action == 'create') - { + if ($action == 'create') { // Price $this->tpl['price'] = $this->price; $this->tpl['price_min'] = $this->price_min; @@ -124,8 +125,7 @@ class ActionsCardProduct $this->tpl['tva_tx'] = $form->load_tva("tva_tx", -1, $mysoc, ''); } - if ($action == 'view') - { + if ($action == 'view') { $head = product_prepare_head($this->object); $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'ref', '', 1, 'ref'); @@ -152,19 +152,16 @@ class ActionsCardProduct $this->tpl['note'] = $this->object->note; $this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte; - if ($action == 'create') - { + if ($action == 'create') { // Title $this->tpl['title'] = $langs->trans("NewProduct"); } - if ($action == 'edit') - { + if ($action == 'edit') { $this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Product').' : '.$this->object->ref; } - if ($action == 'create' || $action == 'edit') - { + if ($action == 'create' || $action == 'edit') { // Status $statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); $this->tpl['status'] = $form->selectarray('statut', $statutarray, $this->object->status); @@ -196,12 +193,10 @@ class ActionsCardProduct $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2); } - if ($action == 'view') - { + if ($action == 'view') { // Photo $this->tpl['nblines'] = 4; - if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) - { + if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) { $this->tpl['photos'] = $this->object->show_photos('product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80); } @@ -209,34 +204,29 @@ class ActionsCardProduct $this->tpl['finished'] = $this->object->getLibFinished(); // Weight - if ($this->object->weight != '') - { + if ($this->object->weight != '') { $this->tpl['weight'] = $this->object->weight." ".measuringUnitString(0, "weight", $this->object->weight_units); } // Length - if ($this->object->length != '') - { + if ($this->object->length != '') { $this->tpl['length'] = $this->object->length." ".measuringUnitString(0, "size", $this->object->length_units); } // Surface - if ($this->object->surface != '') - { + if ($this->object->surface != '') { $this->tpl['surface'] = $this->object->surface." ".measuringUnitString(0, "surface", $this->object->surface_units); } // Volume - if ($this->object->volume != '') - { + if ($this->object->volume != '') { $this->tpl['volume'] = $this->object->volume." ".measuringUnitString(0, "volume", $this->object->volume_units); } $this->tpl['fiche_end'] = dol_get_fiche_end(); } - if ($action == 'list') - { + if ($action == 'list') { $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } @@ -260,13 +250,11 @@ class ActionsCardProduct $sql .= " ORDER BY rang ASC"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $fieldlist = array(); $obj = $this->db->fetch_object($resql); @@ -315,10 +303,8 @@ class ActionsCardProduct // Clean parameters $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); - foreach ($this->field_list as $field) - { - if ($field['enabled']) - { + foreach ($this->field_list as $field) { + if ($field['enabled']) { $fieldname = "s".$field['alias']; $$fieldname = GETPOST($fieldname); } @@ -330,10 +316,8 @@ class ActionsCardProduct $sql .= 'p.rowid, p.price_base_type, p.fk_product_type, p.seuil_stock_alerte, p.entity'; // Fields not requiered - foreach ($this->field_list as $field) - { - if ($field['enabled']) - { + foreach ($this->field_list as $field) { + if ($field['enabled']) { $sql .= ", ".$field['name']." as ".$field['alias']; } } @@ -341,37 +325,34 @@ class ActionsCardProduct $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= " WHERE p.entity IN (".getEntity('product').")"; - if ($sall) - { + if ($sall) { $clause = ''; $sql .= " AND ("; - foreach ($this->field_list as $field) - { - if ($field['enabled']) - { + foreach ($this->field_list as $field) { + if ($field['enabled']) { $sql .= $clause." ".$field['name']." LIKE '%".$this->db->escape($sall)."%'"; - if ($clause == '') $clause = ' OR'; + if ($clause == '') { + $clause = ' OR'; + } } } $sql .= ")"; } // Search fields - foreach ($this->field_list as $field) - { - if ($field['enabled']) - { + foreach ($this->field_list as $field) { + if ($field['enabled']) { $fieldname = "s".$field['alias']; - if (${$fieldname}) $sql .= " AND ".$field['name']." LIKE '%".$this->db->escape(${$fieldname})."%'"; + if (${$fieldname}) { + $sql .= " AND ".$field['name']." LIKE '%".$this->db->escape(${$fieldname})."%'"; + } } } - if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) - { + if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql .= " AND p.tosell = ".$this->db->escape($_GET["tosell"]); } - if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) - { + if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) { $sql .= " AND p.canvas = '".$this->db->escape($_GET["canvas"])."'"; } $sql .= $this->db->order($sortfield, $sortorder); @@ -379,42 +360,45 @@ class ActionsCardProduct //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $datas = array(); $obj = $this->db->fetch_object($resql); $datas["id"] = $obj->rowid; - foreach ($this->field_list as $field) - { - if ($field['enabled']) - { + foreach ($this->field_list as $field) { + if ($field['enabled']) { $alias = $field['alias']; - if ($alias == 'ref') - { + if ($alias == 'ref') { $this->id = $obj->rowid; $this->ref = $obj->$alias; $this->type = $obj->fk_product_type; $this->entity = $obj->entity; $datas[$alias] = $this->getNomUrl(1, '', 24); - } elseif ($alias == 'stock') - { + } elseif ($alias == 'stock') { $this->load_stock(); - if ($this->stock_reel < $obj->seuil_stock_alerte) $datas[$alias] = $this->stock_reel.' '.img_warning($langs->trans("StockTooLow")); - else $datas[$alias] = $this->stock_reel; - } elseif ($alias == 'label') $datas[$alias] = dol_trunc($obj->$alias, 40); - elseif (preg_match('/price/i', $alias)) $datas[$alias] = price($obj->$alias); - elseif ($alias == 'datem') $datas[$alias] = dol_print_date($this->db->jdate($obj->$alias), 'day'); - elseif ($alias == 'status') $datas[$alias] = $this->LibStatut($obj->$alias, 5); - else $datas[$alias] = $obj->$alias; + if ($this->stock_reel < $obj->seuil_stock_alerte) { + $datas[$alias] = $this->stock_reel.' '.img_warning($langs->trans("StockTooLow")); + } else { + $datas[$alias] = $this->stock_reel; + } + } elseif ($alias == 'label') { + $datas[$alias] = dol_trunc($obj->$alias, 40); + } elseif (preg_match('/price/i', $alias)) { + $datas[$alias] = price($obj->$alias); + } elseif ($alias == 'datem') { + $datas[$alias] = dol_print_date($this->db->jdate($obj->$alias), 'day'); + } elseif ($alias == 'status') { + $datas[$alias] = $this->LibStatut($obj->$alias, 5); + } else { + $datas[$alias] = $obj->$alias; + } } } diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index 042734f8fd3..b862eddefc5 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -16,8 +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; } @@ -53,7 +52,9 @@ print dol_get_fiche_head(''); <tr> <td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td> <td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>"> -<?php if ($refalreadyexists == 1) echo $langs->trans("RefAlreadyExists"); ?> +<?php if ($refalreadyexists == 1) { + echo $langs->trans("RefAlreadyExists"); +} ?> </td></tr> <tr> diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 512ab13416b..21f2edefc2d 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -16,8 +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; } diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 2158be2b24d..a5f793e246d 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -16,8 +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; } @@ -37,7 +36,9 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_value $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; -if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; +} dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); ?> diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 48f924bbb46..b27bbf5771c 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -79,14 +79,15 @@ class ActionsCardService global $conf, $langs, $user, $mysoc, $canvas; global $form, $formproduct; - $tmpobject = new Product($this->db); - if (!empty($id) || !empty($ref)) $tmpobject->fetch($id, $ref); + $tmpobject = new Product($this->db); + if (!empty($id) || !empty($ref)) { + $tmpobject->fetch($id, $ref); + } $this->object = $tmpobject; //parent::assign_values($action); - foreach ($this->object as $key => $value) - { + foreach ($this->object as $key => $value) { $this->tpl[$key] = $value; } @@ -113,8 +114,7 @@ class ActionsCardService // Note $this->tpl['note'] = nl2br($this->note); - if ($action == 'create') - { + if ($action == 'create') { // Price $this->tpl['price'] = $this->price; $this->tpl['price_min'] = $this->price_min; @@ -124,8 +124,7 @@ class ActionsCardService $this->tpl['tva_tx'] = $form->load_tva("tva_tx", -1, $mysoc, ''); } - if ($action == 'view') - { + if ($action == 'view') { $head = product_prepare_head($this->object); $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'ref', '', 1, 'ref'); @@ -155,19 +154,16 @@ class ActionsCardService // Duration $this->tpl['duration_value'] = $this->object->duration_value; - if ($action == 'create') - { + if ($action == 'create') { // Title $this->tpl['title'] = $langs->trans("NewService"); } - if ($action == 'edit') - { + if ($action == 'edit') { $this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->object->ref; } - if ($action == 'create' || $action == 'edit') - { + if ($action == 'create' || $action == 'edit') { // Status $statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); $this->tpl['status'] = $form->selectarray('statut', $statutarray, $this->object->status); @@ -192,21 +188,17 @@ class ActionsCardService $this->tpl['duration_unit'] = $duration_unit; } - if ($action == 'view') - { + if ($action == 'view') { // Photo $this->tpl['nblines'] = 4; - if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) - { + if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) { $this->tpl['photos'] = $this->object->show_photos('product', $conf->service->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80); } // Duration - if ($this->object->duration_value > 1) - { + if ($this->object->duration_value > 1) { $dur = array("h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ($this->object->duration_value > 0) - { + } elseif ($this->object->duration_value > 0) { $dur = array("h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } $this->tpl['duration_unit'] = $langs->trans($dur[$this->object->duration_unit]); @@ -214,8 +206,7 @@ class ActionsCardService $this->tpl['fiche_end'] = dol_get_fiche_end(); } - if ($action == 'list') - { + if ($action == 'list') { $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } @@ -239,13 +230,11 @@ class ActionsCardService $sql .= " ORDER BY rang ASC"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $fieldlist = array(); $obj = $this->db->fetch_object($resql); @@ -294,40 +283,43 @@ class ActionsCardService $sql .= ' p.duration, p.tosell as statut, p.seuil_stock_alerte'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; // We'll need this table joined to the select in order to filter by categ - if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; - if (GETPOST("fourn_id", 'int') > 0) - { + if ($search_categ) { + $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + } + if (GETPOST("fourn_id", 'int') > 0) { $fourn_id = GETPOST("fourn_id", 'int'); $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; - if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ - if ($sall) - { + if ($search_categ) { + $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ + } + if ($sall) { $sql .= " AND (p.ref LIKE '%".$this->db->escape($sall)."%' OR p.label LIKE '%".$this->db->escape($sall)."%' OR p.description LIKE '%".$this->db->escape($sall)."%' OR p.note LIKE '%".$this->db->escape($sall)."%')"; } - if ($sref) $sql .= " AND p.ref LIKE '%".$sref."%'"; - if ($search_barcode) $sql .= " AND p.barcode LIKE '%".$search_barcode."%'"; - if ($snom) $sql .= " AND p.label LIKE '%".$this->db->escape($snom)."%'"; - if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) - { + if ($sref) { + $sql .= " AND p.ref LIKE '%".$sref."%'"; + } + if ($search_barcode) { + $sql .= " AND p.barcode LIKE '%".$search_barcode."%'"; + } + if ($snom) { + $sql .= " AND p.label LIKE '%".$this->db->escape($snom)."%'"; + } + if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql .= " AND p.tosell = ".$this->db->escape($_GET["tosell"]); } - if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) - { + if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) { $sql .= " AND p.canvas = '".$this->db->escape($_GET["canvas"])."'"; } - if ($catid) - { + if ($catid) { $sql .= " AND cp.fk_categorie = ".$catid; } - if ($fourn_id > 0) - { + if ($fourn_id > 0) { $sql .= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id; } // Insert categ filter - if ($search_categ) - { + if ($search_categ) { $sql .= " AND cp.fk_categorie = ".$this->db->escape($search_categ); } $sql .= $this->db->order($sortfield, $sortorder); @@ -336,13 +328,11 @@ class ActionsCardService $this->list_datas = array(); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $datas = array(); $obj = $this->db->fetch_object($resql); diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 13fceff4e22..ce3c4f5cc58 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -16,8 +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; } @@ -50,7 +49,9 @@ print dol_get_fiche_head(''); <tr> <td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td> <td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>"> -<?php if ($refalreadyexists == 1) echo $langs->trans("RefAlreadyExists"); ?> +<?php if ($refalreadyexists == 1) { + echo $langs->trans("RefAlreadyExists"); +} ?> </td></tr> <tr> diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index 8e4613f21b0..4906b0dcf2c 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -16,8 +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; } diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index d342d102af0..c816a36ae34 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -16,8 +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; } @@ -37,7 +36,9 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_value $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; -if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; +} dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); ?> diff --git a/htdocs/product/card.php b/htdocs/product/card.php index abf99c1b921..29649693e79 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -53,18 +53,36 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.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->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +} +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +} +if (!empty($conf->commande->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +} +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.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'; +} // Load translation files required by the page $langs->loadLangs(array('products', 'other')); -if (!empty($conf->stock->enabled)) $langs->load("stocks"); -if (!empty($conf->facture->enabled)) $langs->load("bills"); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->stock->enabled)) { + $langs->load("stocks"); +} +if (!empty($conf->facture->enabled)) { + $langs->load("bills"); +} +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} $mesg = ''; $error = 0; $errors = array(); @@ -91,7 +109,9 @@ $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); // by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml'; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $object = new Product($db); $object->type = $type; // so test later to fill $usercancxxx is correct @@ -100,17 +120,21 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled)) { + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + } elseif (!empty($conf->service->enabled)) { + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + } - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs - { - if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs + if (!empty($conf->product->enabled)) { + $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + } else { + $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + } } } @@ -119,8 +143,7 @@ $modulepart = 'product'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('product', 'card', $canvas); @@ -140,23 +163,27 @@ $hookmanager->initHooks(array('productcard', 'globalcard')); * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); $createbarcode = empty($conf->barcode->enabled) ? 0 : 1; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode = 0; +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) { + $createbarcode = 0; +} $parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Type - if ($action == 'setfk_product_type' && $usercancreate) - { + if ($action == 'setfk_product_type' && $usercancreate) { $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -170,29 +197,31 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Barcode type - if ($action == 'setfk_barcode_type' && $createbarcode) - { + if ($action == 'setfk_barcode_type' && $createbarcode) { $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } // Barcode value - if ($action == 'setbarcode' && $createbarcode) - { + if ($action == 'setbarcode' && $createbarcode) { $result = $object->check_barcode(GETPOST('barcode'), GETPOST('barcode_type_code')); - if ($result >= 0) - { + if ($result >= 0) { $result = $object->setValueFrom('barcode', GETPOST('barcode'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { $langs->load("errors"); - if ($result == -1) $errors[] = 'ErrorBadBarCodeSyntax'; - elseif ($result == -2) $errors[] = 'ErrorBarCodeRequired'; - elseif ($result == -3) $errors[] = 'ErrorBarCodeAlreadyUsed'; - else $errors[] = 'FailedToValidateBarCode'; + if ($result == -1) { + $errors[] = 'ErrorBadBarCodeSyntax'; + } elseif ($result == -2) { + $errors[] = 'ErrorBarCodeRequired'; + } elseif ($result == -3) { + $errors[] = 'ErrorBarCodeAlreadyUsed'; + } else { + $errors[] = 'FailedToValidateBarCode'; + } $error++; setEventMessages($errors, null, 'errors'); @@ -200,43 +229,42 @@ if (empty($reshook)) } // Add a product or service - if ($action == 'add' && $usercancreate) - { + if ($action == 'add' && $usercancreate) { $error = 0; - if (!GETPOST('label', $label_security_check)) - { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Label')), null, 'errors'); - $action = "create"; - $error++; - } - if (empty($ref)) - { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Ref')), null, 'errors'); - $action = "create"; - $error++; - } - if (!empty($duration_value) && empty($duration_unit)) - { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Unit')), null, 'errors'); - $action = "create"; - $error++; - } + if (!GETPOST('label', $label_security_check)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Label')), null, 'errors'); + $action = "create"; + $error++; + } + if (empty($ref)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Ref')), null, 'errors'); + $action = "create"; + $error++; + } + if (!empty($duration_value) && empty($duration_unit)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Unit')), null, 'errors'); + $action = "create"; + $error++; + } - if (!$error) - { + if (!$error) { $units = GETPOST('units', 'int'); - $object->ref = $ref; - $object->label = GETPOST('label', $label_security_check); - $object->price_base_type = GETPOST('price_base_type', 'aZ09'); + $object->ref = $ref; + $object->label = GETPOST('label', $label_security_check); + $object->price_base_type = GETPOST('price_base_type', 'aZ09'); - if ($object->price_base_type == 'TTC') + if ($object->price_base_type == 'TTC') { $object->price_ttc = GETPOST('price'); - else $object->price = GETPOST('price'); - if ($object->price_base_type == 'TTC') + } else { + $object->price = GETPOST('price'); + } + if ($object->price_base_type == 'TTC') { $object->price_min_ttc = GETPOST('price_min'); - else $object->price_min = GETPOST('price_min'); + } else { + $object->price_min = GETPOST('price_min'); + } $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' @@ -247,8 +275,7 @@ if (empty($reshook)) $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes $reg = array(); - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. $vatratecode = $reg[1]; // Get record from code @@ -258,8 +285,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; $sql .= " AND t.code = '".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -289,8 +315,7 @@ if (empty($reshook)) $stdobject->element = 'product'; $stdobject->barcode_type = GETPOST('fk_barcode_type'); $result = $stdobject->fetch_barcode(); - if ($result < 0) - { + if ($result < 0) { $error++; $mesg = 'Failed to get bar code type information '; setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); @@ -345,20 +370,41 @@ if (empty($reshook)) $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); - if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } - if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } - if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } - if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } - if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } - if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } + if ($accountancy_code_sell_intra <= 0) { + $object->accountancy_code_sell_intra = ''; + } else { + $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; + } + if ($accountancy_code_sell_export <= 0) { + $object->accountancy_code_sell_export = ''; + } else { + $object->accountancy_code_sell_export = $accountancy_code_sell_export; + } + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } + if ($accountancy_code_buy_intra <= 0) { + $object->accountancy_code_buy_intra = ''; + } else { + $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; + } + if ($accountancy_code_buy_export <= 0) { + $object->accountancy_code_buy_export = ''; + } else { + $object->accountancy_code_buy_export = $accountancy_code_buy_export; + } // MultiPrix - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { - for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { - if (GETPOSTISSET("price_".$i)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + if (GETPOSTISSET("price_".$i)) { $object->multiprices["$i"] = price2num($_POST["price_".$i], 'MU'); $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; } else { @@ -369,23 +415,24 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { $id = $object->create($user); } - if ($id > 0) - { + if ($id > 0) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - if (!empty($backtopage)) - { + if (!empty($backtopage)) { $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - if (preg_match('/\?/', $backtopage)) $backtopage .= '&socid='.$object->id; // Old method + if (preg_match('/\?/', $backtopage)) { + $backtopage .= '&socid='.$object->id; // Old method + } header("Location: ".$backtopage); exit; } else { @@ -393,22 +440,22 @@ if (empty($reshook)) exit; } } else { - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); - else setEventMessages($langs->trans($object->error), null, 'errors'); + if (count($object->errors)) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans($object->error), null, 'errors'); + } $action = "create"; } } } // Update a product or service - if ($action == 'update' && $usercancreate) - { - if (GETPOST('cancel', 'alpha')) - { + if ($action == 'update' && $usercancreate) { + if (GETPOST('cancel', 'alpha')) { $action = ''; } else { - if ($object->id > 0) - { + if ($object->id > 0) { $object->oldcopy = clone $object; $object->ref = $ref; @@ -418,8 +465,7 @@ if (empty($reshook)) $object->description = $desc; $object->url = GETPOST('url'); - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private', 'restricthtml')); $object->note = $object->note_private; } @@ -432,9 +478,9 @@ if (empty($reshook)) $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); // removed from update view so GETPOST always empty /* - $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); - $object->desiredstock = GETPOST('desiredstock'); - */ + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); + $object->desiredstock = GETPOST('desiredstock'); + */ $object->duration_value = GETPOST('duration_value', 'int'); $object->duration_unit = GETPOST('duration_unit', 'alpha'); @@ -474,8 +520,7 @@ if (empty($reshook)) $stdobject->element = 'product'; $stdobject->barcode_type = GETPOST('fk_barcode_type'); $result = $stdobject->fetch_barcode(); - if ($result < 0) - { + if ($result < 0) { $error++; $mesg = 'Failed to get bar code type information '; setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); @@ -491,34 +536,64 @@ if (empty($reshook)) $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); - if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } - if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } - if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } - if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } - if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } - if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } + if ($accountancy_code_sell_intra <= 0) { + $object->accountancy_code_sell_intra = ''; + } else { + $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; + } + if ($accountancy_code_sell_export <= 0) { + $object->accountancy_code_sell_export = ''; + } else { + $object->accountancy_code_sell_export = $accountancy_code_sell_export; + } + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } + if ($accountancy_code_buy_intra <= 0) { + $object->accountancy_code_buy_intra = ''; + } else { + $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; + } + if ($accountancy_code_buy_export <= 0) { + $object->accountancy_code_buy_export = ''; + } else { + $object->accountancy_code_buy_export = $accountancy_code_buy_export; + } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error && $object->check()) - { - if ($object->update($object->id, $user) > 0) - { + if (!$error && $object->check()) { + if ($object->update($object->id, $user) > 0) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $action = 'view'; } else { - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); - else setEventMessages($langs->trans($object->error), null, 'errors'); + if (count($object->errors)) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans($object->error), null, 'errors'); + } $action = 'edit'; } } else { - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); - else setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); + if (count($object->errors)) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); + } $action = 'edit'; } } @@ -526,36 +601,31 @@ if (empty($reshook)) } // Action clone object - if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; } - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) - { - if (!GETPOST('clone_content') && !GETPOST('clone_prices')) - { + if ($action == 'confirm_clone' && $confirm != 'yes') { + $action = ''; + } + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { + if (!GETPOST('clone_content') && !GETPOST('clone_prices')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { $db->begin(); $originalId = $id; - if ($object->id > 0) - { + if ($object->id > 0) { $object->ref = GETPOST('clone_ref', 'alphanohtml'); $object->status = 0; $object->status_buy = 0; $object->id = null; $object->barcode = -1; - if ($object->check()) - { + if ($object->check()) { $object->context['createfromclone'] = 'createfromclone'; $id = $object->create($user); - if ($id > 0) - { - if (GETPOST('clone_composition')) - { + if ($id > 0) { + if (GETPOST('clone_composition')) { $result = $object->clone_associations($originalId, $id); - if ($result < 1) - { + if ($result < 1) { $db->rollback(); setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); @@ -563,12 +633,10 @@ if (empty($reshook)) } } - if (GETPOST('clone_categories')) - { + if (GETPOST('clone_categories')) { $result = $object->cloneCategories($originalId, $id); - if ($result < 1) - { + if ($result < 1) { $db->rollback(); setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); @@ -597,8 +665,7 @@ if (empty($reshook)) } else { $id = $originalId; - if ($object->error == 'ErrorProductAlreadyExists') - { + if ($object->error == 'ErrorProductAlreadyExists') { $db->rollback(); $refalreadyexists++; @@ -610,8 +677,7 @@ if (empty($reshook)) $object->fetch($id); } else { $db->rollback(); - if (count($object->errors)) - { + if (count($object->errors)) { setEventMessages($object->error, $object->errors, 'errors'); dol_print_error($db, $object->errors); } else { @@ -631,13 +697,13 @@ if (empty($reshook)) } // Delete a product - if ($action == 'confirm_delete' && $confirm != 'yes') { $action = ''; } - if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) - { + if ($action == 'confirm_delete' && $confirm != 'yes') { + $action = ''; + } + if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { header('Location: '.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'&delprod='.urlencode($object->ref)); exit; } else { @@ -649,35 +715,28 @@ if (empty($reshook)) // Add product into object - if ($object->id > 0 && $action == 'addin') - { + if ($object->id > 0 && $action == 'addin') { $thirpdartyid = 0; - if (GETPOST('propalid') > 0) - { + if (GETPOST('propalid') > 0) { $propal = new Propal($db); $result = $propal->fetch(GETPOST('propalid')); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db, $propal->error); exit; } $thirpdartyid = $propal->socid; - } elseif (GETPOST('commandeid') > 0) - { + } elseif (GETPOST('commandeid') > 0) { $commande = new Commande($db); $result = $commande->fetch(GETPOST('commandeid')); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db, $commande->error); exit; } $thirpdartyid = $commande->socid; - } elseif (GETPOST('factureid') > 0) - { + } elseif (GETPOST('factureid') > 0) { $facture = new Facture($db); $result = $facture->fetch(GETPOST('factureid')); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db, $facture->error); exit; } @@ -696,7 +755,9 @@ if (empty($reshook)) $tva_tx = get_default_tva($mysoc, $soc, $object->id); $tva_npr = get_default_npr($mysoc, $soc, $object->id); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); @@ -743,8 +804,7 @@ if (empty($reshook)) if (GETPOST('propalid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), 2), $object->id)) < 0) - { + if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -784,8 +844,7 @@ if (empty($reshook)) } elseif (GETPOST('commandeid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) - { + if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -825,8 +884,7 @@ if (empty($reshook)) } elseif (GETPOST('factureid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) - { + if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -885,13 +943,11 @@ if (empty($reshook)) $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -902,36 +958,37 @@ $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); $formcompany = new FormCompany($db); -if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); +} // Load object modBarCodeProduct $res = 0; -if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) -{ +if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); $dirbarcode = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - foreach ($dirbarcode as $dirroot) - { + foreach ($dirbarcode as $dirroot) { $res = dol_include_once($dirroot.$module.'.php'); - if ($res) break; + if ($res) { + break; + } } - if ($res > 0) - { + if ($res > 0) { $modBarCodeProduct = new $module(); } } -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) - { + if (empty($object->error) && $id) { $object = new Product($db); $result = $object->fetch($id); - if ($result <= 0) dol_print_error('', $object->error); + if ($result <= 0) { + dol_print_error('', $object->error); + } } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template @@ -939,8 +996,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // When used in standard mode // ----------------------------------------- - if ($action == 'create' && $usercancreate) - { + if ($action == 'create' && $usercancreate) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -955,13 +1011,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Load object modCodeProduct $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); - if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') - { + if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } $result = dol_include_once('/core/modules/product/'.$module.'.php'); - if ($result > 0) - { + if ($result > 0) { $modCodeProduct = new $module(); } @@ -971,10 +1025,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="type" value="'.$type.'">'."\n"; - if (!empty($modCodeProduct->code_auto)) + if (!empty($modCodeProduct->code_auto)) { print '<input type="hidden" name="code_auto" value="1">'; - if (!empty($modBarCodeProduct->code_auto)) + } + if (!empty($modBarCodeProduct->code_auto)) { print '<input type="hidden" name="barcode_auto" value="1">'; + } print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; if ($type == 1) { @@ -989,8 +1045,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // We set country_id, country_code and country for the selected country $object->country_id = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : null; - if ($object->country_id > 0) - { + if ($object->country_id > 0) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -1002,10 +1057,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr>'; $tmpcode = ''; - if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $type); + if (!empty($modCodeProduct->code_auto)) { + $tmpcode = $modCodeProduct->getNextValue($object, $type); + } print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST('ref', 'alphanohtml') : $tmpcode).'">'; - if ($refalreadyexists) - { + if ($refalreadyexists) { print $langs->trans("RefAlreadyExists"); } print '</td></tr>'; @@ -1026,8 +1082,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Batch number management - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch')); @@ -1035,24 +1090,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { + $showbarcode = 0; + } - if ($showbarcode) - { - print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; - if (GETPOSTISSET('fk_barcode_type')) { - $fk_barcode_type = GETPOST('fk_barcode_type'); + if ($showbarcode) { + print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; + if (GETPOSTISSET('fk_barcode_type')) { + $fk_barcode_type = GETPOST('fk_barcode_type'); } else { - if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + } } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print '</td>'; - if ($conf->browser->layout == 'phone') print '</tr><tr>'; + if ($conf->browser->layout == 'phone') { + print '</tr><tr>'; + } print '<td>'.$langs->trans("BarcodeValue").'</td><td>'; $tmpcode = GETPOSTISSET('barcode') ? GETPOST('barcode') : $object->barcode; - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { + $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + } print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; print '</td></tr>'; } @@ -1070,8 +1132,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST('url').'">'; print '</td></tr>'; - if ($type != 1 && !empty($conf->stock->enabled)) - { + if ($type != 1 && !empty($conf->stock->enabled)) { // Default warehouse print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>'; print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1); @@ -1085,7 +1146,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>'; print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">'; print '</td>'; - if ($conf->browser->layout == 'phone') print '</tr><tr>'; + if ($conf->browser->layout == 'phone') { + print '</tr><tr>'; + } // Stock desired level print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>'; print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">'; @@ -1096,16 +1159,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Duration - if ($type == 1) - { + if ($type == 1) { print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">'; print '<input name="duration_value" size="4" value="'.GETPOST('duration_value', 'int').'">'; print $formproduct->selectMeasuringUnits("duration_unit", "time", GETPOST('duration_value', 'alpha'), 0, 1); print '</td></tr>'; } - if ($type != 1) // Nature, Weight and volume only applies to products and not to services - { + if ($type != 1) { // Nature, Weight and volume only applies to products and not to services // Nature print '<tr><td>'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).'</td><td colspan="3">'; $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); @@ -1119,8 +1180,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Brut Length - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; print '<input name="size" class="width50" value="'.GETPOST('size').'"> x '; print '<input name="sizewidth" class="width50" value="'.GETPOST('sizewidth').'"> x '; @@ -1128,16 +1188,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $formproduct->selectMeasuringUnits("size_units", "size", GETPOSTISSET('size_units') ?GETPOST('size_units', 'alpha') : '0', 0, 2); print '</td></tr>'; } - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { // Brut Surface print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; print '<input name="surface" size="4" value="'.GETPOST('surface').'">'; print $formproduct->selectMeasuringUnits("surface_units", "surface", GETPOSTISSET('surface_units') ?GETPOST('surface_units', 'alpha') : '0', 0, 2); print '</td></tr>'; } - if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) - { + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { // Brut Volume print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; print '<input name="volume" size="4" value="'.GETPOST('volume').'">'; @@ -1145,8 +1203,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; } - if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) - { + if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) { // Net Measure print '<tr><td>'.$langs->trans("NetMeasure").'</td><td colspan="3">'; print '<input name="net_measure" size="4" value="'.GETPOST('net_measure').'">'; @@ -1156,8 +1213,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) - { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; print '<td colspan="3">'; print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, 'units'); @@ -1165,8 +1221,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Custom code - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) - { + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) { print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td></tr>'; // Origin country @@ -1174,15 +1229,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<td>'; print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td>'; // State - if (empty($conf->global->PRODUCT_DISABLE_STATE)) - { - if ($conf->browser->layout == 'phone') print '</tr><tr>'; - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { + if (empty($conf->global->PRODUCT_DISABLE_STATE)) { + if ($conf->browser->layout == 'phone') { + print '</tr><tr>'; + } + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print '<td>'.$form->editfieldkey('RegionStateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">'; } else { print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">'; @@ -1199,8 +1256,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $parameters = array('colspan' => 3, 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1228,8 +1284,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<hr>'; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // We do no show price array on create when multiprices enabled. // We must set them on prices tab. print '<table class="border centpercent">'; @@ -1269,8 +1324,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Accountancy codes print '<table class="border centpercent">'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; print '<td>'; @@ -1283,8 +1337,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>'; print '<td>'; if ($type == 0) { @@ -1299,8 +1352,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Accountancy_code_sell_export print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>'; print '<td>'; - if ($type == 0) - { + if ($type == 0) { $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); } else { $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); @@ -1311,17 +1363,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Accountancy_code_buy print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; print '<td>'; - if ($type == 0) { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); - } else { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); - } + if ($type == 0) { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); + } else { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); + } print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); print '</td></tr>'; // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyIntraCode").'</td>'; print '<td>'; if ($type == 0) { @@ -1336,8 +1387,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Accountancy_code_buy_export print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyExportCode").'</td>'; print '<td>'; - if ($type == 0) - { + if ($type == 0) { $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT); } else { $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); @@ -1346,12 +1396,24 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; } else // For external software { - if (!empty($accountancy_code_sell)) { $object->accountancy_code_sell = $accountancy_code_sell; } - if (!empty($accountancy_code_sell_intra)) { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } - if (!empty($accountancy_code_sell_export)) { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } - if (!empty($accountancy_code_buy)) { $object->accountancy_code_buy = $accountancy_code_buy; } - if (!empty($accountancy_code_buy_intra)) { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } - if (!empty($accountancy_code_buy_export)) { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } + if (!empty($accountancy_code_sell)) { + $object->accountancy_code_sell = $accountancy_code_sell; + } + if (!empty($accountancy_code_sell_intra)) { + $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; + } + if (!empty($accountancy_code_sell_export)) { + $object->accountancy_code_sell_export = $accountancy_code_sell_export; + } + if (!empty($accountancy_code_buy)) { + $object->accountancy_code_buy = $accountancy_code_buy; + } + if (!empty($accountancy_code_buy_intra)) { + $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; + } + if (!empty($accountancy_code_buy_export)) { + $object->accountancy_code_buy_export = $accountancy_code_buy_export; + } // Accountancy_code_sell print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; @@ -1359,8 +1421,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>'; print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.'">'; print '</td></tr>'; @@ -1377,8 +1438,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyIntraCode").'</td>'; print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.'">'; print '</td></tr>'; @@ -1402,11 +1462,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</form>'; } elseif ($object->id > 0) { /* - * Product card - */ + * Product card + */ // Fiche en mode edition - if ($action == 'edit' && $usercancreate) - { + if ($action == 'edit' && $usercancreate) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -1421,8 +1480,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $object->country_id; - if ($object->country_id) - { + if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -1430,7 +1488,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $type = $langs->trans('Product'); - if ($object->isService()) $type = $langs->trans('Service'); + if ($object->isService()) { + $type = $langs->trans('Service'); + } //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); // Main official, simple, and not duplicated code @@ -1457,8 +1517,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Status To sell print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; print '<select class="flat" name="statut">'; - if ($object->status) - { + if ($object->status) { print '<option value="1" selected>'.$langs->trans("OnSell").'</option>'; print '<option value="0">'.$langs->trans("NotOnSell").'</option>'; } else { @@ -1471,8 +1530,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Status To Buy print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; print '<select class="flat" name="statut_buy">'; - if ($object->status_buy) - { + if ($object->status_buy) { print '<option value="1" selected>'.$langs->trans("ProductStatusOnBuy").'</option>'; print '<option value="0">'.$langs->trans("ProductStatusNotOnBuy").'</option>'; } else { @@ -1483,10 +1541,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Batch number managment - if ($conf->productbatch->enabled) - { - if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if ($conf->productbatch->enabled) { + if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); print $form->selectarray('status_batch', $statutarray, $object->status_batch); @@ -1496,23 +1552,28 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Barcode $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { + $showbarcode = 0; + } - if ($showbarcode) - { + if ($showbarcode) { print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; if (GETPOSTISSET('fk_barcode_type')) { - $fk_barcode_type = GETPOST('fk_barcode_type'); + $fk_barcode_type = GETPOST('fk_barcode_type'); } else { $fk_barcode_type = $object->barcode_type; - if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + } } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; $tmpcode = GETPOSTISSET('barcode') ? GETPOST('barcode') : $object->barcode; - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { + $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + } print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; print '</td></tr>'; } @@ -1533,32 +1594,30 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Stock - if ($object->isProduct() && !empty($conf->stock->enabled)) - { + if ($object->isProduct() && !empty($conf->stock->enabled)) { // Default warehouse print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>'; print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1); print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].'?action=create&type='.GETPOST('type', 'int')).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddWarehouse").'"></span></a>'; print '</td>'; /* - print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>'; - print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">'; - print '</td>'; + print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>'; + print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">'; + print '</td>'; - print '<td>'.$langs->trans("DesiredStock").'</td><td>'; - print '<input name="desiredstock" size="4" value="'.$object->desiredstock.'">'; - print '</td></tr>'; - */ + print '<td>'.$langs->trans("DesiredStock").'</td><td>'; + print '<input name="desiredstock" size="4" value="'.$object->desiredstock.'">'; + print '</td></tr>'; + */ } /* - else - { - print '<input name="seuil_stock_alerte" type="hidden" value="'.$object->seuil_stock_alerte.'">'; - print '<input name="desiredstock" type="hidden" value="'.$object->desiredstock.'">'; - }*/ - - if ($object->isService()) + else { + print '<input name="seuil_stock_alerte" type="hidden" value="'.$object->seuil_stock_alerte.'">'; + print '<input name="desiredstock" type="hidden" value="'.$object->desiredstock.'">'; + }*/ + + if ($object->isService()) { // Duration print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">'; print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> '; @@ -1576,8 +1635,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print '</td></tr>'; - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; print '<input name="size" size="5" value="'.$object->length.'">x'; @@ -1586,16 +1644,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units, 0, 2); print '</td></tr>'; } - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { // Brut Surface print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; print '<input name="surface" size="5" value="'.$object->surface.'"> '; print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units, 0, 2); print '</td></tr>'; } - if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) - { + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { // Brut Volume print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; print '<input name="volume" size="5" value="'.$object->volume.'"> '; @@ -1603,8 +1659,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; } - if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) - { + if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) { // Net Measure print '<tr><td>'.$langs->trans("NetMeasure").'</td><td colspan="3">'; print '<input name="net_measure" size="5" value="'.$object->net_measure.'"> '; @@ -1613,8 +1668,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) - { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; print '<td colspan="3">'; print $form->selectUnits($object->fk_unit, 'units'); @@ -1622,22 +1676,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Custom code - if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) - { + if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td></tr>'; // Origin country print '<td>'.$langs->trans("CountryOrigin").'</td>'; print '<td>'; print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td>'; // State - if (empty($conf->global->PRODUCT_DISABLE_STATE)) - { - if ($conf->browser->layout == 'phone') print '</tr><tr>'; - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { + if (empty($conf->global->PRODUCT_DISABLE_STATE)) { + if ($conf->browser->layout == 'phone') { + print '</tr><tr>'; + } + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print '<td>'.$form->editfieldkey('RegionStateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">'; } else { print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">'; @@ -1653,14 +1708,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } // Tags-Categories - if ($conf->categorie->enabled) - { + if ($conf->categorie->enabled) { print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1676,8 +1729,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Note private - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); @@ -1692,8 +1744,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<table class="border centpercent">'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; print '<td>'; @@ -1701,8 +1752,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>'; print '<td>'; print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); @@ -1722,8 +1772,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancyBuyIntraCode").'</td>'; print '<td>'; print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1); @@ -1743,8 +1792,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>'; print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.'">'; print '</td></tr>'; @@ -1761,8 +1809,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancyBuyIntraCode").'</td>'; print '<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="'.$object->accountancy_code_buy_intra.'">'; print '</td></tr>'; @@ -1787,7 +1834,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } else { // Fiche en mode visu $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { + $showbarcode = 0; + } $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); @@ -1799,7 +1848,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -1811,8 +1862,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<table class="border tableforfield" width="100%">'; // Type - if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print '<tr><td class="titlefield">'; print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); @@ -1821,25 +1871,24 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; } - if ($showbarcode) - { + if ($showbarcode) { // Barcode type print '<tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans("BarcodeType"); print '</td>'; - if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; + if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td colspan="2">'; - if ($action == 'editbarcodetype' || $action == 'editbarcode') - { + if ($action == 'editbarcodetype' || $action == 'editbarcode') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); } $fk_barcode_type=''; - if ($action == 'editbarcodetype') - { + if ($action == 'editbarcodetype') { print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); $fk_barcode_type = $object->barcode_type; } else { @@ -1854,13 +1903,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans("BarcodeValue"); print '</td>'; - if (($action != 'editbarcode') && $usercancreate && $createbarcode) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; + if (($action != 'editbarcode') && $usercancreate && $createbarcode) { + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; + } print '</tr></table>'; print '</td><td colspan="2">'; - if ($action == 'editbarcode') - { + if ($action == 'editbarcode') { $tmpcode = GETPOSTISSET('barcode') ? GETPOST('barcode') : $object->barcode; - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { + $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type); + } print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -1879,10 +1931,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancySellCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_sell)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_sell)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code_sell, 1); @@ -1894,15 +1944,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy sell code intra-community - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancySellIntraCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_sell_intra)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_sell_intra)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1); @@ -1918,10 +1965,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancySellExportCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_sell_export)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_sell_export)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1); @@ -1936,10 +1981,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancyBuyCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_buy)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_buy)) { $accountingaccount4 = new AccountingAccount($db); $accountingaccount4->fetch('', $object->accountancy_code_buy, 1); @@ -1951,15 +1994,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Accountancy buy code intra-community - if ($mysoc->isInEEC()) - { + if ($mysoc->isInEEC()) { print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancyBuyIntraCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_buy_intra)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_buy_intra)) { $accountingaccount5 = new AccountingAccount($db); $accountingaccount5->fetch('', $object->accountancy_code_buy_intra, 1); @@ -1975,10 +2015,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr><td class="nowrap">'; print $langs->trans("ProductAccountancyBuyExportCode"); print '</td><td colspan="2">'; - if (!empty($conf->accounting->enabled)) - { - if (!empty($object->accountancy_code_buy_export)) - { + if (!empty($conf->accounting->enabled)) { + if (!empty($object->accountancy_code_buy_export)) { $accountingaccount6 = new AccountingAccount($db); $accountingaccount6->fetch('', $object->accountancy_code_buy_export, 1); @@ -1990,10 +2028,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Batch number management (to batch) - if (!empty($conf->productbatch->enabled)) - { - if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { + if (!empty($conf->productbatch->enabled)) { + if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">'; if (!empty($conf->use_javascript_ajax) && $usercancreate && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); @@ -2013,8 +2049,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '</td></tr>'; // Default warehouse - if ($object->isProduct() && !empty($conf->stock->enabled)) - { + if ($object->isProduct() && !empty($conf->stock->enabled)) { $warehouse = new Entrepot($db); $warehouse->fetch($object->fk_default_warehouse); @@ -2045,15 +2080,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; - if ($object->isService()) - { + if ($object->isService()) { // Duration print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;'; - if ($object->duration_value > 1) - { + if ($object->duration_value > 1) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ($object->duration_value > 0) - { + } elseif ($object->duration_value > 0) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;"; @@ -2067,47 +2099,44 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Brut Weight print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">'; - if ($object->weight != '') - { + if ($object->weight != '') { print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { print '&nbsp;'; } print "</td></tr>\n"; - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="2">'; - if ($object->length != '' || $object->width != '' || $object->height != '') - { + if ($object->length != '' || $object->width != '' || $object->height != '') { print $object->length; - if ($object->width) print " x ".$object->width; - if ($object->height) print " x ".$object->height; + if ($object->width) { + print " x ".$object->width; + } + if ($object->height) { + print " x ".$object->height; + } print ' '.measuringUnitString(0, "size", $object->length_units); } else { print '&nbsp;'; } print "</td></tr>\n"; } - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) - { + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { // Brut Surface print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">'; - if ($object->surface != '') - { + if ($object->surface != '') { print $object->surface." ".measuringUnitString(0, "surface", $object->surface_units); } else { print '&nbsp;'; } print "</td></tr>\n"; } - if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) - { + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { // Brut Volume print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">'; - if ($object->volume != '') - { + if ($object->volume != '') { print $object->volume." ".measuringUnitString(0, "volume", $object->volume_units); } else { print '&nbsp;'; @@ -2115,12 +2144,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print "</td></tr>\n"; } - if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) - { + if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) { // Net Measure print '<tr><td class="titlefield">'.$langs->trans("NetMeasure").'</td><td colspan="2">'; - if ($object->net_measure != '') - { + if ($object->net_measure != '') { print $object->net_measure." ".measuringUnitString($object->net_measure_units); } else { print '&nbsp;'; @@ -2129,8 +2156,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) - { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = $object->getLabelOfUnit(); print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td><td>'; @@ -2141,13 +2167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Custom code - if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) - { + if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>'; // Origin country code print '<tr><td>'.$langs->trans("Origin").'</td><td colspan="2">'.getCountry($object->country_id, 0, $db); - if (!empty($object->state_id)) print ' - '.getState($object->state_id, 0, $db); + if (!empty($object->state_id)) { + print ' - '.getState($object->state_id, 0, $db); + } print '</td>'; } @@ -2163,8 +2190,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Note private - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { print '<!-- show Note --> '."\n"; print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'">'.(dol_textishtml($object->note_private) ? $object->note_private : dol_nl2br($object->note_private, 1, true)).'</td></tr>'."\n"; print '<!-- End show Note --> '."\n"; @@ -2178,40 +2204,37 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print dol_get_fiche_end(); } - } elseif ($action != 'create') - { + } elseif ($action != 'create') { exit; } } // Load object modCodeProduct $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); -if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') -{ +if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } $result = dol_include_once('/core/modules/product/'.$module.'.php'); -if ($result > 0) -{ +if ($result > 0) { $modCodeProduct = new $module(); } $tmpcode = ''; -if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $object->type); +if (!empty($modCodeProduct->code_auto)) { + $tmpcode = $modCodeProduct->getNextValue($object, $object->type); +} $formconfirm = ''; // Confirm delete product if (($action == 'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js -{ + || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js $formconfirm = $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete"); } // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js - || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js -{ + || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js // Define confirmation messages $formquestionclone = array( 'text' => $langs->trans("ConfirmClone"), @@ -2222,8 +2245,7 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->d if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("CustomerPrices").')', 'value' => 0); } - if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) - { + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); } @@ -2233,8 +2255,11 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->d // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'object' => $object); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; -elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; +if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; +} elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; +} // Print form confirm print $formconfirm; @@ -2244,22 +2269,19 @@ print $formconfirm; /* Barre d'action */ /* */ /* ************************************************************************** */ -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print "\n".'<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - if ($usercancreate) - { - if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a>'; + if (empty($reshook)) { + if ($usercancreate) { + if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a>'; + } - if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) - { - if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) - { + if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) { + if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { print '<span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span>'."\n"; } else { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=clone&amp;id='.$object->id.'">'.$langs->trans("ToClone").'</a>'; @@ -2268,12 +2290,9 @@ if ($action != 'create' && $action != 'edit') } $object_is_used = $object->isObjectUsed($object->id); - if ($usercandelete) - { - if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) - { - if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) - { + if ($usercandelete) { + if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) { + if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { print '<span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span>'."\n"; } else { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id.'">'.$langs->trans("Delete").'</a>'; @@ -2293,23 +2312,20 @@ if ($action != 'create' && $action != 'edit') * All the "Add to" areas */ -if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) -{ +if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) { //Variable used to check if any text is going to be printed $html = ''; //print '<div class="fichecenter"><div class="fichehalfleft">'; // Propals - if (!empty($conf->propal->enabled) && $user->rights->propale->creer) - { + if (!empty($conf->propal->enabled) && $user->rights->propale->creer) { $propal = new Propal($db); $langs->load("propal"); $otherprop = $propal->liste_array(2, 1, 0); - if (is_array($otherprop) && count($otherprop)) - { + if (is_array($otherprop) && count($otherprop)) { $html .= '<tr><td style="width: 200px;">'; $html .= $langs->trans("AddToDraftProposals").'</td><td>'; $html .= $form->selectarray("propalid", $otherprop, 0, 1); @@ -2323,15 +2339,13 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Commande - if (!empty($conf->commande->enabled) && $user->rights->commande->creer) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->creer) { $commande = new Commande($db); $langs->load("orders"); $othercom = $commande->liste_array(2, 1, null); - if (is_array($othercom) && count($othercom)) - { + if (is_array($othercom) && count($othercom)) { $html .= '<tr><td style="width: 200px;">'; $html .= $langs->trans("AddToDraftOrders").'</td><td>'; $html .= $form->selectarray("commandeid", $othercom, 0, 1); @@ -2345,15 +2359,13 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Factures - if (!empty($conf->facture->enabled) && $user->rights->facture->creer) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->creer) { $invoice = new Facture($db); $langs->load("bills"); $otherinvoice = $invoice->liste_array(2, 1, null); - if (is_array($otherinvoice) && count($otherinvoice)) - { + if (is_array($otherinvoice) && count($otherinvoice)) { $html .= '<tr><td style="width: 200px;">'; $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; $html .= $form->selectarray("factureid", $otherinvoice, 0, 1); @@ -2367,8 +2379,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } //If any text is going to be printed, then we show the table - if (!empty($html)) - { + if (!empty($html)) { print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="addin">'; @@ -2402,8 +2413,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == * Documents generes */ -if ($action != 'create' && $action != 'edit' && $action != 'delete') -{ +if ($action != 'create' && $action != 'edit' && $action != 'delete') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 189161712d5..2f2d24f7458 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -37,7 +37,7 @@ class Products extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'ref', 'label' ); @@ -217,8 +217,7 @@ class Products extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $product_static = new Product($this->db); if ($product_static->fetch($obj->rowid)) { @@ -290,7 +289,8 @@ class Products extends DolibarrApi $oldproduct = dol_clone($this->product, 0); foreach ($request_data as $field => $value) { - if ($field == 'id') { continue; + if ($field == 'id') { + continue; } if ($field == 'stock_reel') { throw new RestException(400, 'Stock reel cannot be updated here. Use the /stockmovements endpoint instead'); @@ -309,24 +309,32 @@ class Products extends DolibarrApi if ($result > 0 && !empty($conf->global->PRODUCT_PRICE_UNIQ)) { // We update price only if it was changed $pricemodified = false; - if ($this->product->price_base_type != $oldproduct->price_base_type) { $pricemodified = true; + if ($this->product->price_base_type != $oldproduct->price_base_type) { + $pricemodified = true; } else { - if ($this->product->tva_tx != $oldproduct->tva_tx) { $pricemodified = true; + if ($this->product->tva_tx != $oldproduct->tva_tx) { + $pricemodified = true; } - if ($this->product->tva_npr != $oldproduct->tva_npr) { $pricemodified = true; + if ($this->product->tva_npr != $oldproduct->tva_npr) { + $pricemodified = true; } - if ($this->product->default_vat_code != $oldproduct->default_vat_code) { $pricemodified = true; + if ($this->product->default_vat_code != $oldproduct->default_vat_code) { + $pricemodified = true; } if ($this->product->price_base_type == 'TTC') { - if ($this->product->price_ttc != $oldproduct->price_ttc) { $pricemodified = true; + if ($this->product->price_ttc != $oldproduct->price_ttc) { + $pricemodified = true; } - if ($this->product->price_min_ttc != $oldproduct->price_min_ttc) { $pricemodified = true; + if ($this->product->price_min_ttc != $oldproduct->price_min_ttc) { + $pricemodified = true; } } else { - if ($this->product->price != $oldproduct->price) { $pricemodified = true; + if ($this->product->price != $oldproduct->price) { + $pricemodified = true; } - if ($this->product->price_min != $oldproduct->price_min) { $pricemodified = true; + if ($this->product->price_min != $oldproduct->price_min) { + $pricemodified = true; } } } @@ -586,7 +594,9 @@ class Products extends DolibarrApi $prodcustprice = new Productcustomerprice($this->db); $filter = array(); $filter['t.fk_product'] .= $id; - if ($thirdparty_id) $filter['t.fk_soc'] .= $thirdparty_id; + if ($thirdparty_id) { + $filter['t.fk_soc'] .= $thirdparty_id; + } $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); } @@ -805,8 +815,7 @@ class Products extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $product_fourn = new ProductFournisseur($this->db); @@ -1149,7 +1158,8 @@ class Products extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'rowid') { continue; + if ($field == 'rowid') { + continue; } $prodattr->$field = $value; } @@ -1447,7 +1457,8 @@ class Products extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'rowid') { continue; + if ($field == 'rowid') { + continue; } $objectval->$field = $value; } @@ -1606,8 +1617,7 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact, $reference, $ref_ext); - if ($result > 0) - { + if ($result > 0) { return $result; } else { throw new RestException(500, "Error creating new product variant"); @@ -1662,11 +1672,9 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - if (!$prodcomb->fetchByProductCombination2ValuePairs($this->product->id, $features)) - { + if (!$prodcomb->fetchByProductCombination2ValuePairs($this->product->id, $features)) { $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact); - if ($result > 0) - { + if ($result > 0) { return $result; } else { throw new RestException(500, "Error creating new product variant"); @@ -1698,14 +1706,14 @@ class Products extends DolibarrApi $prodcomb->fetch((int) $id); foreach ($request_data as $field => $value) { - if ($field == 'rowid') { continue; + if ($field == 'rowid') { + continue; } $prodcomb->$field = $value; } $result = $prodcomb->update(DolibarrApiAccess::$user); - if ($result > 0) - { + if ($result > 0) { return 1; } throw new RestException(500, "Error editing variant"); @@ -1731,8 +1739,7 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $prodcomb->id = (int) $id; $result = $prodcomb->delete(DolibarrApiAccess::$user); - if ($result <= 0) - { + if ($result <= 0) { throw new RestException(500, "Error deleting variant"); } return $result; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index eed18bbf8bd..56efd8565d1 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -76,57 +76,54 @@ class FormProduct { global $conf, $langs; - if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product + if (empty($fk_product) && count($this->cache_warehouses)) { + return 0; // Cache already loaded and we do not want a list with information specific to a product + } - if (is_array($exclude)) $excludeGroups = implode("','", $exclude); + if (is_array($exclude)) { + $excludeGroups = implode("','", $exclude); + } $warehouseStatus = array(); - if (preg_match('/warehouseclosed/', $status)) - { + if (preg_match('/warehouseclosed/', $status)) { $warehouseStatus[] = Entrepot::STATUS_CLOSED; } - if (preg_match('/warehouseopen/', $status)) - { + if (preg_match('/warehouseopen/', $status)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_ALL; } - if (preg_match('/warehouseinternal/', $status)) - { + if (preg_match('/warehouseinternal/', $status)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL; } $sql = "SELECT e.rowid, e.ref as label, e.description, e.fk_parent"; - if (!empty($fk_product)) - { - if (!empty($batch)) - { + if (!empty($fk_product)) { + if (!empty($batch)) { $sql .= ", pb.qty as stock"; } else { $sql .= ", ps.reel as stock"; } - } elseif ($sumStock) - { + } elseif ($sumStock) { $sql .= ", sum(ps.reel) as stock"; } $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; - if (!empty($fk_product)) - { + if (!empty($fk_product)) { $sql .= " AND ps.fk_product = ".((int) $fk_product); - if (!empty($batch)) - { + if (!empty($batch)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$this->db->escape($batch)."'"; } } $sql .= " WHERE e.entity IN (".getEntity('stock').")"; - if (count($warehouseStatus)) - { + if (count($warehouseStatus)) { $sql .= " AND e.statut IN (".$this->db->sanitize($this->db->escape(implode(',', $warehouseStatus))).")"; } else { $sql .= " AND e.statut = 1"; } - if (!empty($exclude)) $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; + if (!empty($exclude)) { + $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; + } // minimum stock if ($stockMin !== false) { @@ -151,14 +148,14 @@ class FormProduct dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($sumStock) $obj->stock = price2num($obj->stock, 5); + if ($sumStock) { + $obj->stock = price2num($obj->stock, 5); + } $this->cache_warehouses[$obj->rowid]['id'] = $obj->rowid; $this->cache_warehouses[$obj->rowid]['label'] = $obj->label; $this->cache_warehouses[$obj->rowid]['parent_id'] = $obj->fk_parent; @@ -168,7 +165,7 @@ class FormProduct } // Full label init - foreach ($this->cache_warehouses as $obj_rowid=>$tab) { + foreach ($this->cache_warehouses as $obj_rowid => $tab) { $this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab); } @@ -190,10 +187,13 @@ class FormProduct private function get_parent_path($tab, $final_label = '') { //phpcs:enable - if (empty($final_label)) $final_label = $tab['label']; + if (empty($final_label)) { + $final_label = $tab['label']; + } - if (empty($tab['parent_id'])) return $final_label; - else { + if (empty($tab['parent_id'])) { + return $final_label; + } else { if (!empty($this->cache_warehouses[$tab['parent_id']])) { $final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label; return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); @@ -235,14 +235,17 @@ class FormProduct dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss", LOG_DEBUG); $out = ''; - if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; - if (!empty($fk_product)) $this->cache_warehouses = array(); + if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) { + $filterstatus = ''; + } + if (!empty($fk_product)) { + $this->cache_warehouses = array(); + } $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses = count($this->cache_warehouses); - if ($conf->use_javascript_ajax && !$forcecombo) - { + if ($conf->use_javascript_ajax && !$forcecombo) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, $events); $out .= $comboenhancement; @@ -250,22 +253,28 @@ class FormProduct if (strpos($htmlname, 'search_') !== 0) { if (empty($user->fk_warehouse) || $user->fk_warehouse == -1) { - if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; - } - else { - if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $selected = $user->fk_warehouse; + if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { + $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; + } + } else { + if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { + $selected = $user->fk_warehouse; + } } } $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled' : '').' id="'.$htmlname.'" name="'.($htmlname.($disabled ? '_disabled' : '')).'">'; - if ($empty) $out .= '<option value="-1">'.($empty_label ? $empty_label : '&nbsp;').'</option>'; - foreach ($this->cache_warehouses as $id => $arraytypes) - { + if ($empty) { + $out .= '<option value="-1">'.($empty_label ? $empty_label : '&nbsp;').'</option>'; + } + foreach ($this->cache_warehouses as $id => $arraytypes) { $label = ''; - if ($showfullpath) $label .= $arraytypes['full_label']; - else $label .= $arraytypes['label']; - if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) - { + if ($showfullpath) { + $label .= $arraytypes['full_label']; + } else { + $label .= $arraytypes['label']; + } + if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) { if ($arraytypes['stock'] <= 0) { $label .= ' <span class= \'text-warning\'>('.$langs->trans("Stock").':'.$arraytypes['stock'].')</span>'; } else { @@ -274,14 +283,18 @@ class FormProduct } $out .= '<option value="'.$id.'"'; - if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out .= ' selected'; + if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) { + $out .= ' selected'; + } $out .= ' data-html="'.dol_escape_htmltag($label).'"'; $out .= '>'; $out .= $label; $out .= '</option>'; } $out .= '</select>'; - if ($disabled) $out .= '<input type="hidden" name="'.$htmlname.'" value="'.(($selected > 0) ? $selected : '').'">'; + if ($disabled) { + $out .= '<input type="hidden" name="'.$htmlname.'" value="'.(($selected > 0) ? $selected : '').'">'; + } $parameters = array( 'selected' => $selected, @@ -302,8 +315,11 @@ class FormProduct ); $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this); - if ($reshook > 0) $out = $hookmanager->resPrint; - elseif ($reshook == 0) $out .= $hookmanager->resPrint; + if ($reshook > 0) { + $out = $hookmanager->resPrint; + } elseif ($reshook == 0) { + $out .= $hookmanager->resPrint; + } return $out; } @@ -385,7 +401,9 @@ class FormProduct $filter = array(); $filter['t.active'] = 1; - if ($measuring_style) $filter['t.unit_type'] = $measuring_style; + if ($measuring_style) { + $filter['t.unit_type'] = $measuring_style; + } $result = $measuringUnits->fetchAll( '', @@ -399,24 +417,33 @@ class FormProduct return -1; } else { $return .= '<select class="flat" name="'.$name.'">'; - if ($adddefault || $adddefault === '') - { + if ($adddefault || $adddefault === '') { $return .= '<option value="0">'.($adddefault ? $langs->trans("Default") : '').'</option>'; } - foreach ($measuringUnits->records as $lines) - { + foreach ($measuringUnits->records as $lines) { $return .= '<option value="'; - if ($mode == 1) $return .= $lines->short_label; - elseif ($mode == 2) $return .= $lines->scale; - else $return .= $lines->id; + if ($mode == 1) { + $return .= $lines->short_label; + } elseif ($mode == 2) { + $return .= $lines->scale; + } else { + $return .= $lines->id; + } $return .= '"'; - if ($mode == 1 && $lines->short_label == $default) $return .= ' selected'; - elseif ($mode == 2 && $lines->scale == $default) $return .= ' selected'; - elseif ($mode == 0 && $lines->id == $default) $return .= ' selected'; + if ($mode == 1 && $lines->short_label == $default) { + $return .= ' selected'; + } elseif ($mode == 2 && $lines->scale == $default) { + $return .= ' selected'; + } elseif ($mode == 0 && $lines->id == $default) { + $return .= ' selected'; + } $return .= '>'; - if ($measuring_style == 'time') $return .= $langs->trans(ucfirst($lines->label)); - else $return .= $langs->trans($lines->label); + if ($measuring_style == 'time') { + $return .= $langs->trans(ucfirst($lines->label)); + } else { + $return .= $langs->trans($lines->label); + } $return .= '</option>'; } $return .= '</select>'; @@ -472,8 +499,11 @@ class FormProduct if (!empty($productNature->records) && is_array($productNature->records)) { foreach ($productNature->records as $lines) { $return .= '<option value="'; - if ($mode == 1) $return .= $lines->label; - else $return .= $lines->code; + if ($mode == 1) { + $return .= $lines->label; + } else { + $return .= $lines->code; + } $return .= '"'; @@ -520,42 +550,41 @@ class FormProduct $out = ''; $productIdArray = array(); - if (!is_array($objectLines) || !count($objectLines)) - { - if (!empty($fk_product)) $productIdArray[] = $fk_product; + if (!is_array($objectLines) || !count($objectLines)) { + if (!empty($fk_product)) { + $productIdArray[] = $fk_product; + } } else { foreach ($objectLines as $line) { - if ($line->fk_product) $productIdArray[] = $line->fk_product; + if ($line->fk_product) { + $productIdArray[] = $line->fk_product; + } } } $nboflot = $this->loadLotStock($productIdArray); - if ($conf->use_javascript_ajax && !$forcecombo) - { + if ($conf->use_javascript_ajax && !$forcecombo) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, $events); $out .= $comboenhancement; } $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled' : '').' id="'.$htmlname.'" name="'.($htmlname.($disabled ? '_disabled' : '')).'">'; - if ($empty) $out .= '<option value="-1">'.($empty_label ? $empty_label : '&nbsp;').'</option>'; - if (!empty($fk_product)) - { + if ($empty) { + $out .= '<option value="-1">'.($empty_label ? $empty_label : '&nbsp;').'</option>'; + } + if (!empty($fk_product)) { $productIdArray = array($fk_product); // only show lot stock for product } else { - foreach ($this->cache_lot as $key => $value) - { + foreach ($this->cache_lot as $key => $value) { $productIdArray[] = $key; } } - foreach ($productIdArray as $productId) - { - foreach ($this->cache_lot[$productId] as $id => $arraytypes) - { - if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) - { + foreach ($productIdArray as $productId) { + foreach ($this->cache_lot[$productId] as $id => $arraytypes) { + if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { $label = $arraytypes['entrepot_label'].' - '; $label .= $arraytypes['batch']; if ($arraytypes['qty'] <= 0) { @@ -565,7 +594,9 @@ class FormProduct } $out .= '<option value="'.$id.'"'; - if ($selected == $id || ($selected == 'ifone' && $nboflot == 1)) $out .= ' selected'; + if ($selected == $id || ($selected == 'ifone' && $nboflot == 1)) { + $out .= ' selected'; + } $out .= ' data-html="'.dol_escape_htmltag($label).'"'; $out .= '>'; $out .= $label; @@ -574,7 +605,9 @@ class FormProduct } } $out .= '</select>'; - if ($disabled) $out .= '<input type="hidden" name="'.$htmlname.'" value="'.(($selected > 0) ? $selected : '').'">'; + if ($disabled) { + $out .= '<input type="hidden" name="'.$htmlname.'" value="'.(($selected > 0) ? $selected : '').'">'; + } return $out; } @@ -591,22 +624,18 @@ class FormProduct global $conf, $langs; $cacheLoaded = false; - if (empty($productIdArray)) - { + if (empty($productIdArray)) { // only Load lot stock for given products $this->cache_lot = array(); return 0; } - if (count($productIdArray) && count($this->cache_lot)) - { + if (count($productIdArray) && count($this->cache_lot)) { // check cache already loaded for product id's - foreach ($productIdArray as $productId) - { + foreach ($productIdArray as $productId) { $cacheLoaded = !empty($this->cache_lot[$productId]) ? true : false; } } - if ($cacheLoaded) - { + if ($cacheLoaded) { return count($this->cache_lot); } else { // clear cache @@ -616,20 +645,17 @@ class FormProduct $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; - if (!empty($productIdList)) - { + if (!empty($productIdList)) { $sql .= " WHERE ps.fk_product IN (".$productIdList.")"; } $sql .= " ORDER BY e.ref, pb.batch"; dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->cache_lot[$obj->fk_product][$obj->rowid]['id'] = $obj->rowid; $this->cache_lot[$obj->fk_product][$obj->rowid]['batch'] = $obj->batch; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a79b108cdc0..df996bc0a94 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -93,9 +93,9 @@ class Product extends CommonObject public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into images.lib.php /* - * @deprecated - * @see label - */ + * @deprecated + * @see label + */ public $libelle; /** @@ -227,8 +227,8 @@ class Product extends CommonObject public $desiredstock = 0; /* - * Service expiration - */ + * Service expiration + */ public $duration_value; /** @@ -588,8 +588,7 @@ class Product extends CommonObject if (empty($this->ref) || $this->ref == 'auto') { // Load object modCodeProduct $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); - if ($module != 'mod_codeproduct_leopard') // Do not load module file for leopard - { + if ($module != 'mod_codeproduct_leopard') { // Do not load module file for leopard if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } @@ -728,7 +727,8 @@ class Product extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('PRODUCT_CREATE', $user); - if ($result < 0) { $error++; + if ($result < 0) { + $error++; } // End call triggers } @@ -802,10 +802,10 @@ class Product extends CommonObject $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - foreach ($dirsociete as $dirroot) - { + foreach ($dirsociete as $dirroot) { $res = dol_include_once($dirroot.$module.'.php'); - if ($res) { break; + if ($res) { + break; } } @@ -947,16 +947,16 @@ class Product extends CommonObject if ($this->hasbatch() && !$this->oldcopy->hasbatch()) { //$valueforundefinedlot = 'Undefined'; // In previous version, 39 and lower $valueforundefinedlot = '000000'; - if (!empty($conf->global->STOCK_DEFAULT_BATCH)) $valueforundefinedlot = $conf->global->STOCK_DEFAULT_BATCH; + if (!empty($conf->global->STOCK_DEFAULT_BATCH)) { + $valueforundefinedlot = $conf->global->STOCK_DEFAULT_BATCH; + } dol_syslog("Flag batch of product id=".$this->id." is set to ON, so we will create missing records into product_batch"); $this->load_stock(); - foreach ($this->stock_warehouse as $idW => $ObjW) // For each warehouse where we have stocks defined for this product (for each lines in product_stock) - { + foreach ($this->stock_warehouse as $idW => $ObjW) { // For each warehouse where we have stocks defined for this product (for each lines in product_stock) $qty_batch = 0; - foreach ($ObjW->detail_batch as $detail) // Each lines of detail in product_batch of the current $ObjW = product_stock - { + foreach ($ObjW->detail_batch as $detail) { // Each lines of detail in product_batch of the current $ObjW = product_stock if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') { // We discard this line, we will create it later $sqlclean = "DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$this->db->escape($valueforundefinedlot)."') AND fk_product_stock = ".$ObjW->id; @@ -987,7 +987,8 @@ class Product extends CommonObject } // For automatic creation - if ($this->barcode == -1) { $this->barcode = $this->get_barcode($this, $this->barcode_type_code); + if ($this->barcode == -1) { + $this->barcode = $this->get_barcode($this, $this->barcode_type_code); } $sql = "UPDATE ".MAIN_DB_PREFIX."product"; @@ -1201,8 +1202,7 @@ class Product extends CommonObject // Delete all child tables if (!$error) { $elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot'); // product_batch is done before - foreach ($elements as $table) - { + foreach ($elements as $table) { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE fk_product = ".(int) $this->id; @@ -1287,8 +1287,7 @@ class Product extends CommonObject $this->db->commit(); return 1; } else { - 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); } @@ -1314,8 +1313,7 @@ class Product extends CommonObject $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) - { + foreach ($langs_available as $key => $value) { if ($key == $current_lang) { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -1324,18 +1322,19 @@ class Product extends CommonObject $result = $this->db->query($sql); - if ($this->db->num_rows($result)) // if there is already a description line for this language - { + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; $sql2 .= " SET "; $sql2 .= " label='".$this->db->escape($this->label)."',"; $sql2 .= " description='".$this->db->escape($this->description)."'"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note='".$this->db->escape($this->other)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", note='".$this->db->escape($this->other)."'"; } $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", note"; } $sql2 .= ")"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; @@ -1358,8 +1357,7 @@ class Product extends CommonObject $result = $this->db->query($sql); - if ($this->db->num_rows($result)) // if there is already a description line for this language - { + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; $sql2 .= " SET "; $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; @@ -1370,7 +1368,8 @@ class Product extends CommonObject $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", note"; } $sql2 .= ")"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; @@ -1478,7 +1477,9 @@ class Product extends CommonObject if ($resql) { // Call trigger $result = $this->call_trigger('PRODUCT_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers if ($error) { @@ -1514,11 +1515,9 @@ class Product extends CommonObject $result = $this->db->query($sql); if ($result) { - while ($obj = $this->db->fetch_object($result)) - { + while ($obj = $this->db->fetch_object($result)) { //print 'lang='.$obj->lang.' current='.$current_lang.'<br>'; - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. - { + if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. $this->label = $obj->label; $this->description = $obj->description; $this->other = $obj->other; @@ -1618,7 +1617,9 @@ class Product extends CommonObject // Update if prices fields are defined $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); $tva_npr = get_default_npr($thirdparty_seller, $thirdparty_buyer, $this->id); - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } $pu_ht = $this->price; $pu_ttc = $this->price_ttc; @@ -1631,11 +1632,16 @@ class Product extends CommonObject $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level]; $price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx = $this->multiprices_tva_tx[$thirdparty_buyer->price_level]; - if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr = $this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; - if (empty($tva_tx)) $tva_npr = 0; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility + if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) { + $tva_tx = $this->multiprices_tva_tx[$thirdparty_buyer->price_level]; + } + if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) { + $tva_npr = $this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; + } + if (empty($tva_tx)) { + $tva_npr = 0; + } } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // If price per customer @@ -1653,9 +1659,13 @@ class Product extends CommonObject $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { + $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + } $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; + if (empty($tva_tx)) { + $tva_npr = 0; + } } } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { @@ -1664,10 +1674,11 @@ class Product extends CommonObject // yes, this product has some prices per quantity // Search price into product_price_by_qty from $this->id foreach ($this->prices_by_qty_list[0] as $priceforthequantityarray) { - if ($priceforthequantityarray['rowid'] != $pqp) continue; + if ($priceforthequantityarray['rowid'] != $pqp) { + continue; + } // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') - { + if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; } else { $pu_ttc = $priceforthequantityarray['unitprice']; @@ -1680,12 +1691,12 @@ class Product extends CommonObject if ($this->prices_by_qty[$thirdparty_buyer->price_level]) { // yes, this product has some prices per quantity // Search price into product_price_by_qty from $this->id - foreach ($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) - { - if ($priceforthequantityarray['rowid'] != $pqp) continue; + foreach ($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) { + if ($priceforthequantityarray['rowid'] != $pqp) { + continue; + } // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') - { + if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; } else { $pu_ttc = $priceforthequantityarray['unitprice']; @@ -1723,10 +1734,13 @@ class Product extends CommonObject $sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression,"; $sql .= " pfp.default_vat_code,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= ", pfp.packaging"; + } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE pfp.rowid = ".$prodfournprice; - if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty; + if ($qty > 0) { + $sql .= " AND pfp.quantity <= ".$qty; } $sql .= " ORDER BY pfp.quantity DESC"; @@ -1734,8 +1748,7 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj && $obj->quantity > 0) // If we found a supplier prices from the id of supplier price - { + if ($obj && $obj->quantity > 0) { // If we found a supplier prices from the id of supplier price if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) { include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $prod_supplier = new ProductFournisseur($this->db); @@ -1766,7 +1779,9 @@ class Product extends CommonObject $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $this->packaging = $obj->packaging; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $this->packaging = $obj->packaging; + } $result = $obj->fk_product; return $result; } else { // If not found @@ -1778,11 +1793,14 @@ class Product extends CommonObject $sql .= " pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE pfp.fk_product = ".$product_id; - if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$this->db->escape($fourn_ref)."'"; + if ($fourn_ref != 'none') { + $sql .= " AND pfp.ref_fourn = '".$this->db->escape($fourn_ref)."'"; } - if ($fk_soc > 0) { $sql .= " AND pfp.fk_soc = ".$fk_soc; + if ($fk_soc > 0) { + $sql .= " AND pfp.fk_soc = ".$fk_soc; } - if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty; + if ($qty > 0) { + $sql .= " AND pfp.quantity <= ".$qty; } $sql .= " ORDER BY pfp.quantity DESC"; $sql .= " LIMIT 1"; @@ -1791,8 +1809,7 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj && $obj->quantity > 0) // If found - { + if ($obj && $obj->quantity > 0) { // If found if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) { include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $prod_supplier = new ProductFournisseur($this->db); @@ -1824,7 +1841,9 @@ class Product extends CommonObject $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $this->packaging = $obj->packaging; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $this->packaging = $obj->packaging; + } $result = $obj->fk_product; return $result; } else { @@ -2184,10 +2203,8 @@ class Product extends CommonObject } // Load multiprices array - if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($ignore_price_load)) // prices per segment - { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($ignore_price_load)) { // prices per segment + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; @@ -2211,49 +2228,47 @@ class Product extends CommonObject // Price by quantity /* - $this->prices_by_qty[$i]=$result["price_by_qty"]; - $this->prices_by_qty_id[$i]=$result["rowid"]; - // Récuperation de la liste des prix selon qty si flag positionné - if ($this->prices_by_qty[$i] == 1) - { - $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; - $sql.= " ORDER BY quantity ASC"; - $resultat=array(); - $resql = $this->db->query($sql); - if ($resql) - { - $ii=0; - while ($result= $this->db->fetch_array($resql)) { - $resultat[$ii]=array(); - $resultat[$ii]["rowid"]=$result["rowid"]; - $resultat[$ii]["price"]= $result["price"]; - $resultat[$ii]["unitprice"]= $result["unitprice"]; - $resultat[$ii]["quantity"]= $result["quantity"]; - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; - $resultat[$ii]["remise"]= $result["remise"]; // deprecated - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; - $ii++; - } - $this->prices_by_qty_list[$i]=$resultat; - } - else - { - dol_print_error($this->db); - return -1; - } - }*/ + $this->prices_by_qty[$i]=$result["price_by_qty"]; + $this->prices_by_qty_id[$i]=$result["rowid"]; + // Récuperation de la liste des prix selon qty si flag positionné + if ($this->prices_by_qty[$i] == 1) + { + $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; + $sql.= " ORDER BY quantity ASC"; + $resultat=array(); + $resql = $this->db->query($sql); + if ($resql) + { + $ii=0; + while ($result= $this->db->fetch_array($resql)) { + $resultat[$ii]=array(); + $resultat[$ii]["rowid"]=$result["rowid"]; + $resultat[$ii]["price"]= $result["price"]; + $resultat[$ii]["unitprice"]= $result["unitprice"]; + $resultat[$ii]["quantity"]= $result["quantity"]; + $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $resultat[$ii]["remise"]= $result["remise"]; // deprecated + $resultat[$ii]["price_base_type"]= $result["price_base_type"]; + $ii++; + } + $this->prices_by_qty_list[$i]=$resultat; + } + else + { + dol_print_error($this->db); + return -1; + } + }*/ } else { $this->error = $this->db->lasterror; return -1; } } - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && empty($ignore_price_load)) // prices per customers - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && empty($ignore_price_load)) { // prices per customers // Nothing loaded by default. List may be very long. - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) && empty($ignore_price_load)) // prices per quantity - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) && empty($ignore_price_load)) { // prices per quantity $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; @@ -2298,10 +2313,8 @@ class Product extends CommonObject $this->error = $this->db->lasterror; return -1; } - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity - { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) { // prices per customer and quantity + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; @@ -2439,7 +2452,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action); - if ($reshook > 0) $this->stats_mo = $hookmanager->resArray['stats_mo']; + if ($reshook > 0) { + $this->stats_mo = $hookmanager->resArray['stats_mo']; + } return 1; } @@ -2506,7 +2521,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action); - if ($reshook > 0) $this->stats_bom = $hookmanager->resArray['stats_bom']; + if ($reshook > 0) { + $this->stats_bom = $hookmanager->resArray['stats_bom']; + } return 1; } @@ -2574,7 +2591,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsCustomerProposal', $parameters, $this, $action); - if ($reshook > 0) $this->stats_propale = $hookmanager->resArray['stats_propale']; + if ($reshook > 0) { + $this->stats_propale = $hookmanager->resArray['stats_propale']; + } return 1; } else { @@ -2626,7 +2645,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsSupplierProposal', $parameters, $this, $action); - if ($reshook > 0) $this->stats_proposal_supplier = $hookmanager->resArray['stats_proposal_supplier']; + if ($reshook > 0) { + $this->stats_proposal_supplier = $hookmanager->resArray['stats_proposal_supplier']; + } return 1; } else { @@ -2728,7 +2749,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); $reshook = $hookmanager->executeHooks('loadStatsCustomerOrder', $parameters, $this, $action); - if ($reshook > 0) $this->stats_commande = $hookmanager->resArray['stats_commande']; + if ($reshook > 0) { + $this->stats_commande = $hookmanager->resArray['stats_commande']; + } return 1; } else { $this->error = $this->db->error(); @@ -2782,7 +2805,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); $reshook = $hookmanager->executeHooks('loadStatsSupplierOrder', $parameters, $this, $action); - if ($reshook > 0) $this->stats_commande_fournisseur = $hookmanager->resArray['stats_commande_fournisseur']; + if ($reshook > 0) { + $this->stats_commande_fournisseur = $hookmanager->resArray['stats_commande_fournisseur']; + } return 1; } else { @@ -2831,7 +2856,9 @@ class Product extends CommonObject if ($filtrestatut <> '') { $sql .= " AND c.fk_statut IN (".$this->db->sanitize($filtrestatut).")"; } - if (!empty($filterShipmentStatus)) $sql .= " AND e.fk_statut IN (".$this->db->sanitize($filterShipmentStatus).")"; + if (!empty($filterShipmentStatus)) { + $sql .= " AND e.fk_statut IN (".$this->db->sanitize($filterShipmentStatus).")"; + } $result = $this->db->query($sql); if ($result) { @@ -2864,7 +2891,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock, 'filterShipmentStatus' => $filterShipmentStatus); $reshook = $hookmanager->executeHooks('loadStatsSending', $parameters, $this, $action); - if ($reshook > 0) $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } return 1; } else { @@ -2919,7 +2948,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); $reshook = $hookmanager->executeHooks('loadStatsReception', $parameters, $this, $action); - if ($reshook > 0) $this->stats_reception = $hookmanager->resArray['stats_reception']; + if ($reshook > 0) { + $this->stats_reception = $hookmanager->resArray['stats_reception']; + } return 1; } else { @@ -3003,12 +3034,18 @@ class Product extends CommonObject } // Clean data - if ($this->stats_mrptoconsume['qty'] < 0) $this->stats_mrptoconsume['qty'] = 0; - if ($this->stats_mrptoproduce['qty'] < 0) $this->stats_mrptoproduce['qty'] = 0; + if ($this->stats_mrptoconsume['qty'] < 0) { + $this->stats_mrptoconsume['qty'] = 0; + } + if ($this->stats_mrptoproduce['qty'] < 0) { + $this->stats_mrptoproduce['qty'] = 0; + } $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); $reshook = $hookmanager->executeHooks('loadStatsInProduction', $parameters, $this, $action); - if ($reshook > 0) $this->stats_mrptoproduce = $hookmanager->resArray['stats_mrptoproduce']; + if ($reshook > 0) { + $this->stats_mrptoproduce = $hookmanager->resArray['stats_mrptoproduce']; + } return 1; } else { @@ -3080,7 +3117,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsContract', $parameters, $this, $action); - if ($reshook > 0) $this->stats_contrat = $hookmanager->resArray['stats_contrat']; + if ($reshook > 0) { + $this->stats_contrat = $hookmanager->resArray['stats_contrat']; + } return 1; } else { @@ -3152,7 +3191,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsCustomerInvoice', $parameters, $this, $action); - if ($reshook > 0) $this->stats_facture = $hookmanager->resArray['stats_facture']; + if ($reshook > 0) { + $this->stats_facture = $hookmanager->resArray['stats_facture']; + } return 1; } else { @@ -3203,7 +3244,9 @@ class Product extends CommonObject $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsSupplierInvoice', $parameters, $this, $action); - if ($reshook > 0) $this->stats_facture_fournisseur = $hookmanager->resArray['stats_facture_fournisseur']; + if ($reshook > 0) { + $this->stats_facture_fournisseur = $hookmanager->resArray['stats_facture_fournisseur']; + } return 1; } else { @@ -3230,8 +3273,7 @@ class Product extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $arr = $this->db->fetch_array($resql); $keyfortab = (string) $arr[1]; if ($year == -1) { @@ -3262,8 +3304,7 @@ class Product extends CommonObject $result = array(); - for ($j = 0; $j < 12; $j++) - { + for ($j = 0; $j < 12; $j++) { // $ids is 'D', 'N', 'O', 'S', ... (First letter of month in user language) $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, 1970), "%b"), 1, 'right', 'UTF-8', 1)); @@ -3912,8 +3953,10 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql .= " WHERE fk_soc = ".$id_fourn; - if ($ref_fourn) { $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; - } else { $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; + if ($ref_fourn) { + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; + } else { + $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } $sql .= " AND quantity = ".$quantity; $sql .= " AND fk_product = ".$this->id; @@ -3986,8 +4029,7 @@ class Product extends CommonObject if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $list[$i] = $obj->fk_soc; $i++; @@ -4129,16 +4171,16 @@ class Product extends CommonObject // les fournisseurs /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" - . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" - . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" - . " FROM ".MAIN_DB_PREFIX."product_fournisseur" - . " WHERE fk_product = ".$fromId; + . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" + . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" + . " FROM ".MAIN_DB_PREFIX."product_fournisseur" + . " WHERE fk_product = ".$fromId; - if ( ! $this->db->query($sql ) ) - { - $this->db->rollback(); - return -1; - }*/ + if ( ! $this->db->query($sql ) ) + { + $this->db->rollback(); + return -1; + }*/ // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; @@ -4177,21 +4219,22 @@ class Product extends CommonObject $tmpproduct = null; //var_dump($prod); - foreach ($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product - { - if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child - { + foreach ($prod as $id_product => $desc_pere) { // $id_product is 0 (first call starting with root top) or an id of a sub_product + if (is_array($desc_pere)) { // If desc_pere is an array, this means it's a child $id = (!empty($desc_pere[0]) ? $desc_pere[0] : ''); $nb = (!empty($desc_pere[1]) ? $desc_pere[1] : ''); $type = (!empty($desc_pere[2]) ? $desc_pere[2] : ''); $label = (!empty($desc_pere[3]) ? $desc_pere[3] : ''); $incdec = !empty($desc_pere[4]) ? $desc_pere[4] : 0; - if ($multiply < 1) { $multiply = 1; + if ($multiply < 1) { + $multiply = 1; } //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; - if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. + if (is_null($tmpproduct)) { + $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. + } $tmpproduct->fetch($id); // Load product to get ->ref $tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel //$this->fetch($id); // Load product to get ->ref @@ -4269,7 +4312,9 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) { $nb = $obj->nb; } + if ($obj) { + $nb = $obj->nb; + } } else { return -1; } @@ -4291,7 +4336,8 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) { $nb = $obj->nb; + if ($obj) { + $nb = $obj->nb; } } @@ -4386,17 +4432,18 @@ class Product extends CommonObject dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); - if ($level == 1) { $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly + if ($level == 1) { + $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly } // Protection against infinite loop - if ($level > 30) { return array(); + if ($level > 30) { + return array(); } $res = $this->db->query($sql); if ($res) { $prods = array(); - while ($rec = $this->db->fetch_array($res)) - { + while ($rec = $this->db->fetch_array($res)) { if (!empty($alreadyfound[$rec['rowid']])) { dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); continue; @@ -4414,8 +4461,7 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1); - foreach ($listofchilds as $keyChild => $valueChild) - { + foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; } } @@ -4440,12 +4486,10 @@ class Product extends CommonObject // phpcs:enable $parent = array(); - foreach ($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product - { + foreach ($this->getChildsArbo($this->id) as $keyChild => $valueChild) { // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product $parent[$this->label][$keyChild] = $valueChild; } - foreach ($parent as $key => $value) // key=label, value is array of childs - { + foreach ($parent as $key => $value) { // key=label, value is array of childs $this->sousprods[$key] = $value; } } @@ -4507,8 +4551,7 @@ class Product extends CommonObject $label .= '<br><b>'.$langs->trans('BarCode').':</b> '.$this->barcode; } - if ($this->type == Product::TYPE_PRODUCT) - { + if ($this->type == Product::TYPE_PRODUCT) { if ($this->weight) { $label .= "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); } @@ -4522,7 +4565,9 @@ class Product extends CommonObject if ($this->height) { $labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Height").'</b>: '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } - if ($labelsize) $label .= "<br>".$labelsize; + if ($labelsize) { + $label .= "<br>".$labelsize; + } $labelsurfacevolume = ""; if ($this->surface) { @@ -4531,7 +4576,9 @@ class Product extends CommonObject if ($this->volume) { $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } - if ($labelsurfacevolume) $label .= "<br>".$labelsurfacevolume; + if ($labelsurfacevolume) { + $label .= "<br>".$labelsurfacevolume; + } } if (!empty($conf->accounting->enabled) && $this->status) { @@ -4573,9 +4620,11 @@ class Product extends CommonObject 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 ($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'; + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; } } @@ -4584,8 +4633,7 @@ class Product extends CommonObject $linkend = '</a>'; $result .= $linkstart; - if ($withpicto) - { + if ($withpicto) { if ($this->type == Product::TYPE_PRODUCT) { $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } @@ -4650,17 +4698,16 @@ class Product extends CommonObject */ public function getLibStatut($mode = 0, $type = 0) { - switch ($type) - { + switch ($type) { case 0: - return $this->LibStatut($this->status, $mode, $type); + return $this->LibStatut($this->status, $mode, $type); case 1: - return $this->LibStatut($this->status_buy, $mode, $type); + return $this->LibStatut($this->status_buy, $mode, $type); case 2: - return $this->LibStatut($this->status_batch, $mode, $type); + return $this->LibStatut($this->status_batch, $mode, $type); default: //Simulate previous behavior but should return an error string - return $this->LibStatut($this->status_buy, $mode, $type); + return $this->LibStatut($this->status_buy, $mode, $type); } } @@ -4681,12 +4728,12 @@ class Product extends CommonObject $labelStatus = $labelStatusShort = ''; $langs->load('products'); - if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); + if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); } if ($type == 2) { - switch ($mode) - { + switch ($mode) { case 0: $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : $langs->trans('ProductStatusOnBatch')); return dolGetStatus($label); @@ -4911,8 +4958,7 @@ class Product extends CommonObject $num = $this->db->num_rows($result); $i = 0; if ($num > 0) { - while ($i < $num) - { + while ($i < $num) { $row = $this->db->fetch_object($result); $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; @@ -4960,14 +5006,14 @@ class Product extends CommonObject //dol_syslog("load_virtual_stock"); - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { $result = $this->load_stats_commande(0, '1,2', 1); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_commande_client = $this->stats_commande['qty']; } - if (!empty($conf->expedition->enabled)) - { + if (!empty($conf->expedition->enabled)) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $filterShipmentStatus = ''; if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { @@ -4976,37 +5022,49 @@ class Product extends CommonObject $filterShipmentStatus = Expedition::STATUS_CLOSED; } $result = $this->load_stats_sending(0, '1,2', 1, $filterShipmentStatus); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_sending_client = $this->stats_expedition['qty']; } - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) - { + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { $filterStatus = '1,2,3,4'; - if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; + if (isset($includedraftpoforvirtual)) { + $filterStatus = '0,'.$filterStatus; + } $result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { $filterStatus = '4'; - if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; + if (isset($includedraftpoforvirtual)) { + $filterStatus = '0,'.$filterStatus; + } $result = $this->load_stats_reception(0, $filterStatus, 1); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_reception_fournisseur = $this->stats_reception['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { $filterStatus = '4'; - if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; + if (isset($includedraftpoforvirtual)) { + $filterStatus = '0,'.$filterStatus; + } $result = $this->load_stats_reception(0, $filterStatus, 1); // Use same tables than when module reception is not used. - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_reception_fournisseur = $this->stats_reception['qty']; } - if (!empty($conf->mrp->enabled)) - { + if (!empty($conf->mrp->enabled)) { $result = $this->load_stats_inproduction(0, '1,2', 1); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_inproduction = $this->stats_mrptoproduce['qty'] - $this->stats_mrptoconsume['qty']; } @@ -5039,7 +5097,9 @@ class Product extends CommonObject $parameters = array('id'=>$this->id, 'includedraftpoforvirtual' => $includedraftpoforvirtual); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); - if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique']; + if ($reshook > 0) { + $this->stock_theorique = $hookmanager->resArray['stock_theorique']; + } return 1; } @@ -5064,8 +5124,7 @@ class Product extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $result[] = array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); $i++; @@ -5153,8 +5212,7 @@ class Product extends CommonObject if (file_exists($dir_osencoded)) { $handle = opendir($dir_osencoded); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { + while (($file = readdir($handle)) !== false) { if (!utf8_check($file)) { $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory } @@ -5187,9 +5245,9 @@ class Product extends CommonObject $dir_osencoded = dol_osencode($dir); $handle = @opendir($dir_osencoded); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (!utf8_check($file)) { $file = utf8_encode($file); // readdir returns ISO + while (($file = readdir($handle)) !== false) { + if (!utf8_check($file)) { + $file = utf8_encode($file); // readdir returns ISO } if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) { $nbphoto++; @@ -5206,14 +5264,17 @@ class Product extends CommonObject // Objet $obj = array(); $obj['photo'] = $photo; - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; - } else { $obj['photo_vignette'] = ""; + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { + $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + } else { + $obj['photo_vignette'] = ""; } $tabobj[$nbphoto - 1] = $obj; // On continue ou on arrete de boucler ? - if ($nbmax && $nbphoto >= $nbmax) { break; + if ($nbmax && $nbphoto >= $nbmax) { + break; } } } @@ -5300,10 +5361,11 @@ class Product extends CommonObject $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql)) - { - if ($obj->fk_product_type == 1) { $this->nb["services"] = $obj->nb; - } else { $this->nb["products"] = $obj->nb; + while ($obj = $this->db->fetch_object($resql)) { + if ($obj->fk_product_type == 1) { + $this->nb["services"] = $obj->nb; + } else { + $this->nb["products"] = $obj->nb; } } $this->db->free($resql); @@ -5352,10 +5414,10 @@ class Product extends CommonObject $result = ''; if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - foreach ($dirsociete as $dirroot) - { + foreach ($dirsociete as $dirroot) { $res = dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); - if ($res) { break; + if ($res) { + break; } } $var = $conf->global->BARCODE_PRODUCT_ADDON_NUM; @@ -5479,8 +5541,7 @@ class Product extends CommonObject $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', ''); if (is_array($product_fourn_list) && count($product_fourn_list) > 0) { - foreach ($product_fourn_list as $productfourn) - { + foreach ($product_fourn_list as $productfourn) { if ($productfourn->fourn_unitprice > $maxpricesupplier) { $maxpricesupplier = $productfourn->fourn_unitprice; } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index a97437f6a45..ac21ec166dc 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -107,15 +107,15 @@ class Productbatch extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); } // Commit or rollback - if ($error) - { + if ($error) { $this->db->rollback(); return -1 * $error; } else { @@ -155,10 +155,8 @@ class Productbatch extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -197,8 +195,7 @@ class Productbatch extends CommonObject $this->cleanParam(); // TODO Check qty is ok for stock move. Negative may not be allowed. - if ($this->qty < 0) - { + if ($this->qty < 0) { } // Update request @@ -215,13 +212,13 @@ class Productbatch extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -247,21 +244,20 @@ class Productbatch extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element.""; $sql .= " WHERE rowid=".$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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -288,7 +284,7 @@ class Productbatch extends CommonObject $object = new Productbatch($this->db); - $this->db->begin(); + $this->db->begin(); // Load source object $object->fetch($fromid); @@ -303,22 +299,19 @@ class Productbatch extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (!$error) - { + if (!$error) { } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -353,10 +346,18 @@ class Productbatch extends CommonObject */ private function cleanParam() { - if (isset($this->fk_product_stock)) $this->fk_product_stock = (int) trim($this->fk_product_stock); - if (isset($this->batch)) $this->batch = trim($this->batch); - if (isset($this->qty)) $this->qty = (float) trim($this->qty); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->fk_product_stock)) { + $this->fk_product_stock = (int) trim($this->fk_product_stock); + } + if (isset($this->batch)) { + $this->batch = trim($this->batch); + } + if (isset($this->qty)) { + $this->qty = (float) trim($this->qty); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } } /** @@ -385,19 +386,25 @@ class Productbatch extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; $sql .= " WHERE fk_product_stock=".$fk_product_stock; - if (!empty($eatby)) array_push($where, " eatby = '".$this->db->idate($eatby)."'"); // deprecated - if (!empty($sellby)) array_push($where, " sellby = '".$this->db->idate($sellby)."'"); // deprecated + if (!empty($eatby)) { + array_push($where, " eatby = '".$this->db->idate($eatby)."'"); // deprecated + } + if (!empty($sellby)) { + array_push($where, " sellby = '".$this->db->idate($sellby)."'"); // deprecated + } - if (!empty($batch_number)) $sql .= " AND batch = '".$this->db->escape($batch_number)."'"; + if (!empty($batch_number)) { + $sql .= " AND batch = '".$this->db->escape($batch_number)."'"; + } - if (!empty($where)) $sql .= " AND (".implode(" OR ", $where).")"; + if (!empty($where)) { + $sql .= " AND (".implode(" OR ", $where).")"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -414,7 +421,7 @@ class Productbatch extends CommonObject return 1; } else { - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -441,27 +448,26 @@ class Productbatch extends CommonObject $sql .= " t.batch,"; $sql .= " t.qty,"; $sql .= " t.import_key"; - if ($fk_product > 0) - { + if ($fk_product > 0) { $sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; // TODO May add extrafields to ? } $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as t"; - if ($fk_product > 0) - { + if ($fk_product > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.fk_product = ".$fk_product." AND pl.batch = t.batch"; // TODO May add extrafields to ? } $sql .= " WHERE fk_product_stock=".$fk_product_stock; - if ($with_qty) $sql .= " AND t.qty <> 0"; + if ($with_qty) { + $sql .= " AND t.qty <> 0"; + } dol_syslog("productbatch::findAll", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $tmp = new Productbatch($db); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index af767c98cd6..90c958a3e43 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -107,36 +107,51 @@ class Productcustomerprice extends CommonObject // Clean parameters - if (isset($this->entity)) + if (isset($this->entity)) { $this->entity = trim($this->entity); - if (isset($this->fk_product)) + } + if (isset($this->fk_product)) { $this->fk_product = trim($this->fk_product); - if (isset($this->fk_soc)) + } + if (isset($this->fk_soc)) { $this->fk_soc = trim($this->fk_soc); - if (isset($this->ref_customer)) + } + if (isset($this->ref_customer)) { $this->ref_customer = trim($this->ref_customer); - if (isset($this->price)) + } + if (isset($this->price)) { $this->price = trim($this->price); - if (isset($this->price_ttc)) + } + if (isset($this->price_ttc)) { $this->price_ttc = trim($this->price_ttc); - if (isset($this->price_min)) + } + if (isset($this->price_min)) { $this->price_min = trim($this->price_min); - if (isset($this->price_min_ttc)) + } + if (isset($this->price_min_ttc)) { $this->price_min_ttc = trim($this->price_min_ttc); - if (isset($this->price_base_type)) + } + if (isset($this->price_base_type)) { $this->price_base_type = trim($this->price_base_type); - if (isset($this->tva_tx)) + } + if (isset($this->tva_tx)) { $this->tva_tx = trim($this->tva_tx); - if (isset($this->recuperableonly)) + } + if (isset($this->recuperableonly)) { $this->recuperableonly = trim($this->recuperableonly); - if (isset($this->localtax1_tx)) + } + if (isset($this->localtax1_tx)) { $this->localtax1_tx = trim($this->localtax1_tx); - if (isset($this->localtax2_tx)) + } + if (isset($this->localtax2_tx)) { $this->localtax2_tx = trim($this->localtax2_tx); - if (isset($this->fk_user)) + } + if (isset($this->fk_user)) { $this->fk_user = trim($this->fk_user); - if (isset($this->import_key)) + } + if (isset($this->import_key)) { $this->import_key = trim($this->import_key); + } // Check parameters // Put here code to add control on parameters values @@ -342,8 +357,12 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if (empty($sortfield)) $sortfield = "t.rowid"; - if (empty($sortorder)) $sortorder = "DESC"; + if (empty($sortfield)) { + $sortfield = "t.rowid"; + } + if (empty($sortorder)) { + $sortorder = "DESC"; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -394,7 +413,9 @@ class Productcustomerprice extends CommonObject } } $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); + } dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); $resql = $this->db->query($sql); @@ -457,8 +478,12 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if (!empty($sortfield)) $sortfield = "t.rowid"; - if (!empty($sortorder)) $sortorder = "DESC"; + if (!empty($sortfield)) { + $sortfield = "t.rowid"; + } + if (!empty($sortorder)) { + $sortorder = "DESC"; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -493,8 +518,7 @@ class Productcustomerprice extends CommonObject // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { - if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year - { + if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; @@ -505,7 +529,9 @@ class Productcustomerprice extends CommonObject } $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); + } dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG); $resql = $this->db->query($sql); @@ -566,36 +592,51 @@ class Productcustomerprice extends CommonObject // Clean parameters - if (isset($this->entity)) + if (isset($this->entity)) { $this->entity = trim($this->entity); - if (isset($this->fk_product)) + } + if (isset($this->fk_product)) { $this->fk_product = trim($this->fk_product); - if (isset($this->fk_soc)) + } + if (isset($this->fk_soc)) { $this->fk_soc = trim($this->fk_soc); - if (isset($this->ref_customer)) + } + if (isset($this->ref_customer)) { $this->ref_customer = trim($this->ref_customer); - if (isset($this->price)) + } + if (isset($this->price)) { $this->price = trim($this->price); - if (isset($this->price_ttc)) + } + if (isset($this->price_ttc)) { $this->price_ttc = trim($this->price_ttc); - if (isset($this->price_min)) + } + if (isset($this->price_min)) { $this->price_min = trim($this->price_min); - if (isset($this->price_min_ttc)) + } + if (isset($this->price_min_ttc)) { $this->price_min_ttc = trim($this->price_min_ttc); - if (isset($this->price_base_type)) + } + if (isset($this->price_base_type)) { $this->price_base_type = trim($this->price_base_type); - if (isset($this->tva_tx)) + } + if (isset($this->tva_tx)) { $this->tva_tx = trim($this->tva_tx); - if (isset($this->recuperableonly)) + } + if (isset($this->recuperableonly)) { $this->recuperableonly = trim($this->recuperableonly); - if (isset($this->localtax1_tx)) + } + if (isset($this->localtax1_tx)) { $this->localtax1_tx = trim($this->localtax1_tx); - if (isset($this->localtax2_tx)) + } + if (isset($this->localtax2_tx)) { $this->localtax2_tx = trim($this->localtax2_tx); - if (isset($this->fk_user)) + } + if (isset($this->fk_user)) { $this->fk_user = trim($this->fk_user); - if (isset($this->import_key)) + } + if (isset($this->import_key)) { $this->import_key = trim($this->import_key); + } // Check parameters // Put here code to add a control on parameters values @@ -722,11 +763,12 @@ class Productcustomerprice extends CommonObject $this->errors [] = "Error ".$this->db->lasterror(); } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('PRODUCT_CUSTOMER_PRICE_UPDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index c917201b645..dd45651b54e 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -79,12 +79,24 @@ class Propalmergepdfproduct extends CommonObject // Clean parameters - if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); - if (isset($this->file_name)) $this->file_name = trim($this->file_name); - if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author); - if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod); - if (isset($this->lang)) $this->lang = trim($this->lang); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->fk_product)) { + $this->fk_product = trim($this->fk_product); + } + if (isset($this->file_name)) { + $this->file_name = trim($this->file_name); + } + if (isset($this->fk_user_author)) { + $this->fk_user_author = trim($this->fk_user_author); + } + if (isset($this->fk_user_mod)) { + $this->fk_user_mod = trim($this->fk_user_mod); + } + if (isset($this->lang)) { + $this->lang = trim($this->lang); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } @@ -120,20 +132,19 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product"); } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -174,10 +185,8 @@ class Propalmergepdfproduct extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -197,7 +206,7 @@ class Propalmergepdfproduct extends CommonObject return 1; } else { - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -237,10 +246,8 @@ class Propalmergepdfproduct extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { while ($obj = $this->db->fetch_object($resql)) { $line = new PropalmergepdfproductLine(); @@ -290,10 +297,18 @@ class Propalmergepdfproduct extends CommonObject // Clean parameters - if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); - if (isset($this->file_name)) $this->file_name = trim($this->file_name); - if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod); - if (isset($this->lang)) $this->lang = trim($this->lang); + if (isset($this->fk_product)) { + $this->fk_product = trim($this->fk_product); + } + if (isset($this->file_name)) { + $this->file_name = trim($this->file_name); + } + if (isset($this->fk_user_mod)) { + $this->fk_user_mod = trim($this->fk_user_mod); + } + if (isset($this->lang)) { + $this->lang = trim($this->lang); + } // Check parameters // Put here code to add a control on parameters values @@ -315,13 +330,13 @@ class Propalmergepdfproduct extends CommonObject dol_syslog(__METHOD__, 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -334,13 +349,13 @@ class Propalmergepdfproduct extends CommonObject } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -348,21 +363,20 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql .= " WHERE rowid=".$this->id; dol_syslog(__METHOD__, 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -392,8 +406,7 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql .= " WHERE fk_product=".$product_id; @@ -403,14 +416,14 @@ class Propalmergepdfproduct extends CommonObject dol_syslog(__METHOD__, 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -437,21 +450,20 @@ class Propalmergepdfproduct extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; $sql .= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'"; dol_syslog(__METHOD__, 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -493,22 +505,19 @@ class Propalmergepdfproduct extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (!$error) - { + if (!$error) { } unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 620bd69f60a..08dae5169e2 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -45,15 +45,16 @@ $key = GETPOST('key'); $parent = GETPOST('parent'); // Security check -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); $objectid = 0; -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $objectid = $object->id; $id = $object->id; @@ -64,21 +65,19 @@ if ($id > 0 || !empty($ref)) * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} // Add subproduct to product -if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer)) -{ +if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer)) { $error = 0; $maxprod = GETPOST("max_prod", 'int'); - for ($i = 0; $i < $maxprod; $i++) - { + for ($i = 0; $i < $maxprod; $i++) { $qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS'); - if ($qty > 0) - { - if ($object->add_sousproduit($id, GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')) > 0) - { + if ($qty > 0) { + if ($object->add_sousproduit($id, GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')) > 0) { //var_dump($i.' '.GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')); $action = 'edit'; } else { @@ -91,8 +90,7 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se } } } else { - if ($object->del_sousproduit($id, GETPOST("prod_id_".$i, 'int')) > 0) - { + if ($object->del_sousproduit($id, GETPOST("prod_id_".$i, 'int')) > 0) { $action = 'edit'; } else { $error++; @@ -102,20 +100,19 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se } } - if (!$error) - { + if (!$error) { header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } -} elseif ($action === 'save_composed_product') -{ +} elseif ($action === 'save_composed_product') { $TProduct = GETPOST('TProduct', 'array'); - if (!empty($TProduct)) - { - foreach ($TProduct as $id_product => $row) - { - if ($row['qty'] > 0) $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0); - else $object->del_sousproduit($id, $id_product); + if (!empty($TProduct)) { + foreach ($TProduct as $id_product => $row) { + if ($row['qty'] > 0) { + $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0); + } else { + $object->del_sousproduit($id, $id_product); + } } setEventMessages('RecordSaved', null); } @@ -132,17 +129,20 @@ $productstatic = new Product($db); $form = new Form($db); // action recherche des produits par mot-cle et/ou par categorie -if ($action == 'search') -{ +if ($action == 'search') { $current_lang = $langs->getDefaultLang(); $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.tms as datem, p.tobatch'; $sql .= ', p.tosell as status, p.tobuy as status_buy'; - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ', pl.label as labelm, pl.description as descriptionm'; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $sql .= ', pl.label as labelm, pl.description as descriptionm'; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; - if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; + } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($key != "") { // For natural search @@ -186,41 +186,37 @@ $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); print dol_get_fiche_head($head, 'subproduct', $titre, -1, $picto); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { /* * Fiche en mode edition */ - if ($user->rights->produit->lire || $user->rights->service->lire) - { + if ($user->rights->produit->lire || $user->rights->service->lire) { $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 0); - if ($object->type != Product::TYPE_SERVICE || !empty($conf->global->STOCK_SUPPORTS_SERVICES) || empty($conf->global->PRODUIT_MULTIPRICES)) - { + if ($object->type != Product::TYPE_SERVICE || !empty($conf->global->STOCK_SUPPORTS_SERVICES) || empty($conf->global->PRODUIT_MULTIPRICES)) { print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent tableforfield">'; // Nature - if ($object->type != Product::TYPE_SERVICE) - { + if ($object->type != Product::TYPE_SERVICE) { print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td>'; print $object->getLibFinished(); print '</td></tr>'; } - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price print '<tr><td class="titlefield">'.$langs->trans("SellingPrice").'</td><td>'; - if ($object->price_base_type == 'TTC') - { + if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price).' '.$langs->trans($object->price_base_type ? $object->price_base_type : 'HT'); @@ -229,8 +225,7 @@ if ($id > 0 || !empty($ref)) // Price minimum print '<tr><td>'.$langs->trans("MinPrice").'</td><td>'; - if ($object->price_base_type == 'TTC') - { + if ($object->price_base_type == 'TTC') { print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price_min).' '.$langs->trans($object->price_base_type ? $object->price_base_type : 'HT'); @@ -310,7 +305,9 @@ if ($id > 0 || !empty($ref)) print '<td>'.$langs->trans('Label').'</td>'; print '<td class="right" colspan="2">'.$langs->trans('MinSupplierPrice').'</td>'; print '<td class="right" colspan="2">'.$langs->trans('MinCustomerPrice').'</td>'; - if (!empty($conf->stock->enabled)) print '<td class="right">'.$langs->trans('Stock').'</td>'; + if (!empty($conf->stock->enabled)) { + print '<td class="right">'.$langs->trans('Stock').'</td>'; + } print '<td class="center">'.$langs->trans('Qty').'</td>'; print '<td class="center">'.$langs->trans('ComposedProductIncDecStock').'</td>'; print '</tr>'."\n"; @@ -331,11 +328,13 @@ if ($id > 0 || !empty($ref)) // Best buying price print '<td class="right">'; - if ($product_fourn->find_min_price_product_fournisseur($productstatic->id) > 0) - { + if ($product_fourn->find_min_price_product_fournisseur($productstatic->id) > 0) { print $langs->trans("BuyingPriceMinShort").': '; - if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(0, 0); - else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } + if ($product_fourn->product_fourn_price_id > 0) { + print $product_fourn->display_price_product_fournisseur(0, 0); + } else { + print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; + } } print '</td>'; @@ -354,8 +353,7 @@ if ($id > 0 || !empty($ref)) // Best selling price $pricesell = $productstatic->price; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $pricesell = 'Variable'; } else { $totallinesell = price2num($value['nb'] * ($pricesell), 'MT'); @@ -363,16 +361,20 @@ if ($id > 0 || !empty($ref)) } print '<td class="right" colspan="2">'; print ($notdefined ? '' : ($value['nb'] > 1 ? $value['nb'].'x' : '')); - if (is_numeric($pricesell)) print price($pricesell, '', '', 0, 0, -1, $conf->currency); - else print $langs->trans($pricesell); + if (is_numeric($pricesell)) { + print price($pricesell, '', '', 0, 0, -1, $conf->currency); + } else { + print $langs->trans($pricesell); + } print '</td>'; // Stock - if (!empty($conf->stock->enabled)) print '<td class="right">'.$value['stock'].'</td>'; // Real stock + if (!empty($conf->stock->enabled)) { + print '<td class="right">'.$value['stock'].'</td>'; // Real stock + } // Qty + IncDec - if ($user->rights->produit->creer || $user->rights->service->creer) - { + if ($user->rights->produit->creer || $user->rights->service->creer) { print '<td class="center"><input type="text" value="'.$nb_of_subproduct.'" name="TProduct['.$productstatic->id.'][qty]" size="4" class="right" /></td>'; print '<td class="center"><input type="checkbox" name="TProduct['.$productstatic->id.'][incdec]" value="1" '.($value['incdec'] == 1 ? 'checked' : '').' /></td>'; } else { @@ -383,14 +385,18 @@ if ($id > 0 || !empty($ref)) print '</tr>'."\n"; } else { $hide = ''; - if (empty($conf->global->PRODUCT_SHOW_SUB_SUB_PRODUCTS)) $hide = ' hideobject'; // By default, we do not show this. It makes screen very difficult to understand + if (empty($conf->global->PRODUCT_SHOW_SUB_SUB_PRODUCTS)) { + $hide = ' hideobject'; // By default, we do not show this. It makes screen very difficult to understand + } print '<tr class="oddeven'.$hide.'" id="sub-'.$value['id_parent'].'">'; //$productstatic->ref=$value['label']; $productstatic->ref = $value['ref']; print '<td>'; - for ($i = 0; $i < $value['level']; $i++) print ' &nbsp; &nbsp; '; // Add indentation + for ($i = 0; $i < $value['level']; $i++) { + print ' &nbsp; &nbsp; '; // Add indentation + } print $productstatic->getNomUrl(1, 'composition').'</td>'; print '<td>'.$productstatic->label.'</td>'; @@ -401,7 +407,9 @@ if ($id > 0 || !empty($ref)) print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>'; - if (!empty($conf->stock->enabled)) print '<td></td>'; // Real stock + if (!empty($conf->stock->enabled)) { + print '<td></td>'; // Real stock + } print '<td class="center">'.$value['nb'].'</td>'; print '<td>&nbsp;</td>'; @@ -419,7 +427,9 @@ if ($id > 0 || !empty($ref)) print '</td>'; print '<td class="liste_total right">'; - if ($atleastonenotdefined) print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; + if ($atleastonenotdefined) { + print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; + } print ($atleastonenotdefined ? '' : price($total, '', '', 0, 0, -1, $conf->currency)); print '</td>'; @@ -429,23 +439,28 @@ if ($id > 0 || !empty($ref)) print '</td>'; print '<td class="liste_total right">'; - if ($atleastonenotdefined) print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; + if ($atleastonenotdefined) { + print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; + } print ($atleastonenotdefined ? '' : price($totalsell, '', '', 0, 0, -1, $conf->currency)); print '</td>'; // Stock - if (!empty($conf->stock->enabled)) print '<td class="liste_total right">&nbsp;</td>'; + if (!empty($conf->stock->enabled)) { + print '<td class="liste_total right">&nbsp;</td>'; + } print '<td class="right" colspan="2">'; - if ($user->rights->produit->creer || $user->rights->service->creer) - { + if ($user->rights->produit->creer || $user->rights->service->creer) { print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; } print '</td>'; print '</tr>'."\n"; } else { $colspan = 8; - if (!empty($conf->stock->enabled)) $colspan++; + if (!empty($conf->stock->enabled)) { + $colspan++; + } print '<tr class="oddeven">'; print '<td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td>'; @@ -464,12 +479,13 @@ if ($id > 0 || !empty($ref)) // Form with product to add - if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer)) - { + if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer)) { print '<br>'; $rowspan = 1; - if (!empty($conf->categorie->enabled)) $rowspan++; + if (!empty($conf->categorie->enabled)) { + $rowspan++; + } print load_fiche_titre($langs->trans("ProductToAddSearch"), '', ''); print '<form action="'.DOL_URL_ROOT.'/product/composition/card.php?id='.$id.'" method="POST">'; @@ -480,8 +496,7 @@ if ($id > 0 || !empty($ref)) print $langs->trans("KeywordFilter").': '; print '<input type="text" name="key" value="'.$key.'"> &nbsp; '; print '</div>'; - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; print '<div class="inline-block">'.$langs->trans("CategoryFilter").': '; print $form->select_all_categories(Categorie::TYPE_PRODUCT, $parent, 'parent').' &nbsp; </div>'; @@ -495,8 +510,7 @@ if ($id > 0 || !empty($ref)) // List of products - if ($action == 'search') - { + if ($action == 'search') { print '<br>'; print '<form action="'.DOL_URL_ROOT.'/product/composition/card.php?id='.$id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -510,20 +524,19 @@ if ($id > 0 || !empty($ref)) print '<th class="liste_titre right">'.$langs->trans("Qty").'</td>'; print '<th class="center">'.$langs->trans('ComposedProductIncDecStock').'</th>'; print '</tr>'; - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num == 0) print '<tr><td colspan="4">'.$langs->trans("NoMatchFound").'</td></tr>'; + if ($num == 0) { + print '<tr><td colspan="4">'.$langs->trans("NoMatchFound").'</td></tr>'; + } $MAX = 100; - while ($i < min($num, $MAX)) - { + while ($i < min($num, $MAX)) { $objp = $db->fetch_object($resql); - if ($objp->rowid != $id) - { + if ($objp->rowid != $id) { // check if a product is not already a parent product of this one $prod_arbo = new Product($db); $prod_arbo->id = $objp->rowid; @@ -560,13 +573,14 @@ if ($id > 0 || !empty($ref)) print '<td>'.$productstatic->getNomUrl(1, '', 24).'</td>'; $labeltoshow = $objp->label; - if ($conf->global->MAIN_MULTILANGS && $objp->labelm) $labeltoshow = $objp->labelm; + if ($conf->global->MAIN_MULTILANGS && $objp->labelm) { + $labeltoshow = $objp->labelm; + } print '<td>'.$labeltoshow.'</td>'; - if ($object->is_sousproduit($id, $objp->rowid)) - { + if ($object->is_sousproduit($id, $objp->rowid)) { //$addchecked = ' checked'; $qty = $object->is_sousproduit_qty; $incdec = $object->is_sousproduit_incdec; @@ -583,8 +597,9 @@ if ($id > 0 || !empty($ref)) // Inc Dec print '<td class="center">'; - if ($qty) print '<input type="checkbox" name="prod_incdec_'.$i.'" value="1" '.($incdec ? 'checked' : '').'>'; - else { + if ($qty) { + print '<input type="checkbox" name="prod_incdec_'.$i.'" value="1" '.($incdec ? 'checked' : '').'>'; + } else { // TODO Hide field and show it when setting a qty print '<input type="checkbox" name="prod_incdec_'.$i.'" value="1" checked>'; //print '<input type="checkbox" disabled name="prod_incdec_'.$i.'" value="1" checked>'; @@ -609,8 +624,7 @@ if ($id > 0 || !empty($ref)) print '</table>'; print '<input type="hidden" name="max_prod" value="'.$i.'">'; - if ($num > 0) - { + if ($num > 0) { print '<br><div class="center">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Add").'/'.$langs->trans("Update").'">'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 1de27318f84..c218d753d88 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; 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/class/html.formfile.class.php'; -if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) +if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('other', 'products')); @@ -48,7 +49,9 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -59,26 +62,36 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $object = new Product($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product'); - elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product'); + if (!empty($conf->product->enabled)) { + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product'); + } elseif (!empty($conf->service->enabled)) { + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product'); + } - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs - { - if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs + if (!empty($conf->product->enabled)) { + $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + } else { + $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + } } } $modulepart = 'produit'; @@ -92,15 +105,14 @@ $permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->rights->pr $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Delete line if product propal merge is linked to a file - if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) - { - if ($action == 'confirm_deletefile' && $confirm == 'yes') - { + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { + if ($action == 'confirm_deletefile' && $confirm == 'yes') { //extract file name $urlfile = GETPOST('urlfile', 'alpha'); $filename = basename($urlfile); @@ -118,8 +130,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } -if ($action == 'filemerge') -{ +if ($action == 'filemerge') { $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) { $filetomerge_file_array = GETPOST('filetoadd'); @@ -171,13 +182,11 @@ $form = new Form($db); $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Documents'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Documents'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -185,8 +194,7 @@ if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) llxHeader('', $title, $helpurl); -if ($object->id) -{ +if ($object->id) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -196,20 +204,20 @@ if ($object->id) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs - { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs $filearrayold = dol_dir_list($upload_dirold, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = array_merge($filearray, $filearrayold); } $totalsize = 0; - foreach ($filearray as $key => $file) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -218,7 +226,9 @@ if ($object->id) $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -241,8 +251,7 @@ if ($object->id) // Merge propal PDF document PDF files - if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) - { + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { $filetomerge = new Propalmergepdfproduct($db); if ($conf->global->MAIN_MULTILANGS) { @@ -257,14 +266,12 @@ if ($object->id) $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs - { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs $filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } // For each file build select list with PDF extention - if (count($filearray) > 0) - { + if (count($filearray) > 0) { print '<br>'; // Actual file to merge is : if (count($filetomerge->lines) > 0) { @@ -299,23 +306,18 @@ if ($object->id) print '</td></tr>'; } - foreach ($filearray as $filetoadd) - { - if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') - { + foreach ($filearray as $filetoadd) { + if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') { $checked = ''; $filename = $filetoadd['name']; - if ($conf->global->MAIN_MULTILANGS) - { - if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) - { + if ($conf->global->MAIN_MULTILANGS) { + if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $checked = ' checked '; } } else { - if (array_key_exists($filetoadd['name'], $filetomerge->lines)) - { + if (array_key_exists($filetoadd['name'], $filetomerge->lines)) { $checked = ' checked '; } } diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index 218780cce44..ce213222bb9 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -80,8 +80,12 @@ class PriceExpression $error = 0; // Clean parameters - if (isset($this->title)) $this->title = trim($this->title); - if (isset($this->expression)) $this->expression = trim($this->expression); + if (isset($this->title)) { + $this->title = trim($this->title); + } + if (isset($this->expression)) { + $this->expression = trim($this->expression); + } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; @@ -95,10 +99,11 @@ class PriceExpression dol_syslog(__METHOD__, 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); //if (! $notrigger) @@ -114,10 +119,8 @@ class PriceExpression } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -139,8 +142,7 @@ class PriceExpression public function fetch($id) { // Check parameters - if (empty($id)) - { + if (empty($id)) { $this->error = 'ErrorWrongParameters'; return -1; } @@ -151,11 +153,9 @@ class PriceExpression dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $id; $this->title = $obj->title; $this->expression = $obj->expression; @@ -184,12 +184,10 @@ class PriceExpression dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { $price_expression_obj = new PriceExpression($this->db); $price_expression_obj->id = $record["rowid"]; $price_expression_obj->title = $record["title"]; @@ -222,11 +220,9 @@ class PriceExpression dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { return (int) $obj->rowid; } else { return 0; @@ -250,8 +246,12 @@ class PriceExpression $error = 0; // Clean parameters - if (isset($this->title)) $this->title = trim($this->title); - if (isset($this->expression)) $this->expression = trim($this->expression); + if (isset($this->title)) { + $this->title = trim($this->title); + } + if (isset($this->expression)) { + $this->expression = trim($this->expression); + } // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; @@ -263,7 +263,9 @@ class PriceExpression dol_syslog(__METHOD__); $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) // { @@ -280,10 +282,8 @@ class PriceExpression // } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -325,21 +325,20 @@ class PriceExpression // } //} - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE rowid = ".$rowid; dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index fbe5956db7c..4e67b835b07 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -100,14 +100,14 @@ class PriceGlobalVariable dol_syslog(__METHOD__); $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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - if (!$notrigger) - { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -119,10 +119,8 @@ class PriceGlobalVariable } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -149,11 +147,9 @@ class PriceGlobalVariable dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $id; $this->code = $obj->code; $this->description = $obj->description; @@ -193,7 +189,9 @@ class PriceGlobalVariable dol_syslog(__METHOD__); $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) // { @@ -210,10 +208,8 @@ class PriceGlobalVariable // } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -240,10 +236,8 @@ class PriceGlobalVariable $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -254,21 +248,20 @@ class PriceGlobalVariable } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE rowid = ".$rowid; dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -302,11 +295,17 @@ class PriceGlobalVariable public function checkParameters() { // Clean parameters - if (isset($this->code)) $this->code = trim($this->code); - if (isset($this->description)) $this->description = trim($this->description); + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } // Check parameters - if (empty($this->value) || !is_numeric($this->value)) $this->value = 0; + if (empty($this->value) || !is_numeric($this->value)) { + $this->value = 0; + } } /** @@ -322,12 +321,10 @@ class PriceGlobalVariable dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { $variable_obj = new PriceGlobalVariable($this->db); $variable_obj->id = $record["rowid"]; $variable_obj->code = $record["code"]; diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 256e3525ead..eb72a8425f7 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -116,14 +116,14 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__, 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - if (!$notrigger) - { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -135,10 +135,8 @@ class PriceGlobalVariableUpdater } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -165,11 +163,9 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $id; $this->type = $obj->type; $this->description = $obj->description; @@ -217,7 +213,9 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__); $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) // { @@ -234,10 +232,8 @@ class PriceGlobalVariableUpdater // } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -277,21 +273,20 @@ class PriceGlobalVariableUpdater // } //} - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE rowid = ".$rowid; dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -345,15 +340,28 @@ class PriceGlobalVariableUpdater public function checkParameters() { // Clean parameters - if (isset($this->description)) $this->description = trim($this->description); - if (isset($this->parameters)) $this->parameters = trim($this->parameters); - else $this->parameters = ""; - if (isset($this->last_status)) $this->last_status = trim($this->last_status); + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->parameters)) { + $this->parameters = trim($this->parameters); + } else { + $this->parameters = ""; + } + if (isset($this->last_status)) { + $this->last_status = trim($this->last_status); + } // Check parameters - if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type = 0; - if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval = $this->update_min; - if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update = 0; + if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) { + $this->type = 0; + } + if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) { + $this->update_interval = $this->update_min; + } + if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) { + $this->next_update = 0; + } } /** @@ -368,12 +376,10 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { $updater_obj = new PriceGlobalVariableUpdater($this->db); $updater_obj->id = $record["rowid"]; $updater_obj->type = $record["type"]; @@ -408,12 +414,10 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $retarray = array(); - while ($record = $this->db->fetch_array($resql)) - { + while ($record = $this->db->fetch_array($resql)) { $updater_obj = new PriceGlobalVariableUpdater($this->db); $updater_obj->id = $record["rowid"]; $updater_obj->type = $record["type"]; @@ -572,13 +576,13 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -616,13 +620,13 @@ class PriceGlobalVariableUpdater dol_syslog(__METHOD__); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 47cb58c2a7f..3d28f4b6011 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -64,53 +64,49 @@ class PriceParser global $langs; $langs->load("errors"); /* - -No arg - 9, an unexpected error occured - 14, division by zero - 19, expression not found - 20, empty expression + -No arg + 9, an unexpected error occured + 14, division by zero + 19, expression not found + 20, empty expression - -1 Arg - 1, cannot assign to constant '%s' - 2, cannot redefine built-in function '%s' - 3, undefined variable '%s' in function definition - 4, illegal character '%s' - 5, unexpected '%s' - 8, unexpected operator '%s' - 10, operator '%s' lacks operand - 11, expecting '%s' - 17, undefined variable '%s' - 21, empty result '%s' - 22, negative result '%s' - 24, variable '%s' exists but has no value + -1 Arg + 1, cannot assign to constant '%s' + 2, cannot redefine built-in function '%s' + 3, undefined variable '%s' in function definition + 4, illegal character '%s' + 5, unexpected '%s' + 8, unexpected operator '%s' + 10, operator '%s' lacks operand + 11, expecting '%s' + 17, undefined variable '%s' + 21, empty result '%s' + 22, negative result '%s' + 24, variable '%s' exists but has no value - -2 Args - 6, wrong number of arguments (%s given, %s expected) - 23, unknown or non set variable '%s' after %s + -2 Args + 6, wrong number of arguments (%s given, %s expected) + 23, unknown or non set variable '%s' after %s - -internal errors - 7, internal error - 12, internal error - 13, internal error - 15, internal error - 16, internal error - 18, internal error - */ + -internal errors + 7, internal error + 12, internal error + 13, internal error + 15, internal error + 16, internal error + 18, internal error + */ if (empty($this->error_parser)) { return $langs->trans("ErrorPriceExpressionUnknown", 0); //this is not supposed to happen } list($code, $info) = $this->error_parser; - if (in_array($code, array(9, 14, 19, 20))) //Errors which have 0 arg - { + if (in_array($code, array(9, 14, 19, 20))) { //Errors which have 0 arg return $langs->trans("ErrorPriceExpression".$code); - } elseif (in_array($code, array(1, 2, 3, 4, 5, 8, 10, 11, 17, 21, 22))) //Errors which have 1 arg - { + } elseif (in_array($code, array(1, 2, 3, 4, 5, 8, 10, 11, 17, 21, 22))) { //Errors which have 1 arg return $langs->trans("ErrorPriceExpression".$code, $info); - } elseif (in_array($code, array(6, 23))) //Errors which have 2 args - { + } elseif (in_array($code, array(6, 23))) { //Errors which have 2 args return $langs->trans("ErrorPriceExpression".$code, $info[0], $info[1]); - } elseif (in_array($code, array(7, 12, 13, 15, 16, 18))) //Internal errors - { + } elseif (in_array($code, array(7, 12, 13, 15, 16, 18))) { //Internal errors return $langs->trans("ErrorPriceExpressionInternal", $code); } else //Unknown errors { @@ -140,8 +136,7 @@ class PriceParser } //Check if empty $expression = trim($expression); - if (empty($expression)) - { + if (empty($expression)) { $this->error_parser = array(20, null); return -2; } @@ -161,10 +156,8 @@ class PriceParser $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label('product', true); $product->fetch_optionals(); - if (is_array($extrafields->attributes[$product->table_element]['label'])) - { - foreach ($extrafields->attributes[$product->table_element]['label'] as $key=>$label) - { + if (is_array($extrafields->attributes[$product->table_element]['label'])) { + foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { $values["extrafield_".$key] = $product->array_options['options_'.$key]; } } @@ -182,8 +175,7 @@ class PriceParser //Get all global values $price_globals = new PriceGlobalVariable($this->db); - foreach ($price_globals->listGlobalVariables() as $entry) - { + foreach ($price_globals->listGlobalVariables() as $entry) { $values["global_".$entry->code] = $entry->value; } @@ -198,8 +190,7 @@ class PriceParser //Fill each variable in expression from values $expression = str_replace("\n", $this->separator_chr, $expression); - foreach ($values as $key => $value) - { + foreach ($values as $key => $value) { if ($value === null && strpos($expression, $key) !== false) { $this->error_parser = array(24, $key); return -7; @@ -208,11 +199,12 @@ class PriceParser } //Check if there is unfilled variable - if (strpos($expression, $this->special_chr) !== false) - { + if (strpos($expression, $this->special_chr) !== false) { $data = explode($this->special_chr, $expression); $variable = $this->special_chr.$data[1]; - if (isset($data[2])) $variable .= $this->special_chr; + if (isset($data[2])) { + $variable .= $this->special_chr; + } $this->error_parser = array(23, array($variable, $expression)); return -6; } @@ -222,8 +214,7 @@ class PriceParser $expressions = array_slice($expressions, 0, $this->limit); foreach ($expressions as $expr) { $expr = trim($expr); - if (!empty($expr)) - { + if (!empty($expr)) { $last_result = $em->evaluate($expr); $this->error_parser = $em->last_error_code; if ($this->error_parser !== null) { //$em->last_error_code is null if no error happened, so just check if error_parser is not null @@ -236,13 +227,11 @@ class PriceParser if (empty($vars["price"])) { $vars["price"] = $last_result; } - if (!isset($vars["price"])) - { + if (!isset($vars["price"])) { $this->error_parser = array(21, $expression); return -4; } - if ($vars["price"] < 0) - { + if ($vars["price"] < 0) { $this->error_parser = array(22, $expression); return -5; } @@ -305,8 +294,7 @@ class PriceParser //Get the expression from db $price_expression = new PriceExpression($this->db); $res = $price_expression->fetch($product_supplier->fk_supplier_price_expression); - if ($res < 1) - { + if ($res < 1) { $this->error_parser = array(19, null); return -1; } diff --git a/htdocs/product/dynamic_price/editor.php b/htdocs/product/dynamic_price/editor.php index 24f4856698f..418a71166a8 100644 --- a/htdocs/product/dynamic_price/editor.php +++ b/htdocs/product/dynamic_price/editor.php @@ -51,11 +51,9 @@ $price_expression = new PriceExpression($db); $price_globals = new PriceGlobalVariable($db); //Fetch expression data -if (empty($eid)) //This also disables fetch when eid == 0 -{ +if (empty($eid)) { //This also disables fetch when eid == 0 $eid = 0; -} elseif ($action != 'delete') -{ +} elseif ($action != 'delete') { $price_expression->fetch($eid); } @@ -64,13 +62,10 @@ if (empty($eid)) //This also disables fetch when eid == 0 * Actions */ -if ($action == 'add') -{ - if ($eid == 0) - { +if ($action == 'add') { + if ($eid == 0) { $result = $price_expression->find_title($title); - if ($result == 0) //No existing entry found with title, ok - { + if ($result == 0) { //No existing entry found with title, ok //Check the expression validity by parsing it $priceparser = new PriceParser($db); $price_result = $priceparser->testExpression($id, $expression); @@ -80,16 +75,14 @@ if ($action == 'add') $price_expression->title = $title; $price_expression->expression = $expression; $result = $price_expression->create($user); - if ($result > 0) //created successfully, set the eid to newly created entry - { + if ($result > 0) { //created successfully, set the eid to newly created entry $eid = $price_expression->id; setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else { setEventMessages("add: ".$price_expression->error, $price_expression->errors, 'errors'); } } - } elseif ($result < 0) - { + } elseif ($result < 0) { setEventMessages("add find: ".$price_expression->error, $price_expression->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors'); @@ -97,13 +90,10 @@ if ($action == 'add') } } -if ($action == 'update') -{ - if ($eid != 0) - { +if ($action == 'update') { + if ($eid != 0) { $result = $price_expression->find_title($title); - if ($result == 0 || $result == $eid) //No existing entry found with title or existing one is the current one, ok - { + if ($result == 0 || $result == $eid) { //No existing entry found with title or existing one is the current one, ok //Check the expression validity by parsing it $priceparser = new PriceParser($db); $price_result = $priceparser->testExpression($id, $expression); @@ -114,15 +104,13 @@ if ($action == 'update') $price_expression->title = $title; $price_expression->expression = $expression; $result = $price_expression->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages("update: ".$price_expression->error, $price_expression->errors, 'errors'); } else { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } } - } elseif ($result < 0) - { + } elseif ($result < 0) { setEventMessages("update find: ".$price_expression->error, $price_expression->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors'); @@ -130,14 +118,11 @@ if ($action == 'update') } } -if ($action == 'delete') -{ - if ($eid != 0) - { +if ($action == 'delete') { + if ($eid != 0) { $price_expression->fetch($eid); $result = $price_expression->delete($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages("delete: ".$price_expression->error, $price_expression->errors, 'errors'); } $eid = 0; @@ -202,8 +187,7 @@ print dol_get_fiche_end(); print '<div class="center">'; print '<input type="submit" class="butAction button-save" value="'.$langs->trans("Save").'">'; print '<span id="back" class="butAction">'.$langs->trans("Back").'</span>'; -if ($eid == 0) -{ +if ($eid == 0) { print '<div class="inline-block divButAction"><span id="action-delete" class="butActionRefused classfortooltip">'.$langs->trans('Delete').'</span></div>'."\n"; } else { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&amp;tab='.$tab.'&amp;eid='.$eid.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans("Delete").'</a></div>'; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index d0e7ee279e2..9a4518f509e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -40,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.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_parser.class.php'; -if (!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); +if (!empty($conf->barcode->enabled)) { + dol_include_once('/core/class/html.formbarcode.class.php'); +} // Load translation files required by the page $langs->loadLangs(array('products', 'suppliers', 'bills', 'margins', 'stocks')); @@ -59,8 +61,7 @@ $error = 0; $extrafields = new ExtraFields($db); // If socid provided by ajax company selector -if (!empty($_REQUEST['search_fourn_id'])) -{ +if (!empty($_REQUEST['search_fourn_id'])) { $_GET['id_fourn'] = $_GET['search_fourn_id']; $_POST['id_fourn'] = $_POST['search_fourn_id']; $_REQUEST['id_fourn'] = $_REQUEST['search_fourn_id']; @@ -69,62 +70,75 @@ if (!empty($_REQUEST['search_fourn_id'])) // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->fournisseur->lire)) accessforbidden(); +if (empty($user->rights->fournisseur->lire)) { + accessforbidden(); +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "s.nom"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "s.nom"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('pricesuppliercard', 'globalcard')); $object = new ProductFournisseur($db); -if ($id > 0 || $ref) -{ +if ($id > 0 || $ref) { $object->fetch($id, $ref); } $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortfield) $sortfield = "s.nom"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "s.nom"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} /* * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $parameters = array('socid'=>$socid, 'id_prod'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($action == 'setcost_price') - { - if ($id) - { +if (empty($reshook)) { + if ($action == 'setcost_price') { + if ($id) { $result = $object->fetch($id); $object->cost_price = price2num($cost_price); $result = $object->update($object->id, $user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ''; } else { @@ -134,10 +148,8 @@ if (empty($reshook)) } } - if ($action == 'confirm_remove_pf') - { - if ($rowid) // id of product supplier price to remove - { + if ($action == 'confirm_remove_pf') { + if ($rowid) { // id of product supplier price to remove $action = ''; $result = $object->remove_product_fournisseur_price($rowid); if ($result > 0) { @@ -150,14 +162,19 @@ if (empty($reshook)) } } - if ($action == 'save_price') - { + if ($action == 'save_price') { $id_fourn = GETPOST("id_fourn"); - if (empty($id_fourn)) $id_fourn = GETPOST("search_id_fourn"); + if (empty($id_fourn)) { + $id_fourn = GETPOST("search_id_fourn"); + } $ref_fourn = GETPOST("ref_fourn"); - if (empty($ref_fourn)) $ref_fourn = GETPOST("search_ref_fourn"); + if (empty($ref_fourn)) { + $ref_fourn = GETPOST("search_ref_fourn"); + } $ref_fourn_old = GETPOST("ref_fourn_old"); - if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; + if (empty($ref_fourn_old)) { + $ref_fourn_old = $ref_fourn; + } $quantity = price2num(GETPOST("qty", 'nohtml'), 'MS'); $remise_percent = price2num(GETPOST('remise_percent', 'alpha')); @@ -175,40 +192,33 @@ if (empty($reshook)) $fk_barcode_type = GETPOST('fk_barcode_type', 'int'); $packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS'); - if ($tva_tx == '') - { + if ($tva_tx == '') { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors'); } - if (!is_numeric($tva_tx)) - { + if (!is_numeric($tva_tx)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors'); } - if (empty($quantity)) - { + if (empty($quantity)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")), null, 'errors'); } - if (empty($ref_fourn)) - { + if (empty($ref_fourn)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("RefSupplier")), null, 'errors'); } - if ($id_fourn <= 0) - { + if ($id_fourn <= 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Supplier")), null, 'errors'); } - if (price2num($_POST["price"]) < 0 || $_POST["price"] == '') - { - if ($price_expression === '') // Return error of missing price only if price_expression not set - { + if (price2num($_POST["price"]) < 0 || $_POST["price"] == '') { + if ($price_expression === '') { // Return error of missing price only if price_expression not set $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")), null, 'errors'); @@ -234,30 +244,25 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->begin(); - if (!$error) - { + if (!$error) { $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice - if ($ret == -3) - { + if ($ret == -3) { $error++; $object->fetch($object->product_id_already_linked); $productLink = $object->getNomUrl(1, 'supplier'); setEventMessages($langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", $productLink), null, 'errors'); - } elseif ($ret < 0) - { + } elseif ($ret < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $supplier = new Fournisseur($db); $result = $supplier->fetch($id_fourn); if (GETPOSTISSET('ref_fourn_price_id')) { @@ -294,12 +299,15 @@ if (empty($reshook)) $newprice = price2num(GETPOST("price", "alpha")); - if (empty($packaging)) $packaging = 1; - if ($packaging < $quantity) $packaging = $quantity; + if (empty($packaging)) { + $packaging = 1; + } + if ($packaging < $quantity) { + $packaging = $quantity; + } $object->packaging = $packaging; - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { $multicurrency_tx = price2num(GETPOST("multicurrency_tx", 'alpha')); $multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha')); $multicurrency_code = GETPOST("multicurrency_code", 'alpha'); @@ -308,13 +316,11 @@ if (empty($reshook)) } else { $ret = $object->update_buyprice($quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOST("oselDispo"), $ref_fourn, $tva_tx, GETPOST("charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type); } - if ($ret < 0) - { + if ($ret < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { - if (!empty($conf->dynamicprices->enabled) && $price_expression !== '') - { + if (!empty($conf->dynamicprices->enabled) && $price_expression !== '') { //Check the expression validity by parsing it $priceparser = new PriceParser($db); $object->fk_supplier_price_expression = $price_expression; @@ -324,12 +330,10 @@ if (empty($reshook)) setEventMessages($priceparser->translatedError(), null, 'errors'); } } - if (!$error && !empty($conf->dynamicprices->enabled)) - { + if (!$error && !empty($conf->dynamicprices->enabled)) { //Set the price expression for this supplier price $ret = $object->setSupplierPriceExpression($price_expression); - if ($ret < 0) - { + if ($ret < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } @@ -337,8 +341,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->commit(); $action = ''; } else { @@ -358,13 +361,11 @@ if (empty($reshook)) $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -373,18 +374,15 @@ llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'classforhorizontalscrollo $form = new Form($db); -if ($id > 0 || $ref) -{ - if ($result) - { +if ($id > 0 || $ref) { + if ($result) { if ($action == 'ask_remove_pf') { $form = new Form($db); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&rowid='.$rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); echo $formconfirm; } - if ($action <> 'edit' && $action <> 're-edit') - { + if ($action <> 'edit' && $action <> 're-edit') { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -395,7 +393,9 @@ if ($id > 0 || $ref) $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -417,7 +417,9 @@ if ($id > 0 || $ref) // PMP print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>'; print '<td>'; - if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); + if ($object->pmp > 0) { + print price($object->pmp).' '.$langs->trans("HT"); + } print '</td>'; print '</tr>'; @@ -425,10 +427,12 @@ if ($id > 0 || $ref) print '<tr><td class="titlefieldcreate">'.$langs->trans("BuyingPriceMin").'</td>'; print '<td colspan="2">'; $product_fourn = new ProductFournisseur($db); - if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) - { - if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); - else print $langs->trans("NotDefined"); + if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { + if ($product_fourn->product_fourn_price_id > 0) { + print $product_fourn->display_price_product_fournisseur(); + } else { + print $langs->trans("NotDefined"); + } } print '</td></tr>'; @@ -441,12 +445,10 @@ if ($id > 0 || $ref) // Form to add or update a price - if (($action == 'add_price' || $action == 'update_price') && $usercancreate) - { + if (($action == 'add_price' || $action == 'update_price') && $usercancreate) { $langs->load("suppliers"); - if ($rowid) - { + if ($rowid) { $object->fetch_product_fournisseur_price($rowid, 1); //Ignore the math expression when getting the price print load_fiche_titre($langs->trans("ChangeSupplierPrice")); } else { @@ -463,8 +465,7 @@ if ($id > 0 || $ref) // Supplier print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Supplier").'</td><td>'; - if ($rowid) - { + if ($rowid) { $supplier = new Fournisseur($db); $supplier->fetch($socid); print $supplier->getNomUrl(1); @@ -479,10 +480,8 @@ if ($id > 0 || $ref) $parameters = array('filtre'=>"fournisseur=1", 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); - if (empty($reshook)) - { - if (empty($form->result)) - { + if (empty($reshook)) { + if (empty($form->result)) { print ' - <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&type=f&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$action).'">'.$langs->trans("CreateDolibarrThirdPartySupplier").'</a>'; } } @@ -491,8 +490,7 @@ if ($id > 0 || $ref) // Ref supplier print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td>'; - if ($rowid) - { + if ($rowid) { print '<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.'">'; print '<input class="flat width150" maxlength="30" name="ref_fourn" value="'.$object->ref_supplier.'">'; } else { @@ -502,8 +500,7 @@ if ($id > 0 || $ref) print '</tr>'; // Availability - if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) - { + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $langs->load("propal"); print '<tr><td>'.$langs->trans("Availability").'</td><td>'; $form->selectAvailabilityDelay($object->fk_availability, "oselDispo", 1); @@ -515,8 +512,7 @@ if ($id > 0 || $ref) print '<td class="fieldrequired">'.$langs->trans("QtyMin").'</td>'; print '<td>'; $quantity = GETPOSTISSET('qty') ? price2num(GETPOST('qty', 'nohtml'), 'MS') : "1"; - if ($rowid) - { + if ($rowid) { print '<input type="hidden" name="qty" value="'.$object->fourn_qty.'">'; print $object->fourn_qty; } else { @@ -558,20 +554,20 @@ if ($id > 0 || $ref) $mysoc2->tva_assuj = 1; $default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0); $default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0); - if (empty($default_vat)) $default_npr = $default_vat; + if (empty($default_vat)) { + $default_npr = $default_vat; + } print '<tr><td class="fieldrequired">'.$langs->trans("VATRateForSupplierProduct").'</td>'; print '<td>'; //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - if (!empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price - { + if (!empty($rowid)) { // If we have a supplier, it is an update, we must show the vat of current supplier price $tmpproductsupplier = new ProductFournisseur($db); $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1); $default_vat = $tmpproductsupplier->fourn_tva_tx; $default_npr = $tmpproductsupplier->fourn_tva_npr; } else { - if (empty($default_vat)) - { + if (empty($default_vat)) { $default_vat = $object->tva_tx; } } @@ -580,8 +576,7 @@ if ($id > 0 || $ref) print '<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.'">'; print '</td></tr>'; - if (!empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled - { + if (!empty($conf->dynamicprices->enabled)) { //Only show price mode and expression selector if module is enabled // Price mode selector print '<tr><td class="fieldrequired">'.$langs->trans("PriceMode").'</td><td>'; $price_expression = new PriceExpression($db); @@ -619,7 +614,9 @@ if ($id > 0 || $ref) print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>'; print '<td>'; $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); - if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency; + if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) { + $currencycodetouse = $conf->currency; + } print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1); print ' &nbsp; '.$langs->trans("CurrencyRate").' '; print '<input class="flat" name="multicurrency_tx" size="4" value="'.vatrate(GETPOST('multicurrency_tx') ? GETPOST('multicurrency_tx') : (isset($object->fourn_multicurrency_tx) ? $object->fourn_multicurrency_tx : '')).'">'; @@ -724,8 +721,7 @@ END; print '</td></tr>'; // Barcode - if (!empty($conf->barcode->enabled)) - { + if (!empty($conf->barcode->enabled)) { // Option to define a transport cost on supplier price print '<tr>'; print '<td>'.$langs->trans('BarcodeValue').'</td>'; @@ -743,10 +739,8 @@ END; } // Option to define a transport cost on supplier price - if ($conf->global->PRODUCT_CHARGES) - { - if (!empty($conf->margin->enabled)) - { + if ($conf->global->PRODUCT_CHARGES) { + if (!empty($conf->margin->enabled)) { print '<tr>'; print '<td>'.$langs->trans("Charges").'</td>'; print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges') ?price(GETPOST('charges')) : (isset($object->fourn_charges) ?price($object->fourn_charges) : '')).'">'; @@ -756,8 +750,7 @@ END; } // Product description of the supplier - if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) - { + if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -780,11 +773,16 @@ END; if (empty($rowid)) { foreach ($extralabels as $key => $value) { if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { + $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + } print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'; - if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - else print $langs->trans($value); + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { + print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + } else { + print $langs->trans($value); + } print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>'; } } @@ -801,11 +799,16 @@ END; $obj = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { + $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + } print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'; - if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - else print $langs->trans($value); + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { + print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + } else { + print $langs->trans($value); + } print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price'); print '</td></tr>'; @@ -816,8 +819,7 @@ END; } } - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; @@ -840,14 +842,11 @@ END; print "\n<div class=\"tabsAction\">\n"; - if ($action != 'add_price' && $action != 'update_price') - { + if ($action != 'add_price' && $action != 'update_price') { $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - if ($usercancreate) - { + if (empty($reshook)) { + if ($usercancreate) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$object->id.'&amp;action=add_price">'; print $langs->trans("AddSupplierPrice").'</a>'; } @@ -857,11 +856,14 @@ END; print "\n</div>\n"; print '<br>'; - if ($user->rights->fournisseur->lire) // Duplicate ? this check is already in the head of this file - { + if ($user->rights->fournisseur->lire) { // Duplicate ? this check is already in the head of this file $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } $param .= '&ref='.urlencode($object->ref); $product_fourn = new ProductFournisseur($db); @@ -869,7 +871,9 @@ END; $product_fourn_list_all = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, 0, 0); $nbtotalofrecords = count($product_fourn_list_all); $num = count($product_fourn_list); - if (($num + ($offset * $limit)) < $nbtotalofrecords) $num++; + if (($num + ($offset * $limit)) < $nbtotalofrecords) { + $num++; + } print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); @@ -924,24 +928,52 @@ END; $param = "&id=".$object->id; print '<tr class="liste_titre">'; - if (!empty($arrayfields['pfp.datec']['checked'])) print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder, '', '', 1); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder, '', '', 1); + if (!empty($arrayfields['pfp.datec']['checked'])) { + print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder, '', '', 1); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder, '', '', 1); + } print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, '', '', 1); - if (!empty($arrayfields['pfp.fk_availability']['checked'])) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['pfp.quantity']['checked'])) print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.fk_availability']['checked'])) { + print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['pfp.quantity']['checked'])) { + print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->multicurrency->enabled)) print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['pfp.unitprice']['checked'])) print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->multicurrency->enabled)) print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($conf->multicurrency->enabled)) { + print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['pfp.unitprice']['checked'])) { + print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) { + print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($conf->multicurrency->enabled)) { + print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pfp.barcode']['checked'])) print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pfp.packaging']['checked'])) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['pfp.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ', '', 1); + if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) { + print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) { + print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['pfp.barcode']['checked'])) { + print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { + print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['pfp.packaging']['checked'])) { + print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['pfp.tms']['checked'])) { + print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ', '', 1); + } // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); @@ -951,26 +983,30 @@ END; foreach ($extralabels as $key => $value) { // Show field if not hidden if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); - if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - else $extratitle = $langs->trans($value); - if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { + $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + } + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { + $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + } else { + $extratitle = $langs->trans($value); + } + if (!empty($arrayfields['ef.'.$key]['checked'])) { + print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right '); + } } } } - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; - if (is_array($product_fourn_list)) - { - foreach ($product_fourn_list as $productfourn) - { + if (is_array($product_fourn_list)) { + foreach ($product_fourn_list as $productfourn) { print '<tr class="oddeven">'; // Date from @@ -991,8 +1027,7 @@ END; } // Availability - if (!empty($arrayfields['pfp.fk_availability']['checked'])) - { + if (!empty($arrayfields['pfp.fk_availability']['checked'])) { $form->load_cache_availability(); $availability = $form->cache_availability[$productfourn->fk_availability]['label']; print '<td class="left">'.$availability.'</td>'; @@ -1041,7 +1076,8 @@ END; if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) { print '<td class="right">'; print price($productfourn->fourn_multicurrency_unitprice); - print '</td>'; } + print '</td>'; + } // Currency if (!empty($conf->multicurrency->enabled)) { @@ -1130,8 +1166,7 @@ END; } } - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); } @@ -1139,8 +1174,7 @@ END; // Modify-Remove print '<td class="center nowraponall">'; - if ($usercancreate) - { + if ($usercancreate) { print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=update_price&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_edit()."</a>"; print ' &nbsp; '; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=ask_remove_pf&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_picto($langs->trans("Remove"), 'delete').'</a>'; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 7e19d8f3818..89054a11cc5 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -34,13 +34,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $type = GETPOST("type", 'int'); -if ($type == '' && !$user->rights->produit->lire) $type = '1'; // Force global page on service page only -if ($type == '' && !$user->rights->service->lire) $type = '0'; // Force global page on product page only +if ($type == '' && !$user->rights->produit->lire) { + $type = '1'; // Force global page on service page only +} +if ($type == '' && !$user->rights->service->lire) { + $type = '0'; // Force global page on product page only +} // Security check -if ($type == '0') $result = restrictedArea($user, 'produit'); -elseif ($type == '1') $result = restrictedArea($user, 'service'); -else $result = restrictedArea($user, 'produit|service|expedition'); +if ($type == '0') { + $result = restrictedArea($user, 'produit'); +} elseif ($type == '1') { + $result = restrictedArea($user, 'service'); +} else { + $result = restrictedArea($user, 'produit|service|expedition'); +} // Load translation files required by the page $langs->loadLangs(array('products', 'stocks')); @@ -58,18 +66,15 @@ $product_static = new Product($db); $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl = ''; -if (!isset($_GET["type"])) -{ +if (!isset($_GET["type"])) { $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) -{ +if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) { $transAreaType = $langs->trans("ProductsArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) -{ +if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) { $transAreaType = $langs->trans("ServicesArea"); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -83,27 +88,27 @@ print load_fiche_titre($transAreaType, $linkback, 'product'); print '<div class="fichecenter"><div class="fichethirdleft">'; -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 // Search contract - if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) - { + if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { $listofsearchfields['search_product'] = array('text'=>'ProductOrService'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + } print '<tr class="oddeven">'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + if ($i == 0) { + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + } print '</tr>'; $i++; } @@ -117,8 +122,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles /* * Number of products and/or services */ -if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) -{ +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { $prodser = array(); $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0; @@ -132,20 +136,30 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us $sql .= $hookmanager->resPrint; $sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; $result = $db->query($sql); - while ($objp = $db->fetch_object($result)) - { + while ($objp = $db->fetch_object($result)) { $status = 3; // On sale + On purchase - if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase - if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only - if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only + if (!$objp->tosell && !$objp->tobuy) { + $status = 0; // Not on sale, not on purchase + } + if ($objp->tosell && !$objp->tobuy) { + $status = 1; // On sale only + } + if (!$objp->tosell && $objp->tobuy) { + $status = 2; // On purchase only + } $prodser[$objp->fk_product_type][$status] = $objp->total; - if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total; - if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total; - if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total; + if ($objp->tosell) { + $prodser[$objp->fk_product_type]['sell'] += $objp->total; + } + if ($objp->tobuy) { + $prodser[$objp->fk_product_type]['buy'] += $objp->total; + } + if (!$objp->tosell && !$objp->tobuy) { + $prodser[$objp->fk_product_type]['none'] += $objp->total; + } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre"><th>'.$langs->trans("Statistics").'</th></tr>'; @@ -164,14 +178,12 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF; $dataseries = array(); - if (!empty($conf->product->enabled)) - { + if (!empty($conf->product->enabled)) { $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnSale"), round($SommeA)); $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnPurchase"), round($SommeB)); $dataseries[] = array($langs->transnoentitiesnoconv("ProductsNotOnSell"), round($SommeC)); } - if (!empty($conf->service->enabled)) - { + if (!empty($conf->service->enabled)) { $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnSale"), round($SommeD)); $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnPurchase"), round($SommeE)); $dataseries[] = array($langs->transnoentitiesnoconv("ServicesNotOnSell"), round($SommeF)); @@ -193,8 +205,7 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us } -if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS)) -{ +if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; print '<br>'; print '<div class="div-table-responsive-no-min">'; @@ -209,20 +220,16 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA $sql .= " GROUP BY c.label"; $total = 0; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { $dataseries = array(); $rest = 0; $nbmax = 10; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); - if ($i < $nbmax) - { + if ($i < $nbmax) { $dataseries[] = array($obj->label, round($obj->nb)); } else { $rest += $obj->nb; @@ -230,8 +237,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA $total += $obj->nb; $i++; } - if ($i > $nbmax) - { + if ($i > $nbmax) { $dataseries[] = array($langs->trans("Other"), round($rest)); } @@ -245,8 +251,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA $dolgraph->draw('idstatscategproduct'); print $dolgraph->show($total ? 0 : 1); } else { - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print '<tr><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; @@ -268,15 +273,16 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; /* * Latest modified products */ -if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) -{ +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { $max = 15; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; $sql .= " p.entity,"; $sql .= " p.tms as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; - if ($type != '') $sql .= " AND p.fk_product_type = ".$type; + if ($type != '') { + $sql .= " AND p.fk_product_type = ".$type; + } // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -286,30 +292,33 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us //print $sql; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; - if ($num > 0) - { + if ($num > 0) { $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max); - if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts", $max); - if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices", $max); + if (isset($_GET["type"]) && $_GET["type"] == 0) { + $transRecordedType = $langs->trans("LastRecordedProducts", $max); + } + if (isset($_GET["type"]) && $_GET["type"] == 1) { + $transRecordedType = $langs->trans("LastRecordedServices", $max); + } print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; $colnb = 2; - if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + $colnb++; + } print '<tr class="liste_titre"><th colspan="'.$colnb.'">'.$transRecordedType.'</th>'; print '<th class="right" colspan="3"><a href="'.DOL_URL_ROOT.'/product/list.php?sortfield=p.tms&sortorder=DESC">'.$langs->trans("FullList").'</td>'; print '</tr>'; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $product_static->id = $objp->rowid; @@ -322,18 +331,18 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us $product_static->status_batch = $objp->tobatch; //Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$objp->rowid; $sql .= " AND lang='".$db->escape($langs->getDefaultLang())."'"; $resultd = $db->query($sql); - if ($resultd) - { + if ($resultd) { $objtp = $db->fetch_object($resultd); - if ($objtp && $objtp->label != '') $objp->label = $objtp->label; + if ($objtp && $objtp->label != '') { + $objp->label = $objtp->label; + } } } @@ -347,10 +356,8 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us print dol_print_date($db->jdate($objp->datem), 'day'); print "</td>"; // Sell price - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) { $product = new Product($db); $product->fetch($objp->rowid); $priceparser = new PriceParser($db); @@ -360,8 +367,11 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us } } print '<td class="nowrap right">'; - if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); + if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') { + print price($objp->price_ttc).' '.$langs->trans("TTC"); + } else { + print price($objp->price).' '.$langs->trans("HT"); + } print '</td>'; } print '<td class="right nowrap width25"><span class="statusrefsell">'; @@ -389,10 +399,13 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us // TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter" // Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover": // "commitment engagment" method and "cash accounting" method -if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM)) -{ - if (!empty($conf->product->enabled)) activitytrim(0); - if (!empty($conf->service->enabled)) activitytrim(1); +if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM)) { + if (!empty($conf->product->enabled)) { + activitytrim(0); + } + if (!empty($conf->service->enabled)) { + activitytrim(1); + } } @@ -433,8 +446,7 @@ function activitytrim($product_type) $sql .= " ORDER BY annee, mois "; $result = $db->query($sql); - if ($result) - { + if ($result) { $tmpyear = 0; $trim1 = 0; $trim2 = 0; @@ -443,14 +455,15 @@ function activitytrim($product_type) $lgn = 0; $num = $db->num_rows($result); - if ($num > 0) - { + if ($num > 0) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder" width="75%">'; - if ($product_type == 0) + if ($product_type == 0) { print '<tr class="liste_titre"><td class=left>'.$langs->trans("ProductSellByQuarterHT").'</td>'; - else print '<tr class="liste_titre"><td class=left>'.$langs->trans("ServiceSellByQuarterHT").'</td>'; + } else { + print '<tr class="liste_titre"><td class=left>'.$langs->trans("ServiceSellByQuarterHT").'</td>'; + } print '<td class=right>'.$langs->trans("Quarter1").'</td>'; print '<td class=right>'.$langs->trans("Quarter2").'</td>'; print '<td class=right>'.$langs->trans("Quarter3").'</td>'; @@ -460,13 +473,10 @@ function activitytrim($product_type) } $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); - if ($tmpyear != $objp->annee) - { - if ($trim1 + $trim2 + $trim3 + $trim4 > 0) - { + if ($tmpyear != $objp->annee) { + if ($trim1 + $trim2 + $trim3 + $trim4 > 0) { print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>'; print '<td class="nowrap right">'.price($trim1).'</td>'; print '<td class="nowrap right">'.price($trim2).'</td>'; @@ -484,22 +494,25 @@ function activitytrim($product_type) $trim4 = 0; } - if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03") + if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03") { $trim1 += $objp->Mnttot; + } - if ($objp->mois == "04" || $objp->mois == "05" || $objp->mois == "06") + if ($objp->mois == "04" || $objp->mois == "05" || $objp->mois == "06") { $trim2 += $objp->Mnttot; + } - if ($objp->mois == "07" || $objp->mois == "08" || $objp->mois == "09") + if ($objp->mois == "07" || $objp->mois == "08" || $objp->mois == "09") { $trim3 += $objp->Mnttot; + } - if ($objp->mois == "10" || $objp->mois == "11" || $objp->mois == "12") + if ($objp->mois == "10" || $objp->mois == "11" || $objp->mois == "12") { $trim4 += $objp->Mnttot; + } $i++; } - if ($trim1 + $trim2 + $trim3 + $trim4 > 0) - { + if ($trim1 + $trim2 + $trim3 + $trim4 > 0) { print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>'; print '<td class="nowrap right">'.price($trim1).'</td>'; print '<td class="nowrap right">'.price($trim2).'</td>'; @@ -508,7 +521,8 @@ function activitytrim($product_type) print '<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).'</td>'; print '</tr>'; } - if ($num > 0) + if ($num > 0) { print '</table></div>'; + } } } diff --git a/htdocs/product/inventory/ajax/ajax.inventory.php b/htdocs/product/inventory/ajax/ajax.inventory.php index 85dd488df6f..920607f4c1e 100644 --- a/htdocs/product/inventory/ajax/ajax.inventory.php +++ b/htdocs/product/inventory/ajax/ajax.inventory.php @@ -6,16 +6,16 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; $get = GETPOST('get', 'alpha'); $put = GETPOST('put', 'alpha'); -switch ($put) -{ +switch ($put) { case 'qty': - if (empty($user->rights->stock->creer)) { echo -1; exit; } + if (empty($user->rights->stock->creer)) { + echo -1; exit; + } $fk_det_inventory = GETPOST('fk_det_inventory'); $det = new InventoryLine($db); - if ($det->fetch($fk_det_inventory)) - { + if ($det->fetch($fk_det_inventory)) { $det->qty_view += GETPOST('qty'); $res = $det->update($user); @@ -27,13 +27,14 @@ switch ($put) break; case 'pmp': - if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; } + if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { + echo -1; exit; + } $fk_det_inventory = GETPOST('fk_det_inventory'); $det = new InventoryLine($db); - if ($det->fetch($fk_det_inventory)) - { + if ($det->fetch($fk_det_inventory)) { $det->new_pmp = price2num(GETPOST('pmp')); $det->update($user); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 425dd3622e3..e0a03cb322d 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -40,8 +40,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inventorycard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $id); } else { $result = restrictedArea($user, 'stock', $id, '', 'inventory_advance'); @@ -61,12 +60,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -76,8 +78,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $permissiontoread = $user->rights->stock->lire; $permissiontoadd = $user->rights->stock->creer; $permissiontodelete = $user->rights->stock->supprimer; @@ -100,18 +101,22 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/product/inventory/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/product/inventory/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } } } $triggermodname = 'STOCK_INVENTORY_MODIFY'; // Name of trigger action code to execute when we modify record @@ -135,8 +140,7 @@ if (empty($reshook)) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); }*/ - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } @@ -179,15 +183,18 @@ jQuery(document).ready(function() { // Part to create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewInventory"), '', 'product'); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } + if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + } print dol_get_fiche_head(array(), ''); @@ -218,16 +225,19 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("Inventory"), '', 'product'); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } + if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + } print dol_get_fiche_head(); @@ -251,8 +261,7 @@ if (($id || $ref) && $action == 'edit') } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); @@ -277,8 +286,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of action xxxx - if ($action == 'xxx') - { + if ($action == 'xxx') { $formquestion = array(); /* $forcecombo=0; @@ -296,8 +304,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -317,34 +328,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - { - $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref .= '<input type="hidden" name="action" value="classin">'; - $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref .= '</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(); - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + { + $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + if ($action == 'classify') { + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } } */ $morehtmlref .= '</div>'; @@ -378,29 +389,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Send if (empty($user->socid)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n"; } // Back to draft - if ($object->status == $object::STATUS_VALIDATED) - { - if ($permissiontoadd) - { + if ($object->status == $object::STATUS_VALIDATED) { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>'; } } // Modify - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; @@ -408,23 +416,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Validate - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").' ('.$langs->trans("Start").')</a>'; } } // Clone /*if ($permissiontoadd) - { - print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=myobject">'.$langs->trans("ToClone").'</a>'."\n"; - }*/ + { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=myobject">'.$langs->trans("ToClone").'</a>'."\n"; + }*/ // Delete (need delete permission, or if draft, just need create/modify permission) - if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) - { + if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; @@ -439,8 +444,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre @@ -478,7 +482,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //Select mail models is same action as presend - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) { + $action = 'presend'; + } // Presend form $modelmail = 'inventory'; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 47d9425530f..d7bd4956638 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -222,8 +222,12 @@ class Inventory extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled)) { + $this->fields['entity']['enabled'] = 0; + } } @@ -272,20 +276,24 @@ class Inventory extends CommonObject $sql .= ' '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'entrepot as e'; $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= ' AND ps.fk_product = p.rowid AND ps.fk_entrepot = e.rowid'; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; - if ($this->fk_product > 0) $sql .= ' AND ps.fk_product = '.$this->fk_product; - if ($this->fk_warehouse > 0) $sql .= ' AND ps.fk_entrepot = '.$this->fk_warehouse; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND p.fk_product_type = 0"; + } + if ($this->fk_product > 0) { + $sql .= ' AND ps.fk_product = '.$this->fk_product; + } + if ($this->fk_warehouse > 0) { + $sql .= ' AND ps.fk_entrepot = '.$this->fk_warehouse; + } $inventoryline = new InventoryLine($this->db); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $inventoryline->fk_inventory = $this->id; @@ -464,8 +472,7 @@ class Inventory extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -489,7 +496,9 @@ class Inventory 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 = ''; @@ -501,24 +510,28 @@ class Inventory extends CommonObject $url = dol_buildpath('/product/inventory/card.php', 1).'?id='.$this->id; $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowInventory"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; $linkend = '</a>'; $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)) : ''); @@ -573,28 +586,23 @@ class Inventory extends CommonObject $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)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index d5c9ec4966b..40a7b3f6f64 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -45,8 +45,7 @@ $fk_product = GETPOST('fk_product', 'int'); $lineid = GETPOST('lineid', 'int'); $batch = GETPOST('batch', 'alphanohtml'); -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $id); } else { $result = restrictedArea($user, 'stock', $id, '', 'inventory_advance'); @@ -66,12 +65,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -81,8 +83,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $permissiontoadd = $user->rights->stock->creer; $permissiontodelete = $user->rights->stock->supprimer; } else { @@ -99,10 +100,11 @@ $now = dol_now(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; @@ -197,8 +199,7 @@ jQuery(document).ready(function() { // Part to show record -if ($object->id > 0) -{ +if ($object->id > 0) { $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); @@ -211,8 +212,7 @@ if ($object->id > 0) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line - if ($action == 'deleteline') - { + if ($action == 'deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } @@ -226,8 +226,11 @@ if ($object->id > 0) // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -247,34 +250,34 @@ if ($object->id > 0) // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; - if ($user->rights->inventory->creer) - { - if ($action != 'classify') - { - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; - } else { - $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)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($user->rights->inventory->creer) + { + if ($action != 'classify') + { + $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref.='<input type="hidden" name="action" value="classin">'; + $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref.='</form>'; + } else { + $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)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } } */ $morehtmlref .= '</div>'; @@ -309,7 +312,9 @@ if ($object->id > 0) print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } print '<div class="center">'; print '<span class="opacitymedium">'.$langs->trans("InventoryDesc").'</span><br>'; @@ -323,31 +328,28 @@ if ($object->id > 0) print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { - if ($object->status == Inventory::STATUS_DRAFT) - { - if ($permissiontoadd) - { + if (empty($reshook)) { + if ($object->status == Inventory::STATUS_DRAFT) { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").' ('.$langs->trans("Start").')</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Validate').' ('.$langs->trans("Start").')</a>'."\n"; } } - if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { + if ($object->status == Inventory::STATUS_VALIDATED) { + if ($permissiontoadd) { /* - if (!empty($conf->barcode->enabled)) { - print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaningProductBarcode").'</a>'; - } - if (!empty($conf->productbatch->enabled)) { - print '<a href="#" class="butAction">'.$langs->trans('UpdateByScaningLot').'</a>'; - }*/ + if (!empty($conf->barcode->enabled)) { + print '<a href="#" class="butAction">'.$langs->trans("UpdateByScaningProductBarcode").'</a>'; + } + if (!empty($conf->productbatch->enabled)) { + print '<a href="#" class="butAction">'.$langs->trans('UpdateByScaningLot').'</a>'; + }*/ if (!empty($conf->barcode->enabled) || !empty($conf->productbatch->enabled)) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=updatebyscaning" class="butAction">'.$langs->trans("UpdateByScaning").'</a>'; } @@ -356,10 +358,8 @@ if ($object->id > 0) } } - if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { + if ($object->status == Inventory::STATUS_VALIDATED) { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=record">'.$langs->trans("Finish").'</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Finish').'</a>'."\n"; @@ -367,16 +367,16 @@ if ($object->id > 0) } /*if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("RecordVerb").'</a>'."\n"; - } - else - { - print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('RecordVerb').'</a>'."\n"; - } - }*/ + { + if ($permissiontoadd) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("RecordVerb").'</a>'."\n"; + } + else + { + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('RecordVerb').'</a>'."\n"; + } + }*/ } print '</div>'."\n"; } @@ -394,7 +394,9 @@ if ($object->id > 0) print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="updateinventorylines">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } print '<div class="fichecenter">'; //print '<div class="fichehalfleft">'; @@ -459,14 +461,12 @@ if ($object->id > 0) //$sql = ''; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $totalarray = array(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if (is_object($cacheOfWarehouses[$obj->fk_warehouse])) { diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 747abda86b8..64c332fbe1b 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -48,7 +48,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -63,18 +65,20 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check $socid = 0; -if ($user->socid > 0) // Protection if external user -{ +if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $objectid); } else { $result = restrictedArea($user, 'stock', $objectid, '', 'inventory_advance'); @@ -83,30 +87,31 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of fields for list $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -129,31 +134,33 @@ $permissiontodelete = $user->rights->stock->supprimer; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -182,13 +189,14 @@ $title = $langs->trans('ListOfInventories'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + 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(); @@ -196,20 +204,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +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 (t.rowid = ef.fk_object)"; +} +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -222,7 +242,7 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY " foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql.='t.'.$key.', '; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -239,26 +259,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -267,8 +285,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/inventory/card.php?id='.$id); @@ -284,14 +301,24 @@ llxHeader('', $title, $help_url); $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) -{ - 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 (!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 ($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'; @@ -302,12 +329,18 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -327,9 +360,10 @@ $objecttmp = new Inventory($db); $trackid = 'stockinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -340,11 +374,13 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -361,20 +397,26 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } print '</td>'; } } @@ -396,15 +438,18 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -421,11 +466,11 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -433,37 +478,50 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); // Show here line of result print '<tr class="oddeven">'; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; - if ($key == 'status') print $object->getLibStatut(5); - else print $object->showOutputField($val, $key, $object->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -476,14 +534,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -495,10 +556,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -514,10 +578,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ff035dcdb9c..c0a35dabdb1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -41,12 +41,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -if (!empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins')); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); @@ -92,17 +95,31 @@ $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 (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "p.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "p.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Initialize context for list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'productservicelist'; -if ((string) $type == '1') { $contextpage = 'servicelist'; if ($search_type == '') $search_type = '1'; } -if ((string) $type == '0') { $contextpage = 'productlist'; if ($search_type == '') $search_type = '0'; } +if ((string) $type == '1') { + $contextpage = 'servicelist'; if ($search_type == '') { + $search_type = '1'; + } +} +if ((string) $type == '0') { + $contextpage = 'productlist'; if ($search_type == '') { + $search_type = '0'; + } +} // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks $object = new Product($db); @@ -116,22 +133,27 @@ $formproduct = new FormProduct($db); $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (empty($action)) $action = 'list'; +if (empty($action)) { + $action = 'list'; +} // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('product', 'list', $canvas); } // Security check -if ($search_type == '0') $result = restrictedArea($user, 'produit', '', '', '', '', '', 0); -elseif ($search_type == '1') $result = restrictedArea($user, 'service', '', '', '', '', '', 0); -else $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0); +if ($search_type == '0') { + $result = restrictedArea($user, 'produit', '', '', '', '', '', 0); +} elseif ($search_type == '1') { + $result = restrictedArea($user, 'service', '', '', '', '', '', 0); +} else { + $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0); +} // Define virtualdiffersfromphysical $virtualdiffersfromphysical = 0; @@ -140,8 +162,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) -{ + || !empty($conf->mrp->enabled)) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -155,8 +176,7 @@ $fieldstosearchall = array( ); // multilang -if (!empty($conf->global->MAIN_MULTILANGS)) -{ +if (!empty($conf->global->MAIN_MULTILANGS)) { $fieldstosearchall['pl.label'] = 'ProductLabelTranslated'; $fieldstosearchall['pl.description'] = 'ProductDescriptionTranslated'; $fieldstosearchall['pl.note'] = 'ProductNoteTranslated'; @@ -166,13 +186,13 @@ if (!empty($conf->barcode->enabled)) { $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice'; } // Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel' -if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); +if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) { + $fieldstosearchall = dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); +} -if (empty($conf->global->PRODUIT_MULTIPRICES)) -{ +if (empty($conf->global->PRODUIT_MULTIPRICES)) { $titlesellprice = $langs->trans("SellingPrice"); - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $titlesellprice = $form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); } } @@ -228,8 +248,7 @@ $arrayfields = array( // MultiPrices if ($conf->global->PRODUIT_MULTIPRICES) { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; if (!empty($conf->global->$keyforlabel)) { $labelp = $i.' - '.$langs->transnoentitiesnoconv($conf->global->$keyforlabel); @@ -254,24 +273,30 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $rightskey = 'produit'; -if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; +if ($type == Product::TYPE_SERVICE) { + $rightskey = 'service'; +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 $sall = ""; $search_ref = ""; $search_label = ""; @@ -299,8 +324,12 @@ if (empty($reshook)) // Mass actions $objectclass = 'Product'; - if ((string) $search_type == '1') { $objectlabel = 'Services'; } - if ((string) $search_type == '0') { $objectlabel = 'Products'; } + if ((string) $search_type == '1') { + $objectlabel = 'Services'; + } + if ((string) $search_type == '0') { + $objectlabel = 'Products'; + } $permissiontoread = $user->rights->{$rightskey}->lire; $permissiontodelete = $user->rights->{$rightskey}->supprimer; @@ -316,10 +345,8 @@ if (empty($reshook)) $title = $langs->trans("ProductsAndServices"); -if ($search_type != '' && $search_type != '-1') -{ - if ($search_type == 1) - { +if ($search_type != '' && $search_type != '-1') { + if ($search_type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); @@ -334,55 +361,91 @@ $sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.a $sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,'; -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' p.fk_unit, cu.label as cu_label,'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ' p.fk_unit, cu.label as cu_label,'; +} $sql .= ' MIN(pfp.unitprice) as minsellprice'; if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid prod_comb_id'; } // 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 : ''); + 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.'product as p'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; -if (!empty($searchCategoryProductList) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; +} +if (!empty($searchCategoryProductList) || !empty($catid)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang -if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'"; +if (!empty($conf->global->MAIN_MULTILANGS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'"; +} if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit"; +if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit"; +} $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} // if the type is not 1, we show all products (type = 0,2,3) -if (dol_strlen($search_type) && $search_type != '-1') -{ - if ($search_type == 1) $sql .= " AND p.fk_product_type = 1"; - else $sql .= " AND p.fk_product_type <> 1"; +if (dol_strlen($search_type) && $search_type != '-1') { + if ($search_type == 1) { + $sql .= " AND p.fk_product_type = 1"; + } else { + $sql .= " AND p.fk_product_type <> 1"; + } } if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " AND pac.rowid IS NULL"; } -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); -if ($search_label) $sql .= natural_search('p.label', $search_label); -if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); -if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) $sql .= " AND p.tosell = ".((int) $search_tosell); -if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) $sql .= " AND p.tobuy = ".((int) $search_tobuy); -if (isset($search_tobatch) && dol_strlen($search_tobatch) > 0 && $search_tobatch != -1) $sql .= " AND p.tobatch = ".((int) $search_tobatch); -if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate, 1); -if (dol_strlen($canvas) > 0) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; -if ($catid > 0) $sql .= " AND cp.fk_categorie = ".$catid; -if ($catid == -2) $sql .= " AND cp.fk_categorie IS NULL"; +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} +if ($search_label) { + $sql .= natural_search('p.label', $search_label); +} +if ($search_barcode) { + $sql .= natural_search('p.barcode', $search_barcode); +} +if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) { + $sql .= " AND p.tosell = ".((int) $search_tosell); +} +if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) { + $sql .= " AND p.tobuy = ".((int) $search_tobuy); +} +if (isset($search_tobatch) && dol_strlen($search_tobatch) > 0 && $search_tobatch != -1) { + $sql .= " AND p.tobatch = ".((int) $search_tobatch); +} +if ($search_vatrate) { + $sql .= natural_search('p.tva_tx', $search_vatrate, 1); +} +if (dol_strlen($canvas) > 0) { + $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +} +if ($catid > 0) { + $sql .= " AND cp.fk_categorie = ".$catid; +} +if ($catid == -2) { + $sql .= " AND cp.fk_categorie IS NULL"; +} $searchCategoryProductSqlList = array(); if ($searchCategoryProductOperator == 1) { foreach ($searchCategoryProductList as $searchCategoryProduct) { @@ -407,16 +470,36 @@ if ($searchCategoryProductOperator == 1) { $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } } -if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".((int) $fourn_id); -if ($search_country) $sql .= " AND p.fk_country = ".$search_country; -if ($search_state) $sql .= " AND p.fk_state = ".$search_state; -if ($search_finished >= 0 && $search_finished !== '') $sql .= " AND p.finished = ".$search_finished; -if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); -if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); -if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); -if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); -if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); +if ($fourn_id > 0) { + $sql .= " AND pfp.fk_soc = ".((int) $fourn_id); +} +if ($search_country) { + $sql .= " AND p.fk_country = ".$search_country; +} +if ($search_state) { + $sql .= " AND p.fk_state = ".$search_state; +} +if ($search_finished >= 0 && $search_finished !== '') { + $sql .= " AND p.finished = ".$search_finished; +} +if ($search_accountancy_code_sell) { + $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); +} +if ($search_accountancy_code_sell_intra) { + $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); +} +if ($search_accountancy_code_sell_export) { + $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); +} +if ($search_accountancy_code_buy) { + $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +} +if ($search_accountancy_code_buy_intra) { + $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); +} +if ($search_accountancy_code_buy_export) { + $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -429,14 +512,18 @@ $sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_ $sql .= ' p.datec, p.tms, p.entity, p.tobatch, 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, p.pmp, p.cost_price, p.stock,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', p.fk_unit, cu.label'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ', p.fk_unit, cu.label'; +} if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid'; } // 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 : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + } } // Add fields from hooks $parameters = array(); @@ -446,12 +533,10 @@ $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -461,14 +546,12 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) - { + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/product/card.php?id='.$id); @@ -476,22 +559,19 @@ if ($resql) } $helpurl = ''; - if ($search_type != '') - { - if ($search_type == 0) - { + if ($search_type != '') { + if ($search_type == 0) { $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; - } elseif ($search_type == 1) - { + } elseif ($search_type == 1) { $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } } - foreach ($searchCategoryProductList as $searchCategoryProduct) { - $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); - } + foreach ($searchCategoryProductList as $searchCategoryProduct) { + $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); + } - llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, 'classforhorizontalscrolloftabs'); + llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, 'classforhorizontalscrolloftabs'); // Displays product removal confirmation if (GETPOST('delprod')) { @@ -499,36 +579,88 @@ if ($resql) } $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= "&sall=".urlencode($sall); - if ($searchCategoryProductOperator == 1) $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } + if ($searchCategoryProductOperator == 1) { + $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); + } foreach ($searchCategoryProductList as $searchCategoryProduct) { $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); } - if ($search_ref) $param = "&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param = "&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : ""); - if ($search_label) $param .= "&search_label=".urlencode($search_label); - if ($search_tosell != '') $param .= "&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param .= "&search_tobuy=".urlencode($search_tobuy); - if ($search_tobatch) $param = "&search_tobatch=".urlencode($search_tobatch); - if ($search_country != '') $param .= "&search_country=".urlencode($search_country); - if ($search_state != '') $param .= "&search_state=".urlencode($search_state); - if ($search_vatrate) $param = "&search_vatrate=".urlencode($search_vatrate); - if ($fourn_id > 0) $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); + if ($search_ref) { + $param = "&search_ref=".urlencode($search_ref); + } + if ($search_ref_supplier) { + $param = "&search_ref_supplier=".urlencode($search_ref_supplier); + } + if ($search_barcode) { + $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : ""); + } + if ($search_label) { + $param .= "&search_label=".urlencode($search_label); + } + if ($search_tosell != '') { + $param .= "&search_tosell=".urlencode($search_tosell); + } + if ($search_tobuy != '') { + $param .= "&search_tobuy=".urlencode($search_tobuy); + } + if ($search_tobatch) { + $param = "&search_tobatch=".urlencode($search_tobatch); + } + if ($search_country != '') { + $param .= "&search_country=".urlencode($search_country); + } + if ($search_state != '') { + $param .= "&search_state=".urlencode($search_state); + } + if ($search_vatrate) { + $param = "&search_vatrate=".urlencode($search_vatrate); + } + if ($fourn_id > 0) { + $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); + } //if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($show_childproducts) $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); - if ($type != '') $param .= '&type='.urlencode($type); - if ($search_type != '') $param .= '&search_type='.urlencode($search_type); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_accountancy_code_sell) $param = "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_sell_intra) $param = "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); - if ($search_accountancy_code_sell_export) $param = "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); - if ($search_accountancy_code_buy) $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); - if ($search_accountancy_code_buy_intra) $param = "&search_accountancy_code_buy_intra=".urlencode($search_accountancy_code_buy_intra); - if ($search_accountancy_code_buy_export) $param = "&search_accountancy_code_buy_export=".urlencode($search_accountancy_code_buy_export); - if ($search_finished) $param = "&search_finished=".urlencode($search_finished); + if ($show_childproducts) { + $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); + } + if ($type != '') { + $param .= '&type='.urlencode($type); + } + if ($search_type != '') { + $param .= '&search_type='.urlencode($search_type); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_accountancy_code_sell) { + $param = "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + } + if ($search_accountancy_code_sell_intra) { + $param = "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); + } + if ($search_accountancy_code_sell_export) { + $param = "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); + } + if ($search_accountancy_code_buy) { + $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + } + if ($search_accountancy_code_buy_intra) { + $param = "&search_accountancy_code_buy_intra=".urlencode($search_accountancy_code_buy_intra); + } + if ($search_accountancy_code_buy_export) { + $param = "&search_accountancy_code_buy_export=".urlencode($search_accountancy_code_buy_export); + } + if ($search_finished) { + $param = "&search_finished=".urlencode($search_finished); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -539,30 +671,46 @@ if ($resql) //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete"); - if ($user->rights->{$rightskey}->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); - if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); + if ($user->rights->{$rightskey}->supprimer) { + $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete"); + } + if ($user->rights->{$rightskey}->creer) { + $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); + } + if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; - if ($type === "") $perm = ($user->rights->produit->creer || $user->rights->service->creer); - elseif ($type == Product::TYPE_SERVICE) $perm = $user->rights->service->creer; - elseif ($type == Product::TYPE_PRODUCT) $perm = $user->rights->produit->creer; + if ($type === "") { + $perm = ($user->rights->produit->creer || $user->rights->service->creer); + } elseif ($type == Product::TYPE_SERVICE) { + $perm = $user->rights->service->creer; + } elseif ($type == Product::TYPE_PRODUCT) { + $perm = $user->rights->produit->creer; + } $oldtype = $type; $params = array(); - if ($type === "") $params['forcenohideoftext'] = 1; + if ($type === "") { + $params['forcenohideoftext'] = 1; + } if ($type === "") { $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params); $type = Product::TYPE_SERVICE; } $label = 'NewProduct'; - if ($type == Product::TYPE_SERVICE) $label = 'NewService'; + if ($type == Product::TYPE_SERVICE) { + $label = 'NewService'; + } $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type, '', $perm, $params); $type = $oldtype; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -570,10 +718,14 @@ if ($resql) print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; //print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="type" value="'.$type.'">'; - if (empty($arrayfields['p.fk_product_type']['checked'])) print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">'; + if (empty($arrayfields['p.fk_product_type']['checked'])) { + print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">'; + } $picto = 'product'; - if ($type == 1) $picto = 'service'; + if ($type == 1) { + $picto = 'service'; + } print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -583,8 +735,7 @@ if ($resql) $trackid = 'prod'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if (!empty($catid)) - { + if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); $ways = $c->print_all_ways(' &gt; ', 'product/list.php'); @@ -592,16 +743,16 @@ if ($resql) print "</div><br>"; } - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } // Filter on categories $moreforfilter = ''; - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) - { + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('Categories').': '; $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); @@ -621,11 +772,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if ($moreforfilter) - { + if ($moreforfilter) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -633,63 +786,57 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Lines with input filters print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (!empty($arrayfields['pfp.ref_fourn']['checked'])) - { + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_ref_supplier" size="8" value="'.dol_escape_htmltag($search_ref_supplier).'">'; print '</td>'; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).'">'; print '</td>'; } // Type - if (!empty($arrayfields['p.fk_product_type']['checked'])) - { + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print '<td class="liste_titre center">'; $array = array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('search_type', $array, $search_type); print '</td>'; } // Barcode - if (!empty($arrayfields['p.barcode']['checked'])) - { + if (!empty($arrayfields['p.barcode']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">'; print '</td>'; } // Duration - if (!empty($arrayfields['p.duration']['checked'])) - { + if (!empty($arrayfields['p.duration']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Finished - if (!empty($arrayfields['p.finished']['checked'])) - { + if (!empty($arrayfields['p.finished']['checked'])) { print '<td class="liste_titre">'; print $formproduct->selectProductNature('search_finished', $search_finished); print '</td>'; } // Weight - if (!empty($arrayfields['p.weight']['checked'])) - { + if (!empty($arrayfields['p.weight']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -699,8 +846,7 @@ if ($resql) print '</td>'; } // Length - if (!empty($arrayfields['p.length']['checked'])) - { + if (!empty($arrayfields['p.length']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -720,8 +866,7 @@ if ($resql) print '</td>'; } // Height - if (!empty($arrayfields['p.height']['checked'])) - { + if (!empty($arrayfields['p.height']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -731,8 +876,7 @@ if ($resql) print '</td>'; } // Surface - if (!empty($arrayfields['p.surface']['checked'])) - { + if (!empty($arrayfields['p.surface']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -742,8 +886,7 @@ if ($resql) print '</td>'; } // Volume - if (!empty($arrayfields['p.volume']['checked'])) - { + if (!empty($arrayfields['p.volume']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -754,25 +897,21 @@ if ($resql) } // Unit - if (!empty($arrayfields['cu.label']['checked'])) - { + if (!empty($arrayfields['cu.label']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Sell price - if (!empty($arrayfields['p.sellprice']['checked'])) - { + if (!empty($arrayfields['p.sellprice']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } // Multiprice if ($conf->global->PRODUIT_MULTIPRICES) { - foreach ($arraypricelevel as $key => $value) - { - if (!empty($arrayfields['p.sellprice'.$key]['checked'])) - { + foreach ($arraypricelevel as $key => $value) { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } @@ -780,72 +919,87 @@ if ($resql) } // Minimum buying Price - if (!empty($arrayfields['p.minbuyprice']['checked'])) - { + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // Number buying Price - if (!empty($arrayfields['p.numbuyprice']['checked'])) - { + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // Sell price - if (!empty($arrayfields['p.tva_tx']['checked'])) - { + if (!empty($arrayfields['p.tva_tx']['checked'])) { print '<td class="liste_titre right">'; print '<input class="right flat maxwidth50" placeholder="%" type="text" name="search_vatrate" size="1" value="'.dol_escape_htmltag($search_vatrate).'">'; print '</td>'; } // WAP - if (!empty($arrayfields['p.pmp']['checked'])) - { + if (!empty($arrayfields['p.pmp']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // cost_price - if (!empty($arrayfields['p.cost_price']['checked'])) - { + if (!empty($arrayfields['p.cost_price']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // Limit for alert - if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // Desired stock - if (!empty($arrayfields['p.desiredstock']['checked'])) - { + if (!empty($arrayfields['p.desiredstock']['checked'])) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; } // Stock - if (!empty($arrayfields['p.stock']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; + if (!empty($arrayfields['p.stock']['checked'])) { + print '<td class="liste_titre">&nbsp;</td>'; + } // Stock - if (!empty($arrayfields['stock_virtual']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; + if (!empty($arrayfields['stock_virtual']['checked'])) { + print '<td class="liste_titre">&nbsp;</td>'; + } // To batch - if (!empty($arrayfields['p.tobatch']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno('search_tobatch', $search_tobatch, 1, false, 1).'</td>'; + if (!empty($arrayfields['p.tobatch']['checked'])) { + print '<td class="liste_titre center">'.$form->selectyesno('search_tobatch', $search_tobatch, 1, false, 1).'</td>'; + } // Country - if (!empty($arrayfields['p.fk_country']['checked'])) print '<td class="liste_titre center">'.$form->select_country($search_country, 'search_country', '', 0).'</td>'; + if (!empty($arrayfields['p.fk_country']['checked'])) { + print '<td class="liste_titre center">'.$form->select_country($search_country, 'search_country', '', 0).'</td>'; + } // State - if (!empty($arrayfields['p.fk_state']['checked'])) print '<td class="liste_titre center">'.$formcompany->select_state($search_state, $search_country).'</td>'; + if (!empty($arrayfields['p.fk_state']['checked'])) { + print '<td class="liste_titre center">'.$formcompany->select_state($search_state, $search_country).'</td>'; + } // Accountancy code sell - if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>'; - if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>'; - if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>'; + } + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>'; + } + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>'; + } // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>'; - if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_intra" value="'.dol_escape_htmltag($search_accountancy_code_buy_intra).'"></td>'; - if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_export" value="'.dol_escape_htmltag($search_accountancy_code_buy_export).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>'; + } + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_intra" value="'.dol_escape_htmltag($search_accountancy_code_buy_intra).'"></td>'; + } + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { + print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_export" value="'.dol_escape_htmltag($search_accountancy_code_buy_export).'"></td>'; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -853,25 +1007,21 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['p.datec']['checked'])) - { + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['p.tms']['checked'])) - { + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } - if (!empty($arrayfields['p.tosell']['checked'])) - { + if (!empty($arrayfields['p.tosell']['checked'])) { print '<td class="liste_titre right">'; print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'), '1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); print '</td >'; } - if (!empty($arrayfields['p.tobuy']['checked'])) - { + if (!empty($arrayfields['p.tobuy']['checked'])) { print '<td class="liste_titre right">'; print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'), '1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); print '</td>'; @@ -906,29 +1056,53 @@ if ($resql) print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center '); } - if (!empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER['PHP_SELF'], 'p.weight', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.weight_units']['checked'])) print_liste_field_titre($arrayfields['p.weight_units']['label'], $_SERVER['PHP_SELF'], 'p.weight_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER['PHP_SELF'], 'p.length', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.length_units']['checked'])) print_liste_field_titre($arrayfields['p.length_units']['label'], $_SERVER['PHP_SELF'], 'p.length_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.width']['checked'])) print_liste_field_titre($arrayfields['p.width']['label'], $_SERVER['PHP_SELF'], 'p.width', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.width_units']['checked'])) print_liste_field_titre($arrayfields['p.width_units']['label'], $_SERVER['PHP_SELF'], 'p.width_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.height']['checked'])) print_liste_field_titre($arrayfields['p.height']['label'], $_SERVER['PHP_SELF'], 'p.height', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.height_units']['checked'])) print_liste_field_titre($arrayfields['p.height_units']['label'], $_SERVER['PHP_SELF'], 'p.height_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER['PHP_SELF'], "p.surface", '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.surface_units']['checked'])) print_liste_field_titre($arrayfields['p.surface_units']['label'], $_SERVER['PHP_SELF'], 'p.surface_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER['PHP_SELF'], 'p.volume', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['p.volume_units']['checked'])) print_liste_field_titre($arrayfields['p.volume_units']['label'], $_SERVER['PHP_SELF'], 'p.volume_units', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cu.label']['checked'])) print_liste_field_titre($arrayfields['cu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.weight']['checked'])) { + print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER['PHP_SELF'], 'p.weight', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.weight_units']['checked'])) { + print_liste_field_titre($arrayfields['p.weight_units']['label'], $_SERVER['PHP_SELF'], 'p.weight_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.length']['checked'])) { + print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER['PHP_SELF'], 'p.length', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.length_units']['checked'])) { + print_liste_field_titre($arrayfields['p.length_units']['label'], $_SERVER['PHP_SELF'], 'p.length_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.width']['checked'])) { + print_liste_field_titre($arrayfields['p.width']['label'], $_SERVER['PHP_SELF'], 'p.width', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.width_units']['checked'])) { + print_liste_field_titre($arrayfields['p.width_units']['label'], $_SERVER['PHP_SELF'], 'p.width_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.height']['checked'])) { + print_liste_field_titre($arrayfields['p.height']['label'], $_SERVER['PHP_SELF'], 'p.height', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.height_units']['checked'])) { + print_liste_field_titre($arrayfields['p.height_units']['label'], $_SERVER['PHP_SELF'], 'p.height_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.surface']['checked'])) { + print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER['PHP_SELF'], "p.surface", '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.surface_units']['checked'])) { + print_liste_field_titre($arrayfields['p.surface_units']['label'], $_SERVER['PHP_SELF'], 'p.surface_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.volume']['checked'])) { + print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER['PHP_SELF'], 'p.volume', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['p.volume_units']['checked'])) { + print_liste_field_titre($arrayfields['p.volume_units']['label'], $_SERVER['PHP_SELF'], 'p.volume_units', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cu.label']['checked'])) { + print_liste_field_titre($arrayfields['cu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['p.sellprice']['checked'])) { print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } // Multiprices if ($conf->global->PRODUIT_MULTIPRICES) { - foreach ($arraypricelevel as $key => $value) - { - if (!empty($arrayfields['p.sellprice'.$key]['checked'])) - { + foreach ($arraypricelevel as $key => $value) { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { print_liste_field_titre($arrayfields['p.sellprice'.$key]['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } } @@ -1015,13 +1189,11 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // If multilang is enabled - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // If multilang is enabled $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$obj->rowid; @@ -1029,10 +1201,11 @@ if ($resql) $sql .= " LIMIT 1"; $result = $db->query($sql); - if ($result) - { + if ($result) { $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) $obj->label = $objtp->label; + if (!empty($objtp->label)) { + $obj->label = $objtp->label; + } } } @@ -1071,12 +1244,12 @@ if ($resql) } // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock - { - if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { + if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service $option = 'nobatch'; - if (empty($arrayfields['stock_virtual']['checked'])) $option .= ',novirtual'; + if (empty($arrayfields['stock_virtual']['checked'])) { + $option .= ',novirtual'; + } $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } } @@ -1084,33 +1257,35 @@ if ($resql) print '<tr class="oddeven">'; // Ref - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="tdoverflowmax200">'; print $product_static->getNomUrl(1); print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref supplier - if (!empty($arrayfields['pfp.ref_fourn']['checked'])) - { + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '<td class="tdoverflowmax200">'; print $product_static->getNomUrl(1); print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Label - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.$obj->label.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Type - if (!empty($arrayfields['p.fk_product_type']['checked'])) - { + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print '<td class="center">'; $s = ''; if ($obj->fk_product_type == 0) { @@ -1120,165 +1295,200 @@ if ($resql) } print $s; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Barcode - if (!empty($arrayfields['p.barcode']['checked'])) - { + if (!empty($arrayfields['p.barcode']['checked'])) { print '<td>'.$obj->barcode.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Duration - if (!empty($arrayfields['p.duration']['checked'])) - { + if (!empty($arrayfields['p.duration']['checked'])) { print '<td class="center nowraponall">'; - if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) - { + if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $duration_unit = substr($obj->duration, -1); - if ((float) $duration_value > 1) - { + if ((float) $duration_value > 1) { $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ((float) $duration_value > 0) - { + } elseif ((float) $duration_value > 0) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } print $duration_value; print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); - } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) // If duration is a simple char (like 's' of 'm'), we do not show value - { + } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value print $obj->duration; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Finished - if (!empty($arrayfields['p.finished']['checked'])) - { + if (!empty($arrayfields['p.finished']['checked'])) { print '<td class="center">'; print $product_static->getLibFinished(); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Weight - if (!empty($arrayfields['p.weight']['checked'])) - { + if (!empty($arrayfields['p.weight']['checked'])) { print '<td class="center">'; print $obj->weight; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Weight units if (!empty($arrayfields['p.weight_units']['checked'])) { print '<td class="center">'; - if ($product_static->weight != '') print measuringUnitString(0, 'weight', $product_static->weight_units); + if ($product_static->weight != '') { + print measuringUnitString(0, 'weight', $product_static->weight_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Length - if (!empty($arrayfields['p.length']['checked'])) - { + if (!empty($arrayfields['p.length']['checked'])) { print '<td class="center">'; print $obj->length; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Length units if (!empty($arrayfields['p.length_units']['checked'])) { print '<td class="center">'; - if ($product_static->length != '') print measuringUnitString(0, 'size', $product_static->length_units); + if ($product_static->length != '') { + print measuringUnitString(0, 'size', $product_static->length_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Width - if (!empty($arrayfields['p.width']['checked'])) - { + if (!empty($arrayfields['p.width']['checked'])) { print '<td align="center">'; print $obj->width; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Width units if (!empty($arrayfields['p.width_units']['checked'])) { print '<td class="center">'; - if ($product_static->width != '') print measuringUnitString(0, 'size', $product_static->width_units); + if ($product_static->width != '') { + print measuringUnitString(0, 'size', $product_static->width_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Height - if (!empty($arrayfields['p.height']['checked'])) - { + if (!empty($arrayfields['p.height']['checked'])) { print '<td align="center">'; print $obj->height; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Height units if (!empty($arrayfields['p.height_units']['checked'])) { print '<td class="center">'; - if ($product_static->height != '') print measuringUnitString(0, 'size', $product_static->height_units); + if ($product_static->height != '') { + print measuringUnitString(0, 'size', $product_static->height_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Surface - if (!empty($arrayfields['p.surface']['checked'])) - { + if (!empty($arrayfields['p.surface']['checked'])) { print '<td class="center">'; print $obj->surface; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Surface units if (!empty($arrayfields['p.surface_units']['checked'])) { print '<td class="center">'; - if ($product_static->surface != '') print measuringUnitString(0, 'surface', $product_static->surface_units); + if ($product_static->surface != '') { + print measuringUnitString(0, 'surface', $product_static->surface_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Volume - if (!empty($arrayfields['p.volume']['checked'])) - { + if (!empty($arrayfields['p.volume']['checked'])) { print '<td class="center">'; print $obj->volume; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Volume units if (!empty($arrayfields['p.volume_units']['checked'])) { print '<td class="center">'; - if ($product_static->volume != '') print measuringUnitString(0, 'volume', $product_static->volume_units); + if ($product_static->volume != '') { + print measuringUnitString(0, 'volume', $product_static->volume_units); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Unit - if (!empty($arrayfields['cu.label']['checked'])) - { + if (!empty($arrayfields['cu.label']['checked'])) { print '<td align="center">'; if (!empty($obj->cu_label)) { print $langs->trans($obj->cu_label); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Sell price - if (!empty($arrayfields['p.sellprice']['checked'])) - { + if (!empty($arrayfields['p.sellprice']['checked'])) { print '<td class="right nowraponall">'; - if ($obj->tosell) - { - if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); - else print price($obj->price).' '.$langs->trans("HT"); + if ($obj->tosell) { + if ($obj->price_base_type == 'TTC') { + print price($obj->price_ttc).' '.$langs->trans("TTC"); + } else { + print price($obj->price).' '.$langs->trans("HT"); + } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } @@ -1291,8 +1501,7 @@ if ($resql) $productpricescache[$obj->rowid] = array(); } - if ($obj->tosell) - { + if ($obj->tosell) { // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array // then reuse the cache array if we need prices for other price levels $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; @@ -1300,16 +1509,13 @@ if ($resql) $sqlp .= " WHERE fk_product = ".$obj->rowid; $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; $resultp = $db->query($sqlp); - if ($resultp) - { + if ($resultp) { $nump = $db->num_rows($resultp); $j = 0; - while ($j < $nump) - { + while ($j < $nump) { $objp = $db->fetch_object($resultp); - if (empty($productpricescache[$obj->rowid][$objp->price_level])) - { + if (empty($productpricescache[$obj->rowid][$objp->price_level])) { $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; @@ -1324,13 +1530,10 @@ if ($resql) } } - foreach ($arraypricelevel as $key => $value) - { - if (!empty($arrayfields['p.sellprice'.$key]['checked'])) - { + foreach ($arraypricelevel as $key => $value) { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { print '<td class="right nowraponall">'; - if (!empty($productpricescache[$obj->rowid])) - { + if (!empty($productpricescache[$obj->rowid])) { if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { print price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC"); } else { @@ -1338,42 +1541,40 @@ if ($resql) } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } } } // Better buy price - if (!empty($arrayfields['p.minbuyprice']['checked'])) - { + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print '<td class="right nowraponall">'; - if ($obj->tobuy && $obj->minsellprice != '') - { + if ($obj->tobuy && $obj->minsellprice != '') { //print price($obj->minsellprice).' '.$langs->trans("HT"); - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) - { - if ($product_fourn->product_fourn_price_id > 0) - { - if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - { + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { + if ($product_fourn->product_fourn_price_id > 0) { + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); - } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + } else { + print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + } } } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Number of buy prices - if (!empty($arrayfields['p.numbuyprice']['checked'])) - { + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print '<td class="right">'; - if ($obj->tobuy) - { - if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) - { + if ($obj->tobuy) { + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); print $form->textwithpicto(count($productFournList), $htmltext); } @@ -1382,24 +1583,23 @@ if ($resql) } // VAT or Sell Tax Rate - if (!empty($arrayfields['p.tva_tx']['checked'])) - { + if (!empty($arrayfields['p.tva_tx']['checked'])) { print '<td class="right">'; print vatrate($obj->tva_tx, true); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // WAP - if (!empty($arrayfields['p.pmp']['checked'])) - { + if (!empty($arrayfields['p.pmp']['checked'])) { print '<td class="nowrap right">'; print price($product_static->pmp, 1, $langs); print '</td>'; } // Cost price - if (!empty($arrayfields['p.cost_price']['checked'])) - { + if (!empty($arrayfields['p.cost_price']['checked'])) { print '<td class="nowrap right">'; //print $obj->cost_price; print price($obj->cost_price).' '.$langs->trans("HT"); @@ -1407,104 +1607,119 @@ if ($resql) } // Limit alert - if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print '<td class="right">'; - if ($obj->fk_product_type != 1) - { + if ($obj->fk_product_type != 1) { print $obj->seuil_stock_alerte; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Desired stock - if (!empty($arrayfields['p.desiredstock']['checked'])) - { + if (!empty($arrayfields['p.desiredstock']['checked'])) { print '<td class="right">'; - if ($obj->fk_product_type != 1) - { + if ($obj->fk_product_type != 1) { print $obj->desiredstock; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Stock real - if (!empty($arrayfields['p.stock']['checked'])) - { + if (!empty($arrayfields['p.stock']['checked'])) { print '<td class="right">'; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + if ($obj->fk_product_type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } print price2num($product_static->stock_reel, 'MS'); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Stock virtual - if (!empty($arrayfields['stock_virtual']['checked'])) - { + if (!empty($arrayfields['stock_virtual']['checked'])) { print '<td class="right">'; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + if ($obj->fk_product_type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } print price2num($product_static->stock_theorique, 'MS'); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Lot/Serial - if (!empty($arrayfields['p.tobatch']['checked'])) - { + if (!empty($arrayfields['p.tobatch']['checked'])) { print '<td class="center">'; print yn($obj->tobatch); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Country - if (!empty($arrayfields['p.fk_country']['checked'])) - { + if (!empty($arrayfields['p.fk_country']['checked'])) { print '<td>'.getCountry($obj->fk_country, 0, $db).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // State - if (!empty($arrayfields['p.fk_state']['checked'])) - { + if (!empty($arrayfields['p.fk_state']['checked'])) { print '<td>'; - if (!empty($obj->fk_state)) print getState($obj->fk_state, 0, $db); + if (!empty($obj->fk_state)) { + print getState($obj->fk_state, 0, $db); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Accountancy code sell - if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { print '<td>'.$obj->accountancy_code_sell.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { print '<td>'.$obj->accountancy_code_sell_intra.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { print '<td>'.$obj->accountancy_code_sell_export.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print '<td>'.$obj->accountancy_code_buy.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { print '<td>'.$obj->accountancy_code_buy_intra.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) - { + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { print '<td>'.$obj->accountancy_code_buy_export.'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -1513,25 +1728,26 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['p.datec']['checked'])) - { + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="center nowraponall">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['p.tms']['checked'])) - { + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="center nowraponall">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status (to sell) - if (!empty($arrayfields['p.tosell']['checked'])) - { + if (!empty($arrayfields['p.tosell']['checked'])) { print '<td class="right nowrap">'; if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); @@ -1539,11 +1755,12 @@ if ($resql) print $product_static->LibStatut($obj->tosell, 5, 0); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status (to buy) - if (!empty($arrayfields['p.tobuy']['checked'])) - { + if (!empty($arrayfields['p.tobuy']['checked'])) { print '<td class="right nowrap">'; if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); @@ -1551,19 +1768,24 @@ if ($resql) print $product_static->LibStatut($obj->tobuy, 5, 1); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; $i++; diff --git a/htdocs/product/note.php b/htdocs/product/note.php index f0a6293383d..348d5956588 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -40,11 +40,15 @@ $action = GETPOST('action', 'aZ09'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); -if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} $permissionnote = $user->rights->produit->creer; // Used by the include of actions_setnotes.inc.php @@ -63,30 +67,33 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); $helpurl = ''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; +} $title = $langs->trans('ProductServiceCard'); $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } llxHeader('', $title, $help_url); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { /* - * Affichage onglets - */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + * Affichage onglets + */ + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); @@ -98,7 +105,9 @@ if ($id > 0 || !empty($ref)) $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 37019616e96..001635be24b 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -39,16 +39,24 @@ $type = GETPOST("type", "int"); $mode = GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : ''; // Security check -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service'); $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -if (!$sortfield) $sortfield = "c"; -if (!$sortorder) $sortorder = "DESC"; +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +if (!$sortfield) { + $sortfield = "c"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -88,8 +96,12 @@ if ((string) $type == '0') { $title = $langs->trans("ListProductByPopularity"); } -if ($type != '') $param .= '&type='.urlencode($type); -if ($mode != '') $param .= '&mode='.urlencode($mode); +if ($type != '') { + $param .= '&type='.urlencode($type); +} +if ($mode != '') { + $param .= '&mode='.urlencode($mode); +} $h = 0; $head = array(); @@ -134,8 +146,7 @@ $sql .= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type"; if (!empty($mode) && $mode != '-1') { $result = $db->query($sql); - if ($result) - { + if ($result) { $totalnboflines = $db->num_rows($result); } @@ -143,13 +154,11 @@ if (!empty($mode) && $mode != '-1') { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $infoprod[$objp->rowid] = array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label); @@ -179,8 +188,12 @@ print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="action" value="add">'; -if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; -if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; +if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; +} +if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; +} print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $totalnboflines, '', 0, '', '', -1, 0, 0, 1); @@ -195,11 +208,9 @@ print_liste_field_titre($textforqty, $_SERVER["PHP_SELF"], 'c', '', $param, '', print "</tr>\n"; if ($mode && $mode != '-1') { - foreach ($infoprod as $prodid => $vals) - { + foreach ($infoprod as $prodid => $vals) { // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$prodid; @@ -207,22 +218,29 @@ if ($mode && $mode != '-1') { $sql .= " LIMIT 1"; $resultp = $db->query($sql); - if ($resultp) - { + if ($resultp) { $objtp = $db->fetch_object($resultp); - if (!empty($objtp->label)) $vals['label'] = $objtp->label; + if (!empty($objtp->label)) { + $vals['label'] = $objtp->label; + } } } print "<tr>"; print '<td><a href="'.DOL_URL_ROOT.'/product/stats/card.php?id='.$prodid.'">'; - if ($vals['type'] == 1) print img_object($langs->trans("ShowService"), "service"); - else print img_object($langs->trans("ShowProduct"), "product"); + if ($vals['type'] == 1) { + print img_object($langs->trans("ShowService"), "service"); + } else { + print img_object($langs->trans("ShowProduct"), "product"); + } print " "; print $vals['ref'].'</a></td>'; print '<td>'; - if ($vals['type'] == 1) print $langs->trans("Service"); - else print $langs->trans("Product"); + if ($vals['type'] == 1) { + print $langs->trans("Service"); + } else { + print $langs->trans("Product"); + } print '</td>'; print '<td>'.$vals['label'].'</td>'; print '<td class="right">'.$vals['nbline'].'</td>'; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 89695690d38..408c169e363 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -65,17 +65,20 @@ $search_soc = GETPOST('search_soc'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new Product($db); $object->fetch($id, $ref); } // Clean param -if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5; +if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) { + $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productpricecard', 'globalcard')); @@ -85,37 +88,36 @@ $hookmanager->initHooks(array('productpricecard', 'globalcard')); * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} $parameters = array('id'=>$id, 'ref'=>$ref); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - 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 (empty($reshook)) { + 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_soc = ''; } - if ($action == 'setlabelsellingprice' && $user->admin) - { + if ($action == 'setlabelsellingprice' && $user->admin) { require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.GETPOST('pricelevel'); dolibarr_set_const($db, $keyforlabel, GETPOST('labelsellingprice', 'alpha'), 'chaine', 0, '', $conf->entity); $action = ''; } - if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) - { + if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' // We must define tva_tx, npr and local taxes $tva_tx = $tva_tx_txt; $reg = array(); $vatratecode = ''; - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { $vat_src_code = $reg[1]; $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. } @@ -124,8 +126,7 @@ if (empty($reshook)) $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in create product. $vatratecode = $reg[1]; // Get record from code @@ -135,8 +136,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -157,21 +157,18 @@ if (empty($reshook)) $db->begin(); $resql = $object->update($object->id, $user); - if ($resql <= 0) - { + if ($resql <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } - if ($error) - { + if ($error) { //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -180,8 +177,7 @@ if (empty($reshook)) $action = ''; } - if (($action == 'update_price') && !$cancel && $object->getRights()->creer) - { + if (($action == 'update_price') && !$cancel && $object->getRights()->creer) { $error = 0; $pricestoupdate = array(); @@ -218,8 +214,7 @@ if (empty($reshook)) //Shall we generate prices using price rules? $object->price_autogen = GETPOST('usePriceRules') == 'on'; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if (!isset($newprice[$i])) { continue; } @@ -229,8 +224,7 @@ if (empty($reshook)) $tva_tx = $tva_tx_txt; $vatratecode = ''; $reg = array(); - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { $vat_src_code = $reg[1]; $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. } @@ -241,8 +235,7 @@ if (empty($reshook)) $localtax1_type = $newlocaltax1_type[$i]; $localtax2 = $newlocaltax2_tx[$i]; $localtax2_type = $newlocaltax2_type[$i]; - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code $vatratecode = $reg[1]; // Get record from code @@ -252,8 +245,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -278,8 +270,7 @@ if (empty($reshook)) break; } } - } elseif (!$error) - { + } elseif (!$error) { $newprice = price2num(GETPOST('price', 'alpha'), '', 2); $newprice_min = price2num(GETPOST('price_min', 'alpha'), '', 2); $newpricebase = GETPOST('price_base_type', 'alpha'); @@ -288,8 +279,7 @@ if (empty($reshook)) $tva_tx = $tva_tx_txt; $vatratecode = ''; $reg = array(); - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { $vat_src_code = $reg[1]; $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. } @@ -298,8 +288,7 @@ if (empty($reshook)) $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code $vatratecode = $reg[1]; // Get record from code @@ -309,8 +298,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -319,10 +307,9 @@ if (empty($reshook)) $localtax2_type = $obj->localtax2_type; // If spain, we don't use the localtax found into tax record in database with same code, but using the get_localtax rule - if (in_array($mysoc->country_code, array('ES'))) - { + if (in_array($mysoc->country_code, array('ES'))) { $localtax1 = get_localtax($tva_tx, 1); - $localtax2 = get_localtax($tva_tx, 2); + $localtax2 = get_localtax($tva_tx, 2); } } } @@ -356,9 +343,11 @@ if (empty($reshook)) break; } - if ($object->multiprices[$key] != $newprice || $object->multiprices_min[$key] != $newprice_min || $object->multiprices_base_type[$key] != $val['price_base_type']) - $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array'], $val['default_vat_code']); - else $res = 0; + if ($object->multiprices[$key] != $newprice || $object->multiprices_min[$key] != $newprice_min || $object->multiprices_base_type[$key] != $val['price_base_type']) { + $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array'], $val['default_vat_code']); + } else { + $res = 0; + } if ($res < 0) { @@ -385,8 +374,7 @@ if (empty($reshook)) } - if ($action == 'delete' && $user->rights->produit->supprimer) - { + if ($action == 'delete' && $user->rights->produit->supprimer) { $result = $object->log_price_delete($user, GETPOST('lineid', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -394,28 +382,24 @@ if (empty($reshook)) } // Set Price by quantity - if ($action == 'activate_price_by_qty') - { + if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price line with price_by_qty set to 1 $level = GETPOST('level', 'int'); $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); } // Unset Price by quantity - if ($action == 'disable_price_by_qty') - { + if ($action == 'disable_price_by_qty') { // Disabling product price by quantity add a new price line with price_by_qty set to 0 $level = GETPOST('level', 'int'); $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); } - if ($action == 'edit_price_by_qty') - { // Edition d'un prix par quantité + if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité $rowid = GETPOST('rowid', 'int'); } // Add or update price by quantity - if ($action == 'update_price_by_qty') - { + if ($action == 'update_price_by_qty') { // Récupération des variables $rowid = GETPOST('rowid', 'int'); $priceid = GETPOST('priceid', 'int'); @@ -453,7 +437,9 @@ if (empty($reshook)) $sql .= " WHERE rowid = ".$rowid; $result = $db->query($sql); - if (!$result) dol_print_error($db); + if (!$result) { + dol_print_error($db); + } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values ("; $sql .= $priceid.','.$price.','.$unitPrice.','.$quantity.','.$remise_percent.','.$remise.')'; @@ -470,8 +456,7 @@ if (empty($reshook)) } } - if ($action == 'delete_price_by_qty') - { + if ($action == 'delete_price_by_qty') { $rowid = GETPOST('rowid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; @@ -517,8 +502,7 @@ if (empty($reshook)) $tva_tx = $tva_tx_txt; $vatratecode = ''; - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { $vat_src_code = $reg[1]; $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. } @@ -527,8 +511,7 @@ if (empty($reshook)) $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code $vatratecode = $reg[1]; // Get record from code @@ -538,8 +521,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -557,23 +539,20 @@ if (empty($reshook)) $prodcustprice->localtax1_type = $localtax1_type; $prodcustprice->localtax2_type = $localtax2_type; - if (!($prodcustprice->fk_soc > 0)) - { + if (!($prodcustprice->fk_soc > 0)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); $error++; $action = 'add_customer_price'; } - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min < $maxpricesupplier) - { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min < $maxpricesupplier) { $langs->load("errors"); setEventMessages($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')), null, 'errors'); $error++; $action = 'add_customer_price'; } - if (!$error) - { + if (!$error) { $result = $prodcustprice->create($user, 0, $update_child_soc); if ($result < 0) { @@ -586,8 +565,7 @@ if (empty($reshook)) } } - if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) - { + if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) { // Delete price by customer $prodcustprice->id = GETPOST('lineid'); $result = $prodcustprice->delete($user); @@ -600,8 +578,7 @@ if (empty($reshook)) $action = ''; } - if ($action == 'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) - { + if ($action == 'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { $maxpricesupplier = $object->min_recommended_price(); $update_child_soc = GETPOST('updatechildprice', 'int'); @@ -618,8 +595,7 @@ if (empty($reshook)) $tva_tx = $tva_tx_txt; $vatratecode = ''; - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { $vat_src_code = $reg[1]; $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx_txt); // Remove code into vatrate. } @@ -628,8 +604,7 @@ if (empty($reshook)) $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) - { + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { // We look into database using code $vatratecode = $reg[1]; // Get record from code @@ -639,8 +614,7 @@ if (empty($reshook)) $sql .= " AND t.taux = ".$tva_tx." AND t.active = 1"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; $localtax1 = $obj->localtax1; @@ -658,15 +632,13 @@ if (empty($reshook)) $prodcustprice->localtax1_type = $localtax1_type; $prodcustprice->localtax2_type = $localtax2_type; - if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) - { + if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { setEventMessages($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')), null, 'errors'); $error++; $action = 'update_customer_price'; } - if (!$error) - { + if (!$error) { $result = $prodcustprice->update($user, 0, $update_child_soc); if ($result < 0) { @@ -687,8 +659,7 @@ if (empty($reshook)) $form = new Form($db); -if (!empty($id) || !empty($ref)) -{ +if (!empty($id) || !empty($ref)) { // fetch updated prices $object->fetch($id, $ref); } @@ -696,13 +667,11 @@ if (!empty($id) || !empty($ref)) $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('SellingPrices'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('SellingPrices'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -719,7 +688,9 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_value $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; -if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; +} dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -730,11 +701,9 @@ print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; // Price per customer segment/level -if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) -{ +if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { // Price and min price are variable (depends on level of company). - if (!empty($socid)) - { + if (!empty($socid)) { $soc = new Societe($db); $soc->id = $socid; $soc->fetch($socid); @@ -758,24 +727,30 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ // Price min print '<tr><td>'.$langs->trans("MinPrice").'</td><td colspan="2">'; - if ($object->multiprices_base_type[$soc->price_level] == 'TTC') - { + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { print price($object->multiprices_min_ttc[$soc->price_level]).' '.$langs->trans($object->multiprices_base_type[$soc->price_level]); } else { print price($object->multiprices_min[$soc->price_level]).' '.$langs->trans(empty($object->multiprices_base_type[$soc->price_level]) ? 'HT' : $object->multiprices_base_type[$soc->price_level]); } print '</td></tr>'; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility // TVA print '<tr><td>'.$langs->trans("DefaultTaxRate").'</td><td colspan="2">'; $positiverates = ''; - if (price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_tva_tx[$soc->price_level]); - if (price2num($object->multiprices_localtax1_type[$soc->price_level])) $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_localtax1_tx[$soc->price_level]); - if (price2num($object->multiprices_localtax2_type[$soc->price_level])) $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_localtax2_tx[$soc->price_level]); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->multiprices_tva_tx[$soc->price_level])) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_tva_tx[$soc->price_level]); + } + if (price2num($object->multiprices_localtax1_type[$soc->price_level])) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_localtax1_tx[$soc->price_level]); + } + if (price2num($object->multiprices_localtax2_type[$soc->price_level])) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->multiprices_localtax2_tx[$soc->price_level]); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); //print vatrate($object->multiprices_tva_tx[$soc->price_level], true); print '</td></tr>'; @@ -784,22 +759,29 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<tr><td>'.$langs->trans("DefaultTaxRate").'</td><td>'; $positiverates = ''; - if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + } + if (price2num($object->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + } + if (price2num($object->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); /* if ($object->default_vat_code) - { - print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; - } - else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ + { + print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; + } + else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ print '</td></tr>'; } } else { - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility // We show only vat for level 1 print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td>'; print '<td colspan="2">'.vatrate($object->multiprices_tva_tx[1], true).'</td>'; @@ -809,17 +791,25 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>'; $positiverates = ''; - if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + } + if (price2num($object->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + } + if (price2num($object->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); /* - if ($object->default_vat_code) - { - print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; - } - else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ + if ($object->default_vat_code) + { + print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; + } + else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true);*/ print '</td></tr>'; } print '</table>'; @@ -829,21 +819,21 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<table class="noborder tableforfield" width="100%">'; print '<tr class="liste_titre"><td>'; print $langs->trans("PriceLevel"); - if ($user->admin) print ' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editlabelsellingprice&amp;pricelevel='.$i.'&amp;id='.$object->id.'">'.img_edit($langs->trans('EditSellingPriceLabel'), 0).'</a>'; + if ($user->admin) { + print ' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editlabelsellingprice&amp;pricelevel='.$i.'&amp;id='.$object->id.'">'.img_edit($langs->trans('EditSellingPriceLabel'), 0).'</a>'; + } print '</td>'; print '<td style="text-align: right">'.$langs->trans("SellingPrice").'</td>'; print '<td style="text-align: right">'.$langs->trans("MinPrice").'</td>'; print '</tr>'; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print '<tr class="oddeven">'; // Label of price print '<td>'; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; - if (preg_match('/editlabelsellingprice/', $action)) - { + if (preg_match('/editlabelsellingprice/', $action)) { print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="setlabelsellingprice">'; @@ -854,7 +844,9 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '</form>'; } else { print $langs->trans("SellingPrice").' '.$i; - if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + if (!empty($conf->global->$keyforlabel)) { + print ' - '.$langs->trans($conf->global->$keyforlabel); + } } print '</td>'; @@ -872,9 +864,10 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ // Prix min print '<td style="text-align: right">'; - if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i] = "HT"; - if ($object->multiprices_base_type[$i] == 'TTC') - { + if (empty($object->multiprices_base_type[$i])) { + $object->multiprices_base_type[$i] = "HT"; + } + if ($object->multiprices_base_type[$i] == 'TTC') { print price($object->multiprices_min_ttc[$i]).' '.$langs->trans($object->multiprices_base_type[$i]); } else { print price($object->multiprices_min[$i]).' '.$langs->trans($object->multiprices_base_type[$i]); @@ -882,10 +875,11 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '</td></tr>'; // Price by quantity - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // TODO Fix the form included into a tr instead of a td - { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { // TODO Fix the form included into a tr instead of a td print '<tr><td>'.$langs->trans("PriceByQuantity").' '.$i; - if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + if (!empty($conf->global->$keyforlabel)) { + print ' - '.$langs->trans($conf->global->$keyforlabel); + } print '</td><td colspan="2">'; if ($object->prices_by_qty[$i] == 1) { @@ -898,8 +892,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<td class="right">'.$langs->trans("Discount").'</td>'; print '<td>&nbsp;</td>'; print '</tr>'; - foreach ($object->prices_by_qty_list[$i] as $ii => $prices) - { + foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -963,15 +956,23 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>'; $positiverates = ''; - if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + } + if (price2num($object->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + } + if (price2num($object->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); /* if ($object->default_vat_code) { - print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; + print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; } else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/ print '</td></tr>'; @@ -995,8 +996,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '</td></tr>'; // Price by quantity - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // TODO Fix the form inside tr instead of td - { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { // TODO Fix the form inside tr instead of td print '<tr><td>'.$langs->trans("PriceByQuantity"); if ($object->prices_by_qty[0] == 0) { print '&nbsp; <a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=activate_price_by_qty&level=1">('.$langs->trans("Activate").')'; @@ -1005,8 +1005,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ } print '</td><td>'; - if ($object->prices_by_qty[0] == 1) - { + if ($object->prices_by_qty[0] == 1) { print '<table width="50%" class="border" summary="List of quantities">'; print '<tr class="liste_titre">'; //print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>'; @@ -1017,8 +1016,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<td class="right">'.$langs->trans("Discount").'</td>'; print '<td>&nbsp;</td>'; print '</tr>'; - if ($action != 'edit_price_by_qty') - { + if ($action != 'edit_price_by_qty') { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; // FIXME a form into a table is not allowed print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update_price_by_qty">'; @@ -1038,10 +1036,8 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '</form>'; } - foreach ($object->prices_by_qty_list[0] as $ii => $prices) - { - if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) - { + foreach ($object->prices_by_qty_list[0] as $ii => $prices) { + if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update_price_by_qty">'; @@ -1070,8 +1066,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '<td class="right">'.price($prices['unitprice']).'</td>'; print '<td class="right">'.price($prices['remise_percent']).' %</td>'; print '<td class="center">'; - if (($user->rights->produit->creer || $user->rights->service->creer)) - { + if (($user->rights->produit->creer || $user->rights->service->creer)) { print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit_price_by_qty&amp;rowid='.$prices["rowid"].'">'; print img_edit().'</a>'; print '<a class="marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete_price_by_qty&amp;token='.newToken().'&amp;rowid='.$prices["rowid"].'">'; @@ -1108,8 +1103,7 @@ print dol_get_fiche_end(); /* ************************************************************************** */ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $action == 'showlog_default_price' || $action == 'add_customer_price' - || $action == 'activate_price_by_qty' || $action == 'disable_price_by_qty') -{ + || $action == 'activate_price_by_qty' || $action == 'disable_price_by_qty') { print "\n".'<div class="tabsAction">'."\n"; if ($object->isVariant()) { @@ -1149,8 +1143,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a * Edit price area */ -if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) -{ +if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) { print load_fiche_titre($langs->trans("UpdateVAT"), ''); print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; @@ -1180,12 +1173,10 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print '<br></form><br>'; } -if ($action == 'edit_price' && $object->getRights()->creer) -{ +if ($action == 'edit_price' && $object->getRights()->creer) { print load_fiche_titre($langs->trans("NewPrice"), ''); - if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print '<!-- Edit price -->'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -1210,7 +1201,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print '</td>'; print '</tr>'; - // Only show price mode and expression selector if module is enabled + // Only show price mode and expression selector if module is enabled if (!empty($conf->dynamicprices->enabled)) { // Price mode selector print '<tr><td>'.$langs->trans("PriceMode").'</td><td>'; @@ -1270,8 +1261,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) } else { print '<input name="price_min" size="10" value="'.price($object->price_min).'">'; } - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) - { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ' &nbsp; '.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>'; } print '</td>'; @@ -1333,8 +1323,11 @@ if ($action == 'edit_price' && $object->getRights()->creer) print '<td>'.$langs->trans("PriceLevel").'</td>'; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) print '<td style="text-align: center">'.$langs->trans("DefaultTaxRate").'</td>'; - else print '<td></td>'; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { + print '<td style="text-align: center">'.$langs->trans("DefaultTaxRate").'</td>'; + } else { + print '<td></td>'; + } print '<td class="center">'.$langs->trans("SellingPrice").'</td>'; @@ -1347,8 +1340,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print '<tbody>'; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) - { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print '<tr class="oddeven">'; print '<td>'; $text = $langs->trans('SellingPrice').' '.$i; @@ -1389,8 +1381,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) } else { print '<input name="price_min['.$i.']" size="10" value="'.price($object->multiprices_min [$i]).'">'; } - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) - { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print '<td class="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>'; } print '</td>'; @@ -1415,8 +1406,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) // List of price changes - log historic (ordered by descending date) -if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_default_price') && !in_array($action, array('edit_price', 'edit_vat'))) -{ +if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_default_price') && !in_array($action, array('edit_price', 'edit_vat'))) { $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly, p.localtax1_tx, p.localtax1_type, p.localtax2_tx, p.localtax2_type,"; $sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,"; $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; @@ -1425,29 +1415,29 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul $sql .= " WHERE fk_product = ".$object->id; $sql .= " AND p.entity IN (".getEntity('productprice').")"; $sql .= " AND p.fk_user_author = u.rowid"; - if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = ".$soc->price_level; + if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) { + $sql .= " AND p.price_level = ".$soc->price_level; + } $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); $result = $db->query($sql); - if ($result) - { + if ($result) { print '<div class="divlogofpreviouscustomerprice">'; $num = $db->num_rows($result); - if (!$num) - { + if (!$num) { $db->free($result); - // Il doit au moins y avoir la ligne de prix initial. - // On l'ajoute donc pour remettre a niveau (pb vieilles versions) - // We emulate the change of the price from interface with the same value than the one into table llx_product - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); - } else { - $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); - } + // Il doit au moins y avoir la ligne de prix initial. + // On l'ajoute donc pour remettre a niveau (pb vieilles versions) + // We emulate the change of the price from interface with the same value than the one into table llx_product + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); + } else { + $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); + } $result = $db->query($sql); $num = $db->num_rows($result); @@ -1458,8 +1448,11 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul // Log of previous customer prices $backbutton = '<a class="justalink" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'.$langs->trans("Back").'</a>'; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPriceLog"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); - else print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + print_barre_liste($langs->trans("DefaultPriceLog"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); + } else { + print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); + } print '<div class="div-table-responsive">'; print '<table class="liste centpercent">'; @@ -1476,7 +1469,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print '<td class="center">'.$langs->trans("PriceBase").'</td>'; print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL; - if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>'; + if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>'; + } print '<td class="right">'.$langs->trans("HT").'</td>'; print '<td class="right">'.$langs->trans("TTC").'</td>'; if (!empty($conf->dynamicprices->enabled)) { @@ -1485,15 +1480,15 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; print '<td class="right">'.$langs->trans("ChangedBy").'</td>'; - if ($user->rights->produit->supprimer) + if ($user->rights->produit->supprimer) { print '<td class="right">&nbsp;</td>'; + } print '</tr>'; $notfirstlineforlevel = array(); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); print '<tr class="oddeven">'; @@ -1505,8 +1500,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print '<td class="center">'.$objp->price_level."</td>"; } // Price by quantity - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; print '<td class="center">'.$langs->trans($type)."</td>"; } @@ -1517,31 +1511,37 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul } print "</td>"; - if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print '<td class="right">'; if (empty($objp->price_by_qty)) { $positiverates = ''; - if (price2num($objp->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->tva_tx); - if (price2num($objp->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax1_tx); - if (price2num($objp->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($objp->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($objp->tva_tx); + } + if (price2num($objp->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax1_tx); + } + if (price2num($objp->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($objp->default_vat_code ? ' ('.$objp->default_vat_code.')' : ''), '%', $objp->tva_npr); /* - if ($objp->default_vat_code) - { - print vatrate($objp->tva_tx, true) . ' ('.$objp->default_vat_code.')'; - } - else print vatrate($objp->tva_tx, true, $objp->recuperableonly);*/ + if ($objp->default_vat_code) + { + print vatrate($objp->tva_tx, true) . ' ('.$objp->default_vat_code.')'; + } + else print vatrate($objp->tva_tx, true, $objp->recuperableonly);*/ } print "</td>"; } // Price - if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) - { + if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); $res = $price_expression->fetch($objp->fk_price_expression); $title = $price_expression->title; @@ -1586,22 +1586,26 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print '</td>'; // Action - if ($user->rights->produit->supprimer) - { + if ($user->rights->produit->supprimer) { $candelete = 0; - if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { - if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level] = 1; - else $candelete = 1; - } elseif ($i > 0) $candelete = 1; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + if (empty($notfirstlineforlevel[$objp->price_level])) { + $notfirstlineforlevel[$objp->price_level] = 1; + } else { + $candelete = 1; + } + } elseif ($i > 0) { + $candelete = 1; + } print '<td class="right">'; - if ($candelete) - { + if ($candelete) { print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id.'&amp;lineid='.$objp->rowid.'">'; print img_delete(); print '</a>'; - } else print '&nbsp;'; // Can not delete last price (it's current price) + } else { + print '&nbsp;'; // Can not delete last price (it's current price) + } print '</td>'; } @@ -1623,22 +1627,25 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul // Add area to show/add/edit a price for a dedicated customer -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) -{ +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($db); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + 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) + if (!$sortorder) { $sortorder = "ASC"; - if (!$sortfield) + } + if (!$sortfield) { $sortfield = "soc.nom"; + } // Build filter to diplay only concerned lines $filter = array('t.fk_product' => $object->id); @@ -1647,8 +1654,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $filter['soc.nom'] = $search_soc; } - if ($action == 'add_customer_price') - { + if ($action == 'add_customer_price') { // Form to add a new customer price $maxpricesupplier = $object->min_recommended_price(); @@ -1708,8 +1714,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } else { print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">'; } - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) - { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print '<td class="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>'; } print '</td></tr>'; @@ -1732,8 +1737,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '</div>'; print '</form>'; - } elseif ($action == 'edit_customer_price') - { + } elseif ($action == 'edit_customer_price') { // Edit mode $maxpricesupplier = $object->min_recommended_price(); @@ -1800,8 +1804,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min).'">'; } print '</td>'; - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) - { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print '<td class="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'</td>'; } print '</tr>'; @@ -1829,8 +1832,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '</div>'; print '<br></form>'; - } elseif ($action == 'showlog_customer_price') - { + } elseif ($action == 'showlog_customer_price') { // List of all log of prices by customers print '<!-- list of all log of prices per customer -->'."\n"; @@ -1859,8 +1861,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); - if (count($prodcustprice->lines) > 0) - { + if (count($prodcustprice->lines) > 0) { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; @@ -1874,8 +1875,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="center">'.$langs->trans("PriceBase").'</td>'; print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>'; print '<td class="right">'.$langs->trans("HT").'</td>'; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '<td class="right">' . $langs->trans("INCVATONLY") . '</td>'; print '<td class="right">'.$langs->trans("INCT").'</td>'; } else { @@ -1887,8 +1887,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td>&nbsp;</td>'; print '</tr>'; - foreach ($prodcustprice->lines as $line) - { + foreach ($prodcustprice->lines as $line) { // Date $staticsoc = new Societe($db); $staticsoc->fetch($line->fk_soc); @@ -1896,8 +1895,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type == 'HT') - { + if ($line->price_base_type == 'HT') { $pu = $line->price; } else { $pu = $line->price_ttc; @@ -1923,10 +1921,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="right">'; $positiverates = ''; - if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($line->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + } + if (price2num($line->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + } + if (price2num($line->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); @@ -1934,8 +1940,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "</td>"; print '<td class="right">'.price($line->price)."</td>"; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '<td class="right">' . price($line->price_ttc) . "</td>"; print '<td class="right">'.price($resultarray[2]).'</td>'; } else { @@ -1958,8 +1963,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } else { print $langs->trans('None'); } - } elseif ($action != 'showlog_default_price' && $action != 'edit_price') - { + } elseif ($action != 'showlog_default_price' && $action != 'edit_price') { // List of all prices by customers print '<!-- list of all prices per customer -->'."\n"; @@ -1984,8 +1988,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<table class="liste centpercent">'; - if (count($prodcustprice->lines) > 0 || $search_soc) - { + if (count($prodcustprice->lines) > 0 || $search_soc) { $colspan = 9; //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; @@ -2007,8 +2010,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="center">'.$langs->trans("PriceBase").'</td>'; print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>'; print '<td class="right">'.$langs->trans("HT").'</td>'; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '<td class="right">' . $langs->trans("INCVATONLY") . '</td>'; print '<td class="right">'.$langs->trans("INCT").'</td>'; } else { @@ -2022,8 +2024,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '</tr>'; // Line for default price - if ($object->price_base_type == 'HT') - { + if ($object->price_base_type == 'HT') { $pu = $object->price; } else { $pu = $object->price_ttc; @@ -2047,10 +2048,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="right">'; $positiverates = ''; - if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($object->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + } + if (price2num($object->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + } + if (price2num($object->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); //print vatrate($object->tva_tx, true, $object->tva_npr); @@ -2059,8 +2068,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="right">'.price($object->price)."</td>"; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '<td class="right">' . price($object->price_ttc) . "</td>"; print '<td class="right">'.price($resultarray[2]).'</td>'; } else { @@ -2072,8 +2080,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="right">'.price($object->price_min_ttc).'</td>'; print '<td class="right">'; print '</td>'; - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) - { + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print '<td class="right">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=showlog_default_price&amp;id='.$object->id.'">'; print img_info($langs->trans('PriceByCustomerLog')); @@ -2087,10 +2094,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } print "</tr>\n"; - if (count($prodcustprice->lines) > 0) - { - foreach ($prodcustprice->lines as $line) - { + if (count($prodcustprice->lines) > 0) { + foreach ($prodcustprice->lines as $line) { // Date $staticsoc = new Societe($db); $staticsoc->fetch($line->fk_soc); @@ -2098,8 +2103,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type == 'HT') - { + if ($line->price_base_type == 'HT') { $pu = $line->price; } else { $pu = $line->price_ttc; @@ -2126,17 +2130,24 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '<td class="right">'; $positiverates = ''; - if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates = '0'; + if (price2num($line->tva_tx)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + } + if (price2num($line->localtax1_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + } + if (price2num($line->localtax2_type)) { + $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + } + if (empty($positiverates)) { + $positiverates = '0'; + } echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); print "</td>"; print '<td class="right">'.price($line->price)."</td>"; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '<td class="right">' . price($line->price_ttc) . "</td>"; print '<td class="right">'.price($resultarray[2]).'</td>'; } else { @@ -2155,8 +2166,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // Todo Edit or delete button // Action - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) - { + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print '<td class="right nowraponall">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;id='.$object->id.'&amp;socid='.$line->fk_soc.'">'; print img_info($langs->trans('PriceByCustomerLog')); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 715ad66e977..e0d1d7447a0 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->loadLangs(array('products', 'stocks')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service'); @@ -55,11 +57,19 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) $page = 0; -if (!$sortfield) $sortfield = "p.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (empty($page) || $page < 0) { + $page = 0; +} +if (!$sortfield) { + $sortfield = "p.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $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 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; // Load sale and categ filters @@ -69,8 +79,7 @@ $search_categ = GETPOST("search_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('product', 'list', $canvas); @@ -83,8 +92,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) -{ + || !empty($conf->mrp->enabled)) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -97,8 +105,7 @@ $hookmanager->initHooks(array('productreassortlist')); * Actions */ -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 $sref = ""; $snom = ""; $sall = ""; @@ -128,7 +135,9 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price $sql .= ' p.fk_product_type, p.tms as datem,'; $sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql .= ' SUM(s.reel) as stock_physique'; -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', u.short_label as unit_short'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ', u.short_label as unit_short'; +} // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -136,49 +145,73 @@ $sql .= $hookmanager->resPrint; $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 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('entrepot').')'; -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; +} // We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +if ($search_categ) { + $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +} $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +if ($search_categ) { + $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +} +if ($sall) { + $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +} // if the type is not 1, we show all products (type = 0,2,3) -if (dol_strlen($type)) -{ - if ($type == 1) - { +if (dol_strlen($type)) { + if ($type == 1) { $sql .= " AND p.fk_product_type = '1'"; } else { $sql .= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql .= natural_search('p.ref', $sref); -if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); -if ($snom) $sql .= natural_search('p.label', $snom); -if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell; -if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy; -if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; -if ($catid) $sql .= " AND cp.fk_categorie = ".$catid; -if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +if ($sref) { + $sql .= natural_search('p.ref', $sref); +} +if ($search_barcode) { + $sql .= natural_search('p.barcode', $search_barcode); +} +if ($snom) { + $sql .= natural_search('p.label', $snom); +} +if (!empty($tosell)) { + $sql .= " AND p.tosell = ".$tosell; +} +if (!empty($tobuy)) { + $sql .= " AND p.tobuy = ".$tobuy; +} +if (!empty($canvas)) { + $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +} +if ($catid) { + $sql .= " AND cp.fk_categorie = ".$catid; +} +if ($fourn_id > 0) { + $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +} // Insert categ filter -if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); +if ($search_categ) { + $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); +} $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +if ($toolowstock) { + $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +} $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -187,41 +220,68 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall || $snom || $sref)) - { + if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall || $snom || $sref)) { $objp = $db->fetch_object($resql); header("Location: card.php?id=$objp->rowid"); exit; } - if (isset($type)) - { - if ($type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } + if (isset($type)) { + if ($type == 1) { + $texte = $langs->trans("Services"); + } else { + $texte = $langs->trans("Products"); + } } else { $texte = $langs->trans("ProductsAndServices"); } $texte .= ' ('.$langs->trans("MenuStocks").')'; $param = ''; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= "&sall=".urlencode($sall); - if ($tosell) $param .= "&tosell=".urlencode($tosell); - if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); - if ($type) $param .= "&type=".urlencode($type); - if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); - if ($snom) $param .= "&snom=".urlencode($snom); - if ($sref) $param .= "&sref=".urlencode($sref); - if ($search_sale) $param .= "&search_sale=".urlencode($search_sale); - if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); - if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); - if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); - if ($catid) $param .= "&catid=".urlencode($catid); + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } + if ($tosell) { + $param .= "&tosell=".urlencode($tosell); + } + if ($tobuy) { + $param .= "&tobuy=".urlencode($tobuy); + } + if ($type) { + $param .= "&type=".urlencode($type); + } + if ($fourn_id) { + $param .= "&fourn_id=".urlencode($fourn_id); + } + if ($snom) { + $param .= "&snom=".urlencode($snom); + } + if ($sref) { + $param .= "&sref=".urlencode($sref); + } + if ($search_sale) { + $param .= "&search_sale=".urlencode($search_sale); + } + if ($search_categ) { + $param .= "&search_categ=".urlencode($search_categ); + } + if ($toolowstock) { + $param .= "&toolowstock=".urlencode($toolowstock); + } + if ($sbarcode) { + $param .= "&sbarcode=".urlencode($sbarcode); + } + if ($catid) { + $param .= "&catid=".urlencode($catid); + } llxHeader("", $texte, $helpurl); @@ -234,8 +294,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit); - if (!empty($catid)) - { + if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); $c->fetch($catid); @@ -245,21 +304,19 @@ if ($resql) } // Filter on categories - $moreforfilter = ''; - if (!empty($conf->categorie->enabled)) - { - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter .= '</div>'; + $moreforfilter .= '</div>'; } $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock ? ' checked' : '').'>'; $moreforfilter .= '</div>'; - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -269,21 +326,39 @@ if ($resql) } $param = ''; - if ($tosell) $param .= "&tosell=".urlencode($tosell); - if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); - if ($type) $param .= "&type=".urlencode($type); - if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); - if ($snom) $param .= "&snom=".urlencode($snom); - if ($sref) $param .= "&sref=".urlencode($sref); - if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); - if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); + if ($tosell) { + $param .= "&tosell=".urlencode($tosell); + } + if ($tobuy) { + $param .= "&tobuy=".urlencode($tobuy); + } + if ($type) { + $param .= "&type=".urlencode($type); + } + if ($fourn_id) { + $param .= "&fourn_id=".urlencode($fourn_id); + } + if ($snom) { + $param .= "&snom=".urlencode($snom); + } + if ($sref) { + $param .= "&sref=".urlencode($sref); + } + if ($toolowstock) { + $param .= "&toolowstock=".urlencode($toolowstock); + } + if ($search_categ) { + $param .= "&search_categ=".urlencode($search_categ); + } $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; $nb_warehouse = count($warehouses_list); $colspan_warehouse = 1; - if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; } + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { + $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'; @@ -297,8 +372,7 @@ if ($resql) print '<input class="flat" type="text" name="snom" size="8" value="'.$snom.'">'; print '</td>'; // Duration - if (!empty($conf->service->enabled) && $type == 1) - { + if (!empty($conf->service->enabled) && $type == 1) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; @@ -307,7 +381,9 @@ if ($resql) print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre right">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>'; - if ($virtualdiffersfromphysical) print '<td class="liste_titre">&nbsp;</td>'; + if ($virtualdiffersfromphysical) { + print '<td class="liste_titre">&nbsp;</td>'; + } print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre" colspan="'.$colspan_warehouse.'">&nbsp;</td>'; print '<td class="liste_titre"></td>'; @@ -315,8 +391,8 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '<td class="liste_titre maxwidthsearch">'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; print '</td>'; print '</tr>'; @@ -324,20 +400,23 @@ if ($resql) print "<tr class=\"liste_titre\">"; 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->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + if (!empty($conf->service->enabled) && $type == 1) { + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + } print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // Details per warehouse - if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) - { + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right '); } } } - if ($virtualdiffersfromphysical) print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); + if ($virtualdiffersfromphysical) { + print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); + } // Units if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder); @@ -352,8 +431,7 @@ if ($resql) print_liste_field_titre(''); print "</tr>\n"; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); $product = new Product($db); @@ -367,13 +445,17 @@ if ($resql) print '</td>'; print '<td>'.$product->label.'</td>'; - if (!empty($conf->service->enabled) && $type == 1) - { + if (!empty($conf->service->enabled) && $type == 1) { print '<td class="center">'; - if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationDay"); - else print $objp->duration; + if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationYear"); + } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationMonth"); + } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationDay"); + } else { + print $objp->duration; + } print '</td>'; } //print '<td class="right">'.$objp->stock_theorique.'</td>'; @@ -381,13 +463,14 @@ if ($resql) print '<td class="right">'.$objp->desiredstock.'</td>'; // Real stock print '<td class="right">'; - if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) { + print img_warning($langs->trans("StockTooLow")).' '; + } print price2num($objp->stock_physique, 'MS'); print '</td>'; // Details per warehouse - if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) - { + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print '<td class="right">'; @@ -398,10 +481,11 @@ if ($resql) } // Virtual stock - if ($virtualdiffersfromphysical) - { + if ($virtualdiffersfromphysical) { print '<td class="right">'; - if ($objp->seuil_stock_alerte != '' && ($product->stock_theorique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + if ($objp->seuil_stock_alerte != '' && ($product->stock_theorique < $objp->seuil_stock_alerte)) { + print img_warning($langs->trans("StockTooLow")).' '; + } print price2num($product->stock_theorique, 'MS'); print '</td>'; } diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 7949c5441c1..5983d5e6b4e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -38,7 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $langs->loadLangs(array('products', 'stocks', 'productbatch')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service'); @@ -59,11 +61,19 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) $page = 0; -if (!$sortfield) $sortfield = "p.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (empty($page) || $page < 0) { + $page = 0; +} +if (!$sortfield) { + $sortfield = "p.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $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 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; // Load sale and categ filters @@ -73,8 +83,7 @@ $search_categ = GETPOST("search_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('product', 'list', $canvas); @@ -86,8 +95,7 @@ if (!empty($canvas)) * Actions */ -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 $sref = ""; $snom = ""; $sall = ""; @@ -129,32 +137,58 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid' $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +if ($search_categ) { + $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +} $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +if ($search_categ) { + $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +} +if ($sall) { + $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +} // if the type is not 1, we show all products (type = 0,2,3) -if (dol_strlen($type)) -{ - if ($type == 1) - { +if (dol_strlen($type)) { + if ($type == 1) { $sql .= " AND p.fk_product_type = '1'"; } else { $sql .= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql .= natural_search("p.ref", $sref); -if ($search_barcode) $sql .= natural_search("p.barcode", $search_barcode); -if ($snom) $sql .= natural_search("p.label", $snom); -if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell; -if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy; -if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; -if ($catid) $sql .= " AND cp.fk_categorie = ".$catid; -if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +if ($sref) { + $sql .= natural_search("p.ref", $sref); +} +if ($search_barcode) { + $sql .= natural_search("p.barcode", $search_barcode); +} +if ($snom) { + $sql .= natural_search("p.label", $snom); +} +if (!empty($tosell)) { + $sql .= " AND p.tosell = ".$tosell; +} +if (!empty($tobuy)) { + $sql .= " AND p.tobuy = ".$tobuy; +} +if (!empty($canvas)) { + $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +} +if ($catid) { + $sql .= " AND cp.fk_categorie = ".$catid; +} +if ($fourn_id > 0) { + $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +} // Insert categ filter -if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); -if ($search_warehouse) $sql .= natural_search("e.ref", $search_warehouse); -if ($search_batch) $sql .= natural_search("pb.batch", $search_batch); +if ($search_categ) { + $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); +} +if ($search_warehouse) { + $sql .= natural_search("e.ref", $search_warehouse); +} +if ($search_batch) { + $sql .= natural_search("pb.batch", $search_batch); +} $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql .= " p.fk_product_type, p.tms,"; $sql .= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,"; @@ -162,16 +196,16 @@ $sql .= " ps.fk_entrepot,"; $sql .= " e.ref, e.lieu, e.fk_parent,"; $sql .= " pb.batch, pb.eatby, pb.sellby,"; $sql .= " pl.rowid, pl.eatby, pl.sellby"; -if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet +if ($toolowstock) { + $sql .= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet +} $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -180,43 +214,74 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) - { + if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) { $objp = $db->fetch_object($resql); header("Location: card.php?id=$objp->rowid"); exit; } - if (isset($type)) - { - if ($type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } + if (isset($type)) { + if ($type == 1) { + $texte = $langs->trans("Services"); + } else { + $texte = $langs->trans("Products"); + } } else { $texte = $langs->trans("ProductsAndServices"); } $texte .= ' ('.$langs->trans("StocksByLotSerial").')'; $param = ''; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= "&sall=".urlencode($sall); - if ($tosell) $param .= "&tosell=".urlencode($tosell); - if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); - if ($type) $param .= "&type=".urlencode($type); - if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); - if ($snom) $param .= "&snom=".urlencode($snom); - if ($sref) $param .= "&sref=".urlencode($sref); - if ($search_batch) $param .= "&search_batch=".urlencode($search_batch); - if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); - if ($search_warehouse) $param .= "&search_warehouse=".urlencode($search_warehouse); - if ($catid) $param .= "&catid=".urlencode($catid); - if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); - if ($search_sale) $param .= "&search_sale=".urlencode($search_sale); - if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } + if ($tosell) { + $param .= "&tosell=".urlencode($tosell); + } + if ($tobuy) { + $param .= "&tobuy=".urlencode($tobuy); + } + if ($type) { + $param .= "&type=".urlencode($type); + } + if ($fourn_id) { + $param .= "&fourn_id=".urlencode($fourn_id); + } + if ($snom) { + $param .= "&snom=".urlencode($snom); + } + if ($sref) { + $param .= "&sref=".urlencode($sref); + } + if ($search_batch) { + $param .= "&search_batch=".urlencode($search_batch); + } + if ($sbarcode) { + $param .= "&sbarcode=".urlencode($sbarcode); + } + if ($search_warehouse) { + $param .= "&search_warehouse=".urlencode($search_warehouse); + } + if ($catid) { + $param .= "&catid=".urlencode($catid); + } + if ($toolowstock) { + $param .= "&toolowstock=".urlencode($toolowstock); + } + if ($search_sale) { + $param .= "&search_sale=".urlencode($search_sale); + } + if ($search_categ) { + $param .= "&search_categ=".urlencode($search_categ); + } /*if ($eatby) $param.="&eatby=".$eatby; if ($sellby) $param.="&sellby=".$sellby;*/ @@ -231,8 +296,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); - if (!empty($catid)) - { + if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); $c->fetch($catid); @@ -242,18 +306,16 @@ if ($resql) } // Filter on categories - $moreforfilter = ''; - if (!empty($conf->categorie->enabled)) - { - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter .= '</div>'; + $moreforfilter .= '</div>'; } //$moreforfilter.=$langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock?' checked':'').'>'; - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -274,8 +336,7 @@ if ($resql) print '<td class="liste_titre">'; print '<input class="flat" type="text" name="snom" size="8" value="'.$snom.'">'; print '</td>'; - if (!empty($conf->service->enabled) && $type == 1) - { + if (!empty($conf->service->enabled) && $type == 1) { print '<td class="liste_titre">'; print '&nbsp;'; print '</td>'; @@ -302,7 +363,9 @@ if ($resql) print "<tr class=\"liste_titre\">"; 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->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + if (!empty($conf->service->enabled) && $type == 1) { + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + } print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center '); @@ -325,13 +388,11 @@ if ($resql) $product_lot_static = new Productlot($db); $warehousetmp = new Entrepot($db); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$objp->rowid; @@ -339,10 +400,11 @@ if ($resql) $sql .= " LIMIT 1"; $result = $db->query($sql); - if ($result) - { + if ($result) { $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) $objp->label = $objtp->label; + if (!empty($objtp->label)) { + $objp->label = $objtp->label; + } } } @@ -379,13 +441,17 @@ if ($resql) // Label print '<td>'.$objp->label.'</td>'; - if (!empty($conf->service->enabled) && $type == 1) - { + if (!empty($conf->service->enabled) && $type == 1) { print '<td class="center">'; - if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationDay"); - else print $objp->duration; + if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationYear"); + } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationMonth"); + } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationDay"); + } else { + print $objp->duration; + } print '</td>'; } //print '<td class="right">'.$objp->stock_theorique.'</td>'; @@ -394,16 +460,14 @@ if ($resql) // Warehouse print '<td class="nowrap">'; - if ($objp->fk_entrepot > 0) - { + if ($objp->fk_entrepot > 0) { print $warehousetmp->getNomUrl(1); } print '</td>'; // Lot print '<td class="center nowrap">'; - if ($product_lot_static->batch) - { + if ($product_lot_static->batch) { print $product_lot_static->getNomUrl(1); } print '</td>'; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index d1254a65b1e..053d9d6b1a8 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -38,7 +38,9 @@ $ref = GETPOST('ref', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -52,12 +54,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "b.date_valid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "b.date_valid"; +} /* @@ -66,8 +74,7 @@ if (!$sortfield) $sortfield = "b.date_valid"; $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -75,12 +82,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -88,12 +96,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -130,8 +142,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); if ($result) { $totalofrecords = $db->num_rows($result); @@ -180,8 +191,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); if ($result) { $totalofrecords = $db->num_rows($result); @@ -223,20 +233,32 @@ if ($id > 0 || !empty($ref)) $db->free($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("BOMs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', count($bom_data_result), count($bom_data_result), '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste listwithfilterbefore" width="100%">'; @@ -250,8 +272,7 @@ if ($id > 0 || !empty($ref)) print "</tr>\n"; if (!empty($bom_data_result)) { - foreach ($bom_data_result as $data) - { + foreach ($bom_data_result as $data) { print '<tr class="oddeven">'; print '<td>'; print $data['link']; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index e899cee797f..b55976bface 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -51,7 +51,9 @@ $mesg = ''; $graphfiles = array(); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} // Security check $fieldvalue = (!empty($id) ? $id : $ref); @@ -60,7 +62,9 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product $tmp = dol_getdate(dol_now()); $currentyear = $tmp['year']; -if (empty($search_year)) $search_year = $currentyear; +if (empty($search_year)) { + $search_year = $currentyear; +} /* @@ -83,7 +87,7 @@ if (!$id && empty($ref)) { $type = GETPOST('type', 'int'); - $helpurl = ''; + $helpurl = ''; if ($type == '0') { $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; //$title=$langs->trans("StatisticsOfProducts"); @@ -99,7 +103,9 @@ if (!$id && empty($ref)) { } $picto = 'product'; - if ($type == 1) $picto = 'service'; + if ($type == 1) { + $picto = 'service'; + } print load_fiche_titre($title, $mesg, $picto); } else { @@ -189,12 +195,15 @@ if ($result || empty($id)) { // Year print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>'; $arrayyears = array(); - for ($year = $currentyear - 25; $year < $currentyear; $year++) - { + for ($year = $currentyear - 25; $year < $currentyear; $year++) { $arrayyears[$year] = $year; } - if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; - if (!in_array($currentyear, $arrayyears)) $arrayyears[$currentyear] = $currentyear; + if (!in_array($year, $arrayyears)) { + $arrayyears[$year] = $year; + } + if (!in_array($currentyear, $arrayyears)) { + $arrayyears[$currentyear] = $currentyear; + } arsort($arrayyears); print $form->selectarray('search_year', $arrayyears, $search_year, 1); print '</td></tr>'; @@ -206,25 +215,45 @@ if ($result || empty($id)) { // Choice of stats mode (byunit or bynumber) - if (!empty($conf->dol_use_jmobile)) print "\n".'<div class="fichecenter"><div class="nowrap">'."\n"; + if (!empty($conf->dol_use_jmobile)) { + print "\n".'<div class="fichecenter"><div class="nowrap">'."\n"; + } - if ($mode == 'bynumber') print '<a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=byunit&search_year='.$search_year.'">'; - else print '<span class="a-mesure">'; + if ($mode == 'bynumber') { + print '<a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=byunit&search_year='.$search_year.'">'; + } else { + print '<span class="a-mesure">'; + } print $langs->trans("StatsByNumberOfUnits"); - if ($mode == 'bynumber') print '</a>'; - else print '</span>'; + if ($mode == 'bynumber') { + print '</a>'; + } else { + print '</span>'; + } - if (!empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n"; - else print ' &nbsp; '; + if (!empty($conf->dol_use_jmobile)) { + print '</div>'."\n".'<div class="nowrap">'."\n"; + } else { + print ' &nbsp; '; + } - if ($mode == 'byunit') print '<a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=bynumber&search_year='.$search_year.'">'; - else print '<span class="a-mesure">'; + if ($mode == 'byunit') { + print '<a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=bynumber&search_year='.$search_year.'">'; + } else { + print '<span class="a-mesure">'; + } print $langs->trans("StatsByNumberOfEntities"); - if ($mode == 'byunit') print '</a>'; - else print '</span>'; + if ($mode == 'byunit') { + print '</a>'; + } else { + print '</span>'; + } - if (!empty($conf->dol_use_jmobile)) print '</div></div>'; - else print '<br>'; + if (!empty($conf->dol_use_jmobile)) { + print '</div></div>'; + } else { + print '<br>'; + } print '<br>'; //print '<table width="100%">'; @@ -294,7 +323,9 @@ if ($result || empty($id)) { $mesg = $px->isGraphKo(); if (!$mesg) { foreach ($graphfiles as $key => $val) { - if (!$graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) { + continue; + } $graph_data = array(); @@ -312,14 +343,30 @@ if ($result || empty($id)) { $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; } - if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'orders') $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'proposalssuppliers') $graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'contracts') $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - if ($key == 'mrp') $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'propal') { + $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'orders') { + $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'invoices') { + $graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'proposalssuppliers') { + $graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'invoicessuppliers') { + $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'orderssuppliers') { + $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'contracts') { + $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } + if ($key == 'mrp') { + $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + } // TODO Save cachefile $graphfiles[$key]['file'] } @@ -354,15 +401,31 @@ if ($result || empty($id)) { $i = 0; if (count($graphfiles) > 0) { foreach ($graphfiles as $key => $val) { - if (!$graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) { + continue; + } - if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue; - if ($graphfiles == 'order' && !$user->rights->commande->lire) continue; - if ($graphfiles == 'invoices' && !$user->rights->facture->lire) continue; - if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue; - if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue; - if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue; - if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) continue; + if ($graphfiles == 'propal' && !$user->rights->propale->lire) { + continue; + } + if ($graphfiles == 'order' && !$user->rights->commande->lire) { + continue; + } + if ($graphfiles == 'invoices' && !$user->rights->facture->lire) { + continue; + } + if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) { + continue; + } + if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) { + continue; + } + if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) { + continue; + } + if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) { + continue; + } if ($i % 2 == 0) { @@ -373,8 +436,11 @@ if ($result || empty($id)) { // Date generation if ($graphfiles[$key]['output'] && !$px->isGraphKo()) { - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); - else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) { + $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); + } else { + $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + } } else { $dategenerated = ($mesg ? '<font class="error">'.$mesg.'</font>' : $langs->trans("ChartNotGenerated")); } diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index f89305b4d95..cb5087c63f2 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -40,7 +40,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -53,12 +55,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "c.date_commande"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_commande"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -77,8 +85,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -86,12 +93,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -99,12 +107,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -123,26 +135,35 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); - if ($user->rights->commande->lire) - { + if ($user->rights->commande->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,"; $sql .= " c.ref_client,"; $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."commandedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + 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('commande').")"; $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) - $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; - if (!empty($search_year)) - $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; + } $sql .= $db->order($sortfield, $sortorder); //Calcul total qty and amount for global if full scan list @@ -151,8 +172,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -160,25 +180,36 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER ['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -205,10 +236,8 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total_ht += $objp->total_ht; @@ -220,7 +249,7 @@ if ($id > 0 || !empty($ref)) $societestatic->fetch($objp->socid); print '<tr class="oddeven">'; - print '<td>'; + print '<td>'; print $orderstatic->getNomUrl(1); print "</td>\n"; print '<td>'.$societestatic->getNomUrl(1).'</td>'; @@ -235,8 +264,11 @@ if ($id > 0 || !empty($ref)) } } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="3"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 611047f7f13..16dd040887d 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -39,8 +39,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) +if (!empty($user->socid)) { $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -53,14 +54,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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) +if (!$sortorder) { $sortorder = "DESC"; -if (!$sortfield) +} +if (!$sortfield) { $sortfield = "c.date_commande"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -88,13 +93,13 @@ if ($id > 0 || !empty($ref)) { $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) + if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -102,12 +107,16 @@ if ($id > 0 || !empty($ref)) { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -126,30 +135,35 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); - if ($user->rights->fournisseur->commande->lire) - { + if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " c.rowid, d.total_ht as total_ht, c.ref,"; $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as d"; - if (!$user->rights->societe->client->voir && !$socid) + 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 = ".$conf->entity; $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) + if (!empty($search_month)) { $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; - if (!empty($search_year)) + } + if (!empty($search_year)) { $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) + } + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) + } + if ($socid) { $sql .= " AND c.fk_soc = ".$socid; + } $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list @@ -158,8 +172,7 @@ if ($id > 0 || !empty($ref)) { // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -170,20 +183,32 @@ if ($id > 0 || !empty($ref)) { if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -210,10 +235,8 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total_ht += $objp->total_ht; @@ -240,8 +263,11 @@ if ($id > 0 || !empty($ref)) { } } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="3"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 91ca0bd87e2..93778a19047 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -37,7 +37,9 @@ $ref = GETPOST('ref', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -50,12 +52,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "c.date_contrat"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_contrat"; +} /* @@ -67,8 +75,7 @@ $staticcontratligne = new ContratLigne($db); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -76,12 +83,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -89,12 +97,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -123,15 +135,21 @@ if ($id > 0 || !empty($ref)) $sql .= " c.rowid as rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut as statut,"; $sql .= " s.nom as name, s.rowid as socid, s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql .= " WHERE c.rowid = cd.fk_contrat"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('contract').")"; $sql .= " AND cd.fk_product =".$product->id; - 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; + 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 .= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql .= $db->order($sortfield, $sortorder); @@ -141,8 +159,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -150,25 +167,36 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } $i = 0; print '<div class="div-table-responsive">'; @@ -187,10 +215,8 @@ if ($id > 0 || !empty($ref)) $contracttmp = new Contrat($db); - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $contracttmp->id = $objp->rowid; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 8091de9c320..271a834570b 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -54,12 +56,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -81,8 +89,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -90,26 +97,25 @@ if ($id > 0 || !empty($ref)) $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) - { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) - { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } llxHeader('', $title, $helpurl); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -117,12 +123,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -140,29 +150,37 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); - if ($showmessage && $nboflines > 1) - { + if ($showmessage && $nboflines > 1) { print '<span class="opacitymedium">'.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).'</span>'; - } elseif ($user->rights->facture->lire) - { + } elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) + if (!empty($search_month)) { $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; - if (!empty($search_year)) + } + if (!empty($search_year)) { $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list @@ -171,8 +189,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -180,24 +197,35 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER ['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -224,13 +252,13 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty = -($objp->qty); + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } $total_ht += $objp->total_ht; $total_qty += $objp->qty; @@ -256,8 +284,11 @@ if ($id > 0 || !empty($ref)) } } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="3"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 7e0e463e1a5..a42615fdaa9 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -54,12 +56,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -78,8 +86,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -87,12 +94,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -100,12 +108,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -124,26 +136,34 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); - if ($user->rights->fournisseur->facture->lire) - { + if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn_det as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql .= " AND d.fk_facture_fourn = f.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) + if (!empty($search_month)) { $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; - if (!empty($search_year)) + } + if (!empty($search_year)) { $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } $sql .= " ORDER BY $sortfield $sortorder "; // Calcul total qty and amount for global if full scan list @@ -152,8 +172,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -161,24 +180,35 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -205,10 +235,8 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total_ht += $objp->line_total_ht; @@ -231,7 +259,7 @@ if ($id > 0 || !empty($ref)) print "</td>\n"; print '<td>'.$societestatic->getNomUrl(1).'</td>'; print "<td>".$objp->code_client."</td>\n"; - print '<td class="center">'; + print '<td class="center">'; print dol_print_date($db->jdate($objp->datef), 'dayhour')."</td>"; print '<td class="center">'.$objp->qty."</td>\n"; print '<td align="right">'.price($objp->line_total_ht)."</td>\n"; @@ -241,8 +269,11 @@ if ($id > 0 || !empty($ref)) } } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="3"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index cb159646047..479dbdd1a17 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -37,7 +37,9 @@ $ref = GETPOST('ref', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -50,12 +52,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "c.date_valid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_valid"; +} /* @@ -67,8 +75,7 @@ $staticmoligne = new MoLine($db); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -76,12 +83,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -89,12 +97,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -127,7 +139,9 @@ if ($id > 0 || !empty($ref)) $sql .= " WHERE c.rowid = cd.fk_mo"; $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product =".$product->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " GROUP BY c.rowid, c.ref, c.date_valid, c.status"; //$sql .= ", s.nom, s.rowid, s.code_client"; $sql .= $db->order($sortfield, $sortorder); @@ -138,8 +152,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -147,24 +160,35 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("Mos"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } $i = 0; print '<div class="div-table-responsive">'; @@ -183,10 +207,8 @@ if ($id > 0 || !empty($ref)) $motmp = new Mo($db); - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $motmp->id = $objp->rowid; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 9e9a078d8f0..7d08f3ab9c3 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -40,7 +40,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "p.datep"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "p.datep"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -78,8 +86,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -87,12 +94,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -100,12 +108,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -124,30 +136,35 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); - if ($user->rights->propale->lire) - { + if ($user->rights->propale->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; $sql .= " p.ref_client,"; $sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."propaldet as d"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND d.fk_propal = p.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) + if (!empty($search_month)) { $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; - if (!empty($search_year)) + } + if (!empty($search_year)) { $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) + } + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) + } + if ($socid) { $sql .= " AND p.fk_soc = ".$socid; + } $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list @@ -156,8 +173,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -165,24 +181,35 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -208,10 +235,8 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total_ht += $objp->amount; @@ -238,8 +263,11 @@ if ($id > 0 || !empty($ref)) } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="2"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index b4816028d98..19647e85431 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -40,7 +40,9 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "p.date_valid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "p.date_valid"; +} $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); @@ -78,8 +86,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -87,12 +94,13 @@ if ($id > 0 || !empty($ref)) $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } llxHeader("", "", $langs->trans("CardProduct".$product->type)); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -100,12 +108,16 @@ if ($id > 0 || !empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -124,30 +136,35 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); - if ($user->rights->propale->lire) - { + if ($user->rights->propale->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; //$sql .= " p.ref_supplier,"; $sql .= "p.date_valid, p.fk_statut as statut, d.rowid, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; + } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= ", ".MAIN_DB_PREFIX."supplier_proposaldet as d"; - if (!$user->rights->societe->client->voir && !$socid) + if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql .= " AND d.fk_supplier_proposal = p.rowid"; $sql .= " AND d.fk_product =".$product->id; - if (!empty($search_month)) + if (!empty($search_month)) { $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; - if (!empty($search_year)) + } + if (!empty($search_year)) { $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; - if (!$user->rights->societe->client->voir && !$socid) + } + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) + } + if ($socid) { $sql .= " AND p.fk_soc = ".$socid; + } $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list @@ -156,8 +173,7 @@ if ($id > 0 || !empty($ref)) // Count total nb of records $totalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $totalofrecords = $db->num_rows($result); } @@ -165,24 +181,35 @@ if ($id > 0 || !empty($ref)) $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); - if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - if (!empty($id)) $option .= '&id='.$product->id; - if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); - if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($id)) { + $option .= '&id='.$product->id; + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n"; - if (!empty($sortfield)) + if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>'; - if (!empty($sortorder)) + } + if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>'; + } print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - if (!empty($page)) $option .= '&page='.urlencode($page); + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="divsearchfield">'; @@ -208,10 +235,8 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; - if ($num > 0) - { - while ($i < min($num, $limit)) - { + if ($num > 0) { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total_ht += $objp->amount; @@ -237,8 +262,11 @@ if ($id > 0 || !empty($ref)) } print '<tr class="liste_total">'; - if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + if ($num < $limit) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } print '<td colspan="2"></td>'; print '<td class="center">'.$total_qty.'</td>'; print '<td align="right">'.price($total_ht).'</td>'; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index ffd7add3c20..252cccd90ab 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -47,8 +47,12 @@ $ref = GETPOST('ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortfield) $sortfield = "p.ref"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "p.ref"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $backtopage = GETPOST('backtopage', 'alpha'); @@ -87,12 +91,12 @@ $usercandelete = (($user->rights->stock->supprimer)); $parameters = array('id'=>$id, 'ref'=>$ref); $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)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { // Ajout entrepot - if ($action == 'add' && $user->rights->stock->creer) - { + if ($action == 'add' && $user->rights->stock->creer) { $object->ref = (string) GETPOST("ref", "alpha"); $object->fk_parent = (int) GETPOST("fk_parent", "int"); $object->label = (string) GETPOST("libelle", "alpha"); @@ -140,12 +144,10 @@ if (empty($reshook)) } // Delete warehouse - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) - { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) { $object->fetch(GETPOST('id', 'int')); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1'); exit; @@ -156,10 +158,8 @@ if (empty($reshook)) } // Modification entrepot - if ($action == 'update' && $cancel <> $langs->trans("Cancel")) - { - if ($object->fetch($id)) - { + if ($action == 'update' && $cancel <> $langs->trans("Cancel")) { + if ($object->fetch($id)) { $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); $object->description = GETPOST("desc"); @@ -174,11 +174,15 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $ret = $object->update($id, $user); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } if ($error) { @@ -198,7 +202,9 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $result = $object->insertExtraFields(); if ($result < 0) { @@ -206,11 +212,12 @@ if (empty($reshook)) $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } - if ($cancel == $langs->trans("Cancel")) - { + if ($cancel == $langs->trans("Cancel")) { $action = ''; } @@ -236,8 +243,7 @@ $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewWarehouse"), '', 'stock'); dol_set_focus('input[name="libelle"]'); @@ -285,7 +291,9 @@ if ($action == 'create') print '<tr><td>'.$langs->trans('Country').'</td><td>'; print img_picto('', 'globe-americas', 'class="paddingright"'); 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); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td></tr>'; // Phone / Fax @@ -300,10 +308,8 @@ if ($action == 'create') // Status print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<select name="statut" class="flat">'; - foreach ($object->statuts as $key => $value) - { - if ($key == 1) - { + foreach ($object->statuts as $key => $value) { + if ($key == 1) { print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>'; } else { print '<option value="'.$key.'">'.$langs->trans($value).'</option>'; @@ -335,12 +341,10 @@ if ($action == 'create') print '</form>'; } else { $id = GETPOST("id", 'int'); - if ($id > 0 || $ref) - { + if ($id > 0 || $ref) { $object = new Entrepot($db); $result = $object->fetch($id, $ref); - if ($result <= 0) - { + if ($result <= 0) { print 'No record found'; exit; } @@ -348,8 +352,7 @@ if ($action == 'create') /* * Affichage fiche */ - if ($action <> 'edit' && $action <> 're-edit') - { + if ($action <> 'edit' && $action <> 're-edit') { $head = stock_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock'); @@ -357,16 +360,18 @@ if ($action == 'create') $formconfirm = ''; // Confirm delete warehouse - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); } // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -379,7 +384,9 @@ if ($action == 'create') $morehtmlref .= '</div>'; $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -481,21 +488,17 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - if (empty($action)) - { + if (empty($reshook)) { + if (empty($action)) { if ($user->rights->stock->creer) { print '<a class="butAction" href="card.php?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>'; - } - else { + } else { print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Modify").'</a>'; } if ($user->rights->stock->supprimer) { print '<a class="butActionDelete" href="card.php?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>'; - } - else { + } else { print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete").'</a>'; } } @@ -516,7 +519,9 @@ if ($action == 'create') print_liste_field_titre("Product", "", "p.ref", "&amp;id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&amp;id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Units", "", "ps.reel", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit", "", "p.fk_unit", "&amp;id=".$id, "", 'align="left"', $sortfield, $sortorder); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print_liste_field_titre("Unit", "", "p.fk_unit", "&amp;id=".$id, "", 'align="left"', $sortfield, $sortorder); + } print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("EstimatedStockValueShort", "", "", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right '); if (empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -538,7 +543,9 @@ if ($action == 'create') $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; $sql .= " ps.reel as value"; - if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ",fk_unit"; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ",fk_unit"; + } $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE ps.fk_product = p.rowid"; $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) @@ -547,17 +554,14 @@ if ($action == 'create') dol_syslog('List products', LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$objp->rowid; @@ -565,10 +569,11 @@ if ($action == 'create') $sql .= " LIMIT 1"; $result = $db->query($sql); - if ($result) - { + if ($result) { $objtp = $db->fetch_object($result); - if ($objtp->label != '') $objp->produit = $objtp->label; + if ($objtp->label != '') { + $objp->produit = $objtp->label; + } } } @@ -598,7 +603,9 @@ if ($action == 'create') if (!empty($conf->global->PRODUCT_USE_UNITS)) { // Units print '<td align="left">'; - if (is_null($productstatic->fk_unit))$productstatic->fk_unit = 1; + if (is_null($productstatic->fk_unit)) { + $productstatic->fk_unit = 1; + } print $langs->trans($productstatic->getLabelOfUnit()); print '</td>'; } @@ -610,8 +617,7 @@ if ($action == 'create') $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); // Price sell min - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { $pricemin = $objp->price; print '<td class="right">'; print price(price2num($pricemin, 'MU'), 1); @@ -623,22 +629,23 @@ if ($action == 'create') } $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">'; print img_picto($langs->trans("StockMovement"), 'uparrow.png', 'class="hideonsmartphone"').' '.$langs->trans("StockMovement"); print "</a></td>"; } - if ($user->rights->stock->creer) - { + if ($user->rights->stock->creer) { print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=correction&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">'; print $langs->trans("StockCorrection"); print "</a></td>"; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { - if ($i == 0) $units = $productstatic->fk_unit; - elseif ($productstatic->fk_unit != $units) $sameunits = false; + if ($i == 0) { + $units = $productstatic->fk_unit; + } elseif ($productstatic->fk_unit != $units) { + $sameunits = false; + } } print "</tr>"; $i++; @@ -648,14 +655,17 @@ if ($action == 'create') print '<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans("Total").'</td>'; print '<td class="liste_total right">'; $valtoshow = price2num($totalunit, 'MS'); - if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow) ? '0' : $valtoshow; + if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) { + print empty($valtoshow) ? '0' : $valtoshow; + } print '</td>'; print '<td class="liste_total">'; - if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) print $langs->trans($productstatic->getLabelOfUnit()); + if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) { + print $langs->trans($productstatic->getLabelOfUnit()); + } print '</td>'; print '<td class="liste_total right">'.price(price2num($totalvalue, 'MT')).'</td>'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { print '<td class="liste_total">&nbsp;</td>'; print '<td class="liste_total right">'.price(price2num($totalvaluesell, 'MT')).'</td>'; } @@ -672,8 +682,7 @@ if ($action == 'create') /* * Edition fiche */ - if ($action == 'edit' || $action == 're-edit') - { + if ($action == 'edit' || $action == 're-edit') { $langs->trans("WarehouseEdit"); print '<form action="card.php" method="POST">'; @@ -721,7 +730,9 @@ if ($action == 'create') print '<tr><td>'.$langs->trans('Country').'</td><td>'; print img_picto('', 'globe-americas', 'class="paddingright"'); print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td></tr>'; // Phone / Fax @@ -735,10 +746,8 @@ if ($action == 'create') // Status print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<select name="statut" class="flat">'; - foreach ($object->statuts as $key => $value) - { - if ($key == $object->statut) - { + foreach ($object->statuts as $key => $value) { + if ($key == $object->statut) { print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>'; } else { print '<option value="'.$key.'">'.$langs->trans($value).'</option>'; @@ -751,14 +760,12 @@ if ($action == 'create') $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } // Tags-Categories - if ($conf->categorie->enabled) - { + if ($conf->categorie->enabled) { print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -792,8 +799,7 @@ if ($action == 'create') $modulepart = 'stock'; -if ($action != 'create' && $action != 'edit' && $action != 'delete') -{ +if ($action != 'create' && $action != 'edit' && $action != 'delete') { print '<br>'; print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index dba209e5b6f..90b3895c0f2 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -31,7 +31,7 @@ class StockMovements extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'product_id', 'warehouse_id', 'qty' @@ -63,23 +63,23 @@ class StockMovements extends DolibarrApi * @throws RestException */ /* - public function get($id) - { - if(! DolibarrApiAccess::$user->rights->stock->lire) { - throw new RestException(401); - } + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->stock->lire) { + throw new RestException(401); + } - $result = $this->stockmovement->fetch($id); - if( ! $result ) { - throw new RestException(404, 'warehouse not found'); - } + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'warehouse not found'); + } - if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->stockmovement); - }*/ + return $this->_cleanObjectDatas($this->stockmovement); + }*/ /** * Get a list of stock movement @@ -108,10 +108,8 @@ class StockMovements extends DolibarrApi //$sql.= ' WHERE t.entity IN ('.getEntity('stock').')'; $sql .= ' WHERE 1 = 1'; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -120,8 +118,7 @@ class StockMovements extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -130,13 +127,11 @@ class StockMovements extends DolibarrApi } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $stockmovement_static = new MouvementStock($this->db); if ($stockmovement_static->fetch($obj->rowid)) { @@ -196,7 +191,9 @@ class StockMovements extends DolibarrApi if ($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { $errormessage = $this->stockmovement->error; - if (empty($errormessage)) $errormessage = join(',', $this->stockmovement->errors); + if (empty($errormessage)) { + $errormessage = join(',', $this->stockmovement->errors); + } throw new RestException(503, 'Error when create stock movement : '.$errormessage); } @@ -211,31 +208,31 @@ class StockMovements extends DolibarrApi * @return int */ /* - public function put($id, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->stock->creer) { - throw new RestException(401); - } + public function put($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->stock->creer) { + throw new RestException(401); + } - $result = $this->stockmovement->fetch($id); - if( ! $result ) { - throw new RestException(404, 'stock movement not found'); - } + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'stock movement not found'); + } - if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach($request_data as $field => $value) { - if ($field == 'id') continue; - $this->stockmovement->$field = $value; - } + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->stockmovement->$field = $value; + } - if($this->stockmovement->update($id, DolibarrApiAccess::$user)) - return $this->get ($id); + if($this->stockmovement->update($id, DolibarrApiAccess::$user)) + return $this->get ($id); - return false; - }*/ + return false; + }*/ /** * Delete stock movement @@ -244,31 +241,31 @@ class StockMovements extends DolibarrApi * @return array */ /* - public function delete($id) - { - if(! DolibarrApiAccess::$user->rights->stock->supprimer) { - throw new RestException(401); - } - $result = $this->stockmovement->fetch($id); - if( ! $result ) { - throw new RestException(404, 'stock movement not found'); - } + public function delete($id) + { + if(! DolibarrApiAccess::$user->rights->stock->supprimer) { + throw new RestException(401); + } + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'stock movement not found'); + } - if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (! $this->stockmovement->delete(DolibarrApiAccess::$user)) { - throw new RestException(401,'error when delete stock movement'); - } + if (! $this->stockmovement->delete(DolibarrApiAccess::$user)) { + throw new RestException(401,'error when delete stock movement'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Warehouse deleted' - ) - ); - }*/ + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Warehouse deleted' + ) + ); + }*/ @@ -341,8 +338,9 @@ class StockMovements extends DolibarrApi { $stockmovement = array(); foreach (self::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $stockmovement[$field] = $data[$field]; } return $stockmovement; diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index d6f2333f3ef..34338232169 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -31,7 +31,7 @@ class Warehouses extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'label', ); @@ -115,10 +115,8 @@ class Warehouses extends DolibarrApi $sql .= " AND c.fk_warehouse = t.rowid "; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -127,8 +125,7 @@ class Warehouses extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -137,13 +134,11 @@ class Warehouses extends DolibarrApi } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $warehouse_static = new Entrepot($this->db); if ($warehouse_static->fetch($obj->rowid)) { @@ -208,12 +203,15 @@ class Warehouses extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->warehouse->$field = $value; } - if ($this->warehouse->update($id, DolibarrApiAccess::$user)) + if ($this->warehouse->update($id, DolibarrApiAccess::$user)) { return $this->get($id); + } return false; } @@ -282,8 +280,9 @@ class Warehouses extends DolibarrApi { $warehouse = array(); foreach (Warehouses::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $warehouse[$field] = $data[$field]; } return $warehouse; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index ac3ce4636e6..7450b19715f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -203,37 +203,29 @@ class Entrepot extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot"); - if ($id > 0) - { + if ($id > 0) { $this->id = $id; - if (!$error) - { + if (!$error) { $result = $this->update($id, $user); - if ($result <= 0) - { + if ($result <= 0) { $error++; } } // Actions on extra fields - if (!$error) - { - if (!$error) - { + if (!$error) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } } - if (!$error) - { + if (!$error) { $this->db->commit(); return $id; } else { @@ -267,16 +259,18 @@ class Entrepot extends CommonObject $error = 0; - if (empty($id)) $id = $this->id; - if (empty($this->label)) $this->label = $this->libelle; // For backward compatibility + if (empty($id)) { + $id = $this->id; + } + if (empty($this->label)) { + $this->label = $this->libelle; // For backward compatibility + } // Check if new parent is already a child of current warehouse - if (!empty($this->fk_parent)) - { + if (!empty($this->fk_parent)) { $TChildWarehouses = array($id); $TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses); - if (in_array($this->fk_parent, $TChildWarehouses)) - { + if (in_array($this->fk_parent, $TChildWarehouses)) { $this->error = 'ErrorCannotAddThisParentWarehouse'; return -2; } @@ -319,8 +313,7 @@ class Entrepot extends CommonObject if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } @@ -353,25 +346,23 @@ class Entrepot extends CommonObject $this->db->begin(); - if (!$error && empty($notrigger)) - { + if (!$error && empty($notrigger)) { // Call trigger $result = $this->call_trigger('WAREHOUSE_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } $elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties'); - foreach ($elements as $table) - { - if (!$error) - { + foreach ($elements as $table) { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE fk_entrepot = ".$this->id; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -379,47 +370,39 @@ class Entrepot extends CommonObject } // Removed extrafields - if (!$error) - { - if (!$error) - { + if (!$error) { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete Error ".$this->error, LOG_ERR); } } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " WHERE rowid = ".$this->id; $resql1 = $this->db->query($sql); - if (!$resql1) - { + if (!$resql1) { $error++; $this->errors[] = $this->db->lasterror(); dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); } } - if (!$error) - { + if (!$error) { // Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $resql2 = $this->db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; $this->errors[] = $this->db->lasterror(); dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -443,8 +426,7 @@ class Entrepot extends CommonObject dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref); // Check parameters - if (!$id && !$ref) - { + if (!$id && !$ref) { $this->error = 'ErrorWrongParameters'; dol_syslog(get_class($this)."::fetch ".$this->error); return -1; @@ -453,19 +435,18 @@ class Entrepot extends CommonObject $sql = "SELECT rowid, entity, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,"; $sql .= " model_pdf, import_key"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; - if ($id) - { + if ($id) { $sql .= " WHERE rowid = '".$id."'"; } else { $sql .= " WHERE entity = ".$conf->entity; - if ($ref) $sql .= " AND ref = '".$this->db->escape($ref)."'"; + if ($ref) { + $sql .= " AND ref = '".$this->db->escape($ref)."'"; + } } $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result) > 0) - { + if ($result) { + if ($this->db->num_rows($result) > 0) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -522,10 +503,8 @@ class Entrepot extends CommonObject dol_syslog(get_class($this)."::info", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -573,10 +552,8 @@ class Entrepot extends CommonObject $result = $this->db->query($sql); $i = 0; $num = $this->db->num_rows($result); - if ($result) - { - while ($i < $num) - { + if ($result) { + while ($i < $num) { $row = $this->db->fetch_row($result); $liste[$row[0]] = $row[1]; $i++; @@ -605,8 +582,7 @@ class Entrepot extends CommonObject //print $sql; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); $ret['nb'] = $obj->nb; $this->db->free($result); @@ -637,8 +613,7 @@ class Entrepot extends CommonObject //print $sql; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); $ret['nb'] = $obj->nb; $ret['value'] = $obj->value; @@ -676,7 +651,9 @@ class Entrepot extends CommonObject global $langs; $statusType = 'status5'; - if ($status > 0) $statusType = 'status4'; + if ($status > 0) { + $statusType = 'status4'; + } $langs->load('stocks'); $label = $langs->trans($this->statuts[$status]); @@ -700,9 +677,13 @@ class Entrepot extends CommonObject global $conf, $langs, $hookmanager; $langs->load("stocks"); - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto = 0; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) { + $withpicto = 0; + } $result = ''; @@ -718,10 +699,8 @@ class Entrepot extends CommonObject $url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id; $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Warehouse"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -734,8 +713,12 @@ class Entrepot extends CommonObject $linkend = '</a>'; $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 .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label)); + 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 .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label)); + } $result .= $linkend; global $action; @@ -798,20 +781,21 @@ class Entrepot extends CommonObject $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $i = 0; - while ($parentid > 0 && $i < $protection) - { + while ($parentid > 0 && $i < $protection) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $objarbo = $this->db->fetch_object($resql); - if ($objarbo) - { + if ($objarbo) { $warehousetmp->fetch($parentid); $TArbo[] = $warehousetmp->label; - $parentid = $objarbo->fk_parent; - } else break; - } else dol_print_error($this->db); + $parentid = $objarbo->fk_parent; + } else { + break; + } + } else { + dol_print_error($this->db); + } $i++; } diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 639816f842d..17fe7193658 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -164,32 +164,32 @@ class MouvementStock extends CommonObject $hookmanager->initHooks(array('mouvementstock')); // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array( - 'currentcontext' => 'mouvementstock', - 'user' => &$user, - 'fk_product' => &$fk_product, - 'entrepot_id' => &$entrepot_id, - 'qty' => &$qty, - 'type' => &$type, - 'price' => &$price, - 'label' => &$label, - 'inventorycode' => &$inventorycode, - 'datem' => &$datem, - 'eatby' => &$eatby, - 'sellby' => &$sellby, - 'batch' => &$batch, - 'skip_batch' => &$skip_batch, - 'id_product_batch' => &$id_product_batch - ); - $reshook = $hookmanager->executeHooks('stockMovementCreate', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array( + 'currentcontext' => 'mouvementstock', + 'user' => &$user, + 'fk_product' => &$fk_product, + 'entrepot_id' => &$entrepot_id, + 'qty' => &$qty, + 'type' => &$type, + 'price' => &$price, + 'label' => &$label, + 'inventorycode' => &$inventorycode, + 'datem' => &$datem, + 'eatby' => &$eatby, + 'sellby' => &$sellby, + 'batch' => &$batch, + 'skip_batch' => &$skip_batch, + 'id_product_batch' => &$id_product_batch + ); + $reshook = $hookmanager->executeHooks('stockMovementCreate', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) { - if (!empty($hookmanager->resPrint)) - dol_print_error('', $hookmanager->resPrint); - return $reshook; - } elseif ($reshook > 0) { - return $hookmanager->resPrint; - } + if ($reshook < 0) { + if (!empty($hookmanager->resPrint)) + dol_print_error('', $hookmanager->resPrint); + return $reshook; + } elseif ($reshook > 0) { + return $hookmanager->resPrint; + } } // end hook at beginning @@ -1020,15 +1020,13 @@ class MouvementStock extends CommonObject break; default: - if ($origintype) - { + if ($origintype) { // Separate originetype with "@" : left part is class name, right part is module name $origintype_array = explode('@', $origintype); $classname = ucfirst($origintype_array[0]); $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1]; $result = dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); - if ($result) - { + if ($result) { $classname = ucfirst($classname); $origin = new $classname($this->db); } @@ -1036,7 +1034,9 @@ class MouvementStock extends CommonObject break; } - if (empty($origin) || !is_object($origin)) return ''; + if (empty($origin) || !is_object($origin)) { + return ''; + } if ($origin->fetch($fk_origin) > 0) { return $origin->getNomUrl(1); @@ -1055,17 +1055,16 @@ class MouvementStock extends CommonObject */ public function setOrigin($origin_element, $origin_id) { - if (!empty($origin_element) && $origin_id > 0) - { + if (!empty($origin_element) && $origin_id > 0) { $origin = ''; - if ($origin_element == 'project') - { - if (!class_exists('Project')) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($origin_element == 'project') { + if (!class_exists('Project')) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + } $origin = new Project($this->db); } - if (!empty($origin)) - { + if (!empty($origin)) { $this->origin = $origin; $this->origin->id = $origin_id; } @@ -1119,10 +1118,11 @@ class MouvementStock extends CommonObject $link .= '>'; $linkend = '</a>'; - if ($withpicto) - { + if ($withpicto) { $result .= ($link.img_object(($notooltip ? '' : $label), 'stock', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result .= ' '; + if ($withpicto != 2) { + $result .= ' '; + } } $result .= $link.$this->id.$linkend; return $result; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 96650c034f3..10294b2c585 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -215,11 +215,9 @@ class Productlot extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } @@ -230,7 +228,9 @@ class Productlot extends CommonObject // Call triggers $result = $this->call_trigger('PRODUCTLOT_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } @@ -358,8 +358,7 @@ class Productlot extends CommonObject // Check parameters // Put here code to add a control on parameters values - if (empty($this->oldcopy)) - { + if (empty($this->oldcopy)) { $org = new self($this->db); $org->fetch($this->id); $this->oldcopy = $org; @@ -389,11 +388,9 @@ class Productlot extends CommonObject } // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } @@ -401,7 +398,9 @@ class Productlot extends CommonObject if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('PRODUCTLOT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -581,25 +580,28 @@ class Productlot extends CommonObject $url = DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } if ($option == 'nolink') { $linkstart = '<span'; @@ -614,8 +616,12 @@ class Productlot extends CommonObject } $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->batch; + 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->batch; + } $result .= $linkend; return $result; diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index ad36dc43c15..98632325ead 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -93,11 +93,21 @@ class ProductStockEntrepot extends CommonObject // Clean parameters - if (isset($this->fk_product)) $this->fk_product = (int) $this->fk_product; - if (isset($this->fk_entrepot)) $this->fk_entrepot = (int) $this->fk_entrepot; - if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); - if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->fk_product)) { + $this->fk_product = (int) $this->fk_product; + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = (int) $this->fk_entrepot; + } + if (isset($this->seuil_stock_alerte)) { + $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); + } + if (isset($this->desiredstock)) { + $this->desiredstock = trim($this->desiredstock); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } // Check parameters // Put here code to add control on parameters values @@ -168,7 +178,9 @@ class ProductStockEntrepot extends CommonObject */ public function fetch($id, $fk_product = 0, $fk_entrepot = 0) { - if (empty($id) && (empty($fk_product) || empty($fk_entrepot))) return -1; + if (empty($id) && (empty($fk_product) || empty($fk_entrepot))) { + return -1; + } dol_syslog(__METHOD__, LOG_DEBUG); @@ -181,15 +193,16 @@ class ProductStockEntrepot extends CommonObject $sql .= " t.desiredstock,"; $sql .= " t.import_key"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (!empty($id)) $sql .= ' WHERE t.rowid = '.$id; - else $sql .= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; + if (!empty($id)) { + $sql .= ' WHERE t.rowid = '.$id; + } else { + $sql .= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $numrows = $this->db->num_rows($resql); - if ($numrows) - { + if ($numrows) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -263,14 +276,23 @@ class ProductStockEntrepot extends CommonObject $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } - if (count($sqlwhere) > 0) $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + if (count($sqlwhere) > 0) { + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); + } - if (!empty($fk_product)) $sql .= ' AND fk_product = '.$fk_product; - elseif (!empty($fk_entrepot)) $sql .= ' AND fk_entrepot = '.$fk_entrepot; + if (!empty($fk_product)) { + $sql .= ' AND fk_product = '.$fk_product; + } elseif (!empty($fk_entrepot)) { + $sql .= ' AND fk_entrepot = '.$fk_entrepot; + } // "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch - if (!empty($sortfield)) $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit, $offset); + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } $lines = array(); @@ -312,11 +334,21 @@ class ProductStockEntrepot extends CommonObject // Clean parameters - if (isset($this->fk_product)) $this->fk_product = (int) $this->fk_product; - if (isset($this->fk_entrepot)) $this->fk_entrepot = (int) $this->fk_entrepot; - if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); - if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); - if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->fk_product)) { + $this->fk_product = (int) $this->fk_product; + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = (int) $this->fk_entrepot; + } + if (isset($this->seuil_stock_alerte)) { + $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); + } + if (isset($this->desiredstock)) { + $this->desiredstock = trim($this->desiredstock); + } + if (isset($this->import_key)) { + $this->import_key = trim($this->import_key); + } // Check parameters @@ -495,10 +527,11 @@ class ProductStockEntrepot extends CommonObject $link .= '>'; $linkend = '</a>'; - if ($withpicto) - { + if ($withpicto) { $result .= ($link.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); - if ($withpicto != 2) $result .= ' '; + if ($withpicto != 2) { + $result .= ' '; + } } $result .= $link.$this->ref.$linkend; return $result; @@ -528,30 +561,42 @@ class ProductStockEntrepot extends CommonObject // phpcs:enable global $langs; - if ($mode == 0) - { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } elseif ($mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } elseif ($mode == 2) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } elseif ($mode == 3) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } elseif ($mode == 4) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } elseif ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + if ($mode == 0) { + if ($status == 1) { + return $langs->trans('Enabled'); + } elseif ($status == 0) { + return $langs->trans('Disabled'); + } + } elseif ($mode == 1) { + if ($status == 1) { + return $langs->trans('Enabled'); + } elseif ($status == 0) { + return $langs->trans('Disabled'); + } + } elseif ($mode == 2) { + if ($status == 1) { + return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + } elseif ($status == 0) { + return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + } + } elseif ($mode == 3) { + if ($status == 1) { + return img_picto($langs->trans('Enabled'), 'statut4'); + } elseif ($status == 0) { + return img_picto($langs->trans('Disabled'), 'statut5'); + } + } elseif ($mode == 4) { + if ($status == 1) { + return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + } elseif ($status == 0) { + return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + } + } elseif ($mode == 5) { + if ($status == 1) { + return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); + } elseif ($status == 0) { + return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + } } } diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index 55ac057985b..34380efbe7a 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -43,14 +43,14 @@ $form = new Form($db); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); -if ($_GET["id"]) -{ - if ($mesg) print $mesg; +if ($_GET["id"]) { + if ($mesg) { + print $mesg; + } $entrepot = new Entrepot($db); $result = $entrepot->fetch($_GET["id"]); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); } @@ -120,13 +120,11 @@ if ($_GET["id"]) - if (file_exists($file)) - { + if (file_exists($file)) { $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png'; print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">'; - if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) - { + if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) { $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year - 1).'.png'; print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.($year - 1).'">'; } diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index 8a4d81419c4..ff2c99c0b09 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -60,8 +60,7 @@ print load_fiche_titre($langs->trans("StocksArea"), '', 'stock'); print '<div class="fichecenter"><div class="fichethirdleft">'; -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 '<form method="post" action="'.DOL_URL_ROOT.'/product/stock/list.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; @@ -84,8 +83,7 @@ $sql .= $db->plimit($max + 1, 0); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); print '<div class="div-table-responsive-no-min">'; @@ -102,10 +100,8 @@ if ($result) print '</tr>'; $i = 0; - if ($num) - { - while ($i < min($max, $num)) - { + if ($num) { + while ($i < min($max, $num)) { $objp = $db->fetch_object($result); $warehouse->id = $objp->rowid; @@ -153,14 +149,15 @@ $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE m.fk_product = p.rowid"; $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = ".Product::TYPE_PRODUCT; +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND p.fk_product_type = ".Product::TYPE_PRODUCT; +} $sql .= $db->order("datem", "DESC"); $sql .= $db->plimit($max, 0); dol_syslog("Index:list stock movements", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); print '<div class="div-table-responsive-no-min">'; @@ -168,8 +165,7 @@ if ($resql) print "<tr class=\"liste_titre\">"; print '<th>'.$langs->trans("LastMovements", min($num, $max)).'</th>'; print '<th>'.$langs->trans("Product").'</th>'; - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { print '<th>'.$langs->trans("Batch").'</th>'; /*if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print '<th>'.$langs->trans("SellByDate").'</th>'; @@ -185,8 +181,7 @@ if ($resql) $tmplotstatic = new Productlot($db); $i = 0; - while ($i < min($num, $max)) - { + while ($i < min($num, $max)) { $objp = $db->fetch_object($resql); $producttmp->id = $objp->rowid; @@ -225,7 +220,9 @@ if ($resql) print $warehouse->getNomUrl(1); print "</td>\n"; print '<td class="right">'; - if ($objp->qty > 0) print '+'; + if ($objp->qty > 0) { + print '+'; + } print $objp->qty.'</td>'; print "</tr>\n"; $i++; diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 884deaaefff..84c0111f290 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -60,7 +60,9 @@ $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref .= '</div>'; $shownav = 1; -if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; +if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; +} dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index b6ce237a2b5..d0415ccad78 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -43,30 +43,33 @@ function dolDispatchToDo($order_id) $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; $resql = $db->query($sql); - if ($resql && $db->num_rows($resql)) - { - while ($obj = $db->fetch_object($resql)) + if ($resql && $db->num_rows($resql)) { + while ($obj = $db->fetch_object($resql)) { $dispatched[$obj->fk_product] = $obj; + } } // Count nb of quantity to dispatch per product $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet'; $sql .= ' WHERE fk_commande = '.$order_id; $sql .= ' AND fk_product > 0'; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= ' AND product_type = 0'; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= ' AND product_type = 0'; + } $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; $resql = $db->query($sql); - if ($resql && $db->num_rows($resql)) - { - while ($obj = $db->fetch_object($resql)) + if ($resql && $db->num_rows($resql)) { + while ($obj = $db->fetch_object($resql)) { $ordered[$obj->fk_product] = $obj; + } } $todispatch = 0; - foreach ($ordered as $key => $val) - { - if ($ordered[$key] > $dispatched[$key]) $todispatch++; + foreach ($ordered as $key => $val) { + if ($ordered[$key] > $dispatched[$key]) { + $todispatch++; + } } return ($todispatch ? true : false); @@ -85,19 +88,15 @@ function dispatchedOrders() $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur'; $resql = $db->query($sql); $resarray = array(); - if ($resql && $db->num_rows($resql) > 0) - { - while ($obj = $db->fetch_object($resql)) - { - if (!dolDispatchToDo($obj->rowid)) - { + if ($resql && $db->num_rows($resql) > 0) { + while ($obj = $db->fetch_object($resql)) { + if (!dolDispatchToDo($obj->rowid)) { $resarray[] = $obj->rowid; } } } - if (count($resarray)) - { + if (count($resarray)) { $res = '('.implode(',', $resarray).')'; } else { //hack to make sure ordered SQL request won't syntax error @@ -131,11 +130,9 @@ function ordered($product_id) $sql .= ' GROUP BY cfd.fk_product'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $exists = $db->num_rows($resql); - if ($exists) - { + if ($exists) { $obj = $db->fetch_array($resql); return $obj['qty']; //. ' ' . img_picto('','tick'); } else { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index c823042eba0..1aafe3c6ae2 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -28,8 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -54,8 +53,7 @@ $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("sear $search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); $search_status = GETPOST("search_status", "int"); -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array"); } @@ -64,12 +62,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "t.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check $result = restrictedArea($user, 'stock'); @@ -89,18 +93,22 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $search_key = $key; - if ($search_key == 'statut') $search_key = 'status'; // remove this after refactor entrepot.class property statut to status - if (GETPOST('search_'.$search_key, 'alpha') !== '') $search[$search_key] = GETPOST('search_'.$search_key, 'alpha'); + if ($search_key == 'statut') { + $search_key = 'status'; // remove this after refactor entrepot.class property statut to status + } + if (GETPOST('search_'.$search_key, 'alpha') !== '') { + $search[$search_key] = GETPOST('search_'.$search_key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns @@ -133,31 +141,33 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -189,13 +199,14 @@ $title = $langs->trans("ListOfWarehouses"); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } } $sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from hooks @@ -204,33 +215,42 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid"); } -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 (t.rowid = ef.fk_object)"; +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 (t.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays"; $sql .= " WHERE t.entity IN (".getEntity('stock').")"; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "t.rowid", $search_category_list); } -foreach ($search as $key => $val) -{ +foreach ($search as $key => $val) { $class_key = $key; - if ($class_key == 'status') $class_key = 'statut'; // remove this after refactor entrepot.class property statut to status - if (($key == 'status' && $search[$key] == -1) || $key == 'entity') continue; + if ($class_key == 'status') { + $class_key = 'statut'; // remove this after refactor entrepot.class property statut to status + } + if (($key == 'status' && $search[$key] == -1) || $key == 'entity') { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search((($key == 'ref') ? 't.ref' : 't.'.$class_key), $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search((($key == 'ref') ? 't.ref' : 't.'.$class_key), $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -238,13 +258,14 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " GROUP BY "; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + } } // Add where from hooks $parameters = array(); @@ -253,13 +274,11 @@ $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $totalnboflines = 0; $result = $db->query($sql); -if ($result) -{ +if ($result) { $totalnboflines = $db->num_rows($result); // fetch totals $line = $total = $totalsell = $totalStock = 0; - while ($line < $totalnboflines) - { + while ($line < $totalnboflines) { $objp = $db->fetch_object($result); $total += price2num($objp->estimatedvalue, 'MU'); $totalsell += price2num($objp->sellvalue, 'MU'); @@ -274,26 +293,22 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) -{ +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -302,8 +317,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/product/stock/card.php?id='.$id); @@ -319,14 +333,24 @@ llxHeader('', $title, $help_url); $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) -{ - 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 (!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 ($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'; @@ -336,12 +360,18 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); -if ($user->rights->stock->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + $arrayofmassactions = array(); +} +if ($user->rights->stock->creer) { + $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form action="'.$_SERVER["PHP_SELF"].'" id="searchFormList" method="POST" name="formulaire">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -361,16 +391,16 @@ $trackid = 'ware'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list); } @@ -381,11 +411,13 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -402,21 +434,29 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit // -------------------------------------------------------------------- print '<tr class="liste_titre_filter">'; -foreach ($object->fields as $key => $val) -{ - if ($key == 'statut') { continue; } +foreach ($object->fields as $key => $val) { + if ($key == 'statut') { + continue; + } $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } print '</td>'; } } @@ -459,16 +499,21 @@ print '</tr>'."\n"; // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ - if ($key == 'statut') { continue; } +foreach ($object->fields as $key => $val) { + if ($key == 'statut') { + continue; + } $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -504,14 +549,14 @@ print '</tr>'."\n"; // Loop on record // -------------------------------------------------------------------- $i = 0; -if ($num) -{ +if ($num) { $warehouse = new Entrepot($db); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $warehouse->id = $obj->rowid; $warehouse->ref = $obj->ref; @@ -527,22 +572,32 @@ if ($num) // Show here line of result print '<tr class="oddeven">'; - foreach ($warehouse->fields as $key => $val) - { - if ($key == 'statut') { continue; } + foreach ($warehouse->fields as $key => $val) { + if ($key == 'statut') { + continue; + } $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; - if ($key == 'statut') print $warehouse->getLibStatut(5); + if ($key == 'statut') { + print $warehouse->getLibStatut(5); + } if ($key == 'phone') { print dol_print_phone($obj->phone, '', 0, $obj->rowid, 'AC_TEL'); } elseif ($key == 'fax') { @@ -551,10 +606,13 @@ if ($num) print $warehouse->showOutputField($val, $key, $warehouse->$key, ''); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $warehouse->$key; } } @@ -563,31 +621,47 @@ if ($num) // Stock qty if (!empty($arrayfields["stockqty"]['checked'])) { print '<td class="right">'.price2num($obj->stockqty, 5).'</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; + } } // PMP value if (!empty($arrayfields["estimatedvalue"]['checked'])) { print '<td class="right">'; - if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); - else print ''; + if (price2num($obj->estimatedvalue, 'MT')) { + print price(price2num($obj->estimatedvalue, 'MT'), 1); + } else { + print ''; + } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue'; + } } // Selling value if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { print '<td class="right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); - else { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($obj->sellvalue, 'MT'), 1); + } else { $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; + } } // Extra fields @@ -600,19 +674,24 @@ if ($num) // Status if (!empty($arrayfields['t.statut']['checked'])) { print '<td class="center">'.$warehouse->LibStatut($obj->statut, 5).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -620,8 +699,7 @@ if ($num) $i++; } - if ($totalnboflines - $offset <= $limit) - { + if ($totalnboflines - $offset <= $limit) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } @@ -638,10 +716,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 4e35d3832e5..a9a69dd4522 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -56,7 +56,9 @@ $idline = GETPOST('idline'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 if (!$sortfield) { $sortfield = 'p.ref'; @@ -69,51 +71,44 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; $listofdata = array(); -if (!empty($_SESSION['massstockmove'])) $listofdata = json_decode($_SESSION['massstockmove'], true); +if (!empty($_SESSION['massstockmove'])) { + $listofdata = json_decode($_SESSION['massstockmove'], true); +} /* * Actions */ -if ($action == 'addline') -{ - if (!($id_product > 0)) - { +if ($action == 'addline') { + if (!($id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } - if (!($id_sw > 0)) - { + if (!($id_sw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); } - if (!($id_tw > 0)) - { + if (!($id_tw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); } - if ($id_sw > 0 && $id_tw == $id_sw) - { + if ($id_sw > 0 && $id_tw == $id_sw) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); } - if (!$qty) - { + if (!$qty) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); } // Check a batch number is provided if product need it - if (!$error) - { + if (!$error) { $producttmp = new Product($db); $producttmp->fetch($id_product); - if ($producttmp->hasbatch()) - { - if (empty($batch)) - { + if ($producttmp->hasbatch()) { + if (empty($batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); @@ -123,19 +118,19 @@ if ($action == 'addline') // TODO Check qty is ok for stock move. Note qty may not be enough yet, but we make a check now to report a warning. // What is more important is to have qty when doing action 'createmovements' - if (!$error) - { + if (!$error) { // Warning, don't forget lines already added into the $_SESSION['massstockmove'] - if ($producttmp->hasbatch()) - { + if ($producttmp->hasbatch()) { } else { } } - if (!$error) - { - if (count(array_keys($listofdata)) > 0) $id = max(array_keys($listofdata)) + 1; - else $id = 1; + if (!$error) { + if (count(array_keys($listofdata)) > 0) { + $id = max(array_keys($listofdata)) + 1; + } else { + $id = 1; + } $listofdata[$id] = array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); $_SESSION['massstockmove'] = json_encode($listofdata); @@ -147,31 +142,31 @@ if ($action == 'addline') } } -if ($action == 'delline' && $idline != '') -{ - if (!empty($listofdata[$idline])) unset($listofdata[$idline]); - if (count($listofdata) > 0) $_SESSION['massstockmove'] = json_encode($listofdata); - else unset($_SESSION['massstockmove']); +if ($action == 'delline' && $idline != '') { + if (!empty($listofdata[$idline])) { + unset($listofdata[$idline]); + } + if (count($listofdata) > 0) { + $_SESSION['massstockmove'] = json_encode($listofdata); + } else { + unset($_SESSION['massstockmove']); + } } -if ($action == 'createmovements') -{ +if ($action == 'createmovements') { $error = 0; - if (!GETPOST("label")) - { + if (!GETPOST("label")) { $error++; setEventMessages($langs->trans("ErrorFieldRequired"), $langs->transnoentitiesnoconv("MovementLabel"), null, 'errors'); } $db->begin(); - if (!$error) - { + if (!$error) { $product = new Product($db); - foreach ($listofdata as $key => $val) // Loop on each movement to do - { + foreach ($listofdata as $key => $val) { // Loop on each movement to do $id = $val['id']; $id_product = $val['id_product']; $id_sw = $val['id_sw']; @@ -181,21 +176,21 @@ if ($action == 'createmovements') $dlc = -1; // They are loaded later from serial $dluo = -1; // They are loaded later from serial - if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) - { + if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) { $result = $product->fetch($id_product); $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved $pricesrc = 0; - if (!empty($product->pmp)) $pricesrc = $product->pmp; + if (!empty($product->pmp)) { + $pricesrc = $product->pmp; + } $pricedest = $pricesrc; //print 'price src='.$pricesrc.', price dest='.$pricedest;exit; - if (empty($conf->productbatch->enabled) || !$product->hasbatch()) // If product does not need lot/serial - { + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) { // If product does not need lot/serial // Remove stock $result1 = $product->correct_stock( $user, @@ -206,8 +201,7 @@ if ($action == 'createmovements') $pricesrc, GETPOST("codemove") ); - if ($result1 < 0) - { + if ($result1 < 0) { $error++; setEventMessages($product->errors, $product->errorss, 'errors'); } @@ -222,15 +216,13 @@ if ($action == 'createmovements') $pricedest, GETPOST("codemove") ); - if ($result2 < 0) - { + if ($result2 < 0) { $error++; setEventMessages($product->errors, $product->errorss, 'errors'); } } else { $arraybatchinfo = $product->loadBatchInfo($batch); - if (count($arraybatchinfo) > 0) - { + if (count($arraybatchinfo) > 0) { $firstrecord = array_shift($arraybatchinfo); $dlc = $firstrecord['eatby']; $dluo = $firstrecord['sellby']; @@ -253,8 +245,7 @@ if ($action == 'createmovements') $batch, GETPOST("codemove") ); - if ($result1 < 0) - { + if ($result1 < 0) { $error++; setEventMessages($product->errors, $product->errorss, 'errors'); } @@ -272,8 +263,7 @@ if ($action == 'createmovements') $batch, GETPOST("codemove") ); - if ($result2 < 0) - { + if ($result2 < 0) { $error++; setEventMessages($product->errors, $product->errorss, 'errors'); } @@ -285,8 +275,7 @@ if ($action == 'createmovements') } } - if (!$error) - { + if (!$error) { unset($_SESSION['massstockmove']); $db->commit(); @@ -362,7 +351,9 @@ print '</td>'; // Product print '<td class="titlefield">'; $filtertype = 0; -if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = ''; +if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $filtertype = ''; +} if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { $limit = ''; } else { @@ -372,8 +363,7 @@ if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1); print '</td>'; // Batch number -if ($conf->productbatch->enabled) -{ +if ($conf->productbatch->enabled) { print '<td>'; print '<input type="text" name="batch" class="flat maxwidth50" value="'.$batch.'">'; print '</td>'; @@ -386,8 +376,7 @@ print '<td class="right"><input type="submit" class="button" name="addline" valu print '</tr>'; -foreach ($listofdata as $key => $val) -{ +foreach ($listofdata as $key => $val) { $productstatic->fetch($val['id_product']); $warehousestatics->fetch($val['id_sw']); $warehousestatict->fetch($val['id_tw']); @@ -402,8 +391,7 @@ foreach ($listofdata as $key => $val) print '<td>'; print $productstatic->getNomUrl(1).' - '.$productstatic->label; print '</td>'; - if ($conf->productbatch->enabled) - { + if ($conf->productbatch->enabled) { print '<td>'; print $val['batch']; print '</td>'; diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cf3cc67bdc2..5107a558288 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -44,7 +44,9 @@ if (!empty($conf->projet->enabled)) { // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} // Security check $result = restrictedArea($user, 'stock'); @@ -75,10 +77,16 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (!$sortfield) $sortfield = "m.datem"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "m.datem"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $pdluoid = GETPOST('pdluoid', 'int'); @@ -123,18 +131,23 @@ $usercandelete = (($user->rights->stock->mouvement->supprimer)); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click 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 -{ +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 $year = ''; $month = ''; $search_ref = ''; @@ -153,39 +166,35 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Correct stock -if ($action == "correct_stock") -{ +if ($action == "correct_stock") { $product = new Product($db); - if (!empty($product_id)) $result = $product->fetch($product_id); + if (!empty($product_id)) { + $result = $product->fetch($product_id); + } $error = 0; - if (empty($product_id)) - { + if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'correction'; } - if (!is_numeric($_POST["nbpiece"])) - { + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $action = 'correction'; } - if (!$error) - { + if (!$error) { $origin_element = ''; $origin_id = null; - if (GETPOST('projectid', 'int')) - { + if (GETPOST('projectid', 'int')) { $origin_element = 'project'; $origin_id = GETPOST('projectid', 'int'); } - if ($product->hasbatch()) - { + if ($product->hasbatch()) { $batch = GETPOST('batch_number', 'alpha'); //$eatby=GETPOST('eatby'); @@ -221,8 +230,7 @@ if ($action == "correct_stock") ); // We do not change value of stock for a correction } - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -232,57 +240,52 @@ if ($action == "correct_stock") } } - if (!$error) $action = ''; + if (!$error) { + $action = ''; + } } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && !$cancel) -{ +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (!empty($product_id)) $result = $product->fetch($product_id); + if (!empty($product_id)) { + $result = $product->fetch($product_id); + } - if (!(GETPOST("id_entrepot_destination", 'int') > 0)) - { + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; $action = 'transfert'; } - if (empty($product_id)) - { + if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'transfert'; } - if (!GETPOST("nbpiece", 'int')) - { + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'transfert'; } - if ($id == GETPOST("id_entrepot_destination", 'int')) - { + if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; $action = 'transfert'; } - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); $result = $product->fetch($product_id); - if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) - { + if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; $action = 'transfert'; } } - if (!$error) - { - if ($id) - { + if (!$error) { + if ($id) { $object = new Entrepot($db); $result = $object->fetch($id); @@ -292,18 +295,17 @@ if ($action == "transfert_stock" && !$cancel) // Define value of products moved $pricesrc = 0; - if (isset($product->pmp)) $pricesrc = $product->pmp; + if (isset($product->pmp)) { + $pricesrc = $product->pmp; + } $pricedest = $pricesrc; - if ($product->hasbatch()) - { + if ($product->hasbatch()) { $pdluo = new Productbatch($db); - if ($pdluoid > 0) - { + if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); - if ($result) - { + if ($result) { $srcwarehouseid = $pdluo->warehouseid; $batch = $pdluo->batch; $eatby = $pdluo->eatby; @@ -319,8 +321,7 @@ if ($action == "transfert_stock" && !$cancel) $sellby = $d_sellby; } - if (!$error) - { + if (!$error) { // Remove stock $result1 = $product->correct_stock_batch( $user, @@ -371,12 +372,10 @@ if ($action == "transfert_stock" && !$cancel) GETPOST('inventorycode', 'alpha') ); } - if (!$error && $result1 >= 0 && $result2 >= 0) - { + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } else { @@ -403,8 +402,7 @@ $permissiontoadd = $user->rights->stock->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; -if (empty($reshook) && $action != 'remove_file') -{ +if (empty($reshook) && $action != 'remove_file') { $objectclass = 'MouvementStock'; $objectlabel = 'Movements'; $permissiontoread = $user->rights->stock->lire; @@ -427,7 +425,9 @@ $userstatic = new User($db); $form = new Form($db); $formother = new FormOther($db); $formproduct = new FormProduct($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; @@ -438,7 +438,9 @@ $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql .= " u.login, u.photo, u.lastname, u.firstname"; // 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 : ''); + 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(); @@ -447,27 +449,57 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -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 (m.rowid = ef.fk_object)"; +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 (m.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; -if ($msid > 0) $sql .= " AND m.rowid = ".$msid; +if ($msid > 0) { + $sql .= " AND m.rowid = ".$msid; +} $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; -if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND p.fk_product_type = 0"; +} +if ($id > 0) { + $sql .= " AND e.rowid ='".$id."'"; +} $sql .= dolSqlDateFilter('m.datem', 0, $month, $year); -if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct); -if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); -if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); -if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); -if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); -if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); -if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); -if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); -if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); +if ($idproduct > 0) { + $sql .= " AND p.rowid = ".((int) $idproduct); +} +if (!empty($search_ref)) { + $sql .= natural_search('m.rowid', $search_ref, 1); +} +if (!empty($search_movement)) { + $sql .= natural_search('m.label', $search_movement); +} +if (!empty($search_inventorycode)) { + $sql .= natural_search('m.inventorycode', $search_inventorycode); +} +if (!empty($search_product_ref)) { + $sql .= natural_search('p.ref', $search_product_ref); +} +if (!empty($search_product)) { + $sql .= natural_search('p.label', $search_product); +} +if ($search_warehouse != '' && $search_warehouse != '-1') { + $sql .= natural_search('e.rowid', $search_warehouse, 2); +} +if (!empty($search_user)) { + $sql .= natural_search('u.login', $search_user); +} +if (!empty($search_batch)) { + $sql .= natural_search('m.batch', $search_batch); +} +if ($search_qty != '') { + $sql .= natural_search('m.value', $search_qty, 1); +} +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { + $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -477,12 +509,10 @@ $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -492,20 +522,16 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $product = new Product($db); $object = new Entrepot($db); - if ($idproduct > 0) - { + if ($idproduct > 0) { $product->fetch($idproduct); } - if ($id > 0 || $ref) - { + if ($id > 0 || $ref) { $result = $object->fetch($id, $ref); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); } } @@ -517,18 +543,20 @@ if ($resql) $i = 0; $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; - if ($msid) $texte = $langs->trans('StockMovementForId', $msid); - else { + if ($msid) { + $texte = $langs->trans('StockMovementForId', $msid); + } else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) { + $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + } } llxHeader("", $texte, $help_url); /* - * Show tab only if we ask a particular warehouse - */ - if ($object->id > 0) - { + * Show tab only if we ask a particular warehouse + */ + if ($object->id > 0) { $head = stock_prepare_head($object); print dol_get_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); @@ -541,7 +569,9 @@ if ($resql) $morehtmlref .= '</div>'; $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -590,8 +620,7 @@ if ($resql) $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_entrepot = ".(int) $object->id; $resqlbis = $db->query($sql); - if ($resqlbis) - { + if ($resqlbis) { $obj = $db->fetch_object($resqlbis); $lastmovementdate = $db->jdate($obj->datem); } else { @@ -599,8 +628,7 @@ if ($resql) } print '<tr><td>'.$langs->trans("LastMovement").'</td><td>'; - if ($lastmovementdate) - { + if ($lastmovementdate) { print dol_print_date($lastmovementdate, 'dayhour'); } else { print $langs->trans("None"); @@ -622,8 +650,7 @@ if ($resql) /* * Correct stock */ - if ($action == "correction") - { + if ($action == "correction") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; print '<br>'; } @@ -631,8 +658,7 @@ if ($resql) /* * Transfer of units */ - if ($action == "transfert") - { + if ($action == "transfert") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; print '<br>'; } @@ -644,17 +670,14 @@ if ($resql) /* */ /* ************************************************************************** */ - if ((empty($action) || $action == 'list') && $id > 0) - { + if ((empty($action) || $action == 'list') && $id > 0) { print "<div class=\"tabsAction\">\n"; - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=correction">'.$langs->trans("CorrectStock").'</a>'; } - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("TransferStock").'</a>'; } @@ -662,18 +685,42 @@ if ($resql) } $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($id > 0) $param .= '&id='.urlencode($id); - if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param .= '&search_product='.urlencode($search_product); - if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); - if ($search_user) $param .= '&search_user='.urlencode($search_user); - if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($id > 0) { + $param .= '&id='.urlencode($id); + } + if ($search_movement) { + $param .= '&search_movement='.urlencode($search_movement); + } + if ($search_inventorycode) { + $param .= '&search_inventorycode='.urlencode($search_inventorycode); + } + if ($search_type_mouvement) { + $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + } + if ($search_product_ref) { + $param .= '&search_product_ref='.urlencode($search_product_ref); + } + if ($search_product) { + $param .= '&search_product='.urlencode($search_product); + } + if ($search_batch) { + $param .= '&search_batch='.urlencode($search_batch); + } + if ($search_warehouse > 0) { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_user) { + $param .= '&search_user='.urlencode($search_user); + } + if ($idproduct > 0) { + $param .= '&idproduct='.urlencode($idproduct); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -683,11 +730,15 @@ if ($resql) // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -695,14 +746,20 @@ if ($resql) print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; - if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">'; + if ($id > 0) { + print '<input type="hidden" name="id" value="'.$id.'">'; + } - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + if ($id > 0) { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + } else { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + } - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -710,11 +767,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -728,84 +787,74 @@ if ($resql) // Fields title search print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['m.rowid']['checked'])) - { + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (!empty($arrayfields['m.datem']['checked'])) - { + if (!empty($arrayfields['m.datem']['checked'])) { print '<td class="liste_titre nowraponall">'; print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">'; - if (empty($conf->productbatch->enabled)) print '&nbsp;'; + if (empty($conf->productbatch->enabled)) { + print '&nbsp;'; + } //else print '<br>'; $syear = $year ? $year : -1; print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">'; //print $formother->selectyear($syear,'year',1, 20, 5); print '</td>'; } - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">'; print '</td>'; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td class="liste_titre left">'; print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">'; print '</td>'; } // Batch - if (!empty($arrayfields['m.batch']['checked'])) - { + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>'; } - if (!empty($arrayfields['pl.eatby']['checked'])) - { + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } - if (!empty($arrayfields['pl.sellby']['checked'])) - { + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) - { + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone left">'; //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">'; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['m.fk_user_author']['checked'])) - { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">'; print '</td>'; } - if (!empty($arrayfields['m.inventorycode']['checked'])) - { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">'; print '</td>'; } - if (!empty($arrayfields['m.label']['checked'])) - { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">'; print '</td>'; } - if (!empty($arrayfields['m.type_mouvement']['checked'])) - { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print '<td class="liste_titre center">'; //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">'; @@ -821,22 +870,19 @@ if ($resql) // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['origin']['checked'])) - { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="liste_titre left">'; print '&nbsp; '; print '</td>'; } - if (!empty($arrayfields['m.value']['checked'])) - { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">'; print '</td>'; } - if (!empty($arrayfields['m.price']['checked'])) - { + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="liste_titre left">'; print '&nbsp; '; @@ -852,14 +898,12 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['m.datec']['checked'])) - { + if (!empty($arrayfields['m.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['m.tms']['checked'])) - { + if (!empty($arrayfields['m.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -871,38 +915,52 @@ if ($resql) print "</tr>\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['m.datem']['checked'])) + } + if (!empty($arrayfields['m.datem']['checked'])) { print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) + } + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.label']['checked'])) + } + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['m.batch']['checked'])) + } + if (!empty($arrayfields['m.batch']['checked'])) { print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pl.eatby']['checked'])) + } + if (!empty($arrayfields['pl.eatby']['checked'])) { print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pl.sellby']['checked'])) + } + if (!empty($arrayfields['pl.sellby']['checked'])) { print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (!empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.inventorycode']['checked'])) + } + if (!empty($arrayfields['m.inventorycode']['checked'])) { print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.label']['checked'])) + } + if (!empty($arrayfields['m.label']['checked'])) { print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.type_mouvement']['checked'])) + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) { print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['origin']['checked'])) + } + if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.value']['checked'])) + } + if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['m.price']['checked'])) + } + if (!empty($arrayfields['m.price']['checked'])) { print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -956,65 +1014,58 @@ if ($resql) print '<tr class="oddeven">'; // Id movement - if (!empty($arrayfields['m.rowid']['checked'])) - { + if (!empty($arrayfields['m.rowid']['checked'])) { // This is primary not movement id print '<td>'.$objp->mid.'</td>'; } - if (!empty($arrayfields['m.datem']['checked'])) - { + if (!empty($arrayfields['m.datem']['checked'])) { // Date print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>'; } - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '<td class="nowraponall">'; print $productstatic->getNomUrl(1, 'stock', 16); print "</td>\n"; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td>'; /*$productstatic->id=$objp->rowid; - $productstatic->ref=$objp->produit; - $productstatic->type=$objp->type; - print $productstatic->getNomUrl(1,'',16);*/ + $productstatic->ref=$objp->produit; + $productstatic->type=$objp->type; + print $productstatic->getNomUrl(1,'',16);*/ print $productstatic->label; print "</td>\n"; } - if (!empty($arrayfields['m.batch']['checked'])) - { + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="center nowraponall">'; - if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + if ($productlot->id > 0) { + print $productlot->getNomUrl(1); + } else { + print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + } print '</td>'; } - if (!empty($arrayfields['pl.eatby']['checked'])) - { + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>'; } - if (!empty($arrayfields['pl.sellby']['checked'])) - { + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>'; } // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) - { + if (!empty($arrayfields['e.ref']['checked'])) { print '<td>'; print $warehousestatic->getNomUrl(1); print "</td>\n"; } // Author - if (!empty($arrayfields['m.fk_user_author']['checked'])) - { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '<td class="tdoverflowmax100">'; print $userstatic->getNomUrl(-1); print "</td>\n"; } - if (!empty($arrayfields['m.inventorycode']['checked'])) - { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td><a href="' .DOL_URL_ROOT.'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id) @@ -1024,13 +1075,11 @@ if ($resql) .$objp->inventorycode .'</a></td>'; } - if (!empty($arrayfields['m.label']['checked'])) - { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="tdoverflowmax100aaa">'.$objp->label.'</td>'; } - if (!empty($arrayfields['m.type_mouvement']['checked'])) - { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement switch ($objp->type_mouvement) { case "0": @@ -1047,36 +1096,40 @@ if ($resql) break; } } - if (!empty($arrayfields['origin']['checked'])) - { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="nowraponall">'.$origin.'</td>'; } - if (!empty($arrayfields['m.value']['checked'])) - { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; - if ($objp->qt > 0) print '+'; + if ($objp->qt > 0) { + print '+'; + } print $objp->qty; print '</td>'; } - if (!empty($arrayfields['m.price']['checked'])) - { + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="right">'; - if ($objp->price != 0) print price($objp->price); + if ($objp->price != 0) { + print price($objp->price); + } print '</td>'; } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; $i++; @@ -1088,8 +1141,7 @@ if ($resql) print "</form>"; // Add number of product when there is a filter on period - if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) - { + if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { print "<br>"; $productidselected = 0; @@ -1129,8 +1181,7 @@ if ($resql) //Area for doc and last events of warehouse are stored on the main card of warehouse $modulepart = 'movement'; -if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) -{ +if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) { print '<br/>'; print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre @@ -1138,8 +1189,12 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) // Documents $objectref = dol_sanitizeFileName($object->ref); // Add inventorycode & type_mouvement to filename of the pdf - if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; - if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + if (!empty($search_inventorycode)) { + $objectref .= "_".$id."_".$search_inventorycode; + } + if ($search_type_mouvement) { + $objectref .= "_".$search_type_mouvement; + } $relativepath = $comref.'/'.$objectref.'.pdf'; $filedir = $conf->stock->dir_output.'/movement/'.$objectref; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index d67a72d2d63..b4d1c9a1fe8 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -45,7 +45,9 @@ if (!empty($conf->projet->enabled)) { // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} // Security check $result = restrictedArea($user, 'stock'); @@ -89,10 +91,16 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (!$sortfield) $sortfield = "m.datem"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "m.datem"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $pdluoid = GETPOST('pdluoid', 'int'); @@ -154,20 +162,24 @@ $error = 0; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click 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 - { + 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 $search_date_startday = ''; $search_date_startmonth = ''; $search_date_startyear = ''; @@ -206,7 +218,9 @@ if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (!$error) { $result = $tmpwarehouse->insertExtraFields(); if ($result < 0) { @@ -214,43 +228,41 @@ if ($action == 'update_extras') { $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } // Correct stock -if ($action == "correct_stock") -{ +if ($action == "correct_stock") { $product = new Product($db); - if (!empty($product_id)) $result = $product->fetch($product_id); + if (!empty($product_id)) { + $result = $product->fetch($product_id); + } $error = 0; - if (empty($product_id)) - { + if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'correction'; } - if (!is_numeric($_POST["nbpiece"])) - { + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $action = 'correction'; } - if (!$error) - { + if (!$error) { $origin_element = ''; $origin_id = null; - if (GETPOST('projectid', 'int')) - { + if (GETPOST('projectid', 'int')) { $origin_element = 'project'; $origin_id = GETPOST('projectid', 'int'); } - if ($product->hasbatch()) - { + if ($product->hasbatch()) { $batch = GETPOST('batch_number', 'alphanohtml'); //$eatby=GETPOST('eatby'); @@ -265,7 +277,9 @@ if ($action == "correct_stock") GETPOST("mouvement"), GETPOST("label", 'san_alpha'), GETPOST('unitprice'), - $eatby, $sellby, $batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id @@ -284,8 +298,7 @@ if ($action == "correct_stock") ); // We do not change value of stock for a correction } - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -295,57 +308,52 @@ if ($action == "correct_stock") } } - if (!$error) $action = ''; + if (!$error) { + $action = ''; + } } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && !$cancel) -{ +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (!empty($product_id)) $result = $product->fetch($product_id); + if (!empty($product_id)) { + $result = $product->fetch($product_id); + } - if (!(GETPOST("id_entrepot_destination", 'int') > 0)) - { + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; $action = 'transfert'; } - if (empty($product_id)) - { + if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'transfert'; } - if (!GETPOST("nbpiece", 'int')) - { + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'transfert'; } - if ($id == GETPOST("id_entrepot_destination", 'int')) - { + if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; $action = 'transfert'; } - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); $result = $product->fetch($product_id); - if ($product->hasbatch() && !GETPOST("batch_number")) - { + if ($product->hasbatch() && !GETPOST("batch_number")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; $action = 'transfert'; } } - if (!$error) - { - if ($id) - { + if (!$error) { + if ($id) { $object = new Entrepot($db); $result = $object->fetch($id); @@ -355,18 +363,17 @@ if ($action == "transfert_stock" && !$cancel) // Define value of products moved $pricesrc = 0; - if (isset($product->pmp)) $pricesrc = $product->pmp; + if (isset($product->pmp)) { + $pricesrc = $product->pmp; + } $pricedest = $pricesrc; - if ($product->hasbatch()) - { + if ($product->hasbatch()) { $pdluo = new Productbatch($db); - if ($pdluoid > 0) - { + if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); - if ($result) - { + if ($result) { $srcwarehouseid = $pdluo->warehouseid; $batch = $pdluo->batch; $eatby = $pdluo->eatby; @@ -382,8 +389,7 @@ if ($action == "transfert_stock" && !$cancel) $sellby = $d_sellby; } - if (!$error) - { + if (!$error) { // Remove stock $result1 = $product->correct_stock_batch( $user, @@ -392,9 +398,11 @@ if ($action == "transfert_stock" && !$cancel) 1, GETPOST("label", 'san_alpha'), $pricesrc, - $eatby, $sellby, $batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode') - ); + ); // Add stock $result2 = $product->correct_stock_batch( $user, @@ -403,9 +411,11 @@ if ($action == "transfert_stock" && !$cancel) 0, GETPOST("label", 'san_alpha'), $pricedest, - $eatby, $sellby, $batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alphanohtml') - ); + ); } } else { // Remove stock @@ -417,7 +427,7 @@ if ($action == "transfert_stock" && !$cancel) GETPOST("label", 'san_alpha'), $pricesrc, GETPOST('inventorycode', 'alphanohtml') - ); + ); // Add stock $result2 = $product->correct_stock( @@ -428,14 +438,12 @@ if ($action == "transfert_stock" && !$cancel) GETPOST("label", 'san_alpha'), $pricedest, GETPOST('inventorycode', 'alphanohtml') - ); + ); } - if (!$error && $result1 >= 0 && $result2 >= 0) - { + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } else { @@ -464,7 +472,9 @@ $userstatic = new User($db); $form = new Form($db); $formother = new FormOther($db); $formproduct = new FormProduct($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,"; $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,"; @@ -476,7 +486,9 @@ $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql .= " u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status"; // 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 : ''); + 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(); @@ -485,29 +497,65 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -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 (m.rowid = ef.fk_object)"; +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 (m.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; -if ($msid > 0) $sql .= " AND m.rowid = ".$msid; +if ($msid > 0) { + $sql .= " AND m.rowid = ".$msid; +} $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; -if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; -if (!empty($search_date_start)) $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; -if (!empty($search_date_end)) $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'"; -if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct); -if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); -if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); -if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); -if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); -if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); -if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); -if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); -if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); -if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND p.fk_product_type = 0"; +} +if ($id > 0) { + $sql .= " AND e.rowid ='".$id."'"; +} +if (!empty($search_date_start)) { + $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; +} +if (!empty($search_date_end)) { + $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'"; +} +if ($idproduct > 0) { + $sql .= " AND p.rowid = ".((int) $idproduct); +} +if (!empty($search_ref)) { + $sql .= natural_search('m.rowid', $search_ref, 1); +} +if (!empty($search_movement)) { + $sql .= natural_search('m.label', $search_movement); +} +if (!empty($search_inventorycode)) { + $sql .= natural_search('m.inventorycode', $search_inventorycode); +} +if (!empty($search_product_ref)) { + $sql .= natural_search('p.ref', $search_product_ref); +} +if (!empty($search_product)) { + $sql .= natural_search('p.label', $search_product); +} +if ($search_warehouse != '' && $search_warehouse != '-1') { + $sql .= natural_search('e.rowid', $search_warehouse, 2); +} +if (!empty($search_user)) { + $sql .= natural_search('u.login', $search_user); +} +if (!empty($search_batch)) { + $sql .= natural_search('m.batch', $search_batch); +} +if (!empty($product_id)) { + $sql .= natural_search('p.rowid', $product_id); +} +if ($search_qty != '') { + $sql .= natural_search('m.value', $search_qty, 1); +} +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { + $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -517,19 +565,16 @@ $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } } -if (empty($search_inventorycode)) -{ +if (empty($search_inventorycode)) { $sql .= $db->plimit($limit + 1, $offset); } else { $limit = 0; @@ -539,22 +584,20 @@ if (empty($search_inventorycode)) $resql = $db->query($sql); -if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); +if (!empty($search_inventorycode)) { + $limit = $db->num_rows($resql); +} -if ($resql) -{ +if ($resql) { $product = new Product($db); $object = new Entrepot($db); - if ($idproduct > 0) - { + if ($idproduct > 0) { $product->fetch($idproduct); } - if ($id > 0 || $ref) - { + if ($id > 0 || $ref) { $result = $object->fetch($id, $ref); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); } } @@ -566,18 +609,20 @@ if ($resql) $i = 0; $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; - if ($msid) $texte = $langs->trans('StockMovementForId', $msid); - else { + if ($msid) { + $texte = $langs->trans('StockMovementForId', $msid); + } else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) { + $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + } } llxHeader("", $texte, $help_url); /* - * Show tab only if we ask a particular warehouse - */ - if ($object->id > 0) - { + * Show tab only if we ask a particular warehouse + */ + if ($object->id > 0) { $head = stock_prepare_head($object); print dol_get_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); @@ -590,7 +635,9 @@ if ($resql) $morehtmlref .= '</div>'; $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -639,8 +686,7 @@ if ($resql) $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_entrepot = ".((int) $object->id); $resqlbis = $db->query($sql); - if ($resqlbis) - { + if ($resqlbis) { $objbis = $db->fetch_object($resqlbis); $lastmovementdate = $db->jdate($objbis->datem); } else { @@ -648,8 +694,7 @@ if ($resql) } print '<tr><td>'.$langs->trans("LastMovement").'</td><td>'; - if ($lastmovementdate) - { + if ($lastmovementdate) { print dol_print_date($lastmovementdate, 'dayhour'); } else { print $langs->trans("None"); @@ -681,8 +726,7 @@ if ($resql) /* * Correct stock */ - if ($action == "correction") - { + if ($action == "correction") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; print '<br>'; } @@ -690,8 +734,7 @@ if ($resql) /* * Transfer of units */ - if ($action == "transfert") - { + if ($action == "transfert") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; print '<br>'; } @@ -703,17 +746,14 @@ if ($resql) /* */ /* ************************************************************************** */ - if ((empty($action) || $action == 'list') && $id > 0) - { + if ((empty($action) || $action == 'list') && $id > 0) { print "<div class=\"tabsAction\">\n"; - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=correction">'.$langs->trans("CorrectStock").'</a>'; } - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("TransferStock").'</a>'; } @@ -721,24 +761,60 @@ if ($resql) } $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($id > 0) $param .= '&id='.urlencode($id); - if ($search_date_startday) $param .= '&search_date_startday='.urlencode($search_date_startday); - if ($search_date_startmonth) $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); - if ($search_date_startyear) $param .= '&search_date_startyear='.urlencode($search_date_startyear); - if ($search_date_endday) $param .= '&search_date_endday='.urlencode($search_date_endday); - if ($search_date_endmonth) $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); - if ($search_date_endyear) $param .= '&search_date_endyear='.urlencode($search_date_endyear); - if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param .= '&search_product='.urlencode($search_product); - if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); - if ($search_user) $param .= '&search_user='.urlencode($search_user); - if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($id > 0) { + $param .= '&id='.urlencode($id); + } + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); + } + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + } + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); + } + if ($search_movement) { + $param .= '&search_movement='.urlencode($search_movement); + } + if ($search_inventorycode) { + $param .= '&search_inventorycode='.urlencode($search_inventorycode); + } + if ($search_type_mouvement) { + $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + } + if ($search_product_ref) { + $param .= '&search_product_ref='.urlencode($search_product_ref); + } + if ($search_product) { + $param .= '&search_product='.urlencode($search_product); + } + if ($search_batch) { + $param .= '&search_batch='.urlencode($search_batch); + } + if ($search_warehouse > 0) { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_user) { + $param .= '&search_user='.urlencode($search_user); + } + if ($idproduct > 0) { + $param .= '&idproduct='.urlencode($idproduct); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -748,12 +824,18 @@ if ($resql) // 'builddoc'=>$langs->trans("PDFMerge"), ); // By default, we should never accept deletion of stock movement. - if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -761,10 +843,15 @@ if ($resql) print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; - if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">'; + if ($id > 0) { + print '<input type="hidden" name="id" value="'.$id.'">'; + } - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + if ($id > 0) { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + } else { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + } // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendStockMovement"; @@ -773,9 +860,10 @@ if ($resql) $trackid = 'mov'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -783,11 +871,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -801,15 +891,13 @@ if ($resql) // Fields title search print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['m.rowid']['checked'])) - { + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['m.datem']['checked'])) - { + if (! empty($arrayfields['m.datem']['checked'])) { print '<td class="liste_titre center">'; print '<div class="nowrap">'; print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); @@ -819,66 +907,56 @@ if ($resql) print '</div>'; print '</td>'; } - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">'; print '</td>'; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td class="liste_titre left">'; print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">'; print '</td>'; } // Batch - if (!empty($arrayfields['m.batch']['checked'])) - { + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>'; } - if (!empty($arrayfields['pl.eatby']['checked'])) - { + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } - if (!empty($arrayfields['pl.sellby']['checked'])) - { + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) - { + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone left">'; //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">'; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['m.fk_user_author']['checked'])) - { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">'; print '</td>'; } - if (!empty($arrayfields['m.inventorycode']['checked'])) - { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">'; print '</td>'; } - if (!empty($arrayfields['m.label']['checked'])) - { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">'; print '</td>'; } - if (!empty($arrayfields['m.type_mouvement']['checked'])) - { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print '<td class="liste_titre center">'; //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">'; @@ -894,29 +972,25 @@ if ($resql) // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['origin']['checked'])) - { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="liste_titre left">'; print '&nbsp; '; print '</td>'; } - if (!empty($arrayfields['m.value']['checked'])) - { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">'; print '</td>'; } - if (!empty($arrayfields['m.price']['checked'])) - { + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="liste_titre" align="left">'; print '&nbsp; '; print '</td>'; } - if (!empty($arrayfields['m.fk_projet']['checked'])) - { + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print '<td class="liste_titre" align="left">'; print '&nbsp; '; @@ -932,14 +1006,12 @@ if ($resql) $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['m.datec']['checked'])) - { + if (!empty($arrayfields['m.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['m.tms']['checked'])) - { + if (!empty($arrayfields['m.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -1022,8 +1094,7 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); $userstatic->id = $objp->fk_user_author; @@ -1064,60 +1135,53 @@ if ($resql) print '<tr class="oddeven">'; // Id movement - if (!empty($arrayfields['m.rowid']['checked'])) - { + if (!empty($arrayfields['m.rowid']['checked'])) { print '<td>'.$objp->mid.'</td>'; // This is primary not movement id } - if (!empty($arrayfields['m.datem']['checked'])) - { + if (!empty($arrayfields['m.datem']['checked'])) { // Date print '<td class="nowraponall">'.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').'</td>'; } - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '<td class="nowraponall">'; print $productstatic->getNomUrl(1, 'stock', 16); print "</td>\n"; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">'; print $productstatic->label; print "</td>\n"; } - if (!empty($arrayfields['m.batch']['checked'])) - { + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="center nowraponall">'; - if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + if ($productlot->id > 0) { + print $productlot->getNomUrl(1); + } else { + print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + } print '</td>'; } - if (!empty($arrayfields['pl.eatby']['checked'])) - { + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>'; } - if (!empty($arrayfields['pl.sellby']['checked'])) - { + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>'; } // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) - { + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="tdoverflowmax100">'; print $warehousestatic->getNomUrl(1); print "</td>\n"; } // Author - if (!empty($arrayfields['m.fk_user_author']['checked'])) - { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '<td class="tdoverflowmax100">'; print $userstatic->getNomUrl(-1); print "</td>\n"; } - if (!empty($arrayfields['m.inventorycode']['checked'])) - { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td><a href="' .DOL_URL_ROOT.'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id) @@ -1125,13 +1189,11 @@ if ($resql) .'&search_type_mouvement='.urlencode($objp->type_mouvement) .'">'.$objp->inventorycode.'</a></td>'; } - if (!empty($arrayfields['m.label']['checked'])) - { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="tdoverflowmax100aaa">'.$objp->label.'</td>'; } - if (!empty($arrayfields['m.type_mouvement']['checked'])) - { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement switch ($objp->type_mouvement) { case "0": @@ -1148,43 +1210,48 @@ if ($resql) break; } } - if (!empty($arrayfields['origin']['checked'])) - { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="nowraponall">'.$origin.'</td>'; } - if (!empty($arrayfields['m.value']['checked'])) - { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; - if ($objp->qt > 0) print '+'; + if ($objp->qt > 0) { + print '+'; + } print $objp->qty; print '</td>'; } - if (!empty($arrayfields['m.price']['checked'])) - { + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="right">'; - if ($objp->price != 0) print price($objp->price); + if ($objp->price != 0) { + print price($objp->price); + } print '</td>'; } - if (!empty($arrayfields['m.fk_projet']['checked'])) - { + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print '<td align="right">'; - if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project, 'project'); + if ($objp->fk_project != 0) { + print $movement->get_origin($objp->fk_project, 'project'); + } print '</td>'; } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($objp->mid, $arrayofselected)) $selected = 1; + if (in_array($objp->mid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$objp->mid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->mid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; $i++; @@ -1196,13 +1263,11 @@ if ($resql) print "</form>"; // Add number of product when there is a filter on period - if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) - { + if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { print "<br>"; $productidselected = 0; - foreach ($arrayofuniqueproduct as $key => $val) - { + foreach ($arrayofuniqueproduct as $key => $val) { $productidselected = $key; $productlabelselected = $val; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index d1c1ea99ff7..e45f48d9ef8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -55,7 +55,9 @@ if (!empty($conf->variants->enabled)) { // Load translation files required by the page $langs->loadlangs(array('products', 'suppliers', 'orders', 'bills', 'stocks', 'sendings', 'margins')); -if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) { + $langs->load("productbatch"); +} $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -76,7 +78,9 @@ if (!empty($batchnumber)) { } // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); @@ -86,20 +90,20 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); } -if (empty($id) && !empty($object->id)) $id = $object->id; +if (empty($id) && !empty($object->id)) { + $id = $object->id; +} $modulepart = 'product'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('stockproduct', 'card', $canvas); @@ -115,14 +119,17 @@ $error = 0; * Actions */ -if ($cancel) $action = ''; +if ($cancel) { + $action = ''; +} $parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) -{ +if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) { $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); @@ -142,14 +149,18 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) // Update $pse->seuil_stock_alerte = $seuil_stock_alerte; $pse->desiredstock = $desiredstock; - if ($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); + if ($pse->update($user) > 0) { + setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); + } } else { // Create $pse->fk_entrepot = GETPOST('fk_entrepot', 'int'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); - if ($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); + if ($pse->create($user) > 0) { + setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); + } } } @@ -157,66 +168,62 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) exit; } -if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) -{ +if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) { $pse = new ProductStockEntrepot($db); $pse->fetch(GETPOST('fk_productstockwarehouse', 'int')); - if ($pse->delete($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseDeleted'), null, 'mesgs'); + if ($pse->delete($user) > 0) { + setEventMessages($langs->trans('ProductStockWarehouseDeleted'), null, 'mesgs'); + } $action = ''; } // Set stock limit -if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) -{ +if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) { $object = new Product($db); $result = $object->fetch($id); $object->seuil_stock_alerte = $stocklimit; $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } //else // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); $action = ''; } // Set desired stock -if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) -{ +if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) { $object = new Product($db); $result = $object->fetch($id); $object->desiredstock = $desiredstock; $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } $action = ''; } // Correct stock -if ($action == "correct_stock" && !$cancel) -{ - if (!(GETPOST("id_entrepot", 'int') > 0)) - { +if ($action == "correct_stock" && !$cancel) { + if (!(GETPOST("id_entrepot", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; $action = 'correction'; } - if (!GETPOST("nbpiece")) - { + if (!GETPOST("nbpiece")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'correction'; } - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); $result = $object->fetch($id); - if ($object->hasbatch() && !$batchnumber) - { + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; $action = 'correction'; @@ -293,43 +300,35 @@ if ($action == "correct_stock" && !$cancel) } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && !$cancel) -{ - if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) - { +if ($action == "transfert_stock" && !$cancel) { + if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; $action = 'transfert'; } - if (!GETPOST("nbpiece", 'int')) - { + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action = 'transfert'; } - if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) - { + if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; $action = 'transfert'; } - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); $result = $object->fetch($id); - if ($object->hasbatch() && !$batchnumber) - { + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; $action = 'transfert'; } } - if (!$error) - { - if ($id) - { + if (!$error) { + if ($id) { $object = new Product($db); $result = $object->fetch($id); @@ -339,20 +338,19 @@ if ($action == "transfert_stock" && !$cancel) // Define value of products moved $pricesrc = 0; - if (isset($object->pmp)) $pricesrc = $object->pmp; + if (isset($object->pmp)) { + $pricesrc = $object->pmp; + } $pricedest = $pricesrc; $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - if ($object->hasbatch()) - { + if ($object->hasbatch()) { $pdluo = new Productbatch($db); - if ($pdluoid > 0) - { + if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); - if ($result) - { + if ($result) { $srcwarehouseid = $pdluo->warehouseid; $batch = $pdluo->batch; $eatby = $pdluo->eatby; @@ -370,8 +368,7 @@ if ($action == "transfert_stock" && !$cancel) $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - if (!$error) - { + if (!$error) { // Remove stock $result1 = $object->correct_stock_batch( $user, @@ -380,13 +377,16 @@ if ($action == "transfert_stock" && !$cancel) 1, GETPOST("label", 'alphanohtml'), $pricesrc, - $eatby, $sellby, $batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alphanohtml') ); - if ($result1 < 0) $error++; + if ($result1 < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Add stock $result2 = $object->correct_stock_batch( $user, @@ -395,14 +395,17 @@ if ($action == "transfert_stock" && !$cancel) 0, GETPOST("label", 'alphanohtml'), $pricedest, - $eatby, $sellby, $batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alphanohtml') ); - if ($result2 < 0) $error++; + if ($result2 < 0) { + $error++; + } } } else { - if (!$error) - { + if (!$error) { // Remove stock $result1 = $object->correct_stock( $user, @@ -413,10 +416,11 @@ if ($action == "transfert_stock" && !$cancel) $pricesrc, GETPOST('inventorycode', 'alphanohtml') ); - if ($result1 < 0) $error++; + if ($result1 < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Add stock $result2 = $object->correct_stock( $user, @@ -427,17 +431,17 @@ if ($action == "transfert_stock" && !$cancel) $pricedest, GETPOST('inventorycode', 'alphanohtml') ); - if ($result2 < 0) $error++; + if ($result2 < 0) { + $error++; + } } } - if (!$error && $result1 >= 0 && $result2 >= 0) - { + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } else { @@ -454,15 +458,12 @@ if ($action == "transfert_stock" && !$cancel) } // Update batch information -if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) -{ +if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) { $pdluo = new Productbatch($db); $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); - if ($result > 0) - { - if ($pdluo->id) - { + if ($result > 0) { + if ($pdluo->id) { if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); } else { @@ -472,8 +473,7 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) $pdluo->eatby = $d_eatby; $pdluo->sellby = $d_sellby; $result = $pdluo->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($pdluo->error, $pdluo->errors, 'errors'); } } @@ -495,10 +495,11 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) $form = new Form($db); $formproduct = new FormProduct($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} -if ($id > 0 || $ref) -{ +if ($id > 0 || $ref) { $object = new Product($db); $result = $object->fetch($id, $ref); @@ -509,21 +510,18 @@ if ($id > 0 || $ref) $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) - { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Stock'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) - { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Stock'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } llxHeader('', $title, $helpurl); - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -535,7 +533,9 @@ if ($id > 0 || $ref) $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -566,7 +566,9 @@ if ($id > 0 || $ref) // AWP print '<tr><td class="titlefield">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>'; print '<td>'; - if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); + if ($object->pmp > 0) { + print price($object->pmp).' '.$langs->trans("HT"); + } print '</td>'; print '</tr>'; @@ -575,8 +577,11 @@ if ($id > 0 || $ref) print '<td>'; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { - if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); - else print $langs->trans("NotDefined"); + if ($product_fourn->product_fourn_price_id > 0) { + print $product_fourn->display_price_product_fournisseur(); + } else { + print $langs->trans("NotDefined"); + } } print '</td></tr>'; @@ -648,7 +653,9 @@ if ($id > 0 || $ref) print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); print '</td>'; print '<td>'.price2num($object->stock_reel, 'MS'); - if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) { + print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + } print ' &nbsp; &nbsp;<a href="'.DOL_URL_ROOT.'/product/stock/stockatdate.php?productid='.$object->id.'">'.$langs->trans("StockAtDate").'</a>'; print '</td>'; @@ -660,10 +667,16 @@ if ($id > 0 || $ref) $helpondiff = '<strong>'.$langs->trans("StockDiffPhysicTeoric").':</strong><br>'; // Number of customer orders running if (!empty($conf->commande->enabled)) { - if ($found) $helpondiff .= '<br>'; else $found = 1; + if ($found) { + $helpondiff .= '<br>'; + } else { + $found = 1; + } $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; $result = $object->load_stats_commande(0, '0', 1); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } @@ -676,31 +689,48 @@ if ($id > 0 || $ref) } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { $filterShipmentStatus = Expedition::STATUS_CLOSED; } - if ($found) $helpondiff .= '<br>'; else $found = 1; + if ($found) { + $helpondiff .= '<br>'; + } else { + $found = 1; + } $result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus); $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } // Number of supplier order running - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - { - if ($found) $helpondiff .= '<br>'; else $found = 1; + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { + if ($found) { + $helpondiff .= '<br>'; + } else { + $found = 1; + } $result = $object->load_stats_commande_fournisseur(0, '3,4', 1); $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; $result = $object->load_stats_commande_fournisseur(0, '0,1,2', 1); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - if ($found) $helpondiff .= '<br>'; else $found = 1; + if ($found) { + $helpondiff .= '<br>'; + } else { + $found = 1; + } $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } // Number of product in production if (!empty($conf->mrp->enabled)) { - if ($found) $helpondiff .= '<br>'; else $found = 1; + if ($found) { + $helpondiff .= '<br>'; + } else { + $found = 1; + } $helpondiff .= $langs->trans("ProductQtyToConsumeByMO").': '.$object->stats_mrptoconsume['qty'].'<br>'; $helpondiff .= $langs->trans("ProductQtyToProduceByMO").': '.$object->stats_mrptoproduce['qty']; } @@ -713,14 +743,15 @@ if ($id > 0 || $ref) print "<td>"; //print (empty($stocktheo)?0:$stocktheo); print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff); - if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) { + print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + } print ' &nbsp; &nbsp;<a href="'.DOL_URL_ROOT.'/product/stock/stockatdate.php?mode=future&productid='.$object->id.'">'.$langs->trans("VirtualStockAtDate").'</a>'; print '</td>'; print '</tr>'; // Last movement - if (!empty($user->rights->stock->mouvement->lire)) - { + if (!empty($user->rights->stock->mouvement->lire)) { $sql = "SELECT max(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_product = ".((int) $object->id); @@ -754,15 +785,13 @@ if ($id > 0 || $ref) } // Correct stock - if ($action == "correction") - { + if ($action == "correction") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; print '<br><br>'; } // Transfer of units - if ($action == "transfert") - { + if ($action == "transfert") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; print '<br><br>'; } @@ -776,14 +805,11 @@ if ($id > 0 || $ref) $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) -{ - if (empty($action) && $object->id) - { +if (empty($reshook)) { + if (empty($action) && $object->id) { print "<div class=\"tabsAction\">\n"; - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=correction">'.$langs->trans("CorrectStock").'</a>'; } else { @@ -794,8 +820,7 @@ if (empty($reshook)) } //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) - if ($user->rights->stock->mouvement->creer) - { + if ($user->rights->stock->mouvement->creer) { if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=transfert">'.$langs->trans("TransferStock").'</a>'; } else { @@ -888,22 +913,32 @@ if (!$variants) { print '<td class="right">'.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').'</td>'; // Sell price print '<td class="right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1); - else print $langs->trans("Variable"); + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($object->price, 'MU'), 1); + } else { + print $langs->trans("Variable"); + } print '</td>'; // Value sell print '<td class="right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1).'</td>'; - else print $langs->trans("Variable"); + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($object->price * $obj->reel, 'MT'), 1).'</td>'; + } else { + print $langs->trans("Variable"); + } print '</tr>'; $total += $obj->reel; - if (price2num($object->pmp)) $totalwithpmp += $obj->reel; + if (price2num($object->pmp)) { + $totalwithpmp += $obj->reel; + } $totalvalue = $totalvalue + ($object->pmp * $obj->reel); $totalvaluesell = $totalvaluesell + ($object->price * $obj->reel); // Batch Detail if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { $details = Productbatch::findAll($db, $obj->product_stock_id, 0, $object->id); - if ($details < 0) dol_print_error($db); + if ($details < 0) { + dol_print_error($db); + } foreach ($details as $pdluo) { $product_lot_static->id = $pdluo->lotid; $product_lot_static->batch = $pdluo->batch; @@ -961,7 +996,9 @@ if (!$variants) { } $i++; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } // Total line print '<tr class="liste_total"><td class="right liste_total" colspan="4">'.$langs->trans("Total").':</td>'; @@ -974,13 +1011,19 @@ if (!$variants) { print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : '&nbsp;'; print '</td>'; print '<td class="liste_total right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total ? price($totalvaluesell / $total, 1) : '&nbsp;'); - else print $langs->trans("Variable"); + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print ($total ? price($totalvaluesell / $total, 1) : '&nbsp;'); + } else { + print $langs->trans("Variable"); + } print '</td>'; // Value to sell print '<td class="liste_total right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell, 'MT'), 1); - else print $langs->trans("Variable"); + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($totalvaluesell, 'MT'), 1); + } else { + print $langs->trans("Variable"); + } print '</td>'; print "</tr>"; @@ -1068,11 +1111,9 @@ if (!$variants) { </tr> <?php - if (count($productCombinations)) - { + if (count($productCombinations)) { $stock_total = 0; - foreach ($productCombinations as $currcomb) - { + foreach ($productCombinations as $currcomb) { $prodstatic->fetch($currcomb->fk_product_child); $prodstatic->load_stock(); $stock_total += $prodstatic->stock_reel; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 752b84a9ec0..6aacdca2b6c 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -76,14 +76,14 @@ $search_fk_user_creat = GETPOST('search_fk_user_creat', 'int'); $search_fk_user_modif = GETPOST('search_fk_user_modif', 'int'); $search_import_key = GETPOST('search_import_key', 'int'); -if (empty($action) && empty($id) && empty($ref)) $action = 'list'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'list'; +} // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id || $ref) -{ - if ($ref) - { +if ($id || $ref) { + if ($ref) { $tmp = explode('_', $ref); $productid = $tmp[0]; $batch = $tmp[1]; @@ -93,8 +93,7 @@ if ($id || $ref) } // Protection if external user -if ($user->socid > 0) -{ +if ($user->socid > 0) { //accessforbidden(); } //$result = restrictedArea($user, 'mymodule', $id); @@ -133,18 +132,20 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - if ($action == 'seteatby' && $user->rights->stock->creer) - { + if ($action == 'seteatby' && $user->rights->stock->creer) { $newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } } - if ($action == 'setsellby' && $user->rights->stock->creer) - { + if ($action == 'setsellby' && $user->rights->stock->creer) { $newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) dol_print_error($db, $object->error); + if ($result < 0) { + dol_print_error($db, $object->error); + } } $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record @@ -274,7 +275,7 @@ if (empty($reshook)) { else setEventMessages($object->error, null, 'errors'); } } -*/ + */ // Action to build doc include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -375,7 +376,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } $morehtmlref = ''; @@ -436,7 +439,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } if (empty($reshook)) { /*TODO if ($user->rights->stock->lire) @@ -453,7 +458,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</div>'."\n"; } - } diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index ca522f48da7..81f68487cf6 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -48,7 +48,9 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : ''); $fieldtype = 'rowid'; -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -59,19 +61,23 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $modulepart = 'product_batch'; $object = new Productlot($db); -if ($id || $ref) -{ - if ($ref) - { +if ($id || $ref) { + if ($ref) { $tmp = explode('_', $ref); $productid = $tmp[0]; $batch = $tmp[1]; @@ -79,7 +85,9 @@ if ($id || $ref) $object->fetch($id, $productid, $batch); $object->ref = $object->batch; // For document management ( it use $object->ref) - if (!empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); + if (!empty($conf->productbatch->enabled)) { + $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); + } } @@ -89,10 +97,11 @@ if ($id || $ref) $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Action submit/delete file/link include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -109,8 +118,7 @@ $form = new Form($db); llxHeader('', $langs->trans('ProductLot'), ''); -if ($object->id) -{ +if ($object->id) { $head = productlot_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode'); @@ -118,14 +126,15 @@ if ($object->id) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -133,7 +142,9 @@ if ($object->id) $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; - if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 6e818be629d..45dae12ce10 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -54,7 +54,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -72,28 +74,33 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Initialize array of search criterias $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { $visible = dol_eval($val['visible'], 1); @@ -106,10 +113,8 @@ foreach ($object->fields as $key => $val) } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -134,31 +139,33 @@ $permissiontoadd = $user->rights->stock->mouvement->creer; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -187,13 +194,14 @@ $title = $langs->trans('LotSerialList'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + 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(); @@ -201,20 +209,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +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 (t.rowid = ef.fk_object)"; +} +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -244,26 +264,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -272,8 +290,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); @@ -289,14 +306,24 @@ llxHeader('', $title, $help_url); $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) -{ - 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 (!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 ($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'; @@ -307,12 +334,18 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -332,9 +365,10 @@ $objecttmp = new Productlot($db); $trackid = 'lot'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -345,11 +379,13 @@ $moreforfilter = ''; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -366,20 +402,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } print '</td>'; } } @@ -401,15 +443,18 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -426,11 +471,11 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -439,34 +484,43 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); // Show here line of result print '<tr class="oddeven">'; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref' || $key == 'batch') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref' || $key == 'batch') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; - if ($key == 'status') print $object->getLibStatut(5); - elseif ($key == 'rowid') print $object->id; - else { + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->id; + } else { if ($key == 'batch') { print $object->getNomUrl(1); } else { @@ -474,10 +528,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) } } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -490,14 +547,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -508,10 +568,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -527,10 +590,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 64dd485671d..904fa9b7e94 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -68,7 +68,9 @@ $texte = ''; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; @@ -86,8 +88,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) -{ + || !empty($conf->mrp->enabled)) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -96,20 +97,25 @@ if ($virtualdiffersfromphysical) { } else { $usevirtualstock = 0; } -if ($mode == 'physical') $usevirtualstock = 0; -if ($mode == 'virtual') $usevirtualstock = 1; +if ($mode == 'physical') { + $usevirtualstock = 0; +} +if ($mode == 'virtual') { + $usevirtualstock = 1; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} /* * Actions */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('valid')) // Both test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('valid')) { // Both test are required to be compatible with all browsers $search_ref = ''; $search_label = ''; $sall = ''; @@ -117,26 +123,24 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $includeproductswithoutdesiredqty = ''; $draftorder = ''; } -if ($draftorder == 'on') $draftchecked = "checked"; +if ($draftorder == 'on') { + $draftchecked = "checked"; +} // Create orders -if ($action == 'order' && GETPOST('valid')) -{ +if ($action == 'order' && GETPOST('valid')) { $linecount = GETPOST('linecount', 'int'); $box = 0; $errorQty = 0; unset($_POST['linecount']); - if ($linecount > 0) - { + if ($linecount > 0) { $db->begin(); $suppliers = array(); require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productsupplier = new ProductFournisseur($db); - for ($i = 0; $i < $linecount; $i++) - { - if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) - { + for ($i = 0; $i < $linecount; $i++) { + if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) { //one line $box = $i; $supplierpriceid = GETPOST('fourn'.$i, 'int'); @@ -144,10 +148,8 @@ if ($action == 'order' && GETPOST('valid')) $qty = GETPOST('tobuy'.$i, 'int'); $idprod = $productsupplier->get_buyprice($supplierpriceid, $qty); $res = $productsupplier->fetch($idprod); - if ($res && $idprod > 0) - { - if ($qty) - { + if ($res && $idprod > 0) { + if ($qty) { //might need some value checks $line = new CommandeFournisseurLigne($db); $line->qty = $qty; @@ -155,8 +157,7 @@ if ($action == 'order' && GETPOST('valid')) //$product = new Product($db); //$product->fetch($obj->fk_product); - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { $productsupplier->getMultiLangs(); } @@ -167,8 +168,7 @@ if ($action == 'order' && GETPOST('valid')) $desc = $productsupplier->description; } $line->desc = $desc; - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // TODO Get desc in language of thirdparty } @@ -184,8 +184,7 @@ if ($action == 'order' && GETPOST('valid')) $line->fk_unit = $productsupplier->fk_unit; $suppliers[$productsupplier->fourn_socid]['lines'][] = $line; } - } elseif ($idprod == -1) - { + } elseif ($idprod == -1) { $errorQty++; } else { $error = $db->lasterror(); @@ -202,8 +201,7 @@ if ($action == 'order' && GETPOST('valid')) $fail = 0; $orders = array(); $suppliersid = array_keys($suppliers); - foreach ($suppliers as $supplier) - { + foreach ($suppliers as $supplier) { $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; @@ -267,10 +265,11 @@ if ($action == 'order' && GETPOST('valid')) } } - if ($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); + if ($errorQty) { + setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); + } - if (!$fail && $id) - { + if (!$fail && $id) { $db->commit(); setEventMessages($langs->trans('OrderCreated'), null, 'mesgs'); @@ -280,8 +279,7 @@ if ($action == 'order' && GETPOST('valid')) $db->rollback(); } } - if ($box == 0) - { + if ($box == 0) { setEventMessages($langs->trans('SelectProductWithNotNullQty'), null, 'warnings'); } } @@ -340,7 +338,9 @@ $reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Not $sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; -if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +if ($sall) { + $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +} // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { if ($type == 1) { @@ -349,8 +349,12 @@ if (dol_strlen($type)) { $sql .= ' AND p.fk_product_type <> 1'; } } -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); -if ($search_label) $sql .= natural_search('p.label', $search_label); +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} +if ($search_label) { + $sql .= natural_search('p.label', $search_label); +} $sql .= ' AND p.tobuy = 1'; if (empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { // Add test to exclude products that has variants $sql .= ' AND p.rowid NOT IN (SELECT pac.fk_product_parent FROM '.MAIN_DB_PREFIX.'product_attribute_combination as pac WHERE pac.entity IN ('.getEntity('product').'))'; @@ -366,8 +370,7 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre } $sql .= ', s.fk_product'; -if ($usevirtualstock) -{ +if ($usevirtualstock) { if (!empty($conf->commande->enabled)) { $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd1, ".MAIN_DB_PREFIX."commande as c1"; @@ -446,8 +449,7 @@ if ($usevirtualstock) $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; $sql .= ')'; - if ($salert == 'on') // Option to see when stock is lower than alert - { + if ($salert == 'on') { // Option to see when stock is lower than alert $sql .= ' AND ('; if ($includeproductswithoutdesiredqty == 'on') { $sql .= '('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; @@ -469,8 +471,7 @@ if ($usevirtualstock) } $sql .= ')'; - if ($salert == 'on') // Option to see when stock is lower than alert - { + if ($salert == 'on') { // Option to see when stock is lower than alert $sql .= ' AND ('; if ($includeproductswithoutdesiredqty == 'on') { $sql .= ' ('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))'; @@ -507,8 +508,7 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if (empty($resql)) -{ +if (empty($resql)) { dol_print_error($db); exit; } @@ -541,15 +541,13 @@ if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_ print '<span class="opacitymedium">'.$langs->trans("ReplenishmentStatusDescPerWarehouse").'</span>'."\n"; } print '<br><br>'; -if ($usevirtualstock == 1) -{ +if ($usevirtualstock == 1) { print $langs->trans("CurentSelectionMode").': '; print '<span class="a-mesure">'.$langs->trans("UseVirtualStock").'</span>'; print ' <a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?mode=physical'.($fk_supplier > 0 ? '&fk_supplier='.$fk_supplier : '').($fk_entrepot > 0 ? '&fk_entrepot='.$fk_entrepot : '').'">'.$langs->trans("UsePhysicalStock").'</a>'; print '<br>'; } -if ($usevirtualstock == 0) -{ +if ($usevirtualstock == 0) { print $langs->trans("CurentSelectionMode").': '; print '<a class="a-mesure-disabled" href="'.$_SERVER["PHP_SELF"].'?mode=virtual'.($fk_supplier > 0 ? '&fk_supplier='.$fk_supplier : '').($fk_entrepot > 0 ? '&fk_entrepot='.$fk_entrepot : '').'">'.$langs->trans("UseVirtualStock").'</a>'; print ' <span class="a-mesure">'.$langs->trans("UsePhysicalStock").'</span>'; @@ -569,8 +567,7 @@ print '<input type="hidden" name="mode" value="'.$mode.'">'; if ($limit > 0 && $limit != $conf->liste_limit) { print '<input type="hidden" name="limit" value="'.$limit.'">'; } -if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) -{ +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print '<div class="inline-block valignmiddle" style="padding-right: 20px;">'; print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); print '</div>'; @@ -581,7 +578,9 @@ print '</div>'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) print $hookmanager->resPrint; +if (empty($reshook)) { + print $hookmanager->resPrint; +} print '<div class="inline-block valignmiddle">'; print '<input class="button" type="submit" name="valid" value="'.$langs->trans('ToFilter').'">'; @@ -607,8 +606,12 @@ if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST(' $filters .= '&salert='.urlencode($salert); $filters .= '&draftorder='.urlencode($draftorder); $filters .= '&mode='.urlencode($mode); - if ($fk_supplier > 0) $filters .= '&fk_supplier='.urlencode($fk_supplier); - if ($fk_entrepot > 0) $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + if ($fk_supplier > 0) { + $filters .= '&fk_supplier='.urlencode($fk_supplier); + } + if ($fk_entrepot > 0) { + $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + } } else { $filters = '&search_ref='.urlencode($search_ref).'&search_label='.urlencode($search_label); $filters .= '&fourn_id='.urlencode($fourn_id); @@ -616,8 +619,12 @@ if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST(' $filters .= '&='.urlencode($salert); $filters .= '&draftorder='.urlencode($draftorder); $filters .= '&mode='.urlencode($mode); - if ($fk_supplier > 0) $filters .= '&fk_supplier='.urlencode($fk_supplier); - if ($fk_entrepot > 0) $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + if ($fk_supplier > 0) { + $filters .= '&fk_supplier='.urlencode($fk_supplier); + } + if ($fk_entrepot > 0) { + $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + } } if ($limit > 0 && $limit != $conf->liste_limit) { $filters .= '&limit='.urlencode($limit); @@ -632,10 +639,13 @@ $param .= '&fk_entrepot='.urlencode($fk_entrepot); $stocklabel = $langs->trans('Stock'); $stocklabelbis = $langs->trans('Stock'); -if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); -if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); -if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) -{ +if ($usevirtualstock == 1) { + $stocklabel = $langs->trans('VirtualStock'); +} +if ($usevirtualstock == 0) { + $stocklabel = $langs->trans('PhysicalStock'); +} +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $stocklabelbis = $stocklabel.' (Selected warehouse)'; $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; } @@ -684,12 +694,13 @@ print '<tr class="liste_titre_filter">'; print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre"><input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input class="flat" type="text" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'"></td>'; -if (!empty($conf->service->enabled) && $type == 1) print '<td class="liste_titre">&nbsp;</td>'; +if (!empty($conf->service->enabled) && $type == 1) { + print '<td class="liste_titre">&nbsp;</td>'; +} print '<td class="liste_titre right">'.$form->textwithpicto($langs->trans('IncludeEmptyDesiredStock'), $langs->trans('IncludeProductWithUndefinedAlerts')).'&nbsp;<input type="checkbox" id="includeproductswithoutdesiredqty" name="includeproductswithoutdesiredqty" '.(!empty($includeproductswithoutdesiredqtychecked) ? $includeproductswithoutdesiredqtychecked : '').'></td>'; print '<td class="liste_titre right"></td>'; print '<td class="liste_titre right">'.$langs->trans('AlertOnly').'&nbsp;<input type="checkbox" id="salert" name="salert" '.(!empty($alertchecked) ? $alertchecked : '').'></td>'; -if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) -{ +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { print '<td class="liste_titre">&nbsp;</td>'; } print '<td class="liste_titre right">'; @@ -714,12 +725,13 @@ print '<tr class="liste_titre">'; print_liste_field_titre('<input type="checkbox" onClick="toggle(this)" />', $_SERVER["PHP_SELF"], ''); 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->service->enabled) && $type == 1) print_liste_field_titre('Duration', $_SERVER["PHP_SELF"], 'p.duration', $param, '', '', $sortfield, $sortorder, 'center '); +if (!empty($conf->service->enabled) && $type == 1) { + print_liste_field_titre('Duration', $_SERVER["PHP_SELF"], 'p.duration', $param, '', '', $sortfield, $sortorder, 'center '); +} print_liste_field_titre('DesiredStock', $_SERVER["PHP_SELF"], 'p.desiredstock', $param, '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre('StockLimitShort', $_SERVER["PHP_SELF"], 'p.seuil_stock_alerte', $param, '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $param, '', '', $sortfield, $sortorder, 'right '); -if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) -{ +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { print_liste_field_titre($stocklabelbis, $_SERVER["PHP_SELF"], 'stock_real_warehouse', $param, '', '', $sortfield, $sortorder, 'right '); } print_liste_field_titre('Ordered', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right '); @@ -733,18 +745,15 @@ print $hookmanager->resPrint; print "</tr>\n"; -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $objp = $db->fetch_object($resql); - if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) - { + if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) { $prod->fetch($objp->rowid); $prod->load_stock('warehouseopen, warehouseinternal', $draftchecked); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) - { + if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; $sql .= ' WHERE fk_product = '.$objp->rowid; @@ -752,17 +761,19 @@ while ($i < ($limit ? min($num, $limit) : $num)) $sql .= ' LIMIT 1'; $resqlm = $db->query($sql); - if ($resqlm) - { + if ($resqlm) { $objtp = $db->fetch_object($resqlm); - if (!empty($objtp->description)) $objp->description = $objtp->description; - if (!empty($objtp->label)) $objp->label = $objtp->label; + if (!empty($objtp->description)) { + $objp->description = $objtp->description; + } + if (!empty($objtp->label)) { + $objp->label = $objtp->label; + } } } $stockwarehouse = 0; - if ($usevirtualstock) - { + if ($usevirtualstock) { // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. $stock = $prod->stock_theorique; //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; @@ -790,27 +801,30 @@ while ($i < ($limit ? min($num, $limit) : $num)) $alertstockwarehouse = ($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : 0); $warning = ''; - if ($alertstock && ($stock < $alertstock)) - { + if ($alertstock && ($stock < $alertstock)) { $warning = img_warning($langs->trans('StockTooLow')).' '; } $warningwarehouse = ''; - if ($alertstockwarehouse && ($stockwarehouse < $alertstockwarehouse)) - { + if ($alertstockwarehouse && ($stockwarehouse < $alertstockwarehouse)) { $warningwarehouse = img_warning($langs->trans('StockTooLow')).' '; } //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value - if (empty($usevirtualstock)) $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); - else $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0); //ordered is already in $stock in virtual mode - if (empty($usevirtualstock)) $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse - $ordered, 0); - else $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse, 0); //ordered is already in $stock in virtual mode + if (empty($usevirtualstock)) { + $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); + } else { + $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0); //ordered is already in $stock in virtual mode + } + if (empty($usevirtualstock)) { + $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse - $ordered, 0); + } else { + $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse, 0); //ordered is already in $stock in virtual mode + } $picto = ''; - if ($ordered > 0) - { + if ($ordered > 0) { $stockforcompare = ($usevirtualstock ? $stock : $stock + $ordered); /*if ($stockforcompare >= $desiredstock) { @@ -833,8 +847,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) print '<input type="hidden" name="desc'.$i.'" value="'.dol_escape_htmltag($objp->description).'">'; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST print '</td>'; - if (!empty($conf->service->enabled) && $type == 1) - { + if (!empty($conf->service->enabled) && $type == 1) { $regs = array(); if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { $duration = $regs[1].' '.$langs->trans('DurationYear'); @@ -858,8 +871,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) print '<td class="right">'.$warning.$stock.'</td>'; // Current stock (warehouse selected only) - if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) - { + if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { print '<td class="right">'.$warningwarehouse.$stockwarehouse.'</td>'; } diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c73c7b1ca39..f5978313a1e 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -38,7 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('products', 'stocks', 'orders')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service'); $sall = GETPOST('search_all', 'alphanohtml'); @@ -56,10 +58,16 @@ $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_d $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortorder) $sortorder = 'DESC'; -if (!$sortfield) $sortfield = 'cf.date_creation'; +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'cf.date_creation'; +} $page = GETPOST('page', 'int') ? GETPOST('page', 'int') : 0; -if ($page < 0) $page = 0; +if ($page < 0) { + $page = 0; +} $offset = $limit * $page; @@ -67,8 +75,7 @@ $offset = $limit * $page; * Actions */ -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 -{ +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 $sall = ""; $sref = ""; $snom = ""; @@ -130,13 +137,25 @@ if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { if (!$user->rights->societe->client->voir && !$socid) { $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; } -if ($sref) $sql .= natural_search('cf.ref', $sref); -if ($snom) $sql .= natural_search('s.nom', $snom); -if ($suser) $sql .= natural_search('u.login', $suser); -if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); +if ($sref) { + $sql .= natural_search('cf.ref', $sref); +} +if ($snom) { + $sql .= natural_search('s.nom', $snom); +} +if ($suser) { + $sql .= natural_search('u.login', $suser); +} +if ($sttc) { + $sql .= natural_search('cf.total_ttc', $sttc, 1); +} $sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); -if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); -if (!empty($socid)) $sql .= ' AND s.rowid = '.$socid; +if ($sall) { + $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); +} +if (!empty($socid)) { + $sql .= ' AND s.rowid = '.$socid; +} if (GETPOST('statut', 'int')) { $sql .= ' AND fk_statut = '.GETPOST('statut', 'int'); } @@ -148,8 +167,7 @@ if (!$search_product) { } $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -160,16 +178,36 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sref) $param .= '&search_ref='.urlencode($sref); - if ($snom) $param .= '&search_nom='.urlencode($snom); - if ($suser) $param .= '&search_user='.urlencode($suser); - if ($sttc) $param .= '&search_ttc='.urlencode($sttc); - if ($search_dateyear) $param .= '&search_dateyear='.urlencode($search_dateyear); - if ($search_datemonth) $param .= '&search_datemonth='.urlencode($search_datemonth); - if ($search_dateday) $param .= '&search_dateday='.urlencode($search_dateday); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sref) { + $param .= '&search_ref='.urlencode($sref); + } + if ($snom) { + $param .= '&search_nom='.urlencode($snom); + } + if ($suser) { + $param .= '&search_user='.urlencode($suser); + } + if ($sttc) { + $param .= '&search_ttc='.urlencode($sttc); + } + if ($search_dateyear) { + $param .= '&search_dateyear='.urlencode($search_dateyear); + } + if ($search_datemonth) { + $param .= '&search_datemonth='.urlencode($search_datemonth); + } + if ($search_dateday) { + $param .= '&search_dateday='.urlencode($search_dateday); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } print '<table class="noborder centpercent">'; @@ -261,14 +299,12 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $search_product ? $num : $conf->liste_limit)) - { + while ($i < min($num, $search_product ? $num : $conf->liste_limit)) { $obj = $db->fetch_object($resql); $showline = dolDispatchToDo($obj->rowid) && (!$search_product || in_array($search_product, getProducts($obj->rowid))); - if ($showline) - { + if ($showline) { $href = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$obj->rowid; print '<tr>'; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 0b80ab3a36b..cbdaa62014b 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -71,7 +71,9 @@ $fk_warehouse = GETPOST('fk_warehouse', 'int'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; if (!$sortfield) { @@ -83,7 +85,9 @@ if (!$sortorder) { $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} $dateIsValid = true; if ($mode == 'future') { @@ -103,8 +107,7 @@ if ($mode == 'future') { * Actions */ -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 -{ +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 $date = ''; $productid = 0; $fk_warehouse = 0; @@ -142,8 +145,7 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -197,8 +199,7 @@ if ($date && $dateIsValid) { $sql .= " GROUP BY sm.fk_product, sm.fk_entrepot"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -270,7 +271,9 @@ if ($productid > 0) { if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= " AND p.fk_product_type = 0"; } -if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; +if (!empty($canvas)) { + $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; +} if ($fk_warehouse > 0) { $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; $sql .= ' p.tms, p.duration, p.tobuy, p.stock'; @@ -293,12 +296,10 @@ $sql .= $db->order($sortfield, $sortorder); if ($date && $dateIsValid) { // We avoid a heavy sql if mandatory parameter date not yet defined $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -308,8 +309,7 @@ if ($date && $dateIsValid) { // We avoid a heavy sql if mandatory parameter date //print $sql; $resql = $db->query($sql); - if (empty($resql)) - { + if (empty($resql)) { dol_print_error($db); exit; } @@ -341,7 +341,9 @@ print load_fiche_titre($langs->trans('StockAtDate'), '', 'stock'); print dol_get_fiche_head($head, ($mode == 'future' ? 'stockatdatefuture' : 'stockatdatepast'), '', -1, ''); $desc = $langs->trans("StockAtDatePastDesc"); -if ($mode == 'future') $desc = $langs->trans("StockAtDateFutureDesc"); +if ($mode == 'future') { + $desc = $langs->trans("StockAtDateFutureDesc"); +} print '<span class="opacitymedium">'.$desc.'</span><br>'."\n"; print '<br>'."\n"; @@ -366,7 +368,9 @@ print '</div>'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) print $hookmanager->resPrint; +if (empty($reshook)) { + print $hookmanager->resPrint; +} print '<div class="inline-block valignmiddle">'; print '<input class="button" type="submit" name="valid" value="'.$langs->trans('Refresh').'">'; @@ -375,14 +379,28 @@ print '</div>'; //print '</form>'; $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} $param .= '&mode='.$mode; -if ($fk_warehouse > 0) $param .= '&fk_warehouse='.$fk_warehouse; -if ($productid > 0) $param .= '&productid='.$productid; -if (GETPOST('dateday', 'int') > 0) $param .= '&dateday='.GETPOST('dateday', 'int'); -if (GETPOST('datemonth', 'int') > 0) $param .= '&datemonth='.GETPOST('datemonth', 'int'); -if (GETPOST('dateyear', 'int') > 0) $param .= '&dateyear='.GETPOST('dateyear', 'int'); +if ($fk_warehouse > 0) { + $param .= '&fk_warehouse='.$fk_warehouse; +} +if ($productid > 0) { + $param .= '&productid='.$productid; +} +if (GETPOST('dateday', 'int') > 0) { + $param .= '&dateday='.GETPOST('dateday', 'int'); +} +if (GETPOST('datemonth', 'int') > 0) { + $param .= '&datemonth='.GETPOST('datemonth', 'int'); +} +if (GETPOST('dateyear', 'int') > 0) { + $param .= '&dateyear='.GETPOST('dateyear', 'int'); +} // TODO Move this into the title line ? print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); @@ -391,7 +409,9 @@ print '<div class="div-table-responsive">'; // You can use div-table-responsive- print '<table class="liste centpercent">'; $stocklabel = $langs->trans('StockAtDate'); -if ($mode == 'future') $stocklabel = $langs->trans("VirtualStockAtDate"); +if ($mode == 'future') { + $stocklabel = $langs->trans("VirtualStockAtDate"); +} //print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -456,12 +476,10 @@ print $hookmanager->resPrint; print "</tr>\n"; $i = 0; -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $objp = $db->fetch_object($resql); - if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) - { + if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) { $prod->fetch($objp->rowid); // Multilangs @@ -483,8 +501,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) }*/ $currentstock = ''; - if ($fk_warehouse > 0) - { + if ($fk_warehouse > 0) { //if ($productid > 0) { $currentstock = $stock_prod_warehouse[$objp->rowid][$fk_warehouse]; //} else { @@ -545,14 +562,18 @@ while ($i < ($limit ? min($num, $limit) : $num)) // PMP value print '<td class="right">'; - if (price2num($objp->estimatedvalue, 'MT')) print price(price2num($objp->estimatedvalue, 'MT'), 1); - else print ''; + if (price2num($objp->estimatedvalue, 'MT')) { + print price(price2num($objp->estimatedvalue, 'MT'), 1); + } else { + print ''; + } print '</td>'; // Selling value print '<td class="right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue, 'MT'), 1); - else { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($objp->sellvalue, 'MT'), 1); + } else { $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } @@ -588,7 +609,9 @@ print $hookmanager->resPrint; if (empty($date) || ! $dateIsValid) { $colspan = 8; - if ($mode == 'future') $colspan++; + if ($mode == 'future') { + $colspan++; + } print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("EnterADateCriteria").'</span></td></tr>'; } diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 4f88b448239..6e2ab53dd0e 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -30,12 +30,16 @@ if (empty($conf) || !is_object($conf)) { <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP --> <?php $productref = ''; -if ($object->element == 'product') $productref = $object->ref; +if ($object->element == 'product') { + $productref = $object->ref; +} $langs->load("productbatch"); -if (empty($id)) $id = $object->id; +if (empty($id)) { + $id = $object->id; +} print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { @@ -69,7 +73,9 @@ if ($object->element == 'product') { print '<td class="fieldrequired">'.$langs->trans("Warehouse").'</td>'; print '<td>'; $ident = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ? GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))); - if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { + $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE; + } print img_picto('', 'stock').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print ' &nbsp; <select class="button buttongen" name="mouvement" id="mouvement">'; print '<option value="0">'.$langs->trans("Add").'</option>'; @@ -107,8 +113,7 @@ if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $object->element == 'product' if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) -) -{ +) { print '<tr>'; print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">'; print '<input type="text" name="batch_number" size="40" value="'.GETPOST("batch_number").'">'; @@ -134,8 +139,7 @@ if (!empty($conf->productbatch->enabled) && print '<tr>'; print '<td>'.$langs->trans("UnitPurchaseValue").'</td>'; print '<td colspan="'.(!empty($conf->projet->enabled) ? '1' : '3').'"><input name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>'; -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { print '<td>'.$langs->trans('Project').'</td>'; print '<td>'; print img_picto('', 'project'); diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 20445445e8e..e98244e5eed 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -30,21 +30,23 @@ if (empty($conf) || !is_object($conf)) { <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP --> <?php $productref = ''; -if ($object->element == 'product') $productref = $object->ref; +if ($object->element == 'product') { + $productref = $object->ref; +} $langs->load("productbatch"); -if (empty($id)) $id = $object->id; +if (empty($id)) { + $id = $object->id; +} $pdluoid = GETPOST('pdluoid', 'int'); $pdluo = new Productbatch($db); -if ($pdluoid > 0) -{ +if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); - if ($result > 0) - { + if ($result > 0) { $pdluoid = $pdluo->id; } else { dol_print_error($db, $pdluo->error, $pdluo->errors); @@ -60,8 +62,7 @@ print dol_get_fiche_head(); print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="transfert_stock">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; -if ($pdluoid) -{ +if ($pdluoid) { print '<input type="hidden" name="pdluoid" value="'.$pdluoid.'">'; } print '<table class="border centpercent">'; @@ -92,12 +93,10 @@ print '</tr>'; if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) -) -{ +) { print '<tr>'; print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">'; - if ($pdluoid > 0) - { + if ($pdluoid > 0) { // If form was opened for a specific pdluoid, field is disabled print '<input type="text" name="batch_number_bis" size="40" disabled="disabled" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">'; print '<input type="hidden" name="batch_number" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">'; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 35e82abdafc..7f7f9610d1f 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -38,10 +38,16 @@ $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortfield) $sortfield = "e.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "e.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $page = $_GET["page"]; -if ($page < 0) $page = 0; +if ($page < 0) { + $page = 0; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; @@ -58,9 +64,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('stock').")"; -if ($sref) $sql .= natural_search("e.ref", $sref); -if ($sall) -{ +if ($sref) { + $sql .= natural_search("e.ref", $sref); +} +if ($sall) { $sql .= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; $sql .= " OR e.description LIKE '%".$db->escape($sall)."%'"; $sql .= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; @@ -72,8 +79,7 @@ $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; @@ -92,26 +98,30 @@ if ($result) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', '', '', $sortfield, $sortorder, 'right '); print "</tr>\n"; - if ($num) - { + if ($num) { $entrepot = new Entrepot($db); $total = $totalsell = 0; $var = false; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); print '<tr class="oddeven">'; print '<td><a href="card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowWarehouse"), 'stock').' '.$objp->ref.'</a></td>'; print '<td>'.$objp->lieu.'</td>'; // PMP value print '<td class="right">'; - if (price2num($objp->estimatedvalue, 'MT')) print price(price2num($objp->estimatedvalue, 'MT'), 1); - else print ''; + if (price2num($objp->estimatedvalue, 'MT')) { + print price(price2num($objp->estimatedvalue, 'MT'), 1); + } else { + print ''; + } print '</td>'; // Selling value print '<td class="right">'; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue, 'MT'), 1); - else print $langs->trans("Variable"); + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($objp->sellvalue, 'MT'), 1); + } else { + print $langs->trans("Variable"); + } print '</td>'; // Status print '<td class="right">'.$entrepot->LibStatut($objp->statut, 5).'</td>'; @@ -137,15 +147,13 @@ if ($result) print '<br>'; $file = 'entrepot-'.$year.'.png'; - if (file_exists($conf->stock->dir_temp.'/'.$file)) - { + if (file_exists($conf->stock->dir_temp.'/'.$file)) { $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file; print '<img src="'.$url.'">'; } $file = 'entrepot-'.($year - 1).'.png'; - if (file_exists($conf->stock->dir_temp.'/'.$file)) - { + if (file_exists($conf->stock->dir_temp.'/'.$file)) { $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file; print '<br><img src="'.$url.'">'; } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 97eb37a2689..d1d2289fb24 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -42,7 +42,9 @@ $cancel = GETPOST('cancel', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -51,13 +53,11 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product */ // retour a l'affichage des traduction si annulation -if ($cancel == $langs->trans("Cancel")) -{ +if ($cancel == $langs->trans("Cancel")) { $action = ''; } -if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) -{ +if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) { $object = new Product($db); $object->fetch($id); $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user); @@ -66,8 +66,7 @@ if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) // Add translation if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) -{ +($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -96,16 +95,13 @@ $cancel != $langs->trans("Cancel") && // Edit translation if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) -{ +($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); - foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet - { - if ($key == $current_lang) - { + foreach ($object->multilangs as $key => $value) { // enregistrement des nouvelles valeurs dans l'objet + if ($key == $current_lang) { $object->label = $_POST["libelle-".$key]; $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); @@ -116,8 +112,7 @@ $cancel != $langs->trans("Cancel") && } } - if ($object->setMultiLangs($user) > 0) - { + if ($object->setMultiLangs($user) > 0) { $action = ''; } else { $action = 'edit'; @@ -128,15 +123,13 @@ $cancel != $langs->trans("Cancel") && // Delete translation if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) -{ +($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); - if ($object->delMultiLangs($langtodelete, $user) > 0) - { + if ($object->delMultiLangs($langtodelete, $user) > 0) { $action = ''; } else { $action = 'edit'; @@ -155,13 +148,11 @@ $result = $object->fetch($id, $ref); $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) -{ +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Translation'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) -{ +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Translation'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -178,10 +169,8 @@ $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); // Calculate $cnt_trans $cnt_trans = 0; -if (!empty($object->multilangs)) -{ - foreach ($object->multilangs as $key => $value) - { +if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { $cnt_trans++; } } @@ -192,7 +181,9 @@ print dol_get_fiche_head($head, 'translation', $titre, 0, $picto); $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $shownav = 1; -if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; +} dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); @@ -208,12 +199,12 @@ print dol_get_fiche_end(); print "\n<div class=\"tabsAction\">\n"; -if ($action == '') -{ - if ($user->rights->produit->creer || $user->rights->service->creer) - { +if ($action == '') { + if ($user->rights->produit->creer || $user->rights->service->creer) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$object->id.'">'.$langs->trans("Add").'</a>'; - if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=edit&id='.$object->id.'">'.$langs->trans("Update").'</a>'; + if ($cnt_trans > 0) { + print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=edit&id='.$object->id.'">'.$langs->trans("Update").'</a>'; + } } } @@ -221,8 +212,7 @@ print "\n</div>\n"; -if ($action == 'edit') -{ +if ($action == 'edit') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -231,10 +221,8 @@ if ($action == 'edit') print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; - if (!empty($object->multilangs)) - { - foreach ($object->multilangs as $key => $value) - { + if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { $s = picto_from_langcode($key); print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>"; @@ -245,8 +233,7 @@ if ($action == 'edit') $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print '</td></tr>'; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) - { + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print '<tr><td class="tdtop">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'; $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); @@ -265,12 +252,9 @@ if ($action == 'edit') print '</div>'; print '</form>'; -} elseif ($action != 'add') -{ - if (!empty($object->multilangs)) - { - foreach ($object->multilangs as $key => $value) - { +} elseif ($action != 'add') { + if (!empty($object->multilangs)) { + foreach ($object->multilangs as $key => $value) { $s = picto_from_langcode($key); print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>'; @@ -279,15 +263,16 @@ if ($action == 'edit') print '<table class="border centpercent">'; print '<tr><td class="titlefieldcreate">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>'; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) - { + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>'; } print '</table>'; print '</div>'; } } - if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>'; + if (!$cnt_trans && $action != 'add') { + print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>'; + } } @@ -296,8 +281,7 @@ if ($action == 'edit') * Form to add a new translation */ -if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) -{ +if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -319,8 +303,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service $doleditor->Create(); print '</td></tr>'; // Other field (not used) - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) - { + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print '<tr><td class="tdtop">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").'</td><td>'; $doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); From 93f0754be934c2e3e5374f6c2734fada4b01b01e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 14:33:27 +0100 Subject: [PATCH 140/173] Fix removed a bugged section (not used, was in develop mode only) --- htdocs/compta/tva/index.php | 43 +------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 76eed6b1bf8..c831d5fe61c 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -559,7 +559,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; /* - * Paid + * VAT Paid */ print load_fiche_titre($langs->trans("VATPaid"), '', ''); @@ -586,47 +586,6 @@ $sql .= " ORDER BY dm ASC, mode ASC"; pt($db, $sql, $langs->trans("Month")); - -if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - print '<br>'; - - /* - * Recap - */ - - print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - - $sql1 = "SELECT SUM(amount) as mm"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; - $sql1 .= " WHERE f.entity = ".$conf->entity; - $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; - $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; - - $result = $db->query($sql1); - if ($result) { - $obj = $db->fetch_object($result); - print '<table class="noborder centpercent">'; - - print "<tr>"; - print '<td class="right">'.$langs->trans("VATDue").'</td>'; - print '<td class="nowrap right">'.price(price2num($total, 'MT')).'</td>'; - print "</tr>\n"; - - print "<tr>"; - print '<td class="right">'.$langs->trans("VATPaid").'</td>'; - print '<td class="nowrap right">'.price(price2num($obj->mm, 'MT'))."</td>\n"; - print "</tr>\n"; - - $restopay = $total - $obj->mm; - print "<tr>"; - print '<td class="right">'.$langs->trans("RemainToPay").'</td>'; - print '<td class="nowrap right">'.price(price2num($restopay, 'MT')).'</td>'; - print "</tr>\n"; - - print '</table>'; - } -} - print '</div></div>'; llxFooter(); From 5d0a0fe3410eb64e57fe47dc4715347ff287ece2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 14:53:16 +0100 Subject: [PATCH 141/173] Clean code --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 3 ++- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 3 ++- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 3 ++- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 3 ++- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 3 ++- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index ffd18c77cc6..f8f196a9fa3 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1433,7 +1433,8 @@ class pdf_einstein extends ModelePDFCommandes $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 32a5fa18c6f..b64a0066390 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1618,7 +1618,8 @@ class pdf_eratosthene extends ModelePDFCommandes $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 2747ee4e246..d5842b4481f 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1850,7 +1850,8 @@ class pdf_crabe extends ModelePDFFactures $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 49bc90f1d69..a1da1666629 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2116,7 +2116,8 @@ class pdf_sponge extends ModelePDFFactures $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 227b192a85d..1f36c874c2b 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1602,7 +1602,8 @@ class pdf_azur extends ModelePDFPropales $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = 100; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 368b5520421..027b3da46ba 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1718,7 +1718,8 @@ class pdf_cyan extends ModelePDFPropales $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact,$mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; From c4e98486f7485408291c3ec095af3f1582692ea9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 15:15:55 +0100 Subject: [PATCH 142/173] Trans --- htdocs/langs/en_US/productbatch.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index a05a6190fc4..aa13c745c96 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,7 +1,7 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Use lot/serial number ProductStatusOnBatch=Lot (required) -ProductStatusOnSerial=Serial number (must be unique for each equipment) +ProductStatusOnSerial=Unique Serial Number (required) ProductStatusNotOnBatch=No (lot/serial not used) ProductStatusOnBatchShort=Lot ProductStatusOnSerialShort=Serial From c5ff699b3f3100a34304da896e93bc695c14970f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 15:26:09 +0100 Subject: [PATCH 143/173] code syntax printing directory --- htdocs/printing/admin/printing.php | 74 ++++++++++++++-------------- htdocs/printing/lib/printing.lib.php | 8 +-- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index a67ad379ca9..5c79be62197 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -33,7 +33,9 @@ use OAuth\Common\Storage\DoliStorage; // Load translation files required by the page $langs->loadLangs(array('admin', 'printing', 'oauth')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $mode = GETPOST('mode', 'alpha'); @@ -41,9 +43,13 @@ $value = GETPOST('value', 'alpha', 0, null, null, 1); // The value may be __goog $varname = GETPOST('varname', 'alpha'); $driver = GETPOST('driver', 'alpha'); -if (!empty($driver)) $langs->load($driver); +if (!empty($driver)) { + $langs->load($driver); +} -if (!$mode) $mode = 'config'; +if (!$mode) { + $mode = 'config'; +} $OAUTH_SERVICENAME_GOOGLE = 'Google'; @@ -52,21 +58,21 @@ $OAUTH_SERVICENAME_GOOGLE = 'Google'; * Action */ -if (($mode == 'test' || $mode == 'setup') && empty($driver)) -{ +if (($mode == 'test' || $mode == 'setup') && empty($driver)) { setEventMessages($langs->trans('PleaseSelectaDriverfromList'), null); header("Location: ".$_SERVER['PHP_SELF'].'?mode=config'); exit; } -if ($action == 'setconst' && $user->admin) -{ +if ($action == 'setconst' && $user->admin) { $error = 0; $db->begin(); foreach ($_POST['setupdriver'] as $setupconst) { //print '<pre>'.print_r($setupconst, true).'</pre>'; $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } } if (!$error) { @@ -79,12 +85,13 @@ if ($action == 'setconst' && $user->admin) $action = ''; } -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $db->begin(); $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } if (!$error) { $db->commit(); @@ -110,8 +117,7 @@ print load_fiche_titre($langs->trans("PrintingSetup"), $linkback, 'title_setup') $head = printingAdminPrepareHead($mode); -if ($mode == 'setup' && $user->admin) -{ +if ($mode == 'setup' && $user->admin) { print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="setconst">'; @@ -143,8 +149,7 @@ if ($mode == 'setup' && $user->admin) $i = 0; $submit_enabled = 0; - foreach ($printer->conf as $key) - { + foreach ($printer->conf as $key) { switch ($key['type']) { case "text": case "password": @@ -159,8 +164,7 @@ if ($mode == 'setup' && $user->admin) case "info": // Google Api setup or Google OAuth Token print '<tr class="oddeven">'; print '<td'.($key['required'] ? ' class=required' : '').'>'; - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') - { + if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') { print $langs->trans("IsTokenGenerated"); } else { print $langs->trans($key['varname']); @@ -169,10 +173,11 @@ if ($mode == 'setup' && $user->admin) print '<td>'.$langs->trans($key['info']).'</td>'; print '<td>'; //var_dump($key); - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') - { + if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') { // Delete remote tokens - if (!empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; + if (!empty($key['delete'])) { + print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; + } // Request remote token print '<a class="button" href="'.$key['renew'].'">'.$langs->trans('RequestAccess').'</a><br><br>'; // Check remote access @@ -182,13 +187,14 @@ if ($mode == 'setup' && $user->admin) print '</tr>'."\n"; break; case "submit": - if ($key['enabled']) $submit_enabled = 1; + if ($key['enabled']) { + $submit_enabled = 1; + } break; } $i++; - if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') - { + if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') { // Token print '<tr class="oddeven">'; print '<td>'.$langs->trans("Token").'</td>'; @@ -198,20 +204,18 @@ if ($mode == 'setup' && $user->admin) $storage = new DoliStorage($db, $conf); try { $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE); - } catch (Exception $e) - { + } catch (Exception $e) { // Return an error if token not found } - if (is_object($tokenobj)) - { + if (is_object($tokenobj)) { //var_dump($tokenobj); print $tokenobj->getAccessToken().'<br>'; //print 'Refresh: '.$tokenobj->getRefreshToken().'<br>'; //print 'EndOfLife: '.$tokenobj->getEndOfLife().'<br>'; //var_dump($tokenobj->getExtraParams()); /*print '<br>Extra: <br><textarea class="quatrevingtpercent">'; - print ''.join(',',$tokenobj->getExtraParams()); - print '</textarea>';*/ + print ''.join(',',$tokenobj->getExtraParams()); + print '</textarea>';*/ } print '</td>'; print '</tr>'."\n"; @@ -225,8 +229,7 @@ if ($mode == 'setup' && $user->admin) print dol_get_fiche_end(); - if (!empty($driver)) - { + if (!empty($driver)) { if ($submit_enabled) { print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>'; } @@ -234,8 +237,7 @@ if ($mode == 'setup' && $user->admin) print '</form>'; } -if ($mode == 'config' && $user->admin) -{ +if ($mode == 'config' && $user->admin) { print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); print $langs->trans("PrintingDesc")."<br><br>\n"; @@ -287,8 +289,7 @@ if ($mode == 'config' && $user->admin) print dol_get_fiche_end(); } -if ($mode == 'test' && $user->admin) -{ +if ($mode == 'test' && $user->admin) { print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n"; @@ -325,8 +326,7 @@ if ($mode == 'test' && $user->admin) print dol_get_fiche_end(); } -if ($mode == 'userconf' && $user->admin) -{ +if ($mode == 'userconf' && $user->admin) { print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n"; diff --git a/htdocs/printing/lib/printing.lib.php b/htdocs/printing/lib/printing.lib.php index c899eb105b1..291ebd46ca8 100644 --- a/htdocs/printing/lib/printing.lib.php +++ b/htdocs/printing/lib/printing.lib.php @@ -57,10 +57,10 @@ function printingAdminPrepareHead($mode) } /** TODO This feature seem to be not ready yet. - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf"; - $head[$h][1] = $langs->trans("UserConf"); - $head[$h][2] = 'userconf'; - $h++; + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf"; + $head[$h][1] = $langs->trans("UserConf"); + $head[$h][2] = 'userconf'; + $h++; */ //$object=new stdClass(); From be59a70e397dbe509415e1f6a896de40b969c559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 15:27:05 +0100 Subject: [PATCH 144/173] code syntax paypal paybox directory --- htdocs/paybox/admin/paybox.php | 95 +++++++++---- htdocs/paybox/lib/paybox.lib.php | 64 ++++++--- htdocs/paypal/admin/paypal.php | 96 ++++++++----- htdocs/paypal/lib/paypal.lib.php | 158 +++++++++++----------- htdocs/paypal/lib/paypalfunctions.lib.php | 32 +++-- 5 files changed, 267 insertions(+), 178 deletions(-) diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index a342e58b971..7bba308ba9c 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -32,55 +32,84 @@ $servicename = 'PayBox'; // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'paybox', 'paypal')); -if (!$user->admin) - accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $db->begin(); //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE",$_POST["PAYBOX_IBS_DEVISE"],'chaine',0,'',$conf->entity); $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V1", GETPOST('PAYBOX_CGI_URL_V1', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V2", GETPOST('PAYBOX_CGI_URL_V2', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_IBS_SITE", GETPOST('PAYBOX_IBS_SITE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_IBS_RANG", GETPOST('PAYBOX_IBS_RANG', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT", GETPOST('PAYBOX_PBX_IDENTIFIANT', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } // Payment token for URL $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } - if (!$error) - { - $db->commit(); + if (!$error) { + $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); + } else { + $db->rollback(); dol_print_error($db); } } @@ -91,11 +120,17 @@ if ($action == 'setvalue' && $user->admin) */ $IBS_SITE = "1999888"; // Site test -if (empty($conf->global->PAYBOX_IBS_SITE)) $conf->global->PAYBOX_IBS_SITE = $IBS_SITE; +if (empty($conf->global->PAYBOX_IBS_SITE)) { + $conf->global->PAYBOX_IBS_SITE = $IBS_SITE; +} $IBS_RANG = "99"; // Rang test -if (empty($conf->global->PAYBOX_IBS_RANG)) $conf->global->PAYBOX_IBS_RANG = $IBS_RANG; +if (empty($conf->global->PAYBOX_IBS_RANG)) { + $conf->global->PAYBOX_IBS_RANG = $IBS_RANG; +} $IBS_DEVISE = "978"; // Euro -if (empty($conf->global->PAYBOX_IBS_DEVISE)) $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE; +if (empty($conf->global->PAYBOX_IBS_DEVISE)) { + $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE; +} llxHeader(); @@ -191,8 +226,7 @@ print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->n print '</td></tr>'; -if (!empty($conf->banque->enabled)) -{ +if (!empty($conf->banque->enabled)) { print '<tr class="oddeven"><td>'; print $langs->trans("BankAccount").'</td><td>'; $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); @@ -237,8 +271,9 @@ print '</td></tr>'; print '<tr class="oddeven"><td>'; print $langs->trans("SecurityToken").'</td><td>'; print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">'; -if (!empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +} print '</td></tr>'; print '<tr class="oddeven"><td>'; diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php index d1f27bc0b0f..e5f53b34978 100644 --- a/htdocs/paybox/lib/paybox.lib.php +++ b/htdocs/paybox/lib/paybox.lib.php @@ -44,36 +44,46 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) // Clean parameters $PBX_IDENTIFIANT = "2"; // Identifiant pour v2 test - if (!empty($conf->global->PAYBOX_PBX_IDENTIFIANT)) $PBX_IDENTIFIANT = $conf->global->PAYBOX_PBX_IDENTIFIANT; + if (!empty($conf->global->PAYBOX_PBX_IDENTIFIANT)) { + $PBX_IDENTIFIANT = $conf->global->PAYBOX_PBX_IDENTIFIANT; + } $IBS_SITE = "1999888"; // Site test - if (!empty($conf->global->PAYBOX_IBS_SITE)) $IBS_SITE = $conf->global->PAYBOX_IBS_SITE; + if (!empty($conf->global->PAYBOX_IBS_SITE)) { + $IBS_SITE = $conf->global->PAYBOX_IBS_SITE; + } $IBS_RANG = "99"; // Rang test - if (!empty($conf->global->PAYBOX_IBS_RANG)) $IBS_RANG = $conf->global->PAYBOX_IBS_RANG; + if (!empty($conf->global->PAYBOX_IBS_RANG)) { + $IBS_RANG = $conf->global->PAYBOX_IBS_RANG; + } $IBS_DEVISE = "840"; // Currency (Dollar US by default) - if ($CURRENCY == 'EUR') $IBS_DEVISE = "978"; - if ($CURRENCY == 'USD') $IBS_DEVISE = "840"; + if ($CURRENCY == 'EUR') { + $IBS_DEVISE = "978"; + } + if ($CURRENCY == 'USD') { + $IBS_DEVISE = "840"; + } $URLPAYBOX = ""; - if ($conf->global->PAYBOX_CGI_URL_V1) $URLPAYBOX = $conf->global->PAYBOX_CGI_URL_V1; - if ($conf->global->PAYBOX_CGI_URL_V2) $URLPAYBOX = $conf->global->PAYBOX_CGI_URL_V2; + if ($conf->global->PAYBOX_CGI_URL_V1) { + $URLPAYBOX = $conf->global->PAYBOX_CGI_URL_V1; + } + if ($conf->global->PAYBOX_CGI_URL_V2) { + $URLPAYBOX = $conf->global->PAYBOX_CGI_URL_V2; + } - if (empty($IBS_DEVISE)) - { + if (empty($IBS_DEVISE)) { dol_print_error('', "Paybox setup param PAYBOX_IBS_DEVISE not defined"); return -1; } - if (empty($URLPAYBOX)) - { + if (empty($URLPAYBOX)) { dol_print_error('', "Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined"); return -1; } - if (empty($IBS_SITE)) - { + if (empty($IBS_SITE)) { dol_print_error('', "Paybox setup param PAYBOX_IBS_SITE not defined"); return -1; } - if (empty($IBS_RANG)) - { + if (empty($IBS_RANG)) { dol_print_error('', "Paybox setup param PAYBOX_IBS_RANG not defined"); return -1; } @@ -93,12 +103,24 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) $IBS_BKGD = "#FFFFFF"; $IBS_WAIT = "2000"; $IBS_LANG = "GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...) - if (preg_match('/^FR/i', $langs->defaultlang)) $IBS_LANG = "FRA"; - if (preg_match('/^ES/i', $langs->defaultlang)) $IBS_LANG = "ESP"; - if (preg_match('/^IT/i', $langs->defaultlang)) $IBS_LANG = "ITA"; - if (preg_match('/^DE/i', $langs->defaultlang)) $IBS_LANG = "DEU"; - if (preg_match('/^NL/i', $langs->defaultlang)) $IBS_LANG = "NLD"; - if (preg_match('/^SE/i', $langs->defaultlang)) $IBS_LANG = "SWE"; + if (preg_match('/^FR/i', $langs->defaultlang)) { + $IBS_LANG = "FRA"; + } + if (preg_match('/^ES/i', $langs->defaultlang)) { + $IBS_LANG = "ESP"; + } + if (preg_match('/^IT/i', $langs->defaultlang)) { + $IBS_LANG = "ITA"; + } + if (preg_match('/^DE/i', $langs->defaultlang)) { + $IBS_LANG = "DEU"; + } + if (preg_match('/^NL/i', $langs->defaultlang)) { + $IBS_LANG = "NLD"; + } + if (preg_match('/^SE/i', $langs->defaultlang)) { + $IBS_LANG = "SWE"; + } $IBS_OUTPUT = 'E'; $PBX_SOURCE = 'HTML'; $PBX_TYPEPAIEMENT = 'CARTE'; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index b16748f66b4..cfa7628297d 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -35,43 +35,72 @@ $servicename = 'PayPal'; // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'paypal', 'paybox')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $db->begin(); $result = dolibarr_set_const($db, "PAYPAL_API_USER", GETPOST('PAYPAL_API_USER', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_API_PASSWORD", GETPOST('PAYPAL_API_PASSWORD', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_API_SIGNATURE", GETPOST('PAYPAL_API_SIGNATURE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_SSLVERSION", GETPOST('PAYPAL_SSLVERSION', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY", GETPOST('PAYPAL_API_INTEGRAL_OR_PAYPALONLY', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "PAYPAL_ADD_PAYMENT_URL", GETPOST('PAYPAL_ADD_PAYMENT_URL', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } // Payment token for URL $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) $error++; + if (!$result > 0) { + $error++; + } if (empty($conf->use_javascript_ajax)) { $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!$result > 0) { @@ -80,21 +109,21 @@ if ($action == 'setvalue' && $user->admin) } if (!$error) { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); dol_print_error($db); } } -if ($action == "setlive") -{ +if ($action == "setlive") { $liveenable = GETPOST('value', 'int') ? 0 : 1; $res = dolibarr_set_const($db, "PAYPAL_API_SANDBOX", $liveenable, 'yesno', 0, '', $conf->entity); - if (!($res > 0)) $error++; - if (!$error) - { + if (!($res > 0)) { + $error++; + } + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -126,8 +155,7 @@ print dol_get_fiche_head($head, 'paypalaccount', '', -1); print '<span class="opacitymedium">'.$langs->trans("PaypalDesc")."</span><br>\n"; // Test if php curl exist -if (!function_exists('curl_version')) -{ +if (!function_exists('curl_version')) { $langs->load("errors"); setEventMessages($langs->trans("ErrorPhpCurlNotInstalled"), null, 'errors'); } @@ -147,8 +175,7 @@ print "</tr>\n"; print '<tr class="oddeven">'; print '<td>'; print $langs->trans("PaypalLiveEnabled").'</td><td>'; -if (empty($conf->global->PAYPAL_API_SANDBOX)) -{ +if (empty($conf->global->PAYPAL_API_SANDBOX)) { print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlive&token='.newToken().'&value=0">'; print img_picto($langs->trans("Activated"), 'switch_on'); } else { @@ -217,8 +244,7 @@ print '<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.$con print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>'; print '</td></tr>'; -if (!empty($conf->banque->enabled)) -{ +if (!empty($conf->banque->enabled)) { print '<tr class="oddeven"><td>'; print $langs->trans("BankAccount").'</td><td>'; print img_picto('', 'bank_account').' '; @@ -315,8 +341,9 @@ print '<br><br>'; // Help doc print '<u>'.$langs->trans("InformationToFindParameters", "Paypal").'</u>:<br>'; -if (!empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { print '<a class="reposition" id="apidoca">'.$langs->trans("ClickHere").'...</a>'; +} $realpaypalurl = 'www.paypal.com'; $sandboxpaypalurl = 'developer.paypal.com'; @@ -334,8 +361,7 @@ print 'Your API authentication information can be found with following steps. We '; print '</div>'; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print "\n".'<script type="text/javascript">'; print '$(document).ready(function () { $("#apidoc").hide(); diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 873678adcae..dee6476f773 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -82,25 +82,24 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, //' //'------------------------------------------------- - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) { + $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; + } $solutionType = 'Sole'; $landingPage = 'Billing'; // For payment with Paypal only - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') - { + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') { $solutionType = 'Mark'; $landingPage = 'Login'; } // For payment with Credit card or Paypal - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') - { + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') { $solutionType = 'Sole'; $landingPage = 'Billing'; } // For payment with Credit card - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') - { + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') { $solutionType = 'Sole'; $landingPage = 'Billing'; } @@ -130,8 +129,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, dol_syslog("print_paypal_redirect resArray=".var_export($resArray, true), LOG_DEBUG); $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = $resArray["TOKEN"]; // Redirect to paypal.com here @@ -146,8 +144,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - if ($ErrorCode == 10729) - { + if ($ErrorCode == 10729) { $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n"; } else { $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."<br>\n"; @@ -216,26 +213,25 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL); $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL); - if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) - { + if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) { $nvpstr = $nvpstr."&ALLOWNOTE=0"; } - if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) - { + if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) { $nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted } else { $nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) } $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType); $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage); - if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) - { + if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) { $nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number } $paypalprefix = 'PAYMENTREQUEST_0_'; //$paypalprefix = ''; - if (!empty($paypalprefix) && $paymentType == 'Sole') $paymentType = 'Sale'; + if (!empty($paypalprefix) && $paymentType == 'Sole') { + $paymentType = 'Sale'; + } $nvpstr = $nvpstr."&AMT=".urlencode($paymentAmount); // Total for all elements @@ -258,11 +254,14 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode); $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip); $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum); - if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL - if (!empty($desc)) $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + if (!empty($email)) { + $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + } + if (!empty($desc)) { + $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + } - if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) - { + if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) { global $dolibarr_main_url_root; // Define $urlwithroot @@ -273,12 +272,10 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo); } - if (!empty($conf->global->PAYPAL_BRANDNAME)) - { + if (!empty($conf->global->PAYPAL_BRANDNAME)) { $nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME } - if (!empty($conf->global->PAYPAL_NOTETOBUYER)) - { + if (!empty($conf->global->PAYPAL_NOTETOBUYER)) { $nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER } @@ -294,8 +291,7 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, //'--------------------------------------------------------------------------------------------------------------- $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); $_SESSION['TOKEN'] = $token; } @@ -339,8 +335,7 @@ function getDetails($token) //'--------------------------------------------------------------------------- $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $_SESSION['payer_id'] = $resArray['PAYERID']; } return $resArray; @@ -362,9 +357,9 @@ function getDetails($token) function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag) { /* Gather the information to make the final call to - finalize the PayPal payment. The variable nvpstr - holds the name value pairs - */ + finalize the PayPal payment. The variable nvpstr + holds the name value pairs + */ //declaring of global variables global $conf, $langs; @@ -381,14 +376,14 @@ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipad $nvpstr .= '&INVNUM='.urlencode($tag); /* Make the call to PayPal to finalize payment - If an error occured, show the resulting errors - */ + If an error occured, show the resulting errors + */ $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); /* Display the API response back to the browser. - If the response from PayPal was a success, display the response parameters' - If the response was an error, display the errors received using APIError.php. - */ + If the response from PayPal was a success, display the response parameters' + If the response was an error, display the errors received using APIError.php. + */ $ack = strtoupper($resArray["ACK"]); return $resArray; @@ -416,32 +411,32 @@ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipad /* function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag) { - //declaring of global variables - global $conf, $langs; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - //Construct the parameter string that describes DoDirectPayment - $nvpstr = ''; - $nvpstr = $nvpstr . "&AMT=" . urlencode($paymentAmount); // deprecated by paypal - $nvpstr = $nvpstr . "&CURRENCYCODE=" . urlencode($currencyCode); - $nvpstr = $nvpstr . "&PAYMENTACTION=" . urlencode($paymentType); // deprecated by paypal - $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . urlencode($creditCardType); - $nvpstr = $nvpstr . "&ACCT=" . urlencode($creditCardNumber); - $nvpstr = $nvpstr . "&EXPDATE=" . urlencode($expDate); - $nvpstr = $nvpstr . "&CVV2=" . urlencode($cvv2); - $nvpstr = $nvpstr . "&FIRSTNAME=" . urlencode($firstName); - $nvpstr = $nvpstr . "&LASTNAME=" . urlencode($lastName); - $nvpstr = $nvpstr . "&STREET=" . urlencode($street); - $nvpstr = $nvpstr . "&CITY=" . urlencode($city); - $nvpstr = $nvpstr . "&STATE=" . urlencode($state); - $nvpstr = $nvpstr . "&COUNTRYCODE=" . urlencode($countryCode); - $nvpstr = $nvpstr . "&IPADDRESS=" . getUserRemotIP(); - $nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag); + //Construct the parameter string that describes DoDirectPayment + $nvpstr = ''; + $nvpstr = $nvpstr . "&AMT=" . urlencode($paymentAmount); // deprecated by paypal + $nvpstr = $nvpstr . "&CURRENCYCODE=" . urlencode($currencyCode); + $nvpstr = $nvpstr . "&PAYMENTACTION=" . urlencode($paymentType); // deprecated by paypal + $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . urlencode($creditCardType); + $nvpstr = $nvpstr . "&ACCT=" . urlencode($creditCardNumber); + $nvpstr = $nvpstr . "&EXPDATE=" . urlencode($expDate); + $nvpstr = $nvpstr . "&CVV2=" . urlencode($cvv2); + $nvpstr = $nvpstr . "&FIRSTNAME=" . urlencode($firstName); + $nvpstr = $nvpstr . "&LASTNAME=" . urlencode($lastName); + $nvpstr = $nvpstr . "&STREET=" . urlencode($street); + $nvpstr = $nvpstr . "&CITY=" . urlencode($city); + $nvpstr = $nvpstr . "&STATE=" . urlencode($state); + $nvpstr = $nvpstr . "&COUNTRYCODE=" . urlencode($countryCode); + $nvpstr = $nvpstr . "&IPADDRESS=" . getUserRemotIP(); + $nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag); - $resArray=hash_call("DoDirectPayment", $nvpstr); + $resArray=hash_call("DoDirectPayment", $nvpstr); - return $resArray; + return $resArray; } */ @@ -462,8 +457,7 @@ function hash_call($methodName, $nvpStr) // TODO problem with triggers $API_version = "98.0"; - if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' - { + if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) { // We can force sand box with param 'forcesandbox' $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; } else { @@ -473,13 +467,21 @@ function hash_call($methodName, $nvpStr) // Clean parameters $PAYPAL_API_USER = ""; - if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; + if (!empty($conf->global->PAYPAL_API_USER)) { + $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; + } $PAYPAL_API_PASSWORD = ""; - if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; + if (!empty($conf->global->PAYPAL_API_PASSWORD)) { + $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; + } $PAYPAL_API_SIGNATURE = ""; - if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; + if (!empty($conf->global->PAYPAL_API_SIGNATURE)) { + $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; + } $PAYPAL_API_SANDBOX = ""; - if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; + if (!empty($conf->global->PAYPAL_API_SANDBOX)) { + $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; + } // TODO END problem with triggers dol_syslog("Paypal API endpoint ".$API_Endpoint); @@ -488,9 +490,9 @@ function hash_call($methodName, $nvpStr) $ch = curl_init(); /*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."<br>"; - print $USE_PROXY."-".$gv_ApiErrorURL."<br>"; - print $nvpStr; - exit;*/ + print $USE_PROXY."-".$gv_ApiErrorURL."<br>"; + print $nvpStr; + exit;*/ curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); // TLSv1 by default or change to TLSv1.2 in module configuration @@ -507,12 +509,13 @@ function hash_call($methodName, $nvpStr) curl_setopt($ch, CURLOPT_POST, 1); //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled. - if ($USE_PROXY) - { + if ($USE_PROXY) { dol_syslog("Paypal API hash_call 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); + if ($PROXY_USER) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); + } } //NVPRequest for submitting to server @@ -564,8 +567,7 @@ function deformatNVP($nvpstr) $intial = 0; $nvpArray = array(); - while (strlen($nvpstr)) - { + while (strlen($nvpstr)) { //postion of Key $keypos = strpos($nvpstr, '='); //position of value @@ -592,13 +594,11 @@ function getApiError() $resArray = $_SESSION['reshash']; - if (isset($_SESSION['curl_error_no'])) - { + if (isset($_SESSION['curl_error_no'])) { $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; } - foreach ($resArray as $key => $value) - { + foreach ($resArray as $key => $value) { $errors[] = $key.'-'.$value; } diff --git a/htdocs/paypal/lib/paypalfunctions.lib.php b/htdocs/paypal/lib/paypalfunctions.lib.php index 5fbe0f6e9cd..713c304323b 100644 --- a/htdocs/paypal/lib/paypalfunctions.lib.php +++ b/htdocs/paypal/lib/paypalfunctions.lib.php @@ -22,14 +22,13 @@ * \brief Page with Paypal init var. */ -if (session_id() == "") -{ +if (session_id() == "") { session_start(); - if (ini_get('register_globals')) // To solve bug in using $_SESSION - { - foreach ($_SESSION as $key=>$value) - { - if (isset($GLOBALS[$key])) unset($GLOBALS[$key]); + if (ini_get('register_globals')) { // To solve bug in using $_SESSION + foreach ($_SESSION as $key => $value) { + if (isset($GLOBALS[$key])) { + unset($GLOBALS[$key]); + } } } } @@ -48,8 +47,7 @@ $API_version = "56"; ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= */ -if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' -{ +if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) { // We can force sand box with param 'forcesandbox' $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; } else { @@ -59,13 +57,21 @@ if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha' // Clean parameters $PAYPAL_API_USER = ""; -if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; +if (!empty($conf->global->PAYPAL_API_USER)) { + $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; +} $PAYPAL_API_PASSWORD = ""; -if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; +if (!empty($conf->global->PAYPAL_API_PASSWORD)) { + $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; +} $PAYPAL_API_SIGNATURE = ""; -if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; +if (!empty($conf->global->PAYPAL_API_SIGNATURE)) { + $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; +} $PAYPAL_API_SANDBOX = ""; -if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; +if (!empty($conf->global->PAYPAL_API_SANDBOX)) { + $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; +} // Proxy $PROXY_HOST = $conf->global->MAIN_PROXY_HOST; From 155aeb6213591a149f19fe39e5c98cf62f244530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 15:27:57 +0100 Subject: [PATCH 145/173] code syntax opensurvey directory --- htdocs/opensurvey/card.php | 123 ++--- .../class/opensurveysondage.class.php | 107 ++-- htdocs/opensurvey/exportcsv.php | 38 +- htdocs/opensurvey/fonctions.php | 9 +- htdocs/opensurvey/index.php | 11 +- htdocs/opensurvey/list.php | 203 +++++--- htdocs/opensurvey/results.php | 469 ++++++++++-------- htdocs/opensurvey/wizard/choix_autre.php | 25 +- htdocs/opensurvey/wizard/choix_date.php | 85 ++-- htdocs/opensurvey/wizard/create_survey.php | 64 +-- htdocs/opensurvey/wizard/index.php | 8 +- 11 files changed, 620 insertions(+), 522 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index ef583d08ff5..bbd930b013f 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Initialisation des variables $action = GETPOST('action', 'aZ09'); @@ -62,17 +64,21 @@ $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), $parameters = array('id' => $numsondage); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) $action = ''; +if (empty($reshook)) { + if ($cancel) { + $action = ''; + } // Delete - if ($action == 'delete_confirm') - { + if ($action == 'delete_confirm') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $result = $object->delete($user, '', $numsondage); @@ -81,36 +87,33 @@ if (empty($reshook)) } // Close - if ($action == 'close') - { + if ($action == 'close') { $object->status = Opensurveysondage::STATUS_CLOSED; $object->update($user); } // Reopend - if ($action == 'reopen') - { + if ($action == 'reopen') { $object->status = Opensurveysondage::STATUS_VALIDATED; $object->update($user); } // Update - if ($action == 'update') - { + if ($action == 'update') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $error = 0; - if (!GETPOST('nouveautitre')) - { + if (!GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - if (!$error) - { + if (!$error) { $object->title = (string) GETPOST('nouveautitre', 'alphanohtml'); $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); @@ -128,8 +131,7 @@ if (empty($reshook)) } // Add comment - if (GETPOST('ajoutcomment')) - { + if (GETPOST('ajoutcomment')) { $error = 0; if (!GETPOST('comment')) { @@ -147,8 +149,7 @@ if (empty($reshook)) $resql = $object->addComment($comment, $comment_user); - if (!$resql) - { + if (!$resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } } @@ -156,17 +157,20 @@ if (empty($reshook)) // Delete comment $idcomment = GETPOST('deletecomment', 'int'); - if ($idcomment) - { + if ($idcomment) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $resql = $object->deleteComment($idcomment); } if ($action == 'edit') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } } } @@ -177,8 +181,7 @@ if (empty($reshook)) $form = new Form($db); -if ($object->fk_user_creat) -{ +if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } @@ -193,8 +196,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -232,16 +234,16 @@ print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'</td>< print '<tr><td>'; $adresseadmin = $object->mail_admin; print $langs->trans("Title").'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(dol_htmlentities($object->title)).'">'; -} else print dol_htmlentities($object->title); +} else { + print dol_htmlentities($object->title); +} print '</td></tr>'; // Description print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); } else { @@ -253,17 +255,17 @@ print '</td></tr>'; //If linked user, then emails are going to be sent to users' email if (!$object->fk_user_creat) { print '<tr><td>'.$langs->trans("EMail").'</td><td colspan="2">'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.'">'; - } else print dol_print_email($object->mail_admin, 0, 0, 1); + } else { + print dol_print_email($object->mail_admin, 0, 0, 1); + } print '</td></tr>'; } // Receive an email with each vote print '<tr><td>'.$langs->trans('ToReceiveEMailForEachVote').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="mailsonde" '.($object->mailsonde ? 'checked="checked"' : '').'">'; } else { print yn($object->mailsonde); @@ -279,26 +281,31 @@ print '</td></tr>'; // Users can comment print '<tr><td>'.$langs->trans('CanComment').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="cancomment" '.($object->allow_comments ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_comments); +} else { + print yn($object->allow_comments); +} print '</td></tr>'; // Users can see others vote print '<tr><td>'.$langs->trans('CanSeeOthersVote').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_spy); +} else { + print yn($object->allow_spy); +} print '</td></tr>'; // Expire date print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '</td></tr>'; @@ -322,7 +329,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; print '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">'; -if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url); +if ($action != 'edit') { + print ajax_autoselect("opensurveyurl", $url); +} print '</td></tr>'; @@ -332,8 +341,7 @@ print '</div>'; print dol_get_fiche_end(); -if ($action == 'edit') -{ +if ($action == 'edit') { print '<div class="center">'; print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; print ' &nbsp; '; @@ -354,13 +362,11 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { //Modify button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$numsondage.'">'.$langs->trans("Modify").'</a>'; - if ($object->status == Opensurveysondage::STATUS_VALIDATED) - { + if ($object->status == Opensurveysondage::STATUS_VALIDATED) { //Close button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&id='.$numsondage.'">'.$langs->trans("Close").'</a>'; } - if ($object->status == Opensurveysondage::STATUS_CLOSED) - { + if ($object->status == Opensurveysondage::STATUS_CLOSED) { //Opened button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id='.$numsondage.'">'.$langs->trans("ReOpen").'</a>'; } @@ -371,8 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { print '</div>'; -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?&id='.$numsondage, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll", $id), 'delete_confirm', '', '', 1); } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c635c2430a7..badb3f60149 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -175,7 +175,7 @@ class Opensurveysondage extends CommonObject $sql .= "allow_comments,"; $sql .= "allow_spy,"; $sql .= "sujet,"; - $sql .= "entity"; + $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; @@ -188,21 +188,25 @@ class Opensurveysondage extends CommonObject $sql .= " ".((int) $this->allow_comments).","; $sql .= " ".((int) $this->allow_spy).","; $sql .= " '".$this->db->escape($this->sujet)."',"; - $sql .= " ".((int) $conf->entity); + $sql .= " ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", 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 && !$notrigger) { global $langs, $conf; // Call trigger $result = $this->call_trigger('OPENSURVEY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } @@ -250,10 +254,8 @@ class Opensurveysondage extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; @@ -336,15 +338,15 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -369,8 +371,7 @@ class Opensurveysondage extends CommonObject global $conf, $langs; $error = 0; - if (empty($numsondage)) - { + if (empty($numsondage)) { $numsondage = $this->id_sondage; } @@ -379,12 +380,13 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -397,14 +399,14 @@ class Opensurveysondage extends CommonObject 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -431,7 +433,9 @@ class Opensurveysondage 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 = ''; @@ -444,14 +448,16 @@ class Opensurveysondage extends CommonObject // 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -466,8 +472,12 @@ class Opensurveysondage extends CommonObject $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; return $result; @@ -488,19 +498,19 @@ class Opensurveysondage extends CommonObject $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); $ret[] = $tmp; $i++; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } $this->lines = $ret; @@ -543,14 +553,11 @@ class Opensurveysondage extends CommonObject $sql .= " ORDER BY id_comment"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($num_rows > 0) { + while ($obj = $this->db->fetch_object($resql)) { $comments[] = $obj; } } @@ -642,8 +649,7 @@ class Opensurveysondage extends CommonObject // phpcs:enable global $langs, $conf; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -656,10 +662,15 @@ class Opensurveysondage extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { - if (0) $statusType = 'status1'; - else $statusType = 'status4'; + if (0) { + $statusType = 'status1'; + } else { + $statusType = 'status4'; + } + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; } - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php index 6f9a699273b..3a4237f83e6 100644 --- a/htdocs/opensurvey/exportcsv.php +++ b/htdocs/opensurvey/exportcsv.php @@ -30,14 +30,15 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; $action = GETPOST('action', 'aZ09'); $numsondage = ''; -if (GETPOST('id')) -{ +if (GETPOST('id')) { $numsondage = GETPOST("id", 'alpha'); } $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} /* @@ -57,10 +58,8 @@ $toutsujet = explode(",", $object->sujet); // affichage des sujets du sondage $input .= $langs->trans("Name").";"; -for ($i = 0; $toutsujet[$i]; $i++) -{ - if ($object->format == "D") - { +for ($i = 0; $toutsujet[$i]; $i++) { + if ($object->format == "D") { $input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';'; } else { $input .= ''.$toutsujet[$i].';'; @@ -69,11 +68,9 @@ for ($i = 0; $toutsujet[$i]; $i++) $input .= "\r\n"; -if (strpos($object->sujet, '@') !== false) -{ +if (strpos($object->sujet, '@') !== false) { $input .= ";"; - for ($i = 0; $toutsujet[$i]; $i++) - { + for ($i = 0; $toutsujet[$i]; $i++) { $heures = explode("@", $toutsujet[$i]); $input .= ''.$heures[1].';'; } @@ -87,12 +84,10 @@ $sql .= ' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage='".$db->escape($numsondage)."'"; $sql .= " ORDER BY id_users"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); // Le name de l'utilisateur @@ -101,15 +96,12 @@ if ($resql) //affichage des resultats $ensemblereponses = $obj->reponses; - for ($k = 0; $k < $nbcolonnes; $k++) - { + for ($k = 0; $k < $nbcolonnes; $k++) { $car = substr($ensemblereponses, $k, 1); - if ($car == "1") - { + if ($car == "1") { $input .= 'OK;'; $somme[$k]++; - } elseif ($car == "2") - { + } elseif ($car == "2") { $input .= 'KO;'; $somme[$k]++; } else { @@ -120,7 +112,9 @@ if ($resql) $input .= "\r\n"; $i++; } -} else dol_print_error($db); +} else { + dol_print_error($db); +} $filesize = strlen($input); diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 0ea701ebf0b..96d9370c10a 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -96,19 +96,16 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $urllogo = ''; $urllogofull = ''; - if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) - { + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - } 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&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); } // Output html code for logo - if ($urllogo) - { + if ($urllogo) { print '<div class="backgreypublicpayment">'; print '<div class="logopublicpayment">'; print '<img id="dolpaymentlogo" src="'.$urllogo.'"'; diff --git a/htdocs/opensurvey/index.php b/htdocs/opensurvey/index.php index 50198e5202f..8ff138b6681 100644 --- a/htdocs/opensurvey/index.php +++ b/htdocs/opensurvey/index.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $langs->load("opensurvey"); // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} $hookmanager = new HookManager($db); @@ -48,11 +50,12 @@ $sql = 'SELECT COUNT(*) as nb'; $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_sondage'; $sql .= ' WHERE entity IN ('.getEntity('survey').')'; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); $nbsondages = $obj->nb; -} else dol_print_error($db, ''); +} else { + dol_print_error($db, ''); +} $title = $langs->trans("OpenSurveyArea"); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index eaee1b696e1..3f0b6011455 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -67,24 +69,29 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "p.date_fin"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "p.date_fin"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Definition of fields for list $arrayfields = array(); -foreach ($arrayfields as $key => $val) -{ +foreach ($arrayfields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -107,21 +114,25 @@ $permissiontodelete = $user->rights->opensurvey->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_status = ''; $search_title = ''; $search_ref = ''; @@ -129,8 +140,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -160,11 +170,21 @@ $sql .= " u.login, u.firstname, u.lastname"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; $sql .= " WHERE p.entity IN (".getEntity('survey').")"; -if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2); -if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'"; -if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; -if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref); -if ($search_title) $sql .= natural_search("p.titre", $search_title); +if ($search_status != '-1' && $search_status != '') { + $sql .= natural_search("p.status", $search_status, 2); +} +if ($search_expired == 'expired') { + $sql .= " AND p.date_fin < '".$db->idate($now)."'"; +} +if ($search_expired == 'opened') { + $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; +} +if ($search_ref) { + $sql .= natural_search("p.id_sondage", $search_ref); +} +if ($search_title) { + $sql .= natural_search("p.titre", $search_title); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -176,26 +196,22 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) -{ +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -204,8 +220,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id); @@ -221,11 +236,17 @@ llxHeader('', $title, $help_url); $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); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname'; -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'; @@ -234,15 +255,21 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // List of surveys into database print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -261,9 +288,10 @@ $objecttmp = new Opensurveysondage($db); $trackid = 'surv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -274,11 +302,13 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -346,18 +376,20 @@ print '</tr>'."\n"; // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'"; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { $obj2 = $db->fetch_object($resql2); $nbuser = $obj2->nb; - } else dol_print_error($db); + } else { + dol_print_error($db); + } $opensurvey_static->id = $obj->rowid; $opensurvey_static->ref = $obj->rowid; @@ -372,11 +404,15 @@ while ($i < min($num, $limit)) print '<td>'; print $opensurvey_static->getNomUrl(1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Title print '<td>'.dol_htmlentities($obj->title).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Type print '<td>'; @@ -384,7 +420,9 @@ while ($i < min($num, $limit)) print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate"); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td>'; // Author @@ -400,23 +438,35 @@ while ($i < min($num, $limit)) print dol_htmlentities($obj->nom_admin); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Nb of voters print'<td class="right">'.$nbuser.'</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day'); - if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } + if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.dol_print_date($db->jdate($obj->tms), 'dayhour'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -426,14 +476,17 @@ while ($i < min($num, $limit)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; $i++; @@ -444,10 +497,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 8; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -463,10 +519,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index ea07900ba67..cea5cdbcbee 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Init vars @@ -40,7 +42,9 @@ $numsondage = GETPOST("id"); $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} $nblines = $object->fetch_lines(); @@ -58,20 +62,15 @@ if (GETPOST('retoursondage')) { $nbcolonnes = substr_count($object->sujet, ',') + 1; // Add vote -if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox -{ - if (GETPOST('nom')) - { +if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox + if (GETPOST('nom')) { $erreur_prenom = false; $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + for ($i = 0; $i < $nbcolonnes; $i++) { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -87,15 +86,16 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); - if ($num_rows > 0) - { + if ($num_rows > 0) { setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors'); $error++; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } } @@ -104,35 +104,30 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i = 0; $i < $nblines; $i++) -{ - if (isset($_POST['modifierligne'.$i])) - { +for ($i = 0; $i < $nblines; $i++) { + if (isset($_POST['modifierligne'.$i])) { $ligneamodifier = $i; $testligneamodifier = true; } //test pour voir si une ligne est a modifier - if (isset($_POST['validermodifier'.$i])) - { + if (isset($_POST['validermodifier'.$i])) { $modifier = $i; $testmodifier = true; } } -if ($testmodifier) -{ +if ($testmodifier) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { //var_dump($_POST["choix$i"]); - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -145,14 +140,17 @@ if ($testmodifier) $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } // Add column (not for date) -if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") -{ +if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -165,17 +163,19 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } // Add column (with format date) -if (isset($_POST["ajoutercolonne"]) && $object->format == "D") -{ +if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -223,8 +223,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $cleinsertion = count($datesbase); } else { $nbdatesbase = count($datesbase); - for ($i = 0; $i < $nbdatesbase; $i++) - { + for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) { $cleinsertion = $j; @@ -244,14 +243,14 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $dateinsertion = substr("$dateinsertion", 1); // update with new topics into database - if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) - { + if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } @@ -263,12 +262,12 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } // Delete line -for ($i = 0; $i < $nblines; $i++) -{ - if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); +for ($i = 0; $i < $nblines; $i++) { + if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox + // Security check + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $compteur = 0; @@ -278,14 +277,14 @@ for ($i = 0; $i < $nblines; $i++) $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); - if ($compteur == $i) - { + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); @@ -297,13 +296,13 @@ for ($i = 0; $i < $nblines; $i++) } // Delete column -for ($i = 0; $i < $nbcolonnes; $i++) -{ +for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) - && $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox + // Security check + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $db->begin(); @@ -312,12 +311,12 @@ for ($i = 0; $i < $nbcolonnes; $i++) $nouveauxsujets = ''; //parcours de tous les sujets actuels - while (isset($toutsujet[$j])) - { + while (isset($toutsujet[$j])) { //si le sujet n'est pas celui qui a été effacé alors on concatene - if ($i != $j) - { - if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; + if ($i != $j) { + if (!empty($nouveauxsujets)) { + $nouveauxsujets .= ','; + } $nouveauxsujets .= $toutsujet[$j]; } @@ -328,7 +327,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } // Clean current answer to remove deleted columns $compteur = 0; @@ -337,22 +338,19 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; // parcours de toutes les réponses actuelles - for ($j = 0; $j < $nbcolonnes; $j++) - { + for ($j = 0; $j < $nbcolonnes; $j++) { $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { @@ -389,8 +387,7 @@ if ($object->fk_user_creat) { } $result = $object->fetch(0, $numsondage); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -405,8 +402,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -452,10 +448,13 @@ print '</td></tr>'; // Expire date print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '</td></tr>'; @@ -480,8 +479,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; $urllink = '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">'; print $urllink; -if ($action != 'edit') -{ +if ($action != 'edit') { print '<script type="text/javascript"> jQuery(document).ready(function () { jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } ); @@ -511,10 +509,11 @@ print '</div>'; // Show form to add a new field/column -if (GETPOST('ajoutsujet')) -{ +if (GETPOST('ajoutsujet')) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } print '<form name="formulaire" action="" method="POST">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -524,8 +523,7 @@ if (GETPOST('ajoutsujet')) print "<br><br>\n"; // Add new column - if ($object->format == "A") - { + if ($object->format == "A") { print $langs->trans("AddNewColumn").':<br><br>'; print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>'; $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); @@ -628,8 +626,7 @@ print '</tr>'."\n"; // Show choice titles -if ($object->format == "D") -{ +if ($object->format == "D") { //affichage des sujets du sondage print '<tr>'."\n"; print '<td></td>'."\n"; @@ -638,8 +635,7 @@ if ($object->format == "D") //affichage des années $colspan = 1; $nbofsujet = count($toutsujet); - for ($i = 0; $i < $nbofsujet; $i++) - { + for ($i = 0; $i < $nbofsujet; $i++) { $current = $toutsujet[$i]; if (strpos($toutsujet[$i], '@') !== false) { @@ -653,15 +649,20 @@ if ($object->format == "D") } $currenty = 0; - if ($current) $currenty = strftime("%Y", $current); + if ($current) { + $currenty = strftime("%Y", $current); + } $next = 0; - if ($next) $nexty = strftime("%Y", $next); - if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) - { + if ($next) { + $nexty = strftime("%Y", $next); + } + if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) { $colspan++; } else { print '<td colspan='.$colspan.' class="annee">'; - if ($current) print strftime("%Y", $current); + if ($current) { + print strftime("%Y", $current); + } print '</td>'."\n"; $colspan = 1; } @@ -756,8 +757,7 @@ if ($object->format == "D") print '<td></td>'."\n"; print '<td></td>'."\n"; - for ($i = 0; isset($toutsujet[$i]); $i++) - { + for ($i = 0; isset($toutsujet[$i]); $i++) { $tmp = explode('@', $toutsujet[$i]); print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n"; } @@ -776,14 +776,12 @@ $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); -while ($compteur < $num) -{ +while ($compteur < $num) { $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -798,121 +796,167 @@ while ($compteur < $num) print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n"; // si la ligne n'est pas a changer, on affiche les données - if (!$testligneamodifier) - { - for ($i = 0; $i < $nbcolonnes; $i++) - { + if (!$testligneamodifier) { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { - if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; - else print '<td class="non">KO</td>'."\n"; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (((string) $car) == "1") { + print '<td class="ok">OK</td>'."\n"; + } else { + print '<td class="non">KO</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("No").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } } } else { //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs - if ($compteur == $ligneamodifier) - { - for ($i = 0; $i < $nbcolonnes; $i++) - { + if ($compteur == $ligneamodifier) { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); print '<td class="vide">'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print '<input type="checkbox" name="choix'.$i.'" value="1" '; - if ($car == '1') print 'checked'; + if ($car == '1') { + print 'checked'; + } print '>'; } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print '</td>'."\n"; } } else { - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { - if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; - else print '<td class="non">KO</td>'."\n"; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (((string) $car) == "1") { + print '<td class="ok">OK</td>'."\n"; + } else { + print '<td class="non">KO</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } } } } // Button edit at end of line - if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) - { + if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) { print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n"; } //demande de confirmation pour modification de ligne - for ($i = 0; $i < $nblines; $i++) - { - if (GETPOSTISSET("modifierligne".$i)) - { - if ($compteur == $i) - { + for ($i = 0; $i < $nblines; $i++) { + if (GETPOSTISSET("modifierligne".$i)) { + if ($compteur == $i) { print '<td class="casevide">'; print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">'; print '<input type="submit" class="button button-save" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; @@ -926,33 +970,27 @@ while ($compteur < $num) } // Add line to add new record -if (empty($testligneamodifier)) -{ +if (empty($testligneamodifier)) { print '<tr>'."\n"; print '<td></td>'."\n"; print '<td class="nom">'."\n"; print '<input type="text" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64" size="24">'."\n"; print '</td>'."\n"; - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { print '<td class="vide">'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print '<input type="checkbox" name="choix'.$i.'" value="1"'; - if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') - { + if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') { print ' checked'; } print '>'; } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice); } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice); } @@ -966,18 +1004,15 @@ if (empty($testligneamodifier)) // Select value of best choice (for checkbox columns only) $nbofcheckbox = 0; -for ($i = 0; $i < $nbcolonnes + 1; $i++) -{ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - $nbofcheckbox++; - if (isset($sumfor[$i])) - { - if ($i == 0) - { +for ($i = 0; $i < $nbcolonnes + 1; $i++) { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + $nbofcheckbox++; + } + if (isset($sumfor[$i])) { + if ($i == 0) { $meilleurecolonne = $sumfor[$i]; } - if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) - { + if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) { $meilleurecolonne = $sumfor[$i]; } } @@ -988,29 +1023,36 @@ for ($i = 0; $i < $nbcolonnes + 1; $i++) print '<tr>'."\n"; print '<td></td>'."\n"; print '<td class="center">'.$langs->trans("Total").'</td>'."\n"; -for ($i = 0; $i < $nbcolonnes; $i++) -{ +for ($i = 0; $i < $nbcolonnes; $i++) { $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; - if (empty($showsumfor)) $showsumfor = 0; - if (empty($showsumagainst)) $showsumagainst = 0; + if (empty($showsumfor)) { + $showsumfor = 0; + } + if (empty($showsumagainst)) { + $showsumagainst = 0; + } print '<td>'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + print $showsumfor; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; + } print '</td>'."\n"; } print '</tr>'; // Show picto winner -if ($nbofcheckbox >= 2) -{ +if ($nbofcheckbox >= 2) { print '<tr>'."\n"; print '<td></td>'."\n"; print '<td></td>'."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"></td>'."\n"; } else { print '<td class="somme"></td>'."\n"; @@ -1041,10 +1083,8 @@ $toutsujet = explode(",", $object->sujet); // With old versions, this field was $compteursujet = 0; $meilleursujet = ''; -for ($i = 0; $i < $nbcolonnes; $i++) -{ - if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) - { +for ($i = 0; $i < $nbcolonnes; $i++) { + if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { $meilleursujet .= ", "; if ($object->format == "D") { @@ -1068,8 +1108,7 @@ $meilleursujet = substr($meilleursujet, 1); $meilleursujet = str_replace("°", "'", $meilleursujet); // Show best choice -if ($nbofcheckbox >= 2) -{ +if ($nbofcheckbox >= 2) { $vote_str = $langs->trans('votes'); print '<p class="affichageresultats">'."\n"; diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index 42213af2ae2..4919006a5f1 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} @@ -53,20 +55,16 @@ if (isset($_SESSION["nbrecases"])) { $_SESSION["nbrecases"] = 5; } -if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) -{ +if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) { $_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5; } // Create survey into database -if (GETPOSTISSET("confirmecreation")) -{ +if (GETPOSTISSET("confirmecreation")) { //recuperation des données de champs textes $toutchoix = ''; - for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) - { - if (!empty($arrayofchoices[$i])) - { + for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { + if (!empty($arrayofchoices[$i])) { $toutchoix .= ','; $toutchoix .= str_replace(array(",", "@"), " ", $arrayofchoices[$i]).(empty($arrayoftypecolumn[$i]) ? '' : '@'.$arrayoftypecolumn[$i]); } @@ -77,10 +75,8 @@ if (GETPOSTISSET("confirmecreation")) //test de remplissage des cases $testremplissage = ''; - for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) - { - if (isset($arrayofchoices[$i])) - { + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { + if (isset($arrayofchoices[$i])) { $testremplissage = "ok"; } } @@ -107,8 +103,7 @@ $arrayofjs = array(); $arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); -if (empty($_SESSION['title'])) -{ +if (empty($_SESSION['title'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); llxFooter(); exit; diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index ae64c1e6491..ce5f79b1174 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} // Survey type is DATE $_SESSION["formatsondage"] = "D"; @@ -40,19 +42,15 @@ $erreur = false; */ // Insert survey -if (GETPOST('confirmation')) -{ +if (GETPOST('confirmation')) { // We save hours entered - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); $errheure = array(); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { // Show hours choices - for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) - { + for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; $tmphorairesi = GETPOST('horaires'.$i, 'array'); @@ -170,8 +168,7 @@ if (GETPOST('confirmation')) } // Add survey into database - if (!$erreur) - { + if (!$erreur) { $_SESSION["toutchoix"] = substr("$choixdate", 1); ajouter_sondage(); @@ -179,11 +176,9 @@ if (GETPOST('confirmation')) } // Reset days -if (GETPOST('reset')) -{ +if (GETPOST('reset')) { $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { unset($_SESSION["horaires$i"][$j]); } @@ -199,8 +194,7 @@ if (GETPOST('reset')) * View */ -if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) -{ +if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); exit; } @@ -210,11 +204,9 @@ $arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); //nombre de cases par défaut -if (!isset($_SESSION["nbrecaseshoraires"])) -{ +if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; -} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) -{ +} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; } @@ -224,9 +216,15 @@ $moisAJ = date("n"); $anneeAJ = date("Y"); // Initialisation des jour, mois et année -if (!isset($_SESSION['jour'])) $_SESSION['jour'] = date('j'); -if (!isset($_SESSION['mois'])) $_SESSION['mois'] = date('n'); -if (!isset($_SESSION['annee'])) $_SESSION['annee'] = date('Y'); +if (!isset($_SESSION['jour'])) { + $_SESSION['jour'] = date('j'); +} +if (!isset($_SESSION['mois'])) { + $_SESSION['mois'] = date('n'); +} +if (!isset($_SESSION['annee'])) { + $_SESSION['annee'] = date('Y'); +} //mise a jour des valeurs de session si bouton retour a aujourd'hui if (!issetAndNoEmpty('choixjourajout') && !issetAndNoEmpty('choixjourretrait') && (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))) { @@ -245,8 +243,7 @@ if (issetAndNoEmpty('moisavant_x') || issetAndNoEmpty('moisavant')) { } //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -267,11 +264,9 @@ if (issetAndNoEmpty('moisapres_x') || issetAndNoEmpty('moisapres')) { } //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; @@ -285,8 +280,7 @@ if (issetAndNoEmpty('anneeavant_x') || issetAndNoEmpty('anneeavant')) { $_SESSION["annee"] -= 1; //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -302,8 +296,7 @@ if (issetAndNoEmpty('anneeapres_x') || issetAndNoEmpty('anneeapres')) { $_SESSION["annee"] += 1; //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -319,8 +312,7 @@ $nbrejourmois = date("t", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee $premierjourmois = date("N", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])) - 1; //traduction de la valeur du mois -if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) -{ +if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) { $motmois = dol_print_date(mktime(0, 0, 0, $_SESSION["mois"], 10), '%B'); } else { $motmois = dol_print_date(dol_now(), '%B'); @@ -356,8 +348,7 @@ print '<table align="center">'."\n"; // The div class=center has no effect on ta print '<tr>'."\n"; //affichage des jours de la semaine en haut du tableau -for ($i = 0; $i < 7; $i++) -{ +for ($i = 0; $i < 7; $i++) { print '<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10), '%A').'</td>'; } @@ -371,8 +362,7 @@ if (issetAndNoEmpty('choixjourajout')) { // Test pour éviter les doublons dans la variable qui contient toutes les dates $journeuf = true; - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])) { @@ -421,10 +411,8 @@ if (issetAndNoEmpty('choixjourretrait')) { } } - for ($i = 0; $i < $nbofchoice; $i++) - { - if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) - { + for ($i = 0; $i < $nbofchoice; $i++) { + if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) { for ($j = $i; $j < $nbofchoice; $j++) { $k = $j + 1; $_SESSION["horaires$j"] = $_SESSION["horaires$k"]; @@ -468,8 +456,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { if ($i < $premierjourmois) { print '<td class="avant"></td>'."\n"; } else { - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($j = 0; $j < $nbofchoice; $j++) { // show red buttons @@ -501,8 +488,7 @@ print '</div></div>'."\n"; print '<div class="bodydate"><div class="center">'."\n"; // affichage de tous les jours choisis -if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) -{ +if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { //affichage des jours print '<br>'."\n"; print '<div align="left">'; @@ -528,8 +514,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) //affichage de la liste des jours choisis $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { print '<tr>'."\n"; print '<td>'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</td>'; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index cbeb448d2d7..9bf371be2f4 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} $langs->load("opensurvey"); @@ -43,9 +45,10 @@ $creation_sondage_autre = GETPOST('creation_sondage_autre'); // We init some session variable to avoir warning $session_var = array('title', 'description', 'mailsonde'); -foreach ($session_var as $var) -{ - if (isset($_SESSION[$var])) $_SESSION[$var] = null; +foreach ($session_var as $var) { + if (isset($_SESSION[$var])) { + $_SESSION[$var] = null; + } } // On initialise également les autres variables @@ -53,8 +56,7 @@ $cocheplus = ''; $cochemail = ''; // Jump to correct page -if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) -{ +if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) { $_SESSION["title"] = $title; $_SESSION["description"] = $description; @@ -79,11 +81,9 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) $testdate = false; $champdatefin = dol_mktime(0, 0, 0, GETPOST('champdatefinmonth'), GETPOST('champdatefinday'), GETPOST('champdatefinyear')); - if ($champdatefin && ($champdatefin > 0)) // A date was provided - { - // Expire date is not before today - if ($champdatefin >= dol_now()) - { + if ($champdatefin && ($champdatefin > 0)) { // A date was provided + // Expire date is not before today + if ($champdatefin >= dol_now()) { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); } else { @@ -99,16 +99,13 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors'); } - if ($title && $testdate) - { - if (!empty($creation_sondage_date)) - { + if ($title && $testdate) { + if (!empty($creation_sondage_date)) { header("Location: choix_date.php"); exit(); } - if (!empty($creation_sondage_autre)) - { + if (!empty($creation_sondage_autre)) { header("Location: choix_autre.php"); exit(); } @@ -140,8 +137,7 @@ print dol_get_fiche_head(); print '<table class="border centpercent">'."\n"; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td><td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION["title"].'"></td>'."\n"; -if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) -{ +if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); } @@ -170,22 +166,34 @@ print '<br>'."\n"; // Check or not -if ($_SESSION["mailsonde"]) $cochemail = "checked"; +if ($_SESSION["mailsonde"]) { + $cochemail = "checked"; +} print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '.$langs->trans("ToReceiveEMailForEachVote").'<br>'."\n"; -if ($_SESSION['allow_comments']) $allow_comments = 'checked'; -if (GETPOSTISSET('allow_comments')) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; +if ($_SESSION['allow_comments']) { + $allow_comments = 'checked'; +} +if (GETPOSTISSET('allow_comments')) { + $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; +} print '<input type="checkbox" name="allow_comments" '.$allow_comments.'"> '.$langs->trans('CanComment').'<br>'."\n"; -if ($_SESSION['allow_spy']) $allow_spy = 'checked'; -if (GETPOSTISSET('allow_spy')) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; +if ($_SESSION['allow_spy']) { + $allow_spy = 'checked'; +} +if (GETPOSTISSET('allow_spy')) { + $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; +} print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br>'."\n"; -if (GETPOST('choix_sondage')) -{ - if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">'; - else print '<input type="hidden" name="creation_sondage_autre" value="autre">'; +if (GETPOST('choix_sondage')) { + if (GETPOST('choix_sondage') == 'date') { + print '<input type="hidden" name="creation_sondage_date" value="date">'; + } else { + print '<input type="hidden" name="creation_sondage_autre" value="autre">'; + } print '<input type="hidden" name="choix_sondage" value="'.GETPOST('choix_sondage').'">'; print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date' ? $langs->trans("TypeDate") : $langs->trans("TypeClassic")).')">'; } else { diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index 68d660dff3d..fa3d734a488 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -19,7 +19,9 @@ */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -27,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/opensurvey/fonctions.php'; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} $langs->load("opensurvey"); From 3216120f4403c7ec25b2bb04db8c51a915ccfc37 Mon Sep 17 00:00:00 2001 From: Francis Appels <francis.appels@yahoo.com> Date: Fri, 26 Feb 2021 15:38:02 +0100 Subject: [PATCH 146/173] MoLine origin is bomline not bom --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 0f5804490eb..2ee97e9e22a 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -656,7 +656,7 @@ class Mo extends CommonObject $moline->fk_mo = $this->id; $moline->origin_id = $line->id; - $moline->origin_type = 'bom'; + $moline->origin_type = 'bomline'; if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { From 487876101f27e080e4356772be043982d93bd866 Mon Sep 17 00:00:00 2001 From: stickler-ci <support@stickler-ci.com> Date: Fri, 26 Feb 2021 15:00:47 +0000 Subject: [PATCH 147/173] Fixing style errors. --- htdocs/opensurvey/results.php | 4 ++-- htdocs/opensurvey/wizard/create_survey.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index cea5cdbcbee..36228939092 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -264,7 +264,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { // Delete line for ($i = 0; $i < $nblines; $i++) { if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox - // Security check + // Security check if (!$user->rights->opensurvey->write) { accessforbidden(); } @@ -299,7 +299,7 @@ for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox - // Security check + // Security check if (!$user->rights->opensurvey->write) { accessforbidden(); } diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 9bf371be2f4..30e662be7ea 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -82,7 +82,7 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) { $champdatefin = dol_mktime(0, 0, 0, GETPOST('champdatefinmonth'), GETPOST('champdatefinday'), GETPOST('champdatefinyear')); if ($champdatefin && ($champdatefin > 0)) { // A date was provided - // Expire date is not before today + // Expire date is not before today if ($champdatefin >= dol_now()) { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); From 96b0f3a25cdb907c46fc9dc5df011c62b2c15f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 16:19:52 +0100 Subject: [PATCH 148/173] code syntax directory --- .../core/modules/facture/doc/pdf_crabe.modules.php | 5 ++--- .../core/modules/facture/doc/pdf_sponge.modules.php | 5 ++--- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- htdocs/product/card.php | 12 ++++-------- htdocs/product/class/product.class.php | 6 ++---- htdocs/product/list.php | 6 ++---- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d5842b4481f..67e61cb7815 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1053,10 +1053,9 @@ class pdf_crabe extends ModelePDFFactures && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($conf->global->FACTURE_RIB_NUMBER)) { $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); - } - // Avoid having any valid PDF with setup that is not complete - elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) + } elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) { + // Avoid having any valid PDF with setup that is not complete $outputlangs->load("errors"); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index a1da1666629..b1072a50008 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1142,10 +1142,9 @@ class pdf_sponge extends ModelePDFFactures && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($conf->global->FACTURE_RIB_NUMBER)) { $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); - } - // Avoid having any valid PDF with setup that is not complete - elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) + } elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) { + // Avoid having any valid PDF with setup that is not complete $outputlangs->load("errors"); $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 027b3da46ba..6a550018f7a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1719,7 +1719,7 @@ class pdf_cyan extends ModelePDFPropales $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); $mode = 'target'; - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact,$mode, $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 4d4dd8f8ab3..a50eb7bede2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1084,11 +1084,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Batch number management if (!empty($conf->productbatch->enabled)) { print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; - if ( empty($conf->global ->MAIN_ADVANCE_NUMLOT) ) - { + if (empty($conf->global ->MAIN_ADVANCE_NUMLOT)) { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); - } - else { + } else { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); } print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch')); @@ -1550,11 +1548,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($conf->productbatch->enabled) { if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; - if ( empty($conf->global ->MAIN_ADVANCE_NUMLOT) ) - { + if (empty($conf->global ->MAIN_ADVANCE_NUMLOT)) { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); - } - else { + } else { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); } print $form->selectarray('status_batch', $statutarray, $object->status_batch); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0914a191c22..bea9e1173a7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4735,7 +4735,7 @@ class Product extends CommonObject if ($type == 2) { switch ($mode) { case 0: - $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : ($status == 1 || empty($conf->global->MAIN_ADVANCE_NUMLOT) ? $langs->trans('ProductStatusOnBatch') : $langs->trans('ProductStatusOnSerial'))); + $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : ($status == 1 || empty($conf->global->MAIN_ADVANCE_NUMLOT) ? $langs->trans('ProductStatusOnBatch') : $langs->trans('ProductStatusOnSerial'))); return dolGetStatus($label); case 1: $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatchShort') : ($status == 1 || empty($conf->global->MAIN_ADVANCE_NUMLOT) ? $langs->trans('ProductStatusOnBatchShort') : $langs->trans('ProductStatusOnSerialShort'))); @@ -4779,9 +4779,7 @@ class Product extends CommonObject $labelStatus = ($status == 1 || empty($conf->global->MAIN_ADVANCE_NUMLOT) ? $langs->trans('ProductStatusOnBatch') : $langs->trans('ProductStatusOnSerial')); $labelStatusShort = ($status == 1 || empty($conf->global->MAIN_ADVANCE_NUMLOT) ? $langs->trans('ProductStatusOnBatchShort') : $langs->trans('ProductStatusOnSerialShort')); } - } - elseif ( ! empty($conf->global->MAIN_ADVANCE_NUMLOT) && $type == 2 && $status == 2) - { + } elseif (! empty($conf->global->MAIN_ADVANCE_NUMLOT) && $type == 2 && $status == 2) { $labelStatus = $langs->trans('ProductStatusOnSerial'); $labelStatusShort = $langs->trans('ProductStatusOnSerialShort'); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 4ea330e5bee..76f81e43243 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1672,11 +1672,9 @@ if ($resql) { // Lot/Serial if (!empty($arrayfields['p.tobatch']['checked'])) { print '<td class="center">'; - if ( empty($conf->global->MAIN_ADVANCE_NUMLOT) ) - { + if (empty($conf->global->MAIN_ADVANCE_NUMLOT)) { print yn($obj->tobatch); - } - else { + } else { print $product_static->getLibStatut(1, 2); } print '</td>'; From ea18a471137ee8fcef0f395782dbcd2a4b68e775 Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 17:01:53 +0100 Subject: [PATCH 149/173] Fix #16418 missing title in "internal transfer" --- htdocs/compta/bank/transfer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 985a09fb841..1d0613ead0a 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -158,7 +158,10 @@ if ($action == 'add') { * View */ -llxHeader(); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas'; +$title = $langs->trans('MenuBankInternalTransfer'); + +llxHeader('', $title, $help_url); print ' <script type="text/javascript"> $(document).ready(function () { From 07495856875d32c8fcf9996c8148f0d306a5893e Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 17:11:18 +0100 Subject: [PATCH 150/173] Fix #16418 title in "Transaction list by category" --- htdocs/compta/bank/budget.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 5a36e88fa0e..dda8f13437d 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -43,7 +43,10 @@ $result = restrictedArea($user, 'banque'); $companystatic = new Societe($db); -llxHeader(); +$title = $langs->trans('ListTransactionsByCategory'); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas'; + +llxHeader('', $title, $help_url); // List movements bu category for bank transactions print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account'); From 1b6bc8b132107350969a615bcc49443158323063 Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 17:18:09 +0100 Subject: [PATCH 151/173] Fix #16418 missing in "Tags of transactions" --- htdocs/compta/bank/categ.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 5d8f15d9210..48976f8ba25 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -79,7 +79,10 @@ if ($categid) { * View */ -llxHeader(); +$title = $langs->trans('RubriquesTransactions'); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas'; + +llxHeader('', $title, $help_url); print load_fiche_titre($langs->trans("RubriquesTransactions"), '', 'object_category'); From 739cd0466d935ed29a136d97b5c0371b754e7d50 Mon Sep 17 00:00:00 2001 From: daraelmin <daraelmin@gmail.com> Date: Fri, 26 Feb 2021 17:24:39 +0100 Subject: [PATCH 152/173] Fix Dolibarr#16418 missing title in "iNew cCash Fence" --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index ce730df9ee6..d4bec1929ee 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -372,7 +372,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { //var_dump($theoricalamountforterminal); var_dump($theoricalnbofinvoiceforterminal); if ($action != 'close') { - llxHeader(); + llxHeader('', $langs->trans("NewCashFence")); print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); From 5f1d7ee763ac49a12027daa51363b5a93e5fb6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 17:59:31 +0100 Subject: [PATCH 153/173] code syntax ftp holiday directory --- htdocs/ftp/admin/ftpclient.php | 88 +++-- htdocs/ftp/index.php | 284 +++++++------- htdocs/holiday/card.php | 495 +++++++++++------------- htdocs/holiday/class/holiday.class.php | 503 +++++++++++++------------ htdocs/holiday/define_holiday.php | 166 ++++---- htdocs/holiday/document.php | 148 ++++---- htdocs/holiday/info.php | 24 +- htdocs/holiday/list.php | 399 ++++++++++++-------- htdocs/holiday/month_report.php | 215 +++++++---- htdocs/holiday/view_log.php | 149 ++++++-- 10 files changed, 1338 insertions(+), 1133 deletions(-) diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index 6a51d6d0a88..85039a3e6e1 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->loadLangs(array("admin", "ftp")); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $def = array(); $lastftpentry = 0; @@ -45,36 +47,33 @@ $entry = GETPOST('numero_entry', 'alpha'); $sql = "select MAX(name) as name from ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name like 'FTP_SERVER_%'"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $obj = $db->fetch_object($result); preg_match('/([0-9]+)$/i', $obj->name, $reg); - if ($reg[1]) $lastftpentry = $reg[1]; + if ($reg[1]) { + $lastftpentry = $reg[1]; + } } else { dol_print_error($db); } -if ($action == 'add' || GETPOST('modify', 'alpha')) -{ +if ($action == 'add' || GETPOST('modify', 'alpha')) { $ftp_name = "FTP_NAME_".$entry; // $_POST["numero_entry"]; $ftp_server = "FTP_SERVER_".$entry; //$_POST["numero_entry"]; $error = 0; - if (!GETPOST("$ftp_name", 'alpha')) - { + if (!GETPOST("$ftp_name", 'alpha')) { $error = 1; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } - if (!GETPOST("$ftp_server", 'alpha')) - { + if (!GETPOST("$ftp_server", 'alpha')) { $error = 1; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server")), null, 'errors'); } - if (!$error) - { + if (!$error) { $ftp_port = "FTP_PORT_".$entry; $ftp_user = "FTP_USER_".$entry; $ftp_password = "FTP_PASSWORD_".$entry; @@ -83,14 +82,23 @@ if ($action == 'add' || GETPOST('modify', 'alpha')) $db->begin(); $result1 = dolibarr_set_const($db, "FTP_PORT_".$entry, GETPOST($ftp_port, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result1) $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result2) $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result3) $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result4) $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result5) $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity); + if ($result1) { + $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result2) { + $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result3) { + $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result4) { + $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result5) { + $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity); + } - if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) - { + if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -101,21 +109,28 @@ if ($action == 'add' || GETPOST('modify', 'alpha')) } } -if (GETPOST('delete', 'alpha')) -{ - if ($entry) - { +if (GETPOST('delete', 'alpha')) { + if ($entry) { $db->begin(); $result1 = dolibarr_del_const($db, "FTP_PORT_".$entry, $conf->entity); - if ($result1) $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity); - if ($result2) $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity); - if ($result3) $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity); - if ($result4) $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity); - if ($result4) $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity); + if ($result1) { + $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity); + } + if ($result2) { + $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity); + } + if ($result3) { + $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity); + } + if ($result4) { + $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity); + } + if ($result4) { + $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity); + } - if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) - { + if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -139,8 +154,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu print load_fiche_titre($langs->trans("FTPClientSetup"), $linkback, 'title_setup'); print '<br>'; -if (!function_exists('ftp_connect')) -{ +if (!function_exists('ftp_connect')) { print $langs->trans("FTPFeatureNotSupportedByYourPHP"); } else { // Formulaire ajout @@ -186,7 +200,9 @@ if (!function_exists('ftp_connect')) print '<tr class="impair">'; print '<td>'.$langs->trans("FTPPassiveMode").'</td>'; $defaultpassive = GETPOST("FTP_PASSIVE_".($lastftpentry + 1)); - if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1; + if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) { + $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1; + } print '<td>'.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry + 1), $defaultpassive, 2).'</td>'; print '<td>'.$langs->trans("No").'</td>'; print '</tr>'; @@ -211,13 +227,11 @@ if (!function_exists('ftp_connect')) dol_syslog("ftpclient select ftp setup", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); preg_match('/([0-9]+)$/i', $obj->name, $reg); diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 51a8028e1f3..3f04f161038 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -32,13 +32,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; $langs->loadLangs(array('ftp', 'companies', 'other')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ftp', ''); // Get parameters $action = GETPOST('action', 'aZ09'); $section = GETPOST('section'); -if (!$section) $section = '/'; +if (!$section) { + $section = '/'; +} $numero_ftp = GETPOST("numero_ftp"); /* if (! $numero_ftp) $numero_ftp=1; */ $file = GETPOST("file"); @@ -51,12 +55,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "label"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "label"; +} $s_ftp_name = 'FTP_NAME_'.$numero_ftp; $s_ftp_server = 'FTP_SERVER_'.$numero_ftp; @@ -66,7 +76,9 @@ $s_ftp_password = 'FTP_PASSWORD_'.$numero_ftp; $s_ftp_passive = 'FTP_PASSIVE_'.$numero_ftp; $ftp_name = $conf->global->$s_ftp_name; $ftp_server = $conf->global->$s_ftp_server; -$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) $ftp_port = 21; +$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) { + $ftp_port = 21; +} $ftp_user = $conf->global->$s_ftp_user; $ftp_password = $conf->global->$s_ftp_password; $ftp_passive = $conf->global->$s_ftp_passive; @@ -83,29 +95,24 @@ $mesg = ''; */ // Submit file -if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ +if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $result = $ecmdir->fetch(GETPOST("section", 'int')); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - if (dol_mkdir($upload_dir) >= 0) - { + if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0); - if (is_numeric($resupload) && $resupload > 0) - { + if (is_numeric($resupload) && $resupload > 0) { $result = $ecmdir->changeNbOfFiles('+'); } else { $langs->load("errors"); - if ($resupload < 0) // Unknown error - { + if ($resupload < 0) { // Unknown error setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { // Files infected by a virus @@ -123,15 +130,13 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) } // Action ajout d'un rep -if ($action == 'add' && $user->rights->ftp->setup) -{ +if ($action == 'add' && $user->rights->ftp->setup) { $ecmdir->ref = GETPOST("ref"); $ecmdir->label = GETPOST("label"); $ecmdir->description = GETPOST("desc"); $id = $ecmdir->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -141,11 +146,9 @@ if ($action == 'add' && $user->rights->ftp->setup) } // Remove 1 file -if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') -{ +if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -153,11 +156,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -175,8 +176,7 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') } else { $result = @ftp_delete($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs'); } else { dol_syslog("ftp/index.php ftp_delete", LOG_ERR); @@ -192,11 +192,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') } // Delete several lines at once -if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) -{ +if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -204,19 +202,15 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { - foreach (GETPOST('const', 'array') as $const) - { - if ($const["check"]) // Is checkbox checked - { + if ($conn_id && $ok && !$mesg) { + foreach (GETPOST('const', 'array') as $const) { + if ($const["check"]) { // Is checkbox checked $langs->load("other"); // Remote file $file = $const["file"]; $newsection = $const["section"]; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; @@ -229,8 +223,7 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang } else { $result = @ftp_delete($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs'); } else { dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR); @@ -248,11 +241,9 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang } // Remove directory -if ($action == 'confirm_deletesection' && $confirm == 'yes') -{ +if ($action == 'confirm_deletesection' && $confirm == 'yes') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -260,11 +251,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -278,8 +267,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') } else { $result = @ftp_rmdir($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs'); } else { setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors'); @@ -294,11 +282,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') } // Download directory -if ($action == 'download') -{ +if ($action == 'download') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -306,14 +292,12 @@ if ($action == 'download') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { // Local file $localfile = tempnam($download_dir, 'dol_'); $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -327,23 +311,31 @@ if ($action == 'download') } else { $result = ftp_get($conn_id, $localfile, $newremotefileiso, FTP_BINARY); } - if ($result) - { - if (!empty($conf->global->MAIN_UMASK)) - @chmod($localfile, octdec($conf->global->MAIN_UMASK)); + if ($result) { + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($localfile, octdec($conf->global->MAIN_UMASK)); + } // Define mime type $type = 'application/octet-stream'; - if (GETPOSTISSET("type")) $type = GETPOST("type"); - else $type = dol_mimetype($file); + if (GETPOSTISSET("type")) { + $type = GETPOST("type"); + } else { + $type = dol_mimetype($file); + } // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); + if ($type) { + header('Content-Type: '.$type); + } + if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); + } else { + header('Content-Disposition: inline; filename="'.$filename.'"'); + } // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); @@ -374,8 +366,7 @@ if ($action == 'download') llxHeader(); // Add logic to shoow/hide buttons -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { ?> <script type="text/javascript"> jQuery(document).ready(function() { @@ -411,21 +402,17 @@ print load_fiche_titre($langs->trans("FTPArea")); print $langs->trans("FTPAreaDesc")."<br>"; -if (!function_exists('ftp_connect')) -{ +if (!function_exists('ftp_connect')) { print $langs->trans("FTPFeatureNotSupportedByYourPHP"); } else { - if (!empty($ftp_server)) - { + if (!empty($ftp_server)) { // Confirm remove file - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); } // Confirmation de la suppression d'une ligne categorie - if ($action == 'delete_section') - { + if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); } @@ -443,11 +430,11 @@ if (!function_exists('ftp_connect')) print '</a> '; // For other directories $i = 0; - foreach ($sectionarray as $val) - { - if (empty($val)) continue; // Discard first and last entry that should be empty as section start/end with / - if ($i > 0) - { + foreach ($sectionarray as $val) { + if (empty($val)) { + continue; // Discard first and last entry that should be empty as section start/end with / + } + if ($i > 0) { print ' / '; $newsection .= '/'; } @@ -476,14 +463,15 @@ if (!function_exists('ftp_connect')) print '<td class="liste_titre center">'.$langs->trans("Group").'</td>'."\n"; print '<td class="liste_titre center">'.$langs->trans("Permissions").'</td>'."\n"; print '<td class="liste_titre nowrap right">'; - if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> '; + if ($conf->use_javascript_ajax) { + print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> '; + } print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($section ? '&section='.urlencode($section) : '').'">'.img_picto($langs->trans("Refresh"), 'refresh').'</a>&nbsp;'; print '</td>'."\n"; print '</tr>'."\n"; // set up a connection or die - if (empty($conn_id)) - { + if (empty($conn_id)) { $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -491,8 +479,7 @@ if (!function_exists('ftp_connect')) $mesg = $resultarray['mesg']; } - if ($ok) - { + if ($ok) { //$type = ftp_systype($conn_id); $newsection = $section; @@ -500,8 +487,7 @@ if (!function_exists('ftp_connect')) //$newsection='/home'; // List content of directory ($newsection = '/', '/home', ...) - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { if ($newsection == '/') { //$newsection = '/./'; $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 @@ -511,8 +497,7 @@ if (!function_exists('ftp_connect')) //$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./'); $contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection); $buff = array(); - foreach ($contents as $i => $key) - { + foreach ($contents as $i => $key) { $buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key; } } else { @@ -525,31 +510,32 @@ if (!function_exists('ftp_connect')) $nboflines = count($contents); $rawlisthasfailed = false; $i = 0; - while ($i < $nboflines && $i < 1000) - { + while ($i < $nboflines && $i < 1000) { $vals = preg_split('@ +@', utf8_encode($buff[$i]), 9); //$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9); //var_dump($vals); $file = $vals[8]; - if (empty($file)) - { + if (empty($file)) { $rawlisthasfailed = true; $file = utf8_encode($contents[$i]); } - if ($file == '.' || ($file == '..' && $section == '/')) - { + if ($file == '.' || ($file == '..' && $section == '/')) { $i++; continue; } // Is it a directory ? $is_directory = 0; - if ($file == '..') $is_directory = 1; - elseif (!$rawlisthasfailed) - { - if (preg_match('/^d/', $vals[0])) $is_directory = 1; - if (preg_match('/^l/', $vals[0])) $is_link = 1; + if ($file == '..') { + $is_directory = 1; + } elseif (!$rawlisthasfailed) { + if (preg_match('/^d/', $vals[0])) { + $is_directory = 1; + } + if (preg_match('/^l/', $vals[0])) { + $is_link = 1; + } } else { // Remote file $filename = $file; @@ -569,14 +555,21 @@ if (!function_exists('ftp_connect')) print '<td>'; $newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file; $newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa - if ($is_directory) print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">'; + if ($is_directory) { + print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">'; + } print dol_escape_htmltag($file); - if ($is_directory) print '</a>'; + if ($is_directory) { + print '</a>'; + } print '</td>'; // Size print '<td class="center nowrap">'; - if (!$is_directory && !$is_link) print $vals[4]; - else print '&nbsp;'; + if (!$is_directory && !$is_link) { + print $vals[4]; + } else { + print '&nbsp;'; + } print '</td>'; // Date print '<td class="center nowrap">'; @@ -596,12 +589,13 @@ if (!function_exists('ftp_connect')) print '</td>'; // Action print '<td class="right nowrap" width="64">'; - if ($is_directory) - { - if ($file != '..') print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>'; - else print '&nbsp;'; - } elseif ($is_link) - { + if ($is_directory) { + if ($file != '..') { + print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>'; + } else { + print '&nbsp;'; + } + } elseif ($is_link) { $newfile = $file; $newfile = preg_replace('/ ->.*/', '', $newfile); print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>'; @@ -624,8 +618,7 @@ if (!function_exists('ftp_connect')) print "</table>"; - if (!$ok) - { + if (!$ok) { print $mesg.'<br>'."\n"; setEventMessages($mesg, null, 'errors'); } @@ -650,19 +643,16 @@ if (!function_exists('ftp_connect')) $foundsetup = false; $MAXFTP = 20; $i = 1; - while ($i <= $MAXFTP) - { + while ($i <= $MAXFTP) { $paramkey = 'FTP_NAME_'.$i; //print $paramkey; - if (!empty($conf->global->$paramkey)) - { + if (!empty($conf->global->$paramkey)) { $foundsetup = true; break; } $i++; } - if (!$foundsetup) - { + if (!$foundsetup) { print $langs->trans("SetupOfFTPClientModuleNotComplete"); } else { print $langs->trans("ChooseAFTPEntryIntoMenu"); @@ -673,12 +663,9 @@ if (!function_exists('ftp_connect')) print '<br>'; // Close FTP connection -if ($conn_id) -{ - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { - } elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) - { +if ($conn_id) { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { + } elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) { ftp_close($conn_id); } else { ftp_close($conn_id); @@ -709,14 +696,12 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect $ok = 1; $conn_id = null; - if (!is_numeric($ftp_port)) - { + if (!is_numeric($ftp_port)) { $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServer", $ftp_server, $ftp_port); $ok = 0; } - if ($ok) - { + if ($ok) { $connecttimeout = (empty($conf->global->FTP_CONNECT_TIMEOUT) ? 40 : $conf->global->FTP_CONNECT_TIMEOUT); if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { dol_syslog('Try to connect with ssh2_ftp'); @@ -728,15 +713,11 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect dol_syslog('Try to connect with ftp_connect'); $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); } - if ($conn_id || $tmp_conn_id) - { - if ($ftp_user) - { - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if ($conn_id || $tmp_conn_id) { + if ($ftp_user) { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { dol_syslog('Try to authenticate with ssh2_auth_password'); - if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) - { + if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) { // Turn on passive mode transfers (must be after a successful login //if ($ftp_passive) ftp_pasv($conn_id, true); @@ -744,31 +725,31 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect $newsectioniso = utf8_decode($section); //ftp_chdir($conn_id, $newsectioniso); $conn_id = ssh2_sftp($tmp_conn_id); - if (!$conn_id) - { + if (!$conn_id) { dol_syslog('Failed to connect to SFTP after sssh authentication', LOG_DEBUG); $mesg = $langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication"); - $ok = 0; + $ok = 0; $error++; } } else { dol_syslog('Failed to connect to FTP with login '.$ftp_user, LOG_DEBUG); $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); - $ok = 0; + $ok = 0; $error++; } } else { - if (ftp_login($conn_id, $ftp_user, $ftp_password)) - { + if (ftp_login($conn_id, $ftp_user, $ftp_password)) { // Turn on passive mode transfers (must be after a successful login - if ($ftp_passive) ftp_pasv($conn_id, true); + if ($ftp_passive) { + ftp_pasv($conn_id, true); + } // Change the dir $newsectioniso = utf8_decode($section); ftp_chdir($conn_id, $newsectioniso); } else { $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); - $ok = 0; + $ok = 0; $error++; } } @@ -794,8 +775,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect */ function ftp_isdir($connect_id, $dir) { - if (@ftp_chdir($connect_id, $dir)) - { + if (@ftp_chdir($connect_id, $dir)) { ftp_cdup($connect_id); return 1; } else { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index bbd5a1ac9d4..bcd108f6bfe 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -56,7 +56,9 @@ $now = dol_now(); $childids = $user->getAllChildIds(1); $morefilter = ''; -if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) $morefilter = 'AND employee = 1'; +if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) { + $morefilter = 'AND employee = 1'; +} $error = 0; @@ -67,31 +69,43 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if (($id > 0) || $ref) -{ +if (($id > 0) || $ref) { $object->fetch($id, $ref); // Check current user can read this leave request $canread = 0; - if (!empty($user->rights->holiday->readall)) $canread = 1; - if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) $canread = 1; - if (!$canread) - { + if (!empty($user->rights->holiday->readall)) { + $canread = 1; + } + if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } $cancreate = 0; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) $cancreate = 1; -if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate = 1; +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) { + $cancreate = 1; +} +if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) { + $cancreate = 1; +} $candelete = 0; -if (!empty($user->rights->holiday->delete)) $candelete = 1; -if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete = 1; +if (!empty($user->rights->holiday->delete)) { + $candelete = 1; +} +if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) { + $candelete = 1; +} // Protection if external user -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'holiday', $object->id, 'holiday'); @@ -101,14 +115,13 @@ $result = restrictedArea($user, 'holiday', $object->id, 'holiday'); $parameters = array('socid' => $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -116,18 +129,15 @@ if (empty($reshook)) } // Add leave request - if ($action == 'add') - { + if ($action == 'add') { // If no right to create a request - if (!$cancreate) - { + if (!$cancreate) { $error++; setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); $action = 'create'; } - if (!$error) - { + if (!$error) { $object = new Holiday($db); $db->begin(); @@ -140,9 +150,13 @@ if (empty($reshook)) $endhalfday = GETPOST('endhalfday'); $type = GETPOST('type'); $halfday = 0; - if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2; - elseif ($starthalfday == 'afternoon') $halfday = -1; - elseif ($endhalfday == 'morning') $halfday = 1; + if ($starthalfday == 'afternoon' && $endhalfday == 'morning') { + $halfday = 2; + } elseif ($starthalfday == 'afternoon') { + $halfday = -1; + } elseif ($endhalfday == 'morning') { + $halfday = 1; + } $valideur = GETPOST('valideur', 'int'); $description = trim(GETPOST('description', 'restricthtml')); @@ -162,30 +176,26 @@ if (empty($reshook)) } // If no type - if ($type <= 0) - { + if ($type <= 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; $action = 'create'; } // If no start date - if (empty($date_debut)) - { + if (empty($date_debut)) { setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); $error++; $action = 'create'; } // If no end date - if (empty($date_fin)) - { + if (empty($date_fin)) { setEventMessages($langs->trans("NoDateFin"), null, 'errors'); $error++; $action = 'create'; } // If start date after end date - if ($date_debut > $date_fin) - { + if ($date_debut > $date_fin) { setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); $error++; $action = 'create'; @@ -193,8 +203,7 @@ if (empty($reshook)) // Check if there is already holiday for this period $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); - if (!$verifCP) - { + if (!$verifCP) { setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); $error++; $action = 'create'; @@ -202,24 +211,21 @@ if (empty($reshook)) // If there is no Business Days within request $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if ($nbopenedday < 0.5) - { + if ($nbopenedday < 0.5) { setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day $error++; $action = 'create'; } // If no validator designated - if ($valideur < 1) - { + if ($valideur < 1) { setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); $error++; } $result = 0; - if (!$error) - { + if (!$error) { $object->fk_user = $fuserid; $object->description = $description; $object->fk_validator = $valideur; @@ -229,16 +235,14 @@ if (empty($reshook)) $object->halfday = $halfday; $result = $object->create($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } // If no SQL error we redirect to the request card - if (!$error) - { + if (!$error) { $db->commit(); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -249,20 +253,17 @@ if (empty($reshook)) } } - if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) - { + if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { $object->fetch($id); $object->oldcopy = dol_clone($object); $object->fk_validator = GETPOST('valideur', 'int'); - if ($object->fk_validator != $object->oldcopy->fk_validator) - { + if ($object->fk_validator != $object->oldcopy->fk_validator) { $verif = $object->update($user); - if ($verif <= 0) - { + if ($verif <= 0) { setEventMessages($object->error, $object->errors, 'warnings'); $action = 'editvalidator'; } else { @@ -274,8 +275,7 @@ if (empty($reshook)) $action = ''; } - if ($action == 'update' && !GETPOSTISSET('savevalidator')) - { + if ($action == 'update' && !GETPOSTISSET('savevalidator')) { $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); @@ -283,13 +283,16 @@ if (empty($reshook)) $starthalfday = GETPOST('starthalfday'); $endhalfday = GETPOST('endhalfday'); $halfday = 0; - if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2; - elseif ($starthalfday == 'afternoon') $halfday = -1; - elseif ($endhalfday == 'morning') $halfday = 1; + if ($starthalfday == 'afternoon' && $endhalfday == 'morning') { + $halfday = 2; + } elseif ($starthalfday == 'afternoon') { + $halfday = -1; + } elseif ($endhalfday == 'morning') { + $halfday = 1; + } // If no right to modify a request - if (!$user->rights->holiday->write) - { + if (!$user->rights->holiday->write) { setEventMessages($langs->trans("CantUpdate"), null, 'errors'); header('Location: '.$_SERVER["PHP_SELF"].'?action=create'); exit; @@ -298,11 +301,9 @@ if (empty($reshook)) $object->fetch($id); // If under validation - if ($object->statut == Holiday::STATUS_DRAFT) - { + if ($object->statut == Holiday::STATUS_DRAFT) { // If this is the requestor or has read/write rights - if ($cancreate) - { + if ($cancreate) { $valideur = GETPOST('valideur', 'int'); $description = trim(GETPOST('description', 'restricthtml')); @@ -332,8 +333,7 @@ if (empty($reshook)) // If there is no Business Days within request $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if ($nbopenedday < 0.5) - { + if ($nbopenedday < 0.5) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=DureeHoliday'); exit; } @@ -347,8 +347,7 @@ if (empty($reshook)) // Update $verif = $object->update($user); - if ($verif <= 0) - { + if ($verif <= 0) { setEventMessages($object->error, $object->errors, 'warnings'); $action = 'edit'; } else { @@ -366,8 +365,7 @@ if (empty($reshook)) } // If delete of request - if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete) - { + if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete) { $error = 0; $db->begin(); @@ -375,11 +373,9 @@ if (empty($reshook)) $object->fetch($id); // If this is a rough draft, approved, canceled or refused - if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) - { + if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) { // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer - if ($candelete) - { + if ($candelete) { $result = $object->delete($user); } else { $error++; @@ -388,8 +384,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->commit(); header('Location: list.php?restore_lastsearch_values=1'); exit; @@ -399,13 +394,11 @@ if (empty($reshook)) } // Action validate (+ send email for approval) - if ($action == 'confirm_send') - { + if ($action == 'confirm_send') { $object->fetch($id); // If draft and owner of leave - if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) - { + if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { $object->oldcopy = dol_clone($object); $object->statut = Holiday::STATUS_VALIDATED; @@ -413,15 +406,13 @@ if (empty($reshook)) $verif = $object->validate($user); // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) - { + if ($verif > 0) { // To $destinataire = new User($db); $destinataire->fetch($object->fk_validator); $emailTo = $destinataire->email; - if (!$emailTo) - { + if (!$emailTo) { dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; @@ -435,7 +426,9 @@ if (empty($reshook)) // Subject $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); @@ -451,21 +444,17 @@ if (empty($reshook)) $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // Si l'option pour avertir le valideur en cas de délai trop court - if ($object->getConfCP('AlertValidatorDelay')) - { - if ($object->date_debut < $nextMonth) - { + if ($object->getConfCP('AlertValidatorDelay')) { + if ($object->date_debut < $nextMonth) { $message .= "\n"; $message .= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; } } // Si l'option pour avertir le valideur en cas de solde inférieur à la demande - if ($object->getConfCP('AlertValidatorSolde')) - { + if ($object->getConfCP('AlertValidatorSolde')) { $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) - { + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { $message .= "\n"; $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; } @@ -484,8 +473,7 @@ if (empty($reshook)) // Envoi du mail $result = $mail->sendfile(); - if (!$result) - { + if (!$result) { setEventMessages($mail->error, $mail->errors, 'warnings'); $action = ''; } else { @@ -499,37 +487,35 @@ if (empty($reshook)) } } - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('HOLIDAY_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if ($error) + if ($error) { $action = 'edit_extras'; + } } // Approve leave request - if ($action == 'confirm_valid') - { + if ($action == 'confirm_valid') { $object->fetch($id); // If status is waiting approval and approver is also user - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) - { + if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) { $object->oldcopy = dol_clone($object); $object->date_valid = dol_now(); @@ -539,15 +525,13 @@ if (empty($reshook)) $db->begin(); $verif = $object->approve($user); - if ($verif <= 0) - { + if ($verif <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (!$error) - { + if (!$error) { // Calculcate number of days consummed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); @@ -555,30 +539,26 @@ if (empty($reshook)) // On ajoute la modification dans le LOG $result = $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages(null, $object->errors, 'errors'); } //Update balance $result = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages(null, $object->errors, 'errors'); } } - if (!$error) - { + if (!$error) { // To $destinataire = new User($db); $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; - if (!$emailTo) - { + if (!$emailTo) { dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); } else { // From @@ -589,7 +569,9 @@ if (empty($reshook)) // Subject $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); @@ -611,20 +593,18 @@ if (empty($reshook)) // Envoi du mail $result = $mail->sendfile(); - if (!$result) - { + if (!$result) { setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 $action = ''; } } } - if (!$error) - { + if (!$error) { $db->commit(); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } else { $db->rollback(); $action = ''; @@ -632,15 +612,12 @@ if (empty($reshook)) } } - if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') - { - if (!empty($_POST['detail_refuse'])) - { + if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') { + if (!empty($_POST['detail_refuse'])) { $object->fetch($id); // Si statut en attente de validation et valideur = utilisateur - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) - { + if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) { $object->date_refuse = dol_print_date('dayhour', dol_now()); $object->fk_user_refuse = $user->id; $object->statut = Holiday::STATUS_REFUSED; @@ -649,22 +626,19 @@ if (empty($reshook)) $db->begin(); $verif = $object->update($user); - if ($verif <= 0) - { + if ($verif <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (!$error) - { + if (!$error) { // To $destinataire = new User($db); $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; - if (!$emailTo) - { + if (!$emailTo) { dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); } else { // From @@ -675,7 +649,9 @@ if (empty($reshook)) // Subject $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); @@ -698,8 +674,7 @@ if (empty($reshook)) // Envoi du mail $result = $mail->sendfile(); - if (!$result) - { + if (!$result) { setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 $action = ''; } @@ -708,8 +683,7 @@ if (empty($reshook)) $action = ''; } - if (!$error) - { + if (!$error) { $db->commit(); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -727,8 +701,7 @@ if (empty($reshook)) // Si Validation de la demande - if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') - { + if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') { $error = 0; $object->fetch($id); @@ -737,14 +710,12 @@ if (empty($reshook)) $object->statut = Holiday::STATUS_DRAFT; $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors'); } - if (!$error) - { + if (!$error) { $db->commit(); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -755,16 +726,14 @@ if (empty($reshook)) } // Si confirmation of cancellation - if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') - { + if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') { $error = 0; $object->fetch($id); // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))) - { + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))) { $db->begin(); $oldstatus = $object->statut; @@ -774,9 +743,8 @@ if (empty($reshook)) $result = $object->update($user); - if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) // holiday was already validated, status 3, so we must increase back the balance - { - // Calculcate number of days consummed + if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) { // holiday was already validated, status 3, so we must increase back the balance + // Calculcate number of days consummed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); @@ -788,30 +756,26 @@ if (empty($reshook)) // Mise à jour du solde $result2 = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - if ($result1 < 0 || $result2 < 0) - { + if ($result1 < 0 || $result2 < 0) { $error++; setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors'); } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); } // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (!$error && $result > 0) - { + if (!$error && $result > 0) { // To $destinataire = new User($db); $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; - if (!$emailTo) - { + if (!$emailTo) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } @@ -824,12 +788,14 @@ if (empty($reshook)) // Subject $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message .= "\n"; $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; @@ -845,8 +811,7 @@ if (empty($reshook)) // Envoi du mail $result = $mail->sendfile(); - if (!$result) - { + if (!$result) { setEventMessages($mail->error, $mail->errors, 'warnings'); $action = ''; } else { @@ -887,11 +852,9 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t llxHeader('', $langs->trans('CPTitreMenu')); -if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') -{ +if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // If user has no permission to create a leave - if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)))) - { + if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)))) { $errors[] = $langs->trans('CantCreateCP'); } else { // Form to add a leave request @@ -900,28 +863,28 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') // Error management if (GETPOST('error')) { switch (GETPOST('error')) { - case 'datefin' : + case 'datefin': $errors[] = $langs->trans('ErrorEndDateCP'); break; - case 'SQL_Create' : + case 'SQL_Create': $errors[] = $langs->trans('ErrorSQLCreateCP').' <b>'.htmlentities($_GET['msg']).'</b>'; break; - case 'CantCreate' : + case 'CantCreate': $errors[] = $langs->trans('CantCreateCP'); break; - case 'Valideur' : + case 'Valideur': $errors[] = $langs->trans('InvalidValidatorCP'); break; - case 'nodatedebut' : + case 'nodatedebut': $errors[] = $langs->trans('NoDateDebut'); break; - case 'nodatefin' : + case 'nodatefin': $errors[] = $langs->trans('NoDateFin'); break; - case 'DureeHoliday' : + case 'DureeHoliday': $errors[] = $langs->trans('ErrorDureeCP'); break; - case 'alreadyCP' : + case 'alreadyCP': $errors[] = $langs->trans('alreadyCPexist'); break; } @@ -974,8 +937,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $out = ''; $typeleaves = $object->getTypes(1, 1); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $nb_type = $object->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; @@ -1002,8 +964,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '<td class="titlefield fieldrequired">'.$langs->trans("User").'</td>'; print '<td>'; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) - { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) { print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); //print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">'; } else { @@ -1018,14 +979,15 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '<td>'; $typeleaves = $object->getTypes(1, -1); $arraytypeleaves = array(); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td>'; print '</tr>'; @@ -1075,8 +1037,12 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); } else { $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); // Will work only if supervisor has permission to approve so is inside include_users - if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver - if (GETPOST('valideur', 'int') > 0) $defaultselectuser = GETPOST('valideur', 'int'); + if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) { + $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver + } + if (GETPOST('valideur', 'int') > 0) { + $defaultselectuser = GETPOST('valideur', 'int'); + } $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } @@ -1117,8 +1083,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '</div>'; } else { // Affichage de la fiche d'une demande de congés payés - if (($id > 0) || $ref) - { + if (($id > 0) || $ref) { $result = $object->fetch($id, $ref); $valideur = new User($db); @@ -1130,35 +1095,33 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') //print load_fiche_titre($langs->trans('TitreRequestCP')); // Si il y a une erreur - if (GETPOST('error')) - { - switch (GETPOST('error')) - { - case 'datefin' : + if (GETPOST('error')) { + switch (GETPOST('error')) { + case 'datefin': $errors[] = $langs->transnoentitiesnoconv('ErrorEndDateCP'); break; - case 'SQL_Create' : + case 'SQL_Create': $errors[] = $langs->transnoentitiesnoconv('ErrorSQLCreateCP').' '.$_GET['msg']; break; - case 'CantCreate' : + case 'CantCreate': $errors[] = $langs->transnoentitiesnoconv('CantCreateCP'); break; - case 'Valideur' : + case 'Valideur': $errors[] = $langs->transnoentitiesnoconv('InvalidValidatorCP'); break; - case 'nodatedebut' : + case 'nodatedebut': $errors[] = $langs->transnoentitiesnoconv('NoDateDebut'); break; - case 'nodatefin' : + case 'nodatefin': $errors[] = $langs->transnoentitiesnoconv('NoDateFin'); break; - case 'DureeHoliday' : + case 'DureeHoliday': $errors[] = $langs->transnoentitiesnoconv('ErrorDureeCP'); break; - case 'NoMotifRefuse' : + case 'NoMotifRefuse': $errors[] = $langs->transnoentitiesnoconv('NoMotifRefuseCP'); break; - case 'mail' : + case 'mail': $errors[] = $langs->transnoentitiesnoconv('ErrorMailNotSend')."\n".$_GET['error_content']; break; } @@ -1167,13 +1130,13 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') } // On vérifie si l'utilisateur à le droit de lire cette demande - if ($cancreate) - { + if ($cancreate) { $head = holiday_prepare_head($object); - if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) - { - if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) $edit = true; + if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) { + if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) { + $edit = true; + } print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'" />'."\n"; @@ -1215,8 +1178,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon'; - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td class="nowrap">'; print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); @@ -1239,8 +1201,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '</tr>'; } - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td class="nowrap">'; print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); @@ -1269,8 +1230,12 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $htmlhelp = $langs->trans('NbUseDaysCPHelp'); $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); - if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); - if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + if ($includesaturday) { + $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); + } + if ($includesunday) { + $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + } print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); print '</td>'; print '<td>'; @@ -1278,8 +1243,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '</td>'; print '</tr>'; - if ($object->statut == Holiday::STATUS_REFUSED) - { + if ($object->statut == Holiday::STATUS_REFUSED) { print '<tr>'; print '<td>'.$langs->trans('DetailRefusCP').'</td>'; print '<td>'.$object->detail_refuse.'</td>'; @@ -1287,8 +1251,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') } // Description - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td>'.$langs->trans('DescCP').'</td>'; print '<td>'.nl2br($object->description).'</td>'; @@ -1318,8 +1281,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '<table class="border tableforfield centpercent">'."\n"; print '<tbody>'; - if (!empty($object->fk_user_create)) - { + if (!empty($object->fk_user_create)) { $userCreate = new User($db); $userCreate->fetch($object->fk_user_create); print '<tr>'; @@ -1332,13 +1294,15 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') if (!$edit && $action != 'editvalidator') { print '<tr>'; print '<td class="titlefield">'; - if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) print $langs->trans('ApprovedBy'); - else print $langs->trans('ReviewedByCP'); + if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) { + print $langs->trans('ApprovedBy'); + } else { + print $langs->trans('ReviewedByCP'); + } print '</td>'; print '<td>'.$valideur->getNomUrl(-1); $include_users = $object->fetch_users_approver_holiday(); - if (is_array($include_users) && in_array($user->id, $include_users) && $object->statut == Holiday::STATUS_VALIDATED) - { + if (is_array($include_users) && in_array($user->id, $include_users) && $object->statut == Holiday::STATUS_VALIDATED) { print '<a class="editfielda paddingleft" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editvalidator">'.img_edit($langs->trans("Edit")).'</a>'; } print '</td>'; @@ -1348,18 +1312,17 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>'; print '<td>'; $include_users = $object->fetch_users_approver_holiday(); - if (!in_array($object->fk_validator, $include_users)) // Add the current validator to the list to not lose it when editing. - { + if (!in_array($object->fk_validator, $include_users)) { // Add the current validator to the list to not lose it when editing. $include_users[] = $object->fk_validator; } - if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); - else { + if (empty($include_users)) { + print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + } else { $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ? '' : array($user->id)); // Nobody if we are admin or if we are not the user of the leave. $s = $form->select_dolusers($object->fk_validator, "valideur", (($action == 'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } - if ($action == 'editvalidator') - { + if ($action == 'editvalidator') { print '<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; } @@ -1402,52 +1365,42 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') // Confirmation messages - if ($action == 'delete') - { - if ($user->rights->holiday->delete) - { + if ($action == 'delete') { + if ($user->rights->holiday->delete) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleDeleteCP"), $langs->trans("ConfirmDeleteCP"), "confirm_delete", '', 0, 1); } } // Si envoi en validation - if ($action == 'sendToValidate' && $object->statut == Holiday::STATUS_DRAFT) - { + if ($action == 'sendToValidate' && $object->statut == Holiday::STATUS_DRAFT) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleToValidCP"), $langs->trans("ConfirmToValidCP"), "confirm_send", '', 1, 1); } // Si validation de la demande - if ($action == 'valid') - { + if ($action == 'valid') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleValidCP"), $langs->trans("ConfirmValidCP"), "confirm_valid", '', 1, 1); } // Si refus de la demande - if ($action == 'refuse') - { + if ($action == 'refuse') { $array_input = array(array('type'=>"text", 'label'=> $langs->trans('DetailRefusCP'), 'name'=>"detail_refuse", 'size'=>"50", 'value'=>"")); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0); } // Si annulation de la demande - if ($action == 'cancel') - { + if ($action == 'cancel') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleCancelCP"), $langs->trans("ConfirmCancelCP"), "confirm_cancel", '', 1, 1); } // Si back to draft - if ($action == 'backtodraft') - { + if ($action == 'backtodraft') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleSetToDraft"), $langs->trans("ConfirmSetToDraft"), "confirm_draft", '', 1, 1); } - if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) - { - if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) - { + if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) { + if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) { print '<div class="center">'; - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) - { + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print '<input type="submit" value="'.$langs->trans("Save").'" class="button button-save">'; } print '</div>'; @@ -1456,24 +1409,19 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '</form>'; } - if (!$edit) - { + if (!$edit) { // Buttons for actions print '<div class="tabsAction">'; - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) - { + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit" class="butAction">'.$langs->trans("EditCP").'</a>'; } - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) // If draft - { + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { // If draft print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=sendToValidate" class="butAction">'.$langs->trans("Validate").'</a>'; } - if ($object->statut == Holiday::STATUS_VALIDATED) // If validated - { - if ($user->id == $object->fk_validator) - { + if ($object->statut == Holiday::STATUS_VALIDATED) { // If validated + if ($user->id == $object->fk_validator) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>'; } else { @@ -1481,17 +1429,17 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>'; } } - if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved - { - if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>'; - else print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>'; + if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) && ($object->statut == 2 || $object->statut == 3)) { // Status validated or approved + if (($object->date_debut > dol_now()) || $user->admin) { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>'; + } else { + print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>'; + } } - if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) - { + if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>'; } - if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused - { + if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) { // If draft or canceled or refused print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>'; } @@ -1516,8 +1464,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre @@ -1560,4 +1507,6 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') // End of page llxFooter(); -if (is_object($db)) $db->close(); +if (is_object($db)) { + $db->close(); +} diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index f61c0a66ca8..b28d2ef4756 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -170,13 +170,11 @@ class Holiday extends CommonObject global $langs, $conf; $langs->load("order"); - if (empty($conf->global->HOLIDAY_ADDON)) - { + if (empty($conf->global->HOLIDAY_ADDON)) { $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } - if (!empty($conf->global->HOLIDAY_ADDON)) - { + if (!empty($conf->global->HOLIDAY_ADDON)) { $mybool = false; $file = $conf->global->HOLIDAY_ADDON.".php"; @@ -184,16 +182,14 @@ class Holiday extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/holiday/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -201,8 +197,7 @@ class Holiday extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($objsoc, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -230,8 +225,7 @@ class Holiday extends CommonObject // Check nb of users into table llx_holiday_users and update with empty lines //if ($result > 0) $result = $this->verifNbUsers($this->countActiveUsersWithoutCP(), $this->getConfCP('nbUser')); - if ($result >= 0) - { + if ($result >= 0) { $this->db->commit(); return 1; } else { @@ -255,9 +249,15 @@ class Holiday extends CommonObject $now = dol_now(); // Check parameters - if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; } - if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; } - if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; } + if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { + $this->error = "ErrorBadParameterFkUser"; return -1; + } + if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { + $this->error = "ErrorBadParameterFkValidator"; return -1; + } + if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { + $this->error = "ErrorBadParameterFkType"; return -1; + } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; @@ -296,32 +296,33 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); - if ($this->id) - { + if ($this->id) { // update ref $initialref = '(PROV'.$this->id.')'; - if (!empty($this->ref)) $initialref = $this->ref; + if (!empty($this->ref)) { + $initialref = $this->ref; + } $sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->ref = $initialref; - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('HOLIDAY_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -329,10 +330,8 @@ class Holiday extends CommonObject } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -380,15 +379,16 @@ class Holiday extends CommonObject $sql .= " cp.fk_type,"; $sql .= " cp.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - if ($id > 0) $sql .= " WHERE cp.rowid = ".$id; - else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'"; + if ($id > 0) { + $sql .= " WHERE cp.rowid = ".$id; + } else { + $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'"; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -693,8 +693,7 @@ class Holiday extends CommonObject $error = 0; // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) { $num = $this->getNextNumRef(null); } else { $num = $this->ref; @@ -719,22 +718,20 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('HOLIDAY_VALIDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::validate ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -831,22 +828,20 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('HOLIDAY_APPROVE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::approve ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -942,22 +937,20 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('HOLIDAY_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -993,22 +986,20 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('HOLIDAY_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -1037,60 +1028,67 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user, '', ''); - foreach ($this->holiday as $infos_CP) - { - if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays - if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays + foreach ($this->holiday as $infos_CP) { + if ($infos_CP['statut'] == 4) { + continue; // ignore not validated holidays + } + if ($infos_CP['statut'] == 5) { + continue; // ignore not validated holidays + } /* var_dump("--"); var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']); var_dump("new: ".dol_print_date($dateStart,'dayhour').' '.dol_print_date($dateEnd,'dayhour').' '.$halfday); */ - if ($halfday == 0) - { - if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) - { + if ($halfday == 0) { + if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) { return false; } - if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) - { + if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) { return false; } - } elseif ($halfday == -1) - { + } elseif ($halfday == -1) { // new start afternoon, new end afternoon - if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) - { - if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false; + if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) { + if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) { + return false; + } } - if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) - { - if ($dateStart < $dateEnd) return false; - if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false; + if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) { + if ($dateStart < $dateEnd) { + return false; + } + if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) { + return false; + } } - } elseif ($halfday == 1) - { + } elseif ($halfday == 1) { // new start morning, new end morning - if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) - { - if ($dateStart < $dateEnd) return false; - if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false; + if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) { + if ($dateStart < $dateEnd) { + return false; + } + if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) { + return false; + } } - if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) - { - if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false; + if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) { + if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) { + return false; + } } - } elseif ($halfday == 2) - { + } elseif ($halfday == 2) { // new start afternoon, new end morning - if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) - { - if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false; + if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) { + if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) { + return false; + } } - if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) - { - if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false; + if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) { + if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) { + return false; + } } } else { dol_print_error('', 'Bad value of parameter halfday when calling function verifDateHolidayCP'); @@ -1123,18 +1121,17 @@ class Holiday extends CommonObject $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql .= " AND cp.fk_user = ".(int) $fk_user; $sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; - if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")"; + if ($status != '-1') { + $sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")"; + } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon - if ($num_rows > 0) - { + if ($num_rows > 0) { $arrayofrecord = array(); $i = 0; - while ($i < $num_rows) - { + while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); // Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning @@ -1144,27 +1141,39 @@ class Holiday extends CommonObject // We found a record, user is on holiday by default, so is not available is true. $isavailablemorning = true; - foreach ($arrayofrecord as $record) - { - if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue; - if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue; + foreach ($arrayofrecord as $record) { + if ($timestamp == $record['date_start'] && $record['halfday'] == 2) { + continue; + } + if ($timestamp == $record['date_start'] && $record['halfday'] == -1) { + continue; + } $isavailablemorning = false; break; } $isavailableafternoon = true; - foreach ($arrayofrecord as $record) - { - if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue; - if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue; + foreach ($arrayofrecord as $record) { + if ($timestamp == $record['date_end'] && $record['halfday'] == 2) { + continue; + } + if ($timestamp == $record['date_end'] && $record['halfday'] == 1) { + continue; + } $isavailableafternoon = false; break; } } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } $result = array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon); - if (!$isavailablemorning) $result['morning_reason'] = 'leave_request'; - if (!$isavailableafternoon) $result['afternoon_reason'] = 'leave_request'; + if (!$isavailablemorning) { + $result['morning_reason'] = 'leave_request'; + } + if (!$isavailableafternoon) { + $result['afternoon_reason'] = 'leave_request'; + } return $result; } @@ -1194,16 +1203,24 @@ class Holiday extends CommonObject //{ // 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'; + 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 = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; return $result; @@ -1233,8 +1250,7 @@ class Holiday extends CommonObject public function LibStatut($status, $mode = 0, $startdate = '') { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('DraftCP'); @@ -1250,11 +1266,21 @@ class Holiday extends CommonObject } $statusType = 'status6'; - if (!empty($startdate) && $startdate > dol_now()) $statusType = 'status4'; - if ($status == self::STATUS_DRAFT) $statusType = 'status0'; - if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_CANCELED) $statusType = 'status5'; - if ($status == self::STATUS_REFUSED) $statusType = 'status5'; + if (!empty($startdate) && $startdate > dol_now()) { + $statusType = 'status4'; + } + if ($status == self::STATUS_DRAFT) { + $statusType = 'status0'; + } + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status1'; + } + if ($status == self::STATUS_CANCELED) { + $statusType = 'status5'; + } + if ($status == self::STATUS_REFUSED) { + $statusType = 'status5'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -1338,15 +1364,12 @@ class Holiday extends CommonObject if ($result) { $obj = $this->db->fetch_object($result); // Return value - if (empty($obj)) - { - if ($createifnotfound) - { + if (empty($obj)) { + if ($createifnotfound) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)"; $sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return $createifnotfound; } else { $this->error = $this->db->lasterror(); @@ -1379,8 +1402,7 @@ class Holiday extends CommonObject $error = 0; - if (empty($userID) && empty($nbHoliday) && empty($fk_type)) - { + if (empty($userID) && empty($nbHoliday) && empty($fk_type)) { $langs->load("holiday"); // Si mise à jour pour tout le monde en début de mois @@ -1395,8 +1417,7 @@ class Holiday extends CommonObject //print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit; // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp - if ($month != $monthLastUpdate) - { + if ($month != $monthLastUpdate) { $this->db->begin(); $users = $this->fetchUsers(false, false); @@ -1412,7 +1433,9 @@ class Holiday extends CommonObject // Update each user counter foreach ($users as $userCounter) { $nbDaysToAdd = (isset($typeleaves[$userCounter['type']]['newByMonth']) ? $typeleaves[$userCounter['type']]['newByMonth'] : 0); - if (empty($nbDaysToAdd)) continue; + if (empty($nbDaysToAdd)) { + continue; + } dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); @@ -1424,15 +1447,13 @@ class Holiday extends CommonObject $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1449,19 +1470,16 @@ class Holiday extends CommonObject $sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users"; $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; $sql .= " nb_holiday = ".$nbHoliday; $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -1471,8 +1489,7 @@ class Holiday extends CommonObject $sql .= $nbHoliday; $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -1482,8 +1499,7 @@ class Holiday extends CommonObject $error++; } - if (!$error) - { + if (!$error) { return 1; } else { return -1; @@ -1527,19 +1543,19 @@ class Holiday extends CommonObject public function createCPusers($single = false, $userid = '') { // do we have to add balance for all users ? - if (!$single) - { + if (!$single) { dol_syslog(get_class($this).'::createCPusers'); $arrayofusers = $this->fetchUsers(false, true); - foreach ($arrayofusers as $users) - { + foreach ($arrayofusers as $users) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql .= " (fk_user, nb_holiday)"; $sql .= " VALUES (".((int) $users['rowid'])."', '0')"; $resql = $this->db->query($sql); - if (!$resql) dol_print_error($this->db); + if (!$resql) { + dol_print_error($this->db); + } } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; @@ -1547,7 +1563,9 @@ class Holiday extends CommonObject $sql .= " VALUES (".((int) $userid)."', '0')"; $resql = $this->db->query($sql); - if (!$resql) dol_print_error($this->db); + if (!$resql) { + dol_print_error($this->db); + } } } @@ -1579,16 +1597,20 @@ class Holiday extends CommonObject $sql = "SELECT nb_holiday"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users"; $sql .= " WHERE fk_user = ".(int) $user_id; - if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type; + if ($fk_type > 0) { + $sql .= " AND fk_type = ".(int) $fk_type; + } dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); //return number_format($obj->nb_holiday,2); - if ($obj) return $obj->nb_holiday; - else return null; + if ($obj) { + return $obj->nb_holiday; + } else { + return null; + } } else { return null; } @@ -1608,10 +1630,8 @@ class Holiday extends CommonObject dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG); - if ($stringlist) - { - if ($type) - { + if ($stringlist) { + if ($type) { // If user of Dolibarr $sql = "SELECT"; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { @@ -1620,8 +1640,7 @@ class Holiday extends CommonObject $sql .= " u.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " WHERE ((ug.fk_user = u.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; @@ -1630,7 +1649,9 @@ class Holiday extends CommonObject $sql .= " WHERE u.entity IN (".getEntity('user').")"; } $sql .= " AND u.statut > 0"; - if ($filters) $sql .= $filters; + if ($filters) { + $sql .= $filters; + } $resql = $this->db->query($sql); @@ -1641,8 +1662,7 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($i == 0) { @@ -1665,7 +1685,9 @@ class Holiday extends CommonObject $sql = "SELECT DISTINCT cpu.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE cpu.fk_user = u.rowid"; - if ($filters) $sql .= $filters; + if ($filters) { + $sql .= $filters; + } $resql = $this->db->query($sql); @@ -1676,8 +1698,7 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($i == 0) { @@ -1699,8 +1720,7 @@ class Holiday extends CommonObject } else { // Si faux donc return array // List for Dolibarr users - if ($type) - { + if ($type) { // If user of Dolibarr $sql = "SELECT"; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { @@ -1709,8 +1729,7 @@ class Holiday extends CommonObject $sql .= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " WHERE ((ug.fk_user = u.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; @@ -1720,13 +1739,14 @@ class Holiday extends CommonObject } $sql .= " AND u.statut > 0"; - if ($filters) $sql .= $filters; + if ($filters) { + $sql .= $filters; + } $resql = $this->db->query($sql); // Si pas d'erreur SQL - if ($resql) - { + if ($resql) { $i = 0; $tab_result = $this->holiday; $num = $this->db->num_rows($resql); @@ -1761,20 +1781,20 @@ class Holiday extends CommonObject $sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE cpu.fk_user = u.rowid"; - if ($filters) $sql .= $filters; + if ($filters) { + $sql .= $filters; + } $resql = $this->db->query($sql); // Si pas d'erreur SQL - if ($resql) - { + if ($resql) { $i = 0; $tab_result = $this->holiday; $num = $this->db->num_rows($resql); // Boucles du listage des utilisateurs - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user @@ -1827,11 +1847,9 @@ class Holiday extends CommonObject dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; - while ($i < $num_rows) - { + while ($i < $num_rows) { $objp = $this->db->fetch_object($result); array_push($users_validator, $objp->fk_user); $i++; @@ -1888,7 +1906,9 @@ class Holiday extends CommonObject */ public function verifNbUsers($userDolibarrWithoutCP, $userCP) { - if (empty($userCP)) $userCP = 0; + if (empty($userCP)) { + $userCP = 0; + } dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); return 1; } @@ -1914,7 +1934,9 @@ class Holiday extends CommonObject $new_solde = price2num($new_solde, 5); //print "$prev_solde == $new_solde"; - if ($prev_solde == $new_solde) return 0; + if ($prev_solde == $new_solde) { + return 0; + } $this->db->begin(); @@ -1938,21 +1960,17 @@ class Holiday extends CommonObject $sql .= ")"; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { + if (!$error) { $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -2051,23 +2069,26 @@ class Holiday extends CommonObject $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; - if ($active >= 0) $sql .= " AND active = ".((int) $active); - if ($affect >= 0) $sql .= " AND affect = ".((int) $affect); + if ($active >= 0) { + $sql .= " AND active = ".((int) $active); + } + if ($affect >= 0) { + $sql .= " AND affect = ".((int) $affect); + } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); - if ($num) - { - while ($obj = $this->db->fetch_object($result)) - { + if ($num) { + while ($obj = $this->db->fetch_object($result)) { $types[$obj->rowid] = array('rowid'=> $obj->rowid, 'code'=> $obj->code, 'label'=>$obj->label, 'affect'=>$obj->affect, 'delay'=>$obj->delay, 'newByMonth'=>$obj->newByMonth); } return $types; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } return array(); } @@ -2099,10 +2120,8 @@ class Holiday extends CommonObject $sql .= " AND f.entity = ".$conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -2116,26 +2135,22 @@ class Holiday extends CommonObject $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; - if ($obj->fk_user_creation) - { + if ($obj->fk_user_creation) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creation); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_modification) - { + if ($obj->fk_user_modification) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modification); $this->user_modification = $muser; } - if ($obj->fk_user_approve) - { + if ($obj->fk_user_approve) { $auser = new User($this->db); $auser->fetch($obj->fk_user_approve); $this->user_approve = $auser; @@ -2191,8 +2206,7 @@ class Holiday extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; $sql .= " WHERE h.statut > 1"; $sql .= " AND h.entity IN (".getEntity('holiday').")"; - if (empty($user->rights->expensereport->readall)) - { + if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); $sql .= " AND (h.fk_user IN (".join(',', $userchildids).")"; $sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))"; @@ -2224,7 +2238,9 @@ class Holiday 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 + } $now = dol_now(); @@ -2232,16 +2248,14 @@ class Holiday extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; $sql .= " WHERE h.statut = 2"; $sql .= " AND h.entity IN (".getEntity('holiday').")"; - if (empty($user->rights->expensereport->read_all)) - { + if (empty($user->rights->expensereport->read_all)) { $userchildids = $user->getAllChildIds(1); $sql .= " AND (h.fk_user IN (".join(',', $userchildids).")"; $sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))"; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $langs->load("members"); $response = new WorkboardResponse(); @@ -2251,8 +2265,7 @@ class Holiday extends CommonObject $response->url = DOL_URL_ROOT.'/holiday/list.php?search_statut=2&amp;mainmenu=hrm&amp;leftmenu=holiday'; $response->img = img_object('', "holiday"); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; if ($this->db->jdate($obj->date_debut) < ($now - $conf->holiday->approve->warning_delay)) { diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index d3a2f23019f..e57e12dcaee 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -44,19 +44,29 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "t.rowid"; // Set here default search field -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.rowid"; // Set here default search field +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Protection if external user -if ($user->socid > 0) accessforbidden(); +if ($user->socid > 0) { + accessforbidden(); +} // If the user does not have perm to read the page -if (empty($user->rights->holiday->read)) accessforbidden(); +if (empty($user->rights->holiday->read)) { + accessforbidden(); +} // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -65,8 +75,7 @@ $extrafields = new ExtraFields($db); $holiday = new Holiday($db); -if (empty($conf->holiday->enabled)) -{ +if (empty($conf->holiday->enabled)) { llxHeader('', $langs->trans('CPTitreMenu')); print '<div class="tabBar">'; print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>'; @@ -81,21 +90,25 @@ if (empty($conf->holiday->enabled)) * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_name = ''; $search_supervisor = ''; $toselect = ''; @@ -104,17 +117,16 @@ if (empty($reshook)) // Mass actions /* - $objectclass='Skeleton'; - $objectlabel='Skeleton'; - $permissiontoread = $user->rights->skeleton->read; - $permissiontodelete = $user->rights->skeleton->delete; - $uploaddir = $conf->skeleton->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - */ + $objectclass='Skeleton'; + $objectlabel='Skeleton'; + $permissiontoread = $user->rights->skeleton->read; + $permissiontodelete = $user->rights->skeleton->delete; + $uploaddir = $conf->skeleton->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ // Si il y a une action de mise à jour - if ($action == 'update' && isset($_POST['update_cp'])) - { + if ($action == 'update' && isset($_POST['update_cp'])) { $error = 0; $typeleaves = $holiday->getTypes(1, 1); @@ -122,13 +134,11 @@ if (empty($reshook)) $userID = array_keys($_POST['update_cp']); $userID = $userID[0]; - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $userValue = $_POST['nb_holiday_'.$val['rowid']]; $userValue = $userValue[$userID]; - if (!empty($userValue) || (string) $userValue == '0') - { + if (!empty($userValue) || (string) $userValue == '0') { $userValue = price2num($userValue, 5); } else { $userValue = ''; @@ -138,37 +148,36 @@ if (empty($reshook)) $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); //print 'holiday: '.$val['rowid'].'-'.$userValue; - if ($userValue != '') - { + if ($userValue != '') { // We add the modification to the log (must be before update of sold because we read current value of sold) $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']); - if ($result < 0) - { + if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; } // Update of the days of the employee $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']); - if ($result < 0) - { + if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; } // If it first update of balance, we set date to avoid to have sold incremented by new month /* - $now=dol_now(); - $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; - $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. - dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); - $result = $db->query($sql); - */ + $now=dol_now(); + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; + $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; + $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. + dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); + $result = $db->query($sql); + */ } } - if (!$error) setEventMessages('UpdateConfCPOK', '', 'mesgs'); + if (!$error) { + setEventMessages('UpdateConfCPOK', '', 'mesgs'); + } } } @@ -191,7 +200,9 @@ if ($result < 0) { print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="update">'; @@ -217,35 +228,36 @@ $filters = ''; // Filter on array of ids of all childs $userchilds = array(); -if (empty($user->rights->holiday->readall)) -{ +if (empty($user->rights->holiday->readall)) { $userchilds = $user->getAllChildIds(1); $filters .= ' AND u.rowid IN ('.join(', ', $userchilds).')'; } if (!empty($search_name)) { $filters .= natural_search(array('u.firstname', 'u.lastname'), $search_name); } -if ($search_supervisor > 0) $filters .= natural_search(array('u.fk_user'), $search_supervisor, 2); +if ($search_supervisor > 0) { + $filters .= natural_search(array('u.fk_user'), $search_supervisor, 2); +} $filters .= ' AND employee = 1'; // Only employee users are visible $listUsers = $holiday->fetchUsers(false, true, $filters); -if (is_numeric($listUsers) && $listUsers < 0) -{ +if (is_numeric($listUsers) && $listUsers < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); } $i = 0; -if (count($typeleaves) == 0) -{ +if (count($typeleaves) == 0) { //print '<div class="info">'; print $langs->trans("NoLeaveWithCounterDefined")."<br>\n"; print $langs->trans("GoIntoDictionaryHolidayTypes"); //print '</div>'; } else { $canedit = 0; - if (!empty($user->rights->holiday->define_holiday)) $canedit = 1; + if (!empty($user->rights->holiday->define_holiday)) { + $canedit = 1; + } $moreforfilter = ''; @@ -263,10 +275,8 @@ if (count($typeleaves) == 0) print '</td>'; // Type of leave request - if (count($typeleaves)) - { - foreach ($typeleaves as $key => $val) - { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { print '<td class="liste_titre" style="text-align:center"></td>'; } } else { @@ -285,10 +295,8 @@ if (count($typeleaves) == 0) print '<tr class="liste_titre">'; print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]); print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]); - if (count($typeleaves)) - { - foreach ($typeleaves as $key => $val) - { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { $labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']); print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center '); } @@ -301,12 +309,12 @@ if (count($typeleaves) == 0) $usersupervisor = new User($db); - foreach ($listUsers as $users) - { + foreach ($listUsers as $users) { // If user has not permission to edit/read all, we must see only subordinates - if (empty($user->rights->holiday->readall)) - { - if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it. + if (empty($user->rights->holiday->readall)) { + if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) { + continue; // This user is not into hierarchy of current user, we hide it. + } } $userstatic->id = $users['rowid']; @@ -318,7 +326,9 @@ if (count($typeleaves) == 0) $userstatic->employee = $users['employee']; $userstatic->fk_user = $users['fk_user']; - if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user); + if ($userstatic->fk_user > 0) { + $usersupervisor->fetch($userstatic->fk_user); + } print '<tr class="oddeven">'; @@ -329,21 +339,26 @@ if (count($typeleaves) == 0) // Supervisor print '<td>'; - if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1); + if ($userstatic->fk_user > 0) { + print $usersupervisor->getNomUrl(-1); + } print '</td>'; // Amount for each type - if (count($typeleaves)) - { - foreach ($typeleaves as $key => $val) - { + if (count($typeleaves)) { + foreach ($typeleaves as $key => $val) { $nbtoshow = ''; - if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') { + $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + } //var_dump($users['rowid'].' - '.$val['rowid']); print '<td style="text-align:center">'; - if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>'; - else print $nbtoshow; + if ($canedit) { + print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>'; + } else { + print $nbtoshow; + } //print ' '.$langs->trans('days'); print '</td>'."\n"; } @@ -353,13 +368,14 @@ if (count($typeleaves) == 0) // Note print '<td>'; - if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>'; + if ($canedit) { + print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>'; + } print '</td>'; // Button modify print '<td>'; - if (!empty($user->rights->holiday->define_holiday)) // Allowed to set the balance of any user - { + if (!empty($user->rights->holiday->define_holiday)) { // Allowed to set the balance of any user print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'" class="button smallpaddingimp"/>'; } print '</td>'."\n"; diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 3bb48d1de15..1e2a643549a 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -45,7 +45,9 @@ $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, 'holiday', $id, 'holiday'); // Get parameters @@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "position_name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "position_name"; +} $object = new Holiday($db); @@ -86,8 +94,7 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t llxHeader("", "", $langs->trans("InterventionCard")); -if ($object->id) -{ +if ($object->id) { $valideur = new User($db); $valideur->fetch($object->fk_validator); @@ -102,8 +109,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -138,8 +144,7 @@ if ($object->id) $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon'; - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td>'; print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); @@ -162,8 +167,7 @@ if ($object->id) print '</tr>'; } - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td>'; print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); @@ -192,15 +196,18 @@ if ($object->id) $htmlhelp = $langs->trans('NbUseDaysCPHelp'); $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); - if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); - if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + if ($includesaturday) { + $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); + } + if ($includesunday) { + $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + } print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); print '</td>'; print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>'; print '</tr>'; - if ($object->statut == 5) - { + if ($object->statut == 5) { print '<tr>'; print '<td>'.$langs->trans('DetailRefusCP').'</td>'; print '<td>'.$object->detail_refuse.'</td>'; @@ -208,8 +215,7 @@ if ($object->id) } // Description - if (!$edit) - { + if (!$edit) { print '<tr>'; print '<td>'.$langs->trans('DescCP').'</td>'; print '<td>'.nl2br($object->description).'</td>'; @@ -227,67 +233,67 @@ if ($object->id) print '</tbody>'; print '</table>'."\n"; /* - print '</div>'; - print '<div class="fichehalfright">'; - print '<div class="ficheaddleft">'; + print '</div>'; + print '<div class="fichehalfright">'; + print '<div class="ficheaddleft">'; - print '<div class="underbanner clearboth"></div>'; + print '<div class="underbanner clearboth"></div>'; // Info workflow - print '<table class="border tableforfield centpercent">'."\n"; - print '<tbody>'; + print '<table class="border tableforfield centpercent">'."\n"; + print '<tbody>'; - if (! empty($object->fk_user_create)) - { - $userCreate=new User($db); - $userCreate->fetch($object->fk_user_create); - print '<tr>'; - print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>'; - print '<td>'.$userCreate->getNomUrl(-1).'</td>'; - print '</tr>'; - } + if (! empty($object->fk_user_create)) + { + $userCreate=new User($db); + $userCreate->fetch($object->fk_user_create); + print '<tr>'; + print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>'; + print '<td>'.$userCreate->getNomUrl(-1).'</td>'; + print '</tr>'; + } - if (!$edit) { - print '<tr>'; - print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>'; - print '<td>'.$valideur->getNomUrl(-1).'</td>'; - print '</tr>'; - } else { - print '<tr>'; - print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>'; - print '<td>'; + if (!$edit) { + print '<tr>'; + print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>'; + print '<td>'.$valideur->getNomUrl(-1).'</td>'; + print '</tr>'; + } else { + print '<tr>'; + print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>'; + print '<td>'; print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent - print '</td>'; - print '</tr>'; - } + print '</td>'; + print '</tr>'; + } - print '<tr>'; - print '<td>'.$langs->trans('DateCreation').'</td>'; - print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>'; - print '</tr>'; - if ($object->statut == 3) { - print '<tr>'; - print '<td>'.$langs->trans('DateValidCP').'</td>'; - print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>'; - print '</tr>'; - } - if ($object->statut == 4) { - print '<tr>'; - print '<td>'.$langs->trans('DateCancelCP').'</td>'; - print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>'; - print '</tr>'; - } - if ($object->statut == 5) { - print '<tr>'; - print '<td>'.$langs->trans('DateRefusCP').'</td>'; - print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>'; - print '</tr>'; - } - print '</tbody>'; - print '</table>'; + print '<tr>'; + print '<td>'.$langs->trans('DateCreation').'</td>'; + print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>'; + print '</tr>'; + if ($object->statut == 3) { + print '<tr>'; + print '<td>'.$langs->trans('DateValidCP').'</td>'; + print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>'; + print '</tr>'; + } + if ($object->statut == 4) { + print '<tr>'; + print '<td>'.$langs->trans('DateCancelCP').'</td>'; + print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>'; + print '</tr>'; + } + if ($object->statut == 5) { + print '<tr>'; + print '<td>'.$langs->trans('DateRefusCP').'</td>'; + print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>'; + print '</tr>'; + } + print '</tbody>'; + print '</table>'; - print '</div>'; - print '</div>'; */ + print '</div>'; + print '</div>'; */ print '</div>'; print '<div class="clearboth"></div>'; diff --git a/htdocs/holiday/info.php b/htdocs/holiday/info.php index 2209143001c..b710df5fe2a 100644 --- a/htdocs/holiday/info.php +++ b/htdocs/holiday/info.php @@ -37,23 +37,26 @@ $ref = GETPOST('ref', 'alpha'); $childids = $user->getAllChildIds(1); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'holiday', $id, 'holiday'); $object = new Holiday($db); -if (!$object->fetch($id, $ref) > 0) -{ +if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); } -if ($object->id > 0) -{ +if ($object->id > 0) { // Check current user can read this expense report $canread = 0; - if (!empty($user->rights->holiday->readall)) $canread = 1; - if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; - if (!$canread) - { + if (!empty($user->rights->holiday->readall)) { + $canread = 1; + } + if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -69,8 +72,7 @@ $title = $langs->trans("Holiday")." - ".$langs->trans("Info"); $helpurl = ""; llxHeader("", $title, $helpurl); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object = new Holiday($db); $object->fetch($id, $ref); $object->info($object->id); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cb8da24052b..1bf74d9eb64 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -40,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; $langs->loadLangs(array('users', 'other', 'holiday', 'hrm')); // Protection if external user -if ($user->socid > 0) accessforbidden(); +if ($user->socid > 0) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -59,21 +61,24 @@ $childids = $user->getAllChildIds(1); // Security check $socid = 0; -if ($user->socid > 0) // Protection if external user -{ - //$socid = $user->socid; +if ($user->socid > 0) { // Protection if external user +//$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', '', ''); // If we are on the view of a specific user -if ($id > 0) -{ +if ($id > 0) { $canread = 0; - if ($id == $user->id) $canread = 1; - if (!empty($user->rights->holiday->readall)) $canread = 1; - if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1; - if (!$canread) - { + if ($id == $user->id) { + $canread = 1; + } + if (!empty($user->rights->holiday->readall)) { + $canread = 1; + } + if (!empty($user->rights->holiday->read) && in_array($id, $childids)) { + $canread = 1; + } + if (!$canread) { accessforbidden(); } } @@ -86,12 +91,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "cp.rowid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "cp.rowid"; +} $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alphanohtml'); @@ -145,8 +156,7 @@ $arrayfields = array( // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; -if (empty($conf->holiday->enabled)) -{ +if (empty($conf->holiday->enabled)) { llxHeader('', $langs->trans('CPTitreMenu')); print '<div class="tabBar">'; print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>'; @@ -160,21 +170,25 @@ if (empty($conf->holiday->enabled)) * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_ref = ""; $search_month_create = ""; $search_year_create = ""; @@ -190,8 +204,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -230,8 +243,7 @@ $min_year = 10; // Get current user id $user_id = $user->id; -if ($id > 0) -{ +if ($id > 0) { // Charge utilisateur edite $fuser->fetch($id, '', '', 1); $fuser->getrights(); @@ -282,21 +294,29 @@ $sql .= " ua.statut as validator_status,"; $sql .= " ua.photo as validator_photo"; // 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 : ''); + 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."holiday as cp"; -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 (cp.rowid = ef.fk_object)"; +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 (cp.rowid = ef.fk_object)"; +} $sql .= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau // Search all -if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if (!empty($sall)) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} // Ref -if (!empty($search_ref)) $sql .= natural_search("cp.ref", $search_ref); +if (!empty($search_ref)) { + $sql .= natural_search("cp.ref", $search_ref); +} // Start date $sql .= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start); // End date @@ -320,8 +340,12 @@ if (!empty($search_status) && $search_status != -1) { $sql .= " AND cp.statut = '".$db->escape($search_status)."'\n"; } -if (empty($user->rights->holiday->readall)) $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')'; -if ($id > 0) $sql .= " AND cp.fk_user IN (".$id.")"; +if (empty($user->rights->holiday->readall)) { + $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')'; +} +if ($id > 0) { + $sql .= " AND cp.fk_user IN (".$id.")"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -334,12 +358,10 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -350,30 +372,63 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $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); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_day_create) $param .= '&search_day_create='.urlencode($search_day_create); - if ($search_month_create) $param .= '&search_month_create='.urlencode($search_month_create); - if ($search_year_create) $param .= '&search_year_create='.urlencode($search_year_create); - if ($search_day_start) $param .= '&search_day_start='.urlencode($search_day_start); - if ($search_month_start) $param .= '&search_month_start='.urlencode($search_month_start); - if ($search_year_start) $param .= '&search_year_start='.urlencode($search_year_start); - if ($search_day_end) $param .= '&search_day_end='.urlencode($search_day_end); - if ($search_month_end) $param .= '&search_month_end='.urlencode($search_month_end); - if ($search_year_end) $param .= '&search_year_end='.urlencode($search_year_end); - if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee); - if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur); - if ($search_type > 0) $param .= '&search_type='.urlencode($search_type); - if ($search_status > 0) $param .= '&search_status='.urlencode($search_status); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_day_create) { + $param .= '&search_day_create='.urlencode($search_day_create); + } + if ($search_month_create) { + $param .= '&search_month_create='.urlencode($search_month_create); + } + if ($search_year_create) { + $param .= '&search_year_create='.urlencode($search_year_create); + } + if ($search_day_start) { + $param .= '&search_day_start='.urlencode($search_day_start); + } + if ($search_month_start) { + $param .= '&search_month_start='.urlencode($search_month_start); + } + if ($search_year_start) { + $param .= '&search_year_start='.urlencode($search_year_start); + } + if ($search_day_end) { + $param .= '&search_day_end='.urlencode($search_day_end); + } + if ($search_month_end) { + $param .= '&search_month_end='.urlencode($search_month_end); + } + if ($search_year_end) { + $param .= '&search_year_end='.urlencode($search_year_end); + } + if ($search_employee > 0) { + $param .= '&search_employee='.urlencode($search_employee); + } + if ($search_valideur > 0) { + $param .= '&search_valideur='.urlencode($search_valideur); + } + if ($search_type > 0) { + $param .= '&search_type='.urlencode($search_type); + } + if ($search_status > 0) { + $param .= '&search_status='.urlencode($search_status); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -383,23 +438,30 @@ if ($resql) //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->rights->holiday->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; - if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">'; + if ($id > 0) { + print '<input type="hidden" name="id" value="'.$id.'">'; + } - if ($id > 0) // For user tab - { + if ($id > 0) { // For user tab $title = $langs->trans("User"); $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $head = user_prepare_head($fuser); @@ -408,8 +470,7 @@ if ($resql) dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) - { + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { print '<div class="underbanner clearboth"></div>'; print '<br>'; @@ -425,8 +486,7 @@ if ($resql) $canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))); - if ($canedit) - { + if ($canedit) { print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>'; } @@ -445,9 +505,10 @@ if ($resql) $trackid = 'leav'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -455,11 +516,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -471,7 +534,9 @@ if ($resql) $include = ''; - if (empty($user->rights->holiday->readall)) $include = 'hierarchyme'; // Can see only its hierarchyl + if (empty($user->rights->holiday->readall)) { + $include = 'hierarchyme'; // Can see only its hierarchyl + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; @@ -480,23 +545,22 @@ if ($resql) // Filters print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['cp.ref']['checked'])) - { + if (!empty($arrayfields['cp.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (!empty($arrayfields['cp.fk_user']['checked'])) - { + if (!empty($arrayfields['cp.fk_user']['checked'])) { $morefilter = ''; - if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) $morefilter = 'AND employee = 1'; + if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) { + $morefilter = 'AND employee = 1'; + } // User $disabled = 0; // If into the tab holiday of a user ($id is set in such a case) - if ($id && !GETPOSTISSET('search_employee')) - { + if ($id && !GETPOSTISSET('search_employee')) { $search_employee = $id; $disabled = 1; } @@ -507,16 +571,16 @@ if ($resql) } // Approver - if (!empty($arrayfields['cp.fk_validator']['checked'])) - { - if ($user->rights->holiday->readall) - { + if (!empty($arrayfields['cp.fk_validator']['checked'])) { + if ($user->rights->holiday->readall) { print '<td class="liste_titre maxwidthonsmartphone left">'; $validator = new UserGroup($db); $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); - foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id; + foreach ($valideurobjects as $val) { + $valideurarray[$val->id] = $val->id; + } print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150'); print '</td>'; } else { @@ -525,16 +589,14 @@ if ($resql) } // Type - if (!empty($arrayfields['cp.fk_type']['checked'])) - { + if (!empty($arrayfields['cp.fk_type']['checked'])) { print '<td class="liste_titre">'; if (empty($mysoc->country_id)) { setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors'); } else { $typeleaves = $holidaystatic->getTypes(1, -1); $arraytypeleaves = array(); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']] = $labeltoshow; @@ -545,14 +607,12 @@ if ($resql) } // Duration - if (!empty($arrayfields['duration']['checked'])) - { + if (!empty($arrayfields['duration']['checked'])) { print '<td class="liste_titre">&nbsp;</td>'; } // Start date - if (!empty($arrayfields['cp.date_debut']['checked'])) - { + if (!empty($arrayfields['cp.date_debut']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">'; $formother->select_year($search_year_start, 'search_year_start', 1, $min_year, $max_year); @@ -560,8 +620,7 @@ if ($resql) } // End date - if (!empty($arrayfields['cp.date_fin']['checked'])) - { + if (!empty($arrayfields['cp.date_fin']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">'; $formother->select_year($search_year_end, 'search_year_end', 1, $min_year, $max_year); @@ -576,8 +635,7 @@ if ($resql) print $hookmanager->resPrint; // Create date - if (!empty($arrayfields['cp.date_create']['checked'])) - { + if (!empty($arrayfields['cp.date_create']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">'; $formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0); @@ -585,8 +643,7 @@ if ($resql) } // Create date - if (!empty($arrayfields['cp.tms']['checked'])) - { + if (!empty($arrayfields['cp.tms']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).'">'; $formother->select_year($search_year_update, 'search_year_update', 1, $min_year, 0); @@ -594,8 +651,7 @@ if ($resql) } // Status - if (!empty($arrayfields['cp.statut']['checked'])) - { + if (!empty($arrayfields['cp.statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone maxwidth200 right">'; $object->selectStatutCP($search_status, 'search_status'); print '</td>'; @@ -610,22 +666,42 @@ if ($resql) print "</tr>\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100'); - if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.ref']['checked'])) { + print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cp.fk_validator']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cp.fk_type']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['duration']['checked'])) { + print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100'); + } + if (!empty($arrayfields['cp.date_debut']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cp.date_fin']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (!empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cp.date_create']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cp.tms']['checked'])) { + print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['cp.statut']['checked'])) { + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; @@ -637,8 +713,7 @@ if ($resql) $langs->load("errors"); print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>'; $result = 0; - } elseif ($num > 0 && !empty($mysoc->country_id)) - { + } elseif ($num > 0 && !empty($mysoc->country_id)) { // Lines $userstatic = new User($db); $approbatorstatic = new User($db); @@ -647,8 +722,7 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); // Leave request @@ -684,54 +758,61 @@ if ($resql) print '<tr class="oddeven">'; - if (!empty($arrayfields['cp.ref']['checked'])) - { + if (!empty($arrayfields['cp.ref']['checked'])) { print '<td class="nowraponall">'; print $holidaystatic->getNomUrl(1, 1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.fk_user']['checked'])) - { + if (!empty($arrayfields['cp.fk_user']['checked'])) { print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.fk_validator']['checked'])) - { + if (!empty($arrayfields['cp.fk_validator']['checked'])) { print '<td class="tdoverflowmax150">'.$approbatorstatic->getNomUrl(-1).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.fk_type']['checked'])) - { + if (!empty($arrayfields['cp.fk_type']['checked'])) { print '<td>'; $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); print empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['duration']['checked'])) - { + if (!empty($arrayfields['duration']['checked'])) { print '<td class="right">'; $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); print $nbopenedday.' '.$langs->trans('DurationDays'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.date_debut']['checked'])) - { + if (!empty($arrayfields['cp.date_debut']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_debut), 'day'); print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$starthalfday]).')</span>'; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.date_fin']['checked'])) - { + if (!empty($arrayfields['cp.date_fin']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_fin), 'day'); print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$endhalfday]).')</span>'; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Extra fields @@ -742,32 +823,38 @@ if ($resql) print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['cp.date_create']['checked'])) - { + if (!empty($arrayfields['cp.date_create']['checked'])) { print '<td style="text-align: center;">'.dol_print_date($date, 'dayhour').'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.tms']['checked'])) - { + if (!empty($arrayfields['cp.tms']['checked'])) { print '<td style="text-align: center;">'.dol_print_date($date_modif, 'dayhour').'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!empty($arrayfields['cp.statut']['checked'])) - { + if (!empty($arrayfields['cp.statut']['checked'])) { print '<td class="right nowrap">'.$holidaystatic->getLibStatut(5).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -776,10 +863,13 @@ if ($resql) } // Si il n'y a pas d'enregistrement suite à une recherche - if ($num == 0) - { + if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -815,8 +905,7 @@ function showMyBalance($holiday, $user_id) $out = ''; $nb_holiday = 0; $typeleaves = $holiday->getTypes(1, 1); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user_id, $val['rowid']); $nb_holiday += $nb_type; $out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>'; diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index b83d957b27f..ee16bca1d88 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -36,9 +36,8 @@ $langs->loadLangs(array("holiday")); // Security check $socid = 0; -if ($user->socid > 0) // Protection if external user -{ - //$socid = $user->socid; +if ($user->socid > 0) { // Protection if external user +//$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', $id, ''); @@ -57,8 +56,12 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'alpha'); -if (!$sortfield) $sortfield = "cp.rowid"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "cp.rowid"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $hookmanager->initHooks(array('leavemovementlist')); @@ -69,21 +72,25 @@ $arrayofmassactions = array(); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_ref = ''; $search_employee = ''; $search_type = ''; @@ -97,8 +104,7 @@ if (empty($reshook)) || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') - || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search', 'alpha')) { $massaction = ''; } } @@ -141,16 +147,23 @@ $sql .= " WHERE cp.rowid > 0"; $sql .= " AND cp.statut = 3"; // 3 = Approved $sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; -if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref); -if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'"; -if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; -if (!empty($search_description)) $sql .= natural_search('cp.description', $search_description); +if (!empty($search_ref)) { + $sql .= natural_search('cp.ref', $search_ref); +} +if (!empty($search_employee)) { + $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'"; +} +if (!empty($search_type)) { + $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; +} +if (!empty($search_description)) { + $sql .= natural_search('cp.description', $search_description); +} $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); -if (empty($resql)) -{ +if (empty($resql)) { dol_print_error($db); exit; } @@ -158,15 +171,29 @@ if (empty($resql)) $num = $db->num_rows($resql); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref); -if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee); -if (!empty($search_type)) $param .= '&search_type='.urlencode($search_type); -if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if (!empty($search_ref)) { + $param .= '&search_ref='.urlencode($search_ref); +} +if (!empty($search_employee)) { + $param .= '&search_employee='.urlencode($search_employee); +} +if (!empty($search_type)) { + $param .= '&search_type='.urlencode($search_type); +} +if (!empty($search_description)) { + $param .= '&search_description='.urlencode($search_description); +} print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -215,8 +242,7 @@ if (!empty($arrayfields['cp.fk_user']['checked'])) { if (!empty($arrayfields['ct.label']['checked'])) { $typeleaves = $holidaystatic->getTypes(1, -1); $arraytypeleaves = array(); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); $arraytypeleaves[$val['rowid']] = $labeltoshow; } @@ -226,12 +252,24 @@ if (!empty($arrayfields['ct.label']['checked'])) { print '</td>'; } -if (!empty($arrayfields['cp.date_debut']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['cp.date_fin']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['used_days']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['date_start_month']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['date_end_month']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['cp.date_debut']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['cp.date_fin']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['used_days']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['date_start_month']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['date_end_month']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['used_days_month']['checked'])) { + print '<td class="liste_titre"></td>'; +} // Filter: Description if (!empty($arrayfields['cp.description']['checked'])) { @@ -248,26 +286,43 @@ print '</td>'; print '</tr>'; print '<tr class="liste_titre">'; -if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['ct.label']['checked'])) print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['used_days']['checked'])) print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['date_start_month']['checked'])) print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['date_end_month']['checked'])) print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['used_days_month']['checked'])) print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cp.description']['checked'])) print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cp.ref']['checked'])) { + print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cp.fk_user']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['ct.label']['checked'])) { + print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cp.date_debut']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cp.date_fin']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['used_days']['checked'])) { + print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['date_start_month']['checked'])) { + print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['date_end_month']['checked'])) { + print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['used_days_month']['checked'])) { + print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cp.description']['checked'])) { + print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder); +} print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print '</tr>'; -if ($num == 0) -{ +if ($num == 0) { print '<tr><td colspan="10" class="opacitymedium">'.$langs->trans('None').'</td></tr>'; -} -else { - while ($obj = $db->fetch_object($resql)) - { +} else { + while ($obj = $db->fetch_object($resql)) { $user = new User($db); $user->fetch($obj->fk_user); @@ -289,19 +344,25 @@ else { // Set date_start_gmt and date_end_gmt that are date to show for the selected month $date_start_inmonth = $db->jdate($obj->date_debut, true); $date_end_inmonth = $db->jdate($obj->date_fin, true); - if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) - { + if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) { $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); $starthalfdayinmonth = 'morning'; - if ($halfdayinmonth == 2) $halfdayinmonth = 1; - if ($halfdayinmonth == -1) $halfdayinmonth = 0; + if ($halfdayinmonth == 2) { + $halfdayinmonth = 1; + } + if ($halfdayinmonth == -1) { + $halfdayinmonth = 0; + } } - if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) - { + if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) { $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); $endhalfdayinmonth = 'afternoon'; - if ($halfdayinmonth == 2) $halfdayinmonth = -1; - if ($halfdayinmonth == 1) $halfdayinmonth = 0; + if ($halfdayinmonth == 2) { + $halfdayinmonth = -1; + } + if ($halfdayinmonth == 1) { + $halfdayinmonth = 0; + } } // Leave request @@ -310,42 +371,50 @@ else { print '<tr class="oddeven">'; - if (!empty($arrayfields['cp.ref']['checked'])) print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>'; - if (!empty($arrayfields['cp.fk_user']['checked'])) print '<td>'.$user->getFullName($langs).'</td>'; - if (!empty($arrayfields['ct.label']['checked'])) print '<td>'.$obj->label.'</td>'; + if (!empty($arrayfields['cp.ref']['checked'])) { + print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>'; + } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print '<td>'.$user->getFullName($langs).'</td>'; + } + if (!empty($arrayfields['ct.label']['checked'])) { + print '<td>'.$obj->label.'</td>'; + } - if (!empty($arrayfields['cp.date_debut']['checked'])) - { + if (!empty($arrayfields['cp.date_debut']['checked'])) { print '<td class="center">'.dol_print_date($db->jdate($obj->date_debut), 'day'); print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>'; print '</td>'; } - if (!empty($arrayfields['cp.date_fin']['checked'])) - { + if (!empty($arrayfields['cp.date_fin']['checked'])) { print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day'); print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>'; print '</td>'; } - if (!empty($arrayfields['used_days']['checked'])) print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>'; + if (!empty($arrayfields['used_days']['checked'])) { + print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>'; + } - if (!empty($arrayfields['date_start_month']['checked'])) - { + if (!empty($arrayfields['date_start_month']['checked'])) { print '<td class="center">'.dol_print_date($date_start_inmonth, 'day'); print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).')</span>'; print '</td>'; } - if (!empty($arrayfields['date_end_month']['checked'])) - { + if (!empty($arrayfields['date_end_month']['checked'])) { print '<td class="center">'.dol_print_date($date_end_inmonth, 'day'); print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).')</span>'; print '</td>'; } - if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>'; - if (!empty($arrayfields['cp.description']['checked'])) print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>'; + if (!empty($arrayfields['used_days_month']['checked'])) { + print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>'; + } + if (!empty($arrayfields['cp.description']['checked'])) { + print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>'; + } print '<td></td>'; print '</tr>'; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 2f2e223c87c..a2ecbe1e8b3 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -61,15 +61,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "cpl.rowid"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "cpl.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Si l'utilisateur n'a pas le droit de lire cette page -if (!$user->rights->holiday->readall) accessforbidden(); +if (!$user->rights->holiday->readall) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('users', 'other', 'holiday')); @@ -83,8 +91,7 @@ $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_mo $arrayfields = array(); $arrayofmassactions = array(); -if (empty($conf->holiday->enabled)) -{ +if (empty($conf->holiday->enabled)) { llxHeader('', $langs->trans('CPTitreMenu')); print '<div class="tabBar">'; print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>'; @@ -98,12 +105,18 @@ if (empty($conf->holiday->enabled)) * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { // Selection of new fields @@ -129,8 +142,7 @@ if (empty($reshook)) { || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') - || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -184,13 +196,27 @@ if (!empty($search_year) && $search_year > 0) { $sqlwhere .= "AND date_action BETWEEN '".$db->idate($from_date)."' AND '".$db->idate($to_date)."'"; } -if (!empty($search_id) && $search_id > 0) $sqlwhere .= natural_search('rowid', $search_id, 1); -if (!empty($search_validator) && $search_validator > 0) $sqlwhere .= natural_search('fk_user_action', $search_validator, 1); -if (!empty($search_employee) && $search_employee > 0) $sqlwhere .= natural_search('fk_user_update', $search_employee, 1); -if (!empty($search_description)) $sqlwhere .= natural_search('type_action', $search_description); -if (!empty($search_type) && $search_type > 0) $sqlwhere .= natural_search('fk_type', $search_type, 1); -if (!empty($search_prev_solde)) $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1); -if (!empty($search_new_solde)) $sqlwhere .= natural_search('new_solde', $search_new_solde, 1); +if (!empty($search_id) && $search_id > 0) { + $sqlwhere .= natural_search('rowid', $search_id, 1); +} +if (!empty($search_validator) && $search_validator > 0) { + $sqlwhere .= natural_search('fk_user_action', $search_validator, 1); +} +if (!empty($search_employee) && $search_employee > 0) { + $sqlwhere .= natural_search('fk_user_update', $search_employee, 1); +} +if (!empty($search_description)) { + $sqlwhere .= natural_search('type_action', $search_description); +} +if (!empty($search_type) && $search_type > 0) { + $sqlwhere .= natural_search('fk_type', $search_type, 1); +} +if (!empty($search_prev_solde)) { + $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1); +} +if (!empty($search_new_solde)) { + $sqlwhere .= natural_search('new_solde', $search_new_solde, 1); +} $sqlorder = $db->order($sortfield, $sortorder); @@ -214,20 +240,44 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $num = is_array($object->logs) ? count($object->logs) : 0; $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if (!empty($search_id)) $param .= '&search_statut='.urlencode($search_statut); -if (!empty($search_month) && $search_month > 0) $param .= '&search_month='.urlencode($search_month); -if (!empty($search_year) && $search_year > 0) $param .= '&search_year='.urlencode($search_year); -if (!empty($search_validator) && $search_validator > 0) $param .= '&search_validator='.urlencode($search_validator); -if (!empty($search_employee) && $search_employee > 0) $param .= '&search_employee='.urlencode($search_employee); -if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); -if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.urlencode($search_type); -if (!empty($search_prev_solde)) $param .= '&search_prev_solde='.urlencode($search_prev_solde); -if (!empty($search_new_solde)) $param .= '&search_new_solde='.urlencode($search_new_solde); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if (!empty($search_id)) { + $param .= '&search_statut='.urlencode($search_statut); +} +if (!empty($search_month) && $search_month > 0) { + $param .= '&search_month='.urlencode($search_month); +} +if (!empty($search_year) && $search_year > 0) { + $param .= '&search_year='.urlencode($search_year); +} +if (!empty($search_validator) && $search_validator > 0) { + $param .= '&search_validator='.urlencode($search_validator); +} +if (!empty($search_employee) && $search_employee > 0) { + $param .= '&search_employee='.urlencode($search_employee); +} +if (!empty($search_description)) { + $param .= '&search_description='.urlencode($search_description); +} +if (!empty($search_type) && $search_type > 0) { + $param .= '&search_type='.urlencode($search_type); +} +if (!empty($search_prev_solde)) { + $param .= '&search_prev_solde='.urlencode($search_prev_solde); +} +if (!empty($search_new_solde)) { + $param .= '&search_new_solde='.urlencode($search_new_solde); +} print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -348,23 +398,40 @@ print '</td>'; print '</tr>'; print '<tr class="liste_titre">'; -if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder); -if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['cpl.rowid']['checked'])) { + print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cpl.date_action']['checked'])) { + print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cpl.fk_user_action']['checked'])) { + print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cpl.fk_user_update']['checked'])) { + print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cpl.type_action']['checked'])) { + print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cpl.fk_type']['checked'])) { + print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder); +} +if (!empty($arrayfields['cpl.prev_solde']['checked'])) { + print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['variation']['checked'])) { + print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['cpl.new_solde']['checked'])) { + print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right '); +} print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print '</tr>'; // TODO: $i = 0; $i = 1; -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { //TODO: $obj = $db->fetch_object($resql); $obj = next($object->logs); From 629efe7d5a9b46c98fb22bc439b9406fdd0592b1 Mon Sep 17 00:00:00 2001 From: stickler-ci <support@stickler-ci.com> Date: Fri, 26 Feb 2021 17:14:26 +0000 Subject: [PATCH 154/173] Fixing style errors. --- htdocs/holiday/card.php | 2 +- htdocs/holiday/list.php | 2 +- htdocs/holiday/month_report.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index bcd108f6bfe..6217b804787 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -744,7 +744,7 @@ if (empty($reshook)) { $result = $object->update($user); if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) { // holiday was already validated, status 3, so we must increase back the balance - // Calculcate number of days consummed + // Calculcate number of days consummed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 1bf74d9eb64..2518e6d7b2b 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -62,7 +62,7 @@ $childids = $user->getAllChildIds(1); // Security check $socid = 0; if ($user->socid > 0) { // Protection if external user -//$socid = $user->socid; + //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', '', ''); diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index ee16bca1d88..37497fd1810 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -37,7 +37,7 @@ $langs->loadLangs(array("holiday")); // Security check $socid = 0; if ($user->socid > 0) { // Protection if external user -//$socid = $user->socid; + //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', $id, ''); From 6cef78befb31146d60f18b9aa5511a80ac8b4881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 18:20:21 +0100 Subject: [PATCH 155/173] code syntax hrm imports install intracommreport loan directory --- htdocs/hrm/admin/admin_establishment.php | 20 +- htdocs/hrm/admin/admin_hrm.php | 3 +- htdocs/hrm/class/establishment.class.php | 56 +- htdocs/hrm/establishment/card.php | 87 +- htdocs/hrm/establishment/info.php | 40 +- htdocs/hrm/index.php | 124 +-- htdocs/imports/class/import.class.php | 89 ++- htdocs/imports/emptyexample.php | 26 +- htdocs/imports/import.php | 756 ++++++++++-------- htdocs/imports/index.php | 11 +- htdocs/install/repair.php | 669 +++++++--------- .../intracommreport/admin/intracommreport.php | 19 +- htdocs/loan/calcmens.php | 12 +- htdocs/loan/card.php | 244 +++--- htdocs/loan/class/loan.class.php | 162 ++-- htdocs/loan/class/loanschedule.class.php | 106 ++- htdocs/loan/class/paymentloan.class.php | 218 +++-- htdocs/loan/document.php | 22 +- htdocs/loan/info.php | 4 +- htdocs/loan/list.php | 107 ++- htdocs/loan/note.php | 11 +- htdocs/loan/payment/card.php | 48 +- htdocs/loan/payment/payment.php | 255 +++--- htdocs/loan/schedule.php | 85 +- 24 files changed, 1636 insertions(+), 1538 deletions(-) diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index a777ada50f9..eb61b7e7807 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $error = 0; @@ -52,8 +53,12 @@ llxHeader('', $langs->trans("Establishments")); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortorder = GETPOST("sortorder", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "e.rowid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "e.rowid"; +} if (empty($page) || $page == -1) { $page = 0; @@ -79,8 +84,7 @@ $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; @@ -95,12 +99,10 @@ if ($result) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.status", "", "", '', $sortfield, $sortorder, 'right '); print "</tr>\n"; - if ($num > 0) - { + if ($num > 0) { $establishmentstatic = new Establishment($db); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); $establishmentstatic->id = $obj->rowid; diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index c4081e1d454..0131539071a 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index dc97787ae6e..28a354c757f 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -180,7 +180,9 @@ class Establishment extends CommonObject $this->zip = trim($this->zip); $this->town = trim($this->town); - if (empty($this->ref)) $this->ref = '(PROV)'; + if (empty($this->ref)) { + $this->ref = '(PROV)'; + } $this->db->begin(); @@ -248,8 +250,7 @@ class Establishment extends CommonObject global $langs; // Check parameters - if (empty($this->label)) - { + if (empty($this->label)) { $this->error = 'ErrorBadParameter'; return -1; } @@ -296,8 +297,7 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -334,8 +334,7 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->db->commit(); return 1; } else { @@ -367,8 +366,7 @@ class Establishment extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_OPEN] = $langs->trans('Open'); @@ -378,8 +376,12 @@ class Establishment extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_OPEN) $statusType = 'status4'; - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + if ($status == self::STATUS_OPEN) { + $statusType = 'status4'; + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -400,22 +402,18 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::fetch info", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->date_creation = $this->db->jdate($obj->datec); - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_mod) - { + if ($obj->fk_user_mod) { $muser = new User($this->db); $muser->fetch($obj->fk_user_mod); $this->user_modification = $muser; @@ -449,9 +447,15 @@ class Establishment extends CommonObject $label = '<u>'.$langs->trans("Establishment").'</u>'; $label .= '<br>'.$langs->trans("Label").': '.$this->label; - if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.$this->label.$linkend; + if ($withpicto) { + $result .= ($link.img_object($label, $picto).$linkend); + } + if ($withpicto && $withpicto != 2) { + $result .= ' '; + } + if ($withpicto != 2) { + $result .= $link.$this->label.$linkend; + } return $result; } @@ -465,10 +469,14 @@ class Establishment extends CommonObject global $mysoc; // We return country code of bank account - if (!empty($this->country_code)) return $this->country_code; + if (!empty($this->country_code)) { + return $this->country_code; + } // We return country code of managed company - if (!empty($mysoc->country_code)) return $mysoc->country_code; + if (!empty($mysoc->country_code)) { + return $mysoc->country_code; + } return ''; } diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 15fd44e2c3b..6c336d230f0 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array('admin', 'hrm')); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $error = 0; @@ -44,7 +46,9 @@ static $tmpstatus2label = array( '1'=>'OpenEtablishment' ); $status2label = array(''); -foreach ($tmpstatus2label as $key => $val) $status2label[$key] = $langs->trans($val); +foreach ($tmpstatus2label as $key => $val) { + $status2label[$key] = $langs->trans($val); +} $object = new Establishment($db); @@ -56,31 +60,25 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ * Actions */ -if ($action == 'confirm_delete' && $confirm == "yes") -{ +if ($action == 'confirm_delete' && $confirm == "yes") { $result = $object->delete($id); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ../admin/admin_establishment.php"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == 'add') -{ - if (!$cancel) - { +} elseif ($action == 'add') { + if (!$cancel) { $error = 0; $object->label = GETPOST('label', 'alpha'); - if (empty($object->label)) - { + if (empty($object->label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $error++; } - if (empty($error)) - { + if (empty($error)) { $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -92,8 +90,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -106,11 +103,8 @@ if ($action == 'confirm_delete' && $confirm == "yes") header("Location: ../admin/admin_establishment.php"); exit; } -} - -// Update record -elseif ($action == 'update') -{ +} elseif ($action == 'update') { + // Update record $error = 0; if (!$cancel) { @@ -120,8 +114,7 @@ elseif ($action == 'update') $error++; } - if (empty($error)) - { + if (empty($error)) { $object->label = GETPOST('label', 'alphanohtml'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); @@ -133,8 +126,7 @@ elseif ($action == 'update') $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']); exit; } else { @@ -159,8 +151,7 @@ $formcompany = new FormCompany($db); /* * Action create */ -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewEstablishment")); print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; @@ -228,7 +219,9 @@ if ($action == 'create') print '<td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>'; print '<td class="maxwidthonsmartphone">'; print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : ($object->country_id ? $object->country_id : $mysoc->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td>'; print '</tr>'; @@ -253,15 +246,12 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { $result = $object->fetch($id); - if ($result > 0) - { + if ($result > 0) { $head = establishment_prepare_head($object); - if ($action == 'edit') - { + if ($action == 'edit') { print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building'); print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; @@ -284,12 +274,12 @@ if (($id || $ref) && $action == 'edit') // Entity /* - if (! empty($conf->multicompany->enabled)) { - print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>'; + if (! empty($conf->multicompany->enabled)) { + print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>'; print '<td class="maxwidthonsmartphone">'; print $object->entity > 0 ? $object->entity : $conf->entity; - print '</td></tr>'; - }*/ + print '</td></tr>'; + }*/ // Address print '<tr><td>'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>'; @@ -313,7 +303,9 @@ if (($id || $ref) && $action == 'edit') print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>'; print '<td class="maxwidthonsmartphone">'; print $form->select_country($object->country_id, 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print '</td>'; print '</tr>'; @@ -334,19 +326,19 @@ if (($id || $ref) && $action == 'edit') print '</form>'; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); $head = establishment_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteEstablishment"), $langs->trans("ConfirmDeleteEstablishment"), "confirm_delete"); } @@ -404,8 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr>'; print '<td>'.$langs->trans("Country").'</td>'; print '<td>'; - if ($object->country_id > 0) - { + if ($object->country_id > 0) { $img = picto_from_langcode($object->country_code); print $img ? $img.' ' : ''; print getCountry($object->getCountryCode(), 0, $db); @@ -421,8 +412,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); /* - * Barre d'actions - */ + * Barre d'actions + */ print '<div class="tabsAction">'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index 3185f897958..f72b381a2d8 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -37,7 +37,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -47,12 +49,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} // Initialize technical objects $object = new Establishment($db); @@ -64,7 +72,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -80,20 +90,19 @@ $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_ $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // 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 $actioncode = ''; $search_agenda_label = ''; } @@ -107,14 +116,15 @@ if (empty($reshook)) $form = new Form($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $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; $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = establishment_prepare_head($object); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index f0bbb442acc..94dd7f98cd1 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -33,8 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if ($conf->deplacement->enabled) { + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +} +if ($conf->expensereport->enabled) { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +} require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; @@ -47,9 +51,13 @@ $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes')); $socid = GETPOST("socid", "int"); // Protection if external user -if ($user->socid > 0) accessforbidden(); +if ($user->socid > 0) { + accessforbidden(); +} -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { + $setupcompanynotcomplete = 1; +} $holiday = new Holiday($db); $holidaystatic = new Holiday($db); @@ -63,8 +71,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; */ // Update sold -if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) -{ +if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) { $result = $holiday->updateBalance(); } @@ -81,8 +88,7 @@ llxHeader('', $langs->trans('HRMArea')); print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm'); -if (!empty($setupcompanynotcomplete)) -{ +if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>'; @@ -94,36 +100,34 @@ if (!empty($setupcompanynotcomplete)) print '<div class="fichecenter"><div class="fichethirdleft">'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) - { +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $langs->load("holiday"); $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); } - if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) - { + if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) { $langs->load("trips"); $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); } - if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) - { + if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { $langs->load("trips"); $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + } print '<tr '.$bc[false].'>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + if ($i == 0) { + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + } print '</tr>'; $i++; } @@ -135,10 +139,8 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles } -if (!empty($conf->holiday->enabled)) -{ - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) - { +if (!empty($conf->holiday->enabled)) { + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { $user_id = $user->id; print '<div class="div-table-responsive-no-min">'; @@ -149,8 +151,7 @@ if (!empty($conf->holiday->enabled)) $out = ''; $typeleaves = $holiday->getTypes(1, 1); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>'; @@ -161,8 +162,7 @@ if (!empty($conf->holiday->enabled)) print '</td>'; print '</tr>'; print '</table></div><br>'; - } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) - { + } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>'; } } @@ -173,22 +173,22 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; // Latest leave requests -if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) -{ +if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = x.fk_user"; $sql .= " AND x.entity = ".$conf->entity; - if (empty($user->rights->holiday->readall)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + if (empty($user->rights->holiday->readall)) { + $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql .= $db->order("x.tms", "DESC"); $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $var = false; $num = $db->num_rows($result); @@ -208,10 +208,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) print '<th>'.$langs->trans("to").'</th>'; print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; print '</tr>'; - if ($num) - { - while ($i < $num && $i < $max) - { + if ($num) { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $holidaystatic->id = $obj->rowid; @@ -248,28 +246,30 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) print '</table>'; print '</div>'; print '<br>'; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // Latest expense report -if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) -{ +if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,"; $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".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 = x.fk_user_author"; $sql .= " AND x.entity = ".$conf->entity; - if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { + $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql .= $db->order("x.tms", "DESC"); $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; @@ -281,14 +281,12 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print '<th class="right">'.$langs->trans("TotalTTC").'</th>'; print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; print '</tr>'; - if ($num) - { + if ($num) { $total_ttc = $totalam = $total = 0; $expensereportstatic = new ExpenseReport($db); $userstatic = new User($db); - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $expensereportstatic->id = $obj->rowid; @@ -320,26 +318,32 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print '</table>'; print '</div>'; print '<br>'; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // Last modified job position -if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) -{ +if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.fk_soc = $socid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.fk_soc = $socid"; + } $sql .= " ORDER BY rc.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -351,10 +355,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme print '</th>'; print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; print '</tr>'; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $objp = $db->fetch_object($resql); $staticrecruitmentcandidature->id = $objp->rowid; $staticrecruitmentcandidature->ref = $objp->ref; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 19b71cb8cd3..c9bb41389c9 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -87,15 +87,17 @@ class Import $modulesdir = dolGetModulesDirs(); // Load list of modules - foreach ($modulesdir as $dir) - { + foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); - if (!is_resource($handle)) continue; + if (!is_resource($handle)) { + continue; + } // Search module files - while (($file = readdir($handle)) !== false) - { - if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) continue; + while (($file = readdir($handle)) !== false) { + if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) { + continue; + } $modulename = $reg[1]; @@ -103,10 +105,16 @@ class Import $enabled = true; $part = strtolower(preg_replace('/^mod/i', '', $modulename)); // Adds condition for propal module - if ($part === 'propale') $part = 'propal'; - if (empty($conf->$part->enabled)) $enabled = false; + if ($part === 'propale') { + $part = 'propal'; + } + if (empty($conf->$part->enabled)) { + $enabled = false; + } - if (empty($enabled)) continue; + if (empty($enabled)) { + continue; + } // Init load class $file = $dir."/".$modulename.".class.php"; @@ -114,11 +122,11 @@ class Import require_once $file; $module = new $classname($this->db); - if (isset($module->import_code) && is_array($module->import_code)) - { - foreach ($module->import_code as $r => $value) - { - if ($filter && ($filter != $module->import_code[$r])) continue; + if (isset($module->import_code) && is_array($module->import_code)) { + foreach ($module->import_code as $r => $value) { + if ($filter && ($filter != $module->import_code[$r])) { + continue; + } // Test if permissions are ok /*$perm=$module->import_permission[$r][0]; @@ -137,10 +145,8 @@ class Import // Load lang file $langtoload = $module->getLangFilesArray(); - if (is_array($langtoload)) - { - foreach ($langtoload as $key) - { + if (is_array($langtoload)) { + foreach ($langtoload as $key) { $langs->load($key); } } @@ -246,9 +252,15 @@ class Import dol_syslog("Import.class.php::create"); // Check parameters - if (empty($this->model_name)) { $this->error = 'ErrorWrongParameters'; return -1; } - if (empty($this->datatoimport)) { $this->error = 'ErrorWrongParameters'; return -1; } - if (empty($this->hexa)) { $this->error = 'ErrorWrongParameters'; return -1; } + if (empty($this->model_name)) { + $this->error = 'ErrorWrongParameters'; return -1; + } + if (empty($this->datatoimport)) { + $this->error = 'ErrorWrongParameters'; return -1; + } + if (empty($this->hexa)) { + $this->error = 'ErrorWrongParameters'; return -1; + } $this->db->begin(); @@ -259,8 +271,7 @@ class Import dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -285,11 +296,9 @@ class Import dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->hexa = $obj->field; $this->model_name = $obj->label; @@ -325,26 +334,24 @@ class Import 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 (!$notrigger) - { + if (!$error) { + if (!$notrigger) { /* Not used. This is not a business object. To convert it we must herit from CommonObject - // Call trigger - $result=$this->call_trigger('IMPORT_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - */ + // Call trigger + $result=$this->call_trigger('IMPORT_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + */ } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } diff --git a/htdocs/imports/emptyexample.php b/htdocs/imports/emptyexample.php index 7e7cec1707e..a50a2fc9996 100644 --- a/htdocs/imports/emptyexample.php +++ b/htdocs/imports/emptyexample.php @@ -21,7 +21,9 @@ * \brief Show example of import file */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +} /** @@ -58,8 +60,7 @@ $format = GETPOST('format'); $langs->load("exports"); // Check exportkey -if (empty($datatoimport)) -{ +if (empty($datatoimport)) { $user->getrights(); llxHeader(); @@ -81,23 +82,30 @@ $fieldstarget = $objimport->array_import_fields[0]; $valuestarget = $objimport->array_import_examplevalues[0]; $attachment = true; -if (isset($_GET["attachment"])) $attachment = $_GET["attachment"]; +if (isset($_GET["attachment"])) { + $attachment = $_GET["attachment"]; +} //$attachment = false; $contenttype = dol_mimetype($format); -if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"]; +if (isset($_GET["contenttype"])) { + $contenttype = $_GET["contenttype"]; +} //$contenttype='text/plain'; $outputencoding = 'UTF-8'; -if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); -if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); +if ($contenttype) { + header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); +} +if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); +} // List of targets fields $headerlinefields = array(); $contentlinevalues = array(); $i = 0; -foreach ($fieldstarget as $code=>$label) -{ +foreach ($fieldstarget as $code => $label) { $withoutstar = preg_replace('/\*/', '', $fieldstarget[$code]); $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ? '*' : '').' ('.$code.')'; $contentlinevalues[] = $valuestarget[$code]; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 1f8e6bb0bea..dff1940c042 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -41,61 +41,61 @@ $result = restrictedArea($user, 'import'); // Map icons, array duplicated in export.php, was not synchronized, TODO put it somewhere only once $entitytoicon = array( 'invoice' => 'bill', - 'invoice_line' => 'bill', + 'invoice_line' => 'bill', 'order' => 'order', - 'order_line' => 'order', + 'order_line' => 'order', 'propal' => 'propal', - 'propal_line' => 'propal', + 'propal_line' => 'propal', 'intervention' => 'intervention', - 'inter_line' => 'intervention', + 'inter_line' => 'intervention', 'member' => 'user', - 'member_type' => 'group', - 'subscription' => 'payment', - 'payment' => 'payment', + 'member_type' => 'group', + 'subscription' => 'payment', + 'payment' => 'payment', 'tax' => 'bill', - 'tax_type' => 'generic', - 'other' => 'generic', + 'tax_type' => 'generic', + 'other' => 'generic', 'account' => 'account', 'product' => 'product', - 'virtualproduct'=>'product', + 'virtualproduct'=>'product', 'subproduct' => 'product', 'product_supplier_ref' => 'product', - 'stock' => 'stock', + 'stock' => 'stock', 'warehouse' => 'stock', 'batch' => 'stock', 'stockbatch' => 'stock', 'category' => 'category', 'shipment' => 'sending', - 'shipment_line'=> 'sending', - 'reception'=> 'sending', - 'reception_line'=> 'sending', + 'shipment_line'=> 'sending', + 'reception'=> 'sending', + 'reception_line'=> 'sending', 'expensereport'=> 'trip', - 'expensereport_line'=> 'trip', + 'expensereport_line'=> 'trip', 'holiday' => 'holiday', - 'contract_line' => 'contract', - 'translation' => 'generic', - 'bomm' => 'bom', - 'bomline' => 'bom' + 'contract_line' => 'contract', + 'translation' => 'generic', + 'bomm' => 'bom', + 'bomline' => 'bom' ); // Translation code, array duplicated in export.php, was not synchronized, TODO put it somewhere only once $entitytolang = array( 'user' => 'User', 'company' => 'Company', - 'contact' => 'Contact', + 'contact' => 'Contact', 'invoice' => 'Bill', - 'invoice_line' => 'InvoiceLine', + 'invoice_line' => 'InvoiceLine', 'order' => 'Order', - 'order_line' => 'OrderLine', - 'propal' => 'Proposal', - 'propal_line' => 'ProposalLine', + 'order_line' => 'OrderLine', + 'propal' => 'Proposal', + 'propal_line' => 'ProposalLine', 'intervention' => 'Intervention', - 'inter_line' => 'InterLine', + 'inter_line' => 'InterLine', 'member' => 'Member', - 'member_type' => 'MemberType', - 'subscription' => 'Subscription', + 'member_type' => 'MemberType', + 'subscription' => 'Subscription', 'tax' => 'SocialContribution', - 'tax_type' => 'DictionarySocialContributions', + 'tax_type' => 'DictionarySocialContributions', 'account' => 'BankTransactions', 'payment' => 'Payment', 'product' => 'Product', @@ -103,28 +103,28 @@ $entitytolang = array( 'subproduct' => 'SubProduct', 'product_supplier_ref' => 'SupplierPrices', 'service' => 'Service', - 'stock' => 'Stock', + 'stock' => 'Stock', 'movement' => 'StockMovement', 'batch' => 'Batch', 'stockbatch' => 'StockDetailPerBatch', 'warehouse' => 'Warehouse', 'category' => 'Category', 'other' => 'Other', - 'trip' => 'TripsAndExpenses', - 'shipment' => 'Shipments', - 'shipment_line'=> 'ShipmentLine', - 'project' => 'Projects', - 'projecttask' => 'Tasks', - 'task_time' => 'TaskTimeSpent', + 'trip' => 'TripsAndExpenses', + 'shipment' => 'Shipments', + 'shipment_line'=> 'ShipmentLine', + 'project' => 'Projects', + 'projecttask' => 'Tasks', + 'task_time' => 'TaskTimeSpent', 'action' => 'Event', 'expensereport'=> 'ExpenseReport', 'expensereport_line'=> 'ExpenseReportLine', 'holiday' => 'TitreRequestCP', 'contract' => 'Contract', - 'contract_line'=> 'ContractLine', - 'translation' => 'Translation', - 'bom' => 'BOM', - 'bomline' => 'BOMLine' + 'contract_line'=> 'ContractLine', + 'translation' => 'Translation', + 'bom' => 'BOM', + 'bomline' => 'BOMLine' ); $datatoimport = GETPOST('datatoimport'); @@ -155,13 +155,11 @@ $formfile = new FormFile($db); $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database"]) ? $_SESSION["dol_array_match_file_to_database"] : ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $serialized_array_match_file_to_database); -foreach ($fieldsarray as $elem) -{ +foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val) - { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -196,37 +194,32 @@ if ($action=='downfield' || $action=='upfield') } } */ -if ($action == 'builddoc') -{ +if ($action == 'builddoc') { // Build import file $result = $objimport->build_file($user, GETPOST('model', 'alpha'), $datatoimport, $array_match_file_to_database); - if ($result < 0) - { + if ($result < 0) { setEventMessages($objimport->error, $objimport->errors, 'errors'); } else { setEventMessages($langs->trans("FileSuccessfullyBuilt"), null, 'mesgs'); } } -if ($action == 'deleteprof') -{ - if (GETPOST("id", 'int')) - { +if ($action == 'deleteprof') { + if (GETPOST("id", 'int')) { $objimport->fetch(GETPOST("id", 'int')); $result = $objimport->delete($user); } } // Save import config to database -if ($action == 'add_import_model') -{ - if ($import_name) - { +if ($action == 'add_import_model') { + if ($import_name) { // Set save string $hexa = ''; - foreach ($array_match_file_to_database as $key=>$val) - { - if ($hexa) $hexa .= ','; + foreach ($array_match_file_to_database as $key => $val) { + if ($hexa) { + $hexa .= ','; + } $hexa .= $key.'='.$val; } @@ -235,13 +228,11 @@ if ($action == 'add_import_model') $objimport->hexa = $hexa; $result = $objimport->create($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("ImportModelSaved", $objimport->model_name), null, 'mesgs'); } else { $langs->load("errors"); - if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ErrorImportDuplicateProfil"), null, 'errors'); } else { setEventMessages($objimport->error, null, 'errors'); @@ -252,16 +243,13 @@ if ($action == 'add_import_model') } } -if ($step == 3 && $datatoimport) -{ - if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) - { +if ($step == 3 && $datatoimport) { + if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { dol_mkdir($conf->import->dir_temp); $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $fullpath = $conf->import->dir_temp."/".$nowyearmonth.'-'.$_FILES['userfile']['name']; - if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) - { + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { dol_syslog("File ".$fullpath." was added for import"); } else { $langs->load("errors"); @@ -270,25 +258,30 @@ if ($step == 3 && $datatoimport) } // Delete file - if ($action == 'confirm_deletefile' && $confirm == 'yes') - { + if ($action == 'confirm_deletefile' && $confirm == 'yes') { $langs->load("other"); $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } $file = $conf->import->dir_temp.'/'.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'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } Header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.$param); exit; } } -if ($step == 4 && $action == 'select_model') -{ +if ($step == 4 && $action == 'select_model') { // Reinit match arrays $_SESSION["dol_array_match_file_to_database"] = ''; $serialized_array_match_file_to_database = ''; @@ -297,17 +290,14 @@ if ($step == 4 && $action == 'select_model') // Load model from $importmodelid and set $array_match_file_to_database // and $_SESSION["dol_array_match_file_to_database"] $result = $objimport->fetch($importmodelid); - if ($result > 0) - { + if ($result > 0) { $serialized_array_match_file_to_database = $objimport->hexa; $fieldsarray = explode(',', $serialized_array_match_file_to_database); - foreach ($fieldsarray as $elem) - { + foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem); $key = $tabelem[0]; $val = $tabelem[1]; - if ($key && $val) - { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -315,8 +305,7 @@ if ($step == 4 && $action == 'select_model') } } -if ($action == 'saveorder') -{ +if ($action == 'saveorder') { // Enregistrement de la position des champs dol_syslog("boxorder=".$_GET['boxorder']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG); $part = explode(':', $_GET['boxorder']); @@ -332,15 +321,12 @@ if ($action == 'saveorder') $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); $pos = 0; - foreach ($fieldsarray as $fieldnb) // For each elem in list. fieldnb start from 1 to ... - { + foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield $posbis = 0; $namefield = ''; - foreach ($fieldstarget as $key => $val) // key: val: - { + foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if ($posbis < $pos) - { + if ($posbis < $pos) { $posbis++; continue; } @@ -351,10 +337,11 @@ if ($action == 'saveorder') break; } - if ($fieldnb && $namefield) - { + if ($fieldnb && $namefield) { $array_match_file_to_database[$fieldnb] = $namefield; - if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .= ','; + if ($serialized_array_match_file_to_database) { + $serialized_array_match_file_to_database .= ','; + } $serialized_array_match_file_to_database .= ($fieldnb.'='.$namefield); } @@ -375,18 +362,25 @@ if ($action == 'saveorder') // STEP 1: Page to select dataset to import -if ($step == 1 || !$datatoimport) -{ +if ($step == 1 || !$datatoimport) { // Clean saved file-database matching $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $_SESSION["dol_array_match_file_to_database"] = ''; $param = ''; - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); @@ -405,16 +399,16 @@ if ($step == 1 || !$datatoimport) print '<td>&nbsp;</td>'; print '</tr>'; - if (count($objimport->array_import_module)) - { + if (count($objimport->array_import_module)) { $sortedarrayofmodules = dol_sort_array($objimport->array_import_module, 'position_of_profile', 'asc', 0, 0, 1); - foreach ($sortedarrayofmodules as $key => $value) - { + foreach ($sortedarrayofmodules as $key => $value) { //var_dump($key.' '.$value['position_of_profile'].' '.$value['import_code'].' '.$objimport->array_import_module[$key]['module']->getName().' '.$objimport->array_import_code[$key]); print '<tr class="oddeven"><td>'; $titleofmodule = $objimport->array_import_module[$key]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td><td>'; $entity = preg_replace('/:.*$/', '', $objimport->array_import_icon[$key]); @@ -422,8 +416,7 @@ if ($step == 1 || !$datatoimport) print img_object($objimport->array_import_module[$key]['module']->getName(), $entityicon).' '; print $objimport->array_import_label[$key]; print '</td><td style="text-align: right">'; - if ($objimport->array_import_perms[$key]) - { + if ($objimport->array_import_perms[$key]) { print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$objimport->array_import_code[$key].$param.'">'.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15x"').'</a>'; } else { print $langs->trans("NotEnoughPermissions"); @@ -441,13 +434,20 @@ if ($step == 1 || !$datatoimport) // STEP 2: Page to select input format file -if ($step == 2 && $datatoimport) -{ +if ($step == 2 && $datatoimport) { $param = '&datatoimport='.urlencode($datatoimport); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); @@ -465,7 +465,9 @@ if ($step == 2 && $datatoimport) print '<td>'; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td></tr>'; @@ -503,8 +505,7 @@ if ($step == 2 && $datatoimport) print $langs->trans("FileMustHaveOneOfFollowingFormat"); print '</td></tr>'; $list = $objmodelimport->liste_modeles($db); - foreach ($list as $key) - { + foreach ($list as $key) { print '<tr class="oddeven">'; print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).'</td>'; $text = $objmodelimport->getDriverDescForKey($key); @@ -525,13 +526,20 @@ if ($step == 2 && $datatoimport) // STEP 3: Page to select file -if ($step == 3 && $datatoimport) -{ +if ($step == 3 && $datatoimport) { $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } $list = $objmodelimport->liste_modeles($db); @@ -544,8 +552,7 @@ if ($step == 3 && $datatoimport) /* * Confirm delete file */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } @@ -559,7 +566,9 @@ if ($step == 3 && $datatoimport) print '<td>'; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td></tr>'; @@ -635,33 +644,45 @@ if ($step == 3 && $datatoimport) $out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : ''); print '<input type="submit" class="button" value="'.$langs->trans("AddFile").'"'.$out.' name="sendit">'; $out = ''; - if (!empty($conf->global->MAIN_UPLOAD_DOC)) - { + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $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; + 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 (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; + } // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) - { + if ($maxphp > 0) { $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } - if ($maxphp2 > 0) - { + if ($maxphp2 > 0) { $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) - { + if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; $maxphptoshowparam = 'post_max_size'; } @@ -679,20 +700,22 @@ if ($step == 3 && $datatoimport) // Search available imports $filearray = dol_dir_list($conf->import->dir_temp, 'files', 0, '', '', 'name', SORT_DESC); - if (count($filearray) > 0) - { + if (count($filearray) > 0) { $dir = $conf->import->dir_temp; // Search available files to import $i = 0; - foreach ($filearray as $key => $val) - { + foreach ($filearray as $key => $val) { $file = $val['name']; // readdir return value in ISO and we want UTF8 in memory - if (!utf8_check($file)) $file = utf8_encode($file); + if (!utf8_check($file)) { + $file = utf8_encode($file); + } - if (preg_match('/^\./', $file)) continue; + if (preg_match('/^\./', $file)) { + continue; + } $modulepart = 'import'; $urlsource = $_SERVER["PHP_SELF"].'?step='.$step.$param.'&filetoimport='.urlencode($filetoimport); @@ -728,8 +751,7 @@ if ($step == 3 && $datatoimport) // STEP 4: Page to make matching between source file and database fields -if ($step == 4 && $datatoimport) -{ +if ($step == 4 && $datatoimport) { $model = $format; $list = $objmodelimport->liste_modeles($db); @@ -739,14 +761,12 @@ if ($step == 4 && $datatoimport) $classname = "Import".ucfirst($model); require_once $dir.$file; $obj = new $classname($db, $datatoimport); - if ($model == 'csv') - { + if ($model == 'csv') { $obj->separator = $separator; $obj->enclosure = $enclosure; } if ($model == 'xlsx') { - if (!preg_match('/\.xlsx$/i', $filetoimport)) - { + if (!preg_match('/\.xlsx$/i', $filetoimport)) { $langs->load("errors"); $param = '&datatoimport='.$datatoimport.'&format='.$format; setEventMessages($langs->trans("ErrorFileMustHaveFormat", $model), null, 'errors'); @@ -762,14 +782,12 @@ if ($step == 4 && $datatoimport) // Load source fields in input file $fieldssource = array(); $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); - if ($result >= 0) - { + if ($result >= 0) { // Read first line $arrayrecord = $obj->import_read_record(); // Put into array fieldssource starting with 1. $i = 1; - foreach ($arrayrecord as $key => $val) - { + foreach ($arrayrecord as $key => $val) { $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); $i++; } @@ -784,29 +802,26 @@ if ($step == 4 && $datatoimport) //var_dump($array_match_file_to_database); // Is it a first time in page (if yes, we must initialize array_match_file_to_database) - if (count($array_match_file_to_database) == 0) - { + if (count($array_match_file_to_database) == 0) { // This is first input in screen, we need to define // $array_match_file_to_database // $serialized_array_match_file_to_database // $_SESSION["dol_array_match_file_to_database"] $pos = 1; $num = count($fieldssource); - while ($pos <= $num) - { - if ($num >= 1 && $pos <= $num) - { + while ($pos <= $num) { + if ($num >= 1 && $pos <= $num) { $posbis = 1; - foreach ($fieldstarget as $key => $val) - { - if ($posbis < $pos) - { + foreach ($fieldstarget as $key => $val) { + if ($posbis < $pos) { $posbis++; continue; } // We found the key of targets that is at position pos $array_match_file_to_database[$pos] = $key; - if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .= ','; + if ($serialized_array_match_file_to_database) { + $serialized_array_match_file_to_database .= ','; + } $serialized_array_match_file_to_database .= ($pos.'='.$key); break; } @@ -825,10 +840,18 @@ if ($step == 4 && $datatoimport) // Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database) $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); @@ -846,7 +869,9 @@ if ($step == 4 && $datatoimport) print '<td>'; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td></tr>'; @@ -954,8 +979,7 @@ if ($step == 4 && $datatoimport) $fieldsplaced = array(); $valforsourcefieldnb = array(); $listofkeys = array(); - foreach ($array_match_file_to_database as $key => $val) - { + foreach ($array_match_file_to_database as $key => $val) { $listofkeys[$key] = 1; } @@ -965,8 +989,7 @@ if ($step == 4 && $datatoimport) // List of source fields $var = true; $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) - { + foreach ($array_match_file_to_database as $key => $val) { $var = !$var; show_elem($fieldssource, $key, $val, $var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; @@ -975,15 +998,16 @@ if ($step == 4 && $datatoimport) $valforsourcefieldnb[$lefti] = $key; $lefti++; - if ($lefti > count($fieldstarget)) break; // Other fields are in the not imported area + if ($lefti > count($fieldstarget)) { + break; // Other fields are in the not imported area + } } //var_dump($valforsourcefieldnb); // Complete source fields from count($fieldssource)+1 to count($fieldstarget) $more = 1; $num = count($fieldssource); - while ($lefti <= $num) - { + while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file @@ -1005,8 +1029,7 @@ if ($step == 4 && $datatoimport) $mandatoryfieldshavesource = true; print '<table width="100%" class="nobordernopadding">'; - foreach ($fieldstarget as $code=>$label) - { + foreach ($fieldstarget as $code => $label) { print '<tr class="oddeven" style="height:'.$height.'">'; $i++; @@ -1023,11 +1046,12 @@ if ($step == 4 && $datatoimport) $newlabel = preg_replace('/\*$/', '', $label); $text = $langs->trans($newlabel); $more = ''; - if (preg_match('/\*$/', $label)) - { + if (preg_match('/\*$/', $label)) { $text = '<span class="fieldrequired">'.$text.'</span>'; $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + } //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } print $text; @@ -1037,43 +1061,54 @@ if ($step == 4 && $datatoimport) $filecolumn = $array_match_database_to_file[$code]; // Source field info $htmltext = '<b><u>'.$langs->trans("FieldSource").'</u></b><br>'; - if ($filecolumn > count($fieldssource)) $htmltext .= $langs->trans("DataComeFromNoWhere").'<br>'; - else { - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { + if ($filecolumn > count($fieldssource)) { + $htmltext .= $langs->trans("DataComeFromNoWhere").'<br>'; + } else { + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion $filecolumntoshow = $filecolumn; $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'<br>'; } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'<br>'; - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'<br>'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'<br>'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'<br>'; + } } } // Source required $htmltext .= $langs->trans("SourceRequired").': <b>'.yn(preg_match('/\*$/', $label)).'</b><br>'; $example = $objimport->array_import_examplevalues[0][$code]; // Example - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { - if ($example) $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>'; + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion + if ($example) { + $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>'; + } } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>'; - elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>'; - elseif ($example) $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>'; + } elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>'; + } elseif ($example) { + $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>'; + } } // Format control rule - if (!empty($objimport->array_import_regex[0][$code])) - { + if (!empty($objimport->array_import_regex[0][$code])) { $htmltext .= $langs->trans("FormatControlRule").': <b>'.$objimport->array_import_regex[0][$code].'</b><br>'; } $htmltext .= '<br>'; // Target field info $htmltext .= '<b><u>'.$langs->trans("FieldTarget").'</u></b><br>'; - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion $htmltext .= $langs->trans("DataIsInsertedInto").'<br>'; } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'<br>'; - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'<br>'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'<br>'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'<br>'; + } } $htmltext .= $langs->trans("FieldTitle").": <b>".$langs->trans($newlabel)."</b><br>"; $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': <b>'.$tablename." -> ".preg_replace('/^.*\./', '', $code)."</b><br>"; @@ -1096,10 +1131,8 @@ if ($step == 4 && $datatoimport) print '<div id="right" class="connectedSortable">'."\n"; $nbofnotimportedfields = 0; - foreach ($fieldssource as $key => $val) - { - if (empty($fieldsplaced[$key])) - { + foreach ($fieldssource as $key => $val) { + if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; show_elem($fieldssource, $key, '', $var, 'nostyle'); @@ -1122,8 +1155,7 @@ if ($step == 4 && $datatoimport) print '</td>'; print '<td width="50%">'; $i = 0; - while ($i < $nbofnotimportedfields) - { + while ($i < $nbofnotimportedfields) { // Print empty cells show_elem('', '', 'none', $var, 'nostyle'); $i++; @@ -1134,8 +1166,7 @@ if ($step == 4 && $datatoimport) print '</div>'; - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<script type="text/javascript" language="javascript">'; print 'jQuery(function() { jQuery("#left, #right").sortable({ @@ -1176,10 +1207,8 @@ if ($step == 4 && $datatoimport) */ print '<div class="tabsAction">'; - if (count($array_match_file_to_database)) - { - if ($mandatoryfieldshavesource) - { + if (count($array_match_file_to_database)) { + if ($mandatoryfieldshavesource) { print '<a class="butAction" href="import.php?step=5'.$param.'&filetoimport='.urlencode($filetoimport).'">'.$langs->trans("NextStep").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SomeMandatoryFieldHaveNoSource")).'">'.$langs->trans("NextStep").'</a>'; @@ -1190,8 +1219,7 @@ if ($step == 4 && $datatoimport) // Area for profils import - if (count($array_match_file_to_database)) - { + if (count($array_match_file_to_database)) { print '<br>'."\n"; print '<!-- Area to add new import profile -->'."\n"; print '<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans("SaveImportModel").'</span></div>'; @@ -1226,12 +1254,10 @@ if ($step == 4 && $datatoimport) $sql .= " WHERE type = '".$db->escape($datatoimport)."'"; $sql .= " ORDER BY rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven"><td>'; print $obj->label; @@ -1253,12 +1279,10 @@ if ($step == 4 && $datatoimport) // STEP 5: Summary of choices and launch simulation -if ($step == 5 && $datatoimport) -{ +if ($step == 5 && $datatoimport) { $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); - if ($max_time && $max_time < $max_execution_time_for_importexport) - { + if ($max_time && $max_time < $max_execution_time_for_importexport) { dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 } @@ -1281,14 +1305,12 @@ if ($step == 5 && $datatoimport) $fieldssource = array(); $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); - if ($result >= 0) - { + if ($result >= 0) { // Read first line $arrayrecord = $obj->import_read_record(); // Put into array fieldssource starting with 1. $i = 1; - foreach ($arrayrecord as $key => $val) - { + foreach ($arrayrecord as $key => $val) { $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); $i++; } @@ -1299,9 +1321,15 @@ if ($step == 5 && $datatoimport) $param = '&leftmenu=import&format='.urlencode($format).'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport).'&nboflines='.urlencode($nboflines).'&separator='.urlencode($separator).'&enclosure='.urlencode($enclosure); $param2 = $param; // $param2 = $param without excludefirstline and endatlinenb - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if (!empty($updatekeys)) $param .= '&updatekeys[]='.implode('&updatekeys[]=', $updatekeys); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if (!empty($updatekeys)) { + $param .= '&updatekeys[]='.implode('&updatekeys[]=', $updatekeys); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); @@ -1325,7 +1353,9 @@ if ($step == 5 && $datatoimport) print '<td>'; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td></tr>'; @@ -1384,8 +1414,7 @@ if ($step == 5 && $datatoimport) print '<tr><td>'; print $langs->trans("ImportFromToLine"); print '</td><td>'; - if ($action == 'launchsimu') - { + if ($action == 'launchsimu') { print '<input type="number" class="maxwidth50" name="excludefirstlinebis" disabled="disabled" value="'.$excludefirstline.'">'; print '<input type="hidden" name="excludefirstline" value="'.$excludefirstline.'">'; } else { @@ -1393,15 +1422,16 @@ if ($step == 5 && $datatoimport) print $form->textwithpicto("", $langs->trans("SetThisValueTo2ToExcludeFirstLine")); } print ' - '; - if ($action == 'launchsimu') - { + if ($action == 'launchsimu') { print '<input type="text" class="maxwidth50" name="endatlinenbbis" disabled="disabled" value="'.$endatlinenb.'">'; print '<input type="hidden" name="endatlinenb" value="'.$endatlinenb.'">'; } else { print '<input type="text" class="maxwidth50" name="endatlinenb" value="'.$endatlinenb.'">'; print $form->textwithpicto("", $langs->trans("KeepEmptyToGoToEndOfFile")); } - if ($action == 'launchsimu') print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=5'.$param.'">'.$langs->trans("Modify").'</a>'; + if ($action == 'launchsimu') { + print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=5'.$param.'">'.$langs->trans("Modify").'</a>'; + } print '</td></tr>'; // Keys for data UPDATE (not INSERT of new data) @@ -1409,8 +1439,7 @@ if ($step == 5 && $datatoimport) print $langs->trans("KeysToUseForUpdates"); print '</td><td>'; if ($action == 'launchsimu') { - if (count($updatekeys)) - { + if (count($updatekeys)) { print $form->multiselectarray('updatekeysbis', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%', 'disabled'); } else { print '<span class="opacitymedium">'.$langs->trans("NoUpdateAttempt").'</span> &nbsp; -'; @@ -1420,8 +1449,7 @@ if ($step == 5 && $datatoimport) } print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=5'.$param.'">'.$langs->trans("Modify").'</a>'; } else { - if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0])) - { //TODO dropdown UL is created inside nested SPANS + if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0])) { //TODO dropdown UL is created inside nested SPANS print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%'); print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); } else { @@ -1450,21 +1478,22 @@ if ($step == 5 && $datatoimport) print '</td><td>'; $listtables = array(); $sort_array_match_file_to_database = $array_match_file_to_database; - foreach ($array_match_file_to_database as $code=>$label) - { + foreach ($array_match_file_to_database as $code => $label) { //var_dump($fieldssource); - if ($code > count($fieldssource)) continue; + if ($code > count($fieldssource)) { + continue; + } //print $code.'-'.$label; $alias = preg_replace('/(\..*)$/i', '', $label); $listtables[$alias] = $objimport->array_import_tables[0][$alias]; } - if (count($listtables)) - { + if (count($listtables)) { $newval = ''; //ksort($listtables); - foreach ($listtables as $val) - { - if ($newval) print ', '; + foreach ($listtables as $val) { + if ($newval) { + print ', '; + } $newval = $val; // Link to Dolibarr wiki pages /*$helppagename='EN:Table_'.$newval; @@ -1479,7 +1508,9 @@ if ($step == 5 && $datatoimport) }*/ print $newval; } - } else print $langs->trans("Error"); + } else { + print $langs->trans("Error"); + } print '</td></tr>'; // Fields imported @@ -1491,11 +1522,12 @@ if ($step == 5 && $datatoimport) $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); - foreach ($sort_array_match_file_to_database as $code=>$label) - { + foreach ($sort_array_match_file_to_database as $code => $label) { $i++; //var_dump($fieldssource); - if ($code > count($fieldssource)) continue; + if ($code > count($fieldssource)) { + continue; + } //print $code.'-'.$label; $alias = preg_replace('/(\..*)$/i', '', $label); $listfields[$i] = $langs->trans("Field").' '.$code.'->'.$label; @@ -1509,8 +1541,7 @@ if ($step == 5 && $datatoimport) print dol_get_fiche_end(); - if ($action != 'launchsimu') - { + if ($action != 'launchsimu') { // Show import id print '<br><span class="opacitymedium">'; print $langs->trans("NowClickToTestTheImport", $langs->transnoentitiesnoconv("RunSimulateImportFile")).'</span><br>'; @@ -1518,8 +1549,7 @@ if ($step == 5 && $datatoimport) // Actions print '<div class="center">'; - if ($user->rights->import->run) - { + if ($user->rights->import->run) { print '<input type="submit" class="butAction" value="'.$langs->trans("RunSimulateImportFile").'">'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>'; @@ -1544,34 +1574,41 @@ if ($step == 5 && $datatoimport) $nbok = 0; $pathfile = $conf->import->dir_temp.'/'.$filetoimport; $result = $obj->import_open_file($pathfile, $langs); - if ($result > 0) - { + if ($result > 0) { global $tablewithentity_cache; $tablewithentity_cache = array(); $sourcelinenb = 0; $endoffile = 0; // Loop on each input file record - while (($sourcelinenb < $nboflines) && !$endoffile) - { + while (($sourcelinenb < $nboflines) && !$endoffile) { $sourcelinenb++; // Read line and store it into $arrayrecord //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb); $arrayrecord = $obj->import_read_record(); - if ($arrayrecord === false) - { + if ($arrayrecord === false) { $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines. Ensure the complete string is delimited correctly when there is a separator character in the text string.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); $endoffile++; continue; } - if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; + if ($excludefirstline && ($sourcelinenb < $excludefirstline)) { + continue; + } + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) { + break; + } // Run import $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); - if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors; - if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings; - if (!count($obj->errors) && !count($obj->warnings)) $nbok++; + if (count($obj->errors)) { + $arrayoferrors[$sourcelinenb] = $obj->errors; + } + if (count($obj->warnings)) { + $arrayofwarnings[$sourcelinenb] = $obj->warnings; + } + if (!count($obj->errors) && !count($obj->warnings)) { + $nbok++; + } } // Close file $obj->import_close_file(); @@ -1583,15 +1620,12 @@ if ($step == 5 && $datatoimport) // Run the sql after import if defined //var_dump($objimport->array_import_run_sql_after[0]); - if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) - { + if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) { $i = 0; - foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport) - { + foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport) { $i++; $resqlafterimport = $db->query($sqlafterimport); - if (!$resqlafterimport) - { + if (!$resqlafterimport) { $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $error++; } @@ -1607,25 +1641,23 @@ if ($step == 5 && $datatoimport) print $langs->trans("NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).'<br>'; print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).'<br><br>'; print '</div>'; - } else print $langs->trans("NbOfLinesOK", $nbok).'<br><br>'; + } else { + print $langs->trans("NbOfLinesOK", $nbok).'<br><br>'; + } // Show Errors //var_dump($arrayoferrors); - if (count($arrayoferrors)) - { + if (count($arrayoferrors)) { print img_error().' <b>'.$langs->trans("ErrorsOnXLines", count($arrayoferrors)).'</b><br>'; print '<table width="100%" class="border"><tr><td>'; - foreach ($arrayoferrors as $key => $val) - { + foreach ($arrayoferrors as $key => $val) { $nboferrors++; - if ($nboferrors > $maxnboferrors) - { + if ($nboferrors > $maxnboferrors) { print $langs->trans("TooMuchErrors", (count($arrayoferrors) - $nboferrors))."<br>"; break; } print '* '.$langs->trans("Line").' '.$key.'<br>'; - foreach ($val as $i => $err) - { + foreach ($val as $i => $err) { print ' &nbsp; &nbsp; > '.$err['lib'].'<br>'; } } @@ -1635,21 +1667,17 @@ if ($step == 5 && $datatoimport) // Show Warnings //var_dump($arrayoferrors); - if (count($arrayofwarnings)) - { + if (count($arrayofwarnings)) { print img_warning().' <b>'.$langs->trans("WarningsOnXLines", count($arrayofwarnings)).'</b><br>'; print '<table width="100%" class="border"><tr><td>'; - foreach ($arrayofwarnings as $key => $val) - { + foreach ($arrayofwarnings as $key => $val) { $nbofwarnings++; - if ($nbofwarnings > $maxnbofwarnings) - { + if ($nbofwarnings > $maxnbofwarnings) { print $langs->trans("TooMuchWarnings", (count($arrayofwarnings) - $nbofwarnings))."<br>"; break; } print ' * '.$langs->trans("Line").' '.$key.'<br>'; - foreach ($val as $i => $err) - { + foreach ($val as $i => $err) { print ' &nbsp; &nbsp; > '.$err['lib'].'<br>'; } } @@ -1662,17 +1690,17 @@ if ($step == 5 && $datatoimport) print '<div class="center">'; print '<span class="opacitymedium">'.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'</span><br>'; - if (empty($nboferrors)) print $langs->trans("DataLoadedWithId", $importid).'<br>'; + if (empty($nboferrors)) { + print $langs->trans("DataLoadedWithId", $importid).'<br>'; + } print '</div>'; print '<br>'; // Actions print '<div class="center">'; - if ($user->rights->import->run) - { - if (empty($nboferrors)) - { + if ($user->rights->import->run) { + if (empty($nboferrors)) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=6&importid='.$importid.$param.'">'.$langs->trans("RunImportFile").'</a>'; } else { //print '<input type="submit" class="butAction" value="'.dol_escape_htmltag($langs->trans("RunSimulateImportFile")).'">'; @@ -1692,12 +1720,10 @@ if ($step == 5 && $datatoimport) // STEP 6: Real import -if ($step == 6 && $datatoimport) -{ +if ($step == 6 && $datatoimport) { $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); - if ($max_time && $max_time < $max_execution_time_for_importexport) - { + if ($max_time && $max_time < $max_execution_time_for_importexport) { dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 } @@ -1721,14 +1747,12 @@ if ($step == 6 && $datatoimport) // Load source fields in input file $fieldssource = array(); $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); - if ($result >= 0) - { + if ($result >= 0) { // Read first line $arrayrecord = $obj->import_read_record(); // Put into array fieldssource starting with 1. $i = 1; - foreach ($arrayrecord as $key => $val) - { + foreach ($arrayrecord as $key => $val) { $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); $i++; } @@ -1738,10 +1762,18 @@ if ($step == 6 && $datatoimport) $nboflines = (!empty($_GET["nboflines"]) ? $_GET["nboflines"] : dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport)); $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport).'&nboflines='.urlencode($nboflines); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones'); @@ -1759,7 +1791,9 @@ if ($step == 6 && $datatoimport) print '<td>'; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print '</td></tr>'; @@ -1846,20 +1880,21 @@ if ($step == 6 && $datatoimport) print $langs->trans("TablesTarget"); print '</td><td>'; $listtables = array(); - foreach ($array_match_file_to_database as $code=>$label) - { + foreach ($array_match_file_to_database as $code => $label) { //var_dump($fieldssource); - if ($code > count($fieldssource)) continue; + if ($code > count($fieldssource)) { + continue; + } //print $code.'-'.$label; $alias = preg_replace('/(\..*)$/i', '', $label); $listtables[$alias] = $objimport->array_import_tables[0][$alias]; } - if (count($listtables)) - { + if (count($listtables)) { $newval = ''; - foreach ($listtables as $val) - { - if ($newval) print ', '; + foreach ($listtables as $val) { + if ($newval) { + print ', '; + } $newval = $val; // Link to Dolibarr wiki pages /*$helppagename='EN:Table_'.$newval; @@ -1874,7 +1909,9 @@ if ($step == 6 && $datatoimport) }*/ print $newval; } - } else print $langs->trans("Error"); + } else { + print $langs->trans("Error"); + } print '</td></tr>'; // Fields imported @@ -1885,11 +1922,12 @@ if ($step == 6 && $datatoimport) $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); - foreach ($sort_array_match_file_to_database as $code=>$label) - { + foreach ($sort_array_match_file_to_database as $code => $label) { $i++; //var_dump($fieldssource); - if ($code > count($fieldssource)) continue; + if ($code > count($fieldssource)) { + continue; + } //print $code.'-'.$label; $alias = preg_replace('/(\..*)$/i', '', $label); $listfields[$i] = $langs->trans("Field").' '.$code.'->'.$label; @@ -1918,31 +1956,38 @@ if ($step == 6 && $datatoimport) $nbok = 0; $pathfile = $conf->import->dir_temp.'/'.$filetoimport; $result = $obj->import_open_file($pathfile, $langs); - if ($result > 0) - { + if ($result > 0) { global $tablewithentity_cache; $tablewithentity_cache = array(); $sourcelinenb = 0; $endoffile = 0; - while ($sourcelinenb < $nboflines && !$endoffile) - { + while ($sourcelinenb < $nboflines && !$endoffile) { $sourcelinenb++; $arrayrecord = $obj->import_read_record(); - if ($arrayrecord === false) - { + if ($arrayrecord === false) { $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); $endoffile++; continue; } - if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; + if ($excludefirstline && ($sourcelinenb < $excludefirstline)) { + continue; + } + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) { + break; + } // Run import $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys); - if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors; - if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings; - if (!count($obj->errors) && !count($obj->warnings)) $nbok++; + if (count($obj->errors)) { + $arrayoferrors[$sourcelinenb] = $obj->errors; + } + if (count($obj->warnings)) { + $arrayofwarnings[$sourcelinenb] = $obj->warnings; + } + if (!count($obj->errors) && !count($obj->warnings)) { + $nbok++; + } } // Close file $obj->import_close_file(); @@ -1950,29 +1995,30 @@ if ($step == 6 && $datatoimport) print $langs->trans("ErrorFailedToOpenFile", $pathfile); } - if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors. - else { + if (count($arrayoferrors) > 0) { + $db->rollback(); // We force rollback because this was errors. + } else { $error = 0; // Run the sql after import if defined //var_dump($objimport->array_import_run_sql_after[0]); - if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) - { + if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) { $i = 0; - foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport) - { + foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport) { $i++; $resqlafterimport = $db->query($sqlafterimport); - if (!$resqlafterimport) - { + if (!$resqlafterimport) { $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $error++; } } } - if (!$error) $db->commit(); // We can commit if no errors. - else $db->rollback(); + if (!$error) { + $db->commit(); // We can commit if no errors. + } else { + $db->rollback(); + } } print dol_get_fiche_end(); @@ -2028,8 +2074,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print '<table summary="boxtable'.$pos.'" width="100%" class="nobordernopadding">'."\n"; } - if ($pos && $pos > count($fieldssource)) // No fields - { + if ($pos && $pos > count($fieldssource)) { // No fields print '<tr'.($nostyle ? '' : ' '.$bc[$var]).' style="height:'.$height.'">'; print '<td class="nocellnopadding" width="16" style="font-weight: normal">'; print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); @@ -2038,8 +2083,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print $langs->trans("NoFields"); print '</td>'; print '</tr>'; - } elseif ($key == 'none') // Empty line - { + } elseif ($key == 'none') { // Empty line print '<tr'.($nostyle ? '' : ' '.$bc[$var]).' style="height:'.$height.'">'; print '<td class="nocellnopadding" width="16" style="font-weight: normal">'; print '&nbsp;'; @@ -2058,9 +2102,10 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print '<td style="font-weight: normal">'; print $langs->trans("Field").' '.$pos; $example = $fieldssource[$pos]['example1']; - if ($example) - { - if (!utf8_check($example)) $example = utf8_encode($example); + if ($example) { + if (!utf8_check($example)) { + $example = utf8_encode($example); + } print ' (<i>'.$example.'</i>)'; } print '</td>'; @@ -2086,15 +2131,16 @@ function getnewkey(&$fieldssource, &$listofkey) $i = count($fieldssource) + 1; // Max number of key $maxkey = 0; - foreach ($listofkey as $key=>$val) - { + foreach ($listofkey as $key => $val) { $maxkey = max($maxkey, $key); } // Found next empty key - while ($i <= $maxkey) - { - if (empty($listofkey[$i])) break; - else $i++; + while ($i <= $maxkey) { + if (empty($listofkey[$i])) { + break; + } else { + $i++; + } } $listofkey[$i] = 1; diff --git a/htdocs/imports/index.php b/htdocs/imports/index.php index e27712a5e56..ac3d2b23f69 100644 --- a/htdocs/imports/index.php +++ b/htdocs/imports/index.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php'; // Load translation files required by the page $langs->load("exports"); -if (!$user->socid == 0) - accessforbidden(); +if (!$user->socid == 0) { + accessforbidden(); +} $import = new Import($db); $import->load_arrays($user); @@ -49,8 +50,7 @@ print '<br>'; print '<div class="center">'; -if (count($import->array_import_code)) -{ +if (count($import->array_import_code)) { print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import'); } print '</div>'; @@ -70,8 +70,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; $model = new ModeleImports(); $list = $model->liste_modeles($db); -foreach ($list as $key) -{ +foreach ($list as $key) { print '<tr class="oddeven">'; print '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>'; $text = $model->getDriverDescForKey($key); diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index baac0eb2cbd..2a9c2bb11f2 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -24,7 +24,9 @@ */ include_once 'inc.php'; -if (file_exists($conffile)) include_once $conffile; +if (file_exists($conffile)) { + include_once $conffile; +} require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; include_once $dolibarr_main_document_root.'/core/lib/images.lib.php'; require_once $dolibarr_main_document_root.'/core/class/extrafields.class.php'; @@ -46,13 +48,21 @@ $langs->setDefaultLang($setuplang); $langs->loadLangs(array("admin", "install", "other")); -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("--- repair: entering upgrade.php page"); -if (!is_object($conf)) dolibarr_install_syslog("repair: conf file not initialized", LOG_ERR); +if (!is_object($conf)) { + dolibarr_install_syslog("repair: conf file not initialized", LOG_ERR); +} /* @@ -90,15 +100,15 @@ print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; $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)) - { + 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 - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf is already instancied inside inc.php @@ -115,8 +125,7 @@ $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $doli $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); -if ($db->connected) -{ +if ($db->connected) { print '<tr><td class="nowrap">'; print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td class=\"right\">".$langs->trans("OK")."</td></tr>"; dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection").": ".$dolibarr_main_db_host.$langs->transnoentities("OK")); @@ -127,10 +136,8 @@ if ($db->connected) $ok = 0; } -if ($ok) -{ - if ($db->database_selected) - { +if ($ok) { + if ($db->database_selected) { print '<tr><td class="nowrap">'; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td class=\"right\">".$langs->trans("OK")."</td></tr>"; dolibarr_install_syslog("repair: database connection successful: ".$dolibarr_main_db_name); @@ -143,8 +150,7 @@ if ($ok) } // Show database version -if ($ok) -{ +if ($ok) { $version = $db->getVersion(); $versionarray = $db->getVersionArray(); print '<tr><td>'.$langs->trans("ServerVersion").'</td>'; @@ -155,7 +161,9 @@ if ($ok) $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; @@ -166,8 +174,7 @@ $oneoptionset = (GETPOST('standard', 'alpha') || GETPOST('restore_thirdparties_l || GETPOST('clean_perm_table', 'alpha') || GETPOST('force_disable_of_modules_not_found', 'alpha') || GETPOST('force_utf8_on_tables', 'alpha')); -if ($ok && $oneoptionset) -{ +if ($ok && $oneoptionset) { // Show wait message print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'<br><br></td></tr>'; flush(); @@ -175,8 +182,7 @@ if ($ok && $oneoptionset) // run_sql: Run repair SQL file -if ($ok && GETPOST('standard', 'alpha')) -{ +if ($ok && GETPOST('standard', 'alpha')) { $dir = "mysql/migration/"; $filelist = array(); @@ -186,26 +192,23 @@ if ($ok && GETPOST('standard', 'alpha')) // Recupere list fichier $filesindir = array(); $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/\.sql$/i', $file)) { + $filesindir[] = $file; + } } } sort($filesindir); - foreach ($filesindir as $file) - { - if (preg_match('/repair/i', $file)) - { + foreach ($filesindir as $file) { + if (preg_match('/repair/i', $file)) { $filelist[] = $file; } } // Loop on each file - foreach ($filelist as $file) - { + foreach ($filelist as $file) { print '<tr><td class="nowrap">*** '; print $langs->trans("Script").'</td><td class="right">'.$file.'</td></tr>'; @@ -219,8 +222,7 @@ if ($ok && GETPOST('standard', 'alpha')) // sync_extrafields: Search list of fields declared and list of fields created into databases, then create fields missing -if ($ok && GETPOST('standard', 'alpha')) -{ +if ($ok && GETPOST('standard', 'alpha')) { $extrafields = new ExtraFields($db); $listofmodulesextra = array('societe'=>'societe', 'adherent'=>'adherent', 'product'=>'product', 'socpeople'=>'socpeople', 'propal'=>'propal', 'commande'=>'commande', 'facture'=>'facture', @@ -228,8 +230,7 @@ if ($ok && GETPOST('standard', 'alpha')) 'actioncomm'=>'actioncomm', 'bom_bom'=>'bom_bom', 'mrp_mo'=>'mrp_mo', 'adherent_type'=>'adherent_type', 'user'=>'user', 'projet'=>'projet', 'projet_task'=>'projet_task'); print '<tr><td colspan="2"><br>*** Check fields into extra table structure match table of definition. If not add column into table</td></tr>'; - foreach ($listofmodulesextra as $tablename => $elementtype) - { + foreach ($listofmodulesextra as $tablename => $elementtype) { // Get list of fields $tableextra = MAIN_DB_PREFIX.$tablename.'_extrafields'; @@ -239,15 +240,12 @@ if ($ok && GETPOST('standard', 'alpha')) // Define $arrayoffieldsfound $arrayoffieldsfound = array(); $resql = $db->DDLDescTable($tableextra); - if ($resql) - { + if ($resql) { print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n"; $i = 0; - while ($obj = $db->fetch_object($resql)) - { + while ($obj = $db->fetch_object($resql)) { $fieldname = $fieldtype = ''; - if (preg_match('/mysql/', $db->type)) - { + if (preg_match('/mysql/', $db->type)) { $fieldname = $obj->Field; $fieldtype = $obj->Type; } else { @@ -255,20 +253,22 @@ if ($ok && GETPOST('standard', 'alpha')) $fieldtype = isset($obj->Type) ? $obj->Type : 'varchar'; } - if (empty($fieldname)) continue; - if (in_array($fieldname, array('rowid', 'tms', 'fk_object', 'import_key'))) continue; + if (empty($fieldname)) { + continue; + } + if (in_array($fieldname, array('rowid', 'tms', 'fk_object', 'import_key'))) { + continue; + } $arrayoffieldsfound[$fieldname] = array('type'=>$fieldtype); } // If it does not match, we create fields - foreach ($arrayoffieldsdesc as $code => $label) - { - if (!in_array($code, array_keys($arrayoffieldsfound))) - { + foreach ($arrayoffieldsdesc as $code => $label) { + if (!in_array($code, array_keys($arrayoffieldsfound))) { print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; $type = $extrafields->attributes[$elementtype]['type'][$code]; $length = $extrafields->attributes[$elementtype]['size'][$code]; $attribute = ''; $default = ''; $extra = ''; $null = 'null'; - if ($type == 'boolean') { + if ($type == 'boolean') { $typedb = 'int'; $lengthdb = '1'; } elseif ($type == 'price') { @@ -302,12 +302,10 @@ if ($ok && GETPOST('standard', 'alpha')) //var_dump($field_desc);exit; $result = 0; - if (GETPOST('standard', 'alpha') == 'confirmed') - { + if (GETPOST('standard', 'alpha') == 'confirmed') { $result = $db->DDLAddField($tableextra, $code, $field_desc, ""); - if ($result < 0) - { + if ($result < 0) { print "KO ".$db->lasterror."<br>\n"; } else { print "OK<br>\n"; @@ -327,15 +325,13 @@ if ($ok && GETPOST('standard', 'alpha')) // clean_data_ecm_dir: Clean data into ecm_directories table -if ($ok && GETPOST('standard', 'alpha')) -{ +if ($ok && GETPOST('standard', 'alpha')) { clean_data_ecm_directories(); } // clean declaration constants -if ($ok && GETPOST('standard', 'alpha')) -{ +if ($ok && GETPOST('standard', 'alpha')) { print '<tr><td colspan="2"><br>*** Clean constant record of modules not enabled</td></tr>'; $sql = "SELECT name, entity, value"; @@ -347,22 +343,18 @@ if ($ok && GETPOST('standard', 'alpha')) $sql .= " ORDER BY name, entity"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $db->begin(); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $reg = array(); - if (preg_match('/MAIN_MODULE_([^_]+)_(.+)/i', $obj->name, $reg)) - { + if (preg_match('/MAIN_MODULE_([^_]+)_(.+)/i', $obj->name, $reg)) { $name = $reg[1]; $type = $reg[2]; @@ -371,16 +363,13 @@ if ($ok && GETPOST('standard', 'alpha')) $sql2 .= " WHERE name = 'MAIN_MODULE_".$name."'"; $sql2 .= " AND entity = ".$obj->entity; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { $obj2 = $db->fetch_object($resql2); - if ($obj2 && $obj2->nb == 0) - { + if ($obj2 && $obj2->nb == 0) { // Module not found, so we can remove entry $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$db->escape($obj->name)."' AND entity = ".$obj->entity; - if (GETPOST('standard', 'alpha') == 'confirmed') - { + if (GETPOST('standard', 'alpha') == 'confirmed') { $db->query($sqldelete); print '<tr><td>Widget '.$obj->name.' set in entity '.$obj->entity.' with value '.$obj->value.' -> Module '.$name.' not enabled in entity '.$obj->entity.', we delete record</td></tr>'; @@ -405,30 +394,25 @@ if ($ok && GETPOST('standard', 'alpha')) // clean box of not enabled modules -if ($ok && GETPOST('standard', 'alpha')) -{ +if ($ok && GETPOST('standard', 'alpha')) { print '<tr><td colspan="2"><br>*** Clean definition of boxes of modules not enabled</td></tr>'; $sql = "SELECT file, entity FROM ".MAIN_DB_PREFIX."boxes_def"; $sql .= " WHERE file like '%@%'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $db->begin(); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $reg = array(); - if (preg_match('/^(.+)@(.+)$/i', $obj->file, $reg)) - { + if (preg_match('/^(.+)@(.+)$/i', $obj->file, $reg)) { $name = $reg[1]; $module = $reg[2]; @@ -438,17 +422,14 @@ if ($ok && GETPOST('standard', 'alpha')) $sql2 .= " AND entity = ".$obj->entity; $sql2 .= " AND value <> 0"; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { $obj2 = $db->fetch_object($resql2); - if ($obj2 && $obj2->nb == 0) - { + if ($obj2 && $obj2->nb == 0) { // Module not found, so we canremove entry $sqldeletea = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE entity = ".$obj->entity." AND box_id IN (SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def WHERE file = '".$db->escape($obj->file)."' AND entity = ".$obj->entity.")"; $sqldeleteb = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def WHERE file = '".$db->escape($obj->file)."' AND entity = ".$obj->entity; - if (GETPOST('standard', 'alpha') == 'confirmed') - { + if (GETPOST('standard', 'alpha') == 'confirmed') { $db->query($sqldeletea); $db->query($sqldeleteb); @@ -472,8 +453,7 @@ if ($ok && GETPOST('standard', 'alpha')) // restore_thirdparties_logos: Move logos to correct new directory. -if ($ok && GETPOST('restore_thirdparties_logos')) -{ +if ($ok && GETPOST('restore_thirdparties_logos')) { //$exts=array('gif','png','jpg'); $ext = ''; @@ -482,13 +462,11 @@ if ($ok && GETPOST('restore_thirdparties_logos')) $sql = "SELECT s.rowid, s.nom as name, s.logo FROM ".MAIN_DB_PREFIX."societe as s ORDER BY s.nom"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); /* @@ -499,43 +477,37 @@ if ($ok && GETPOST('restore_thirdparties_logos')) $tmp = explode('.', $obj->logo); $name = $tmp[0]; - if (isset($tmp[1])) $ext = '.'.$tmp[1]; + if (isset($tmp[1])) { + $ext = '.'.$tmp[1]; + } - if (!empty($name)) - { + if (!empty($name)) { $filetotest = $dolibarr_main_data_root.'/societe/logos/'.$name.$ext; $filetotestsmall = $dolibarr_main_data_root.'/societe/logos/thumbs/'.$name.'_small'.$ext; $exists = dol_is_file($filetotest); print 'Check thirdparty '.$obj->rowid.' name='.$obj->name.' logo='.$obj->logo.' file '.$filetotest." exists=".$exists."<br>\n"; - if ($exists) - { + if ($exists) { $filetarget = $dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/'.$name.$ext; $filetargetsmall = $dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/thumbs/'.$name.'_small'.$ext; $existt = dol_is_file($filetarget); - if (!$existt) - { - if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') - { + if (!$existt) { + if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') { dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos'); } print " &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotest." -> ".$filetarget."<br>\n"; - if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') - { + if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') { dol_copy($filetotest, $filetarget, '', 0); } } $existtt = dol_is_file($filetargetsmall); - if (!$existtt) - { - if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') - { + if (!$existtt) { + if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') { dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/thumbs'); } print " &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotestsmall." -> ".$filetargetsmall."<br>\n"; - if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') - { + if (GETPOST('restore_thirdparties_logos', 'alpha') == 'confirmed') { dol_copy($filetotestsmall, $filetargetsmall, '', 0); } } @@ -555,8 +527,7 @@ if ($ok && GETPOST('restore_thirdparties_logos')) // restore_user_pictures: Move pictures to correct new directory. -if ($ok && GETPOST('restore_user_pictures', 'alpha')) -{ +if ($ok && GETPOST('restore_user_pictures', 'alpha')) { //$exts=array('gif','png','jpg'); $ext = ''; @@ -565,13 +536,11 @@ if ($ok && GETPOST('restore_user_pictures', 'alpha')) $sql = "SELECT s.rowid, s.firstname, s.lastname, s.login, s.photo FROM ".MAIN_DB_PREFIX."user as s ORDER BY s.rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); /* @@ -582,62 +551,53 @@ if ($ok && GETPOST('restore_user_pictures', 'alpha')) $tmp = explode('.', $obj->photo); $name = $tmp[0]; - if (isset($tmp[1])) $ext = '.'.$tmp[1]; + if (isset($tmp[1])) { + $ext = '.'.$tmp[1]; + } - if (!empty($name)) - { + if (!empty($name)) { $filetotest = $dolibarr_main_data_root.'/users/'.substr(sprintf('%08d', $obj->rowid), -1, 1).'/'.substr(sprintf('%08d', $obj->rowid), -2, 1).'/'.$name.$ext; $filetotestsmall = $dolibarr_main_data_root.'/users/'.substr(sprintf('%08d', $obj->rowid), -1, 1).'/'.substr(sprintf('%08d', $obj->rowid), -2, 1).'/thumbs/'.$name.'_small'.$ext; $filetotestmini = $dolibarr_main_data_root.'/users/'.substr(sprintf('%08d', $obj->rowid), -1, 1).'/'.substr(sprintf('%08d', $obj->rowid), -2, 1).'/thumbs/'.$name.'_mini'.$ext; $exists = dol_is_file($filetotest); print 'Check user '.$obj->rowid.' lastname='.$obj->lastname.' fistname='.$obj->firstname.' photo='.$obj->photo.' file '.$filetotest." exists=".$exists."<br>\n"; - if ($exists) - { + if ($exists) { $filetarget = $dolibarr_main_data_root.'/users/'.$obj->rowid.'/'.$name.$ext; $filetargetsmall = $dolibarr_main_data_root.'/users/'.$obj->rowid.'/thumbs/'.$name.'_small'.$ext; $filetargetmini = $dolibarr_main_data_root.'/users/'.$obj->rowid.'/thumbs/'.$name.'_mini'.$ext; $existt = dol_is_file($filetarget); - if (!$existt) - { - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (!$existt) { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_mkdir($dolibarr_main_data_root.'/users/'.$obj->rowid); } print " &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotest." -> ".$filetarget."<br>\n"; - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_copy($filetotest, $filetarget, '', 0); } } $existtt = dol_is_file($filetargetsmall); - if (!$existtt) - { - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (!$existtt) { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_mkdir($dolibarr_main_data_root.'/users/'.$obj->rowid.'/thumbs'); } print " &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotestsmall." -> ".$filetargetsmall."<br>\n"; - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_copy($filetotestsmall, $filetargetsmall, '', 0); } } $existtt = dol_is_file($filetargetmini); - if (!$existtt) - { - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (!$existtt) { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_mkdir($dolibarr_main_data_root.'/users/'.$obj->rowid.'/thumbs'); } print " &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotestmini." -> ".$filetargetmini."<br>\n"; - if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') - { + if (GETPOST('restore_user_pictures', 'alpha') == 'confirmed') { dol_copy($filetotestmini, $filetargetmini, '', 0); } } @@ -656,8 +616,7 @@ if ($ok && GETPOST('restore_user_pictures', 'alpha')) // rebuild_product_thumbs: Rebuild thumbs for product files -if ($ok && GETPOST('rebuild_product_thumbs', 'alpha')) -{ +if ($ok && GETPOST('rebuild_product_thumbs', 'alpha')) { $ext = ''; global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; @@ -665,33 +624,26 @@ if ($ok && GETPOST('rebuild_product_thumbs', 'alpha')) $sql = "SELECT s.rowid, s.ref FROM ".MAIN_DB_PREFIX."product as s ORDER BY s.ref"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if (!empty($obj->ref)) - { + if (!empty($obj->ref)) { $files = dol_dir_list($dolibarr_main_data_root.'/produit/'.$obj->ref, 'files', 0); - foreach ($files as $file) - { + foreach ($files as $file) { // Generate thumbs. - if (image_format_supported($file['fullname']) == 1) - { + if (image_format_supported($file['fullname']) == 1) { $imgThumbSmall = 'notbuild'; - if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') - { + if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') { // Used on logon for example $imgThumbSmall = vignette($file['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); } print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbSmall." maxwidthsmall=".$maxwidthsmall." maxheightsmall=".$maxheightsmall."<br>\n"; $imgThumbMini = 'notbuild'; - if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') - { + if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') { // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($file['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); @@ -712,8 +664,7 @@ if ($ok && GETPOST('rebuild_product_thumbs', 'alpha')) } // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_linked_elements', 'alpha')) -{ +if ($ok && GETPOST('clean_linked_elements', 'alpha')) { print '<tr><td colspan="2"><br>*** Check table of linked elements and delete orphelins links</td></tr>'; // propal => order print '<tr><td colspan="2">'.checkLinkedElements('propal', 'commande')."</td></tr>\n"; @@ -736,8 +687,7 @@ if ($ok && GETPOST('clean_linked_elements', 'alpha')) // clean_menus: Check orphelins menus -if ($ok && GETPOST('clean_menus', 'alpha')) -{ +if ($ok && GETPOST('clean_menus', 'alpha')) { print '<tr><td colspan="2"><br>*** Clean menu entries coming from disabled modules</td></tr>'; $sql = "SELECT rowid, module"; @@ -746,14 +696,11 @@ if ($ok && GETPOST('clean_menus', 'alpha')) $sql .= " ORDER BY module"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $modulecond = $obj->module; @@ -764,30 +711,33 @@ if ($ok && GETPOST('clean_menus', 'alpha')) $db->begin(); - if ($modulecond) // And menu entry for module $modulecond was found in database. - { + if ($modulecond) { // And menu entry for module $modulecond was found in database. $moduleok = 0; - foreach ($modulecondarray as $tmpname) - { - if ($tmpname == 'margins') $tmpname = 'margin'; // TODO Remove this when normalized + foreach ($modulecondarray as $tmpname) { + if ($tmpname == 'margins') { + $tmpname = 'margin'; // TODO Remove this when normalized + } $result = 0; - if (!empty($conf->$tmpname)) $result = $conf->$tmpname->enabled; - if ($result) $moduleok++; + if (!empty($conf->$tmpname)) { + $result = $conf->$tmpname->enabled; + } + if ($result) { + $moduleok++; + } } - if (!$moduleok && $modulecond) - { + if (!$moduleok && $modulecond) { print ' - Module condition '.$modulecond.' seems ko, we delete menu entry.'; - if (GETPOST('clean_menus') == 'confirmed') - { + if (GETPOST('clean_menus') == 'confirmed') { $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE module = '".$db->escape($modulecond)."'"; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); - } else print ' - <span class="warning">Cleaned</span>'; + } else { + print ' - <span class="warning">Cleaned</span>'; + } } else { print ' - <span class="warning">Canceled (test mode)</span>'; } @@ -796,12 +746,17 @@ if ($ok && GETPOST('clean_menus', 'alpha')) } } - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } print'</td></tr>'; - if ($error) break; + if ($error) { + break; + } $i++; } @@ -816,70 +771,72 @@ if ($ok && GETPOST('clean_menus', 'alpha')) // clean_orphelin_dir: Run purge of directory -if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) -{ +if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) { $listmodulepart = array('company', 'invoice', 'invoice_supplier', 'propal', 'order', 'order_supplier', 'contract', 'tax'); - foreach ($listmodulepart as $modulepart) - { + foreach ($listmodulepart as $modulepart) { $filearray = array(); $upload_dir = isset($conf->$modulepart->dir_output) ? $conf->$modulepart->dir_output : ''; - if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing - if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output; - if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output; - if ($modulepart == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - if ($modulepart == 'contract') $upload_dir = $conf->contrat->dir_output; + if ($modulepart == 'company') { + $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing + } + if ($modulepart == 'invoice') { + $upload_dir = $conf->facture->dir_output; + } + if ($modulepart == 'invoice_supplier') { + $upload_dir = $conf->fournisseur->facture->dir_output; + } + if ($modulepart == 'order') { + $upload_dir = $conf->commande->dir_output; + } + if ($modulepart == 'order_supplier') { + $upload_dir = $conf->fournisseur->commande->dir_output; + } + if ($modulepart == 'contract') { + $upload_dir = $conf->contrat->dir_output; + } - if (empty($upload_dir)) continue; + if (empty($upload_dir)) { + continue; + } print '<tr><td colspan="2"><br>*** Clean orphelins files into files '.$upload_dir.'</td></tr>'; $filearray = dol_dir_list($upload_dir, "files", 1, '', array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'), '', SORT_DESC, 1, true); // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'company') - { + if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $object_instance = new Societe($db); } - if ($modulepart == 'invoice') - { + if ($modulepart == 'invoice') { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object_instance = new Facture($db); - } elseif ($modulepart == 'invoice_supplier') - { + } elseif ($modulepart == 'invoice_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object_instance = new FactureFournisseur($db); - } elseif ($modulepart == 'propal') - { + } elseif ($modulepart == 'propal') { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object_instance = new Propal($db); - } elseif ($modulepart == 'order') - { + } elseif ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $object_instance = new Commande($db); - } elseif ($modulepart == 'order_supplier') - { + } elseif ($modulepart == 'order_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $object_instance = new CommandeFournisseur($db); - } elseif ($modulepart == 'contract') - { + } elseif ($modulepart == 'contract') { include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $object_instance = new Contrat($db); - } elseif ($modulepart == 'tax') - { + } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($db); } - foreach ($filearray as $key => $file) - { + foreach ($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' - ) - { + ) { // Define relative path used to store the file $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); @@ -909,23 +866,22 @@ if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = $reg[1]; } - if ($id || $ref) - { + if ($id || $ref) { //print 'Fetch '.$id.' or '.$ref.'<br>'; $result = $object_instance->fetch($id, $ref); //print $result.'<br>'; - if ($result == 0) // Not found but no error - { + if ($result == 0) { // Not found but no error // Clean of orphelins directories are done into repair.php print '<tr><td colspan="2">'; print 'Delete orphelins file '.$file['fullname'].'<br>'; - if (GETPOST('clean_orphelin_dir', 'alpha') == 'confirmed') - { + if (GETPOST('clean_orphelin_dir', 'alpha') == 'confirmed') { dol_delete_file($file['fullname'], 1, 1, 1); dol_delete_dir(dirname($file['fullname']), 1); } print "</td></tr>"; - } elseif ($result < 0) print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'<br>'; + } elseif ($result < 0) { + print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'<br>'; + } } } } @@ -933,8 +889,7 @@ if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) } // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) -{ +if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { $methodtofix = GETPOST('methodtofix', 'alpha') ?GETPOST('methodtofix', 'alpha') : 'updatestock'; print '<tr><td colspan="2"><br>*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)</td></tr>'; @@ -947,32 +902,25 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) $sql .= " HAVING reel != SUM(pb.qty) or SUM(pb.qty) IS NULL"; print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr><td>Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch ? $obj->reelbatch : '0').' (sum product_batch)'; // Fix - if ($obj->reel != $obj->reelbatch) - { - if ($methodtofix == 'updatebatch') - { + if ($obj->reel != $obj->reelbatch) { + if ($methodtofix == 'updatebatch') { // Method 1 print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; - if (GETPOST('clean_product_stock_batch') == 'confirmed') - { + if (GETPOST('clean_product_stock_batch') == 'confirmed') { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { // TODO If it fails, we must make update //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; @@ -980,12 +928,10 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) } } } - if ($methodtofix == 'updatestock') - { + if ($methodtofix == 'updatestock') { // Method 2 print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? $obj->reelbatch : '0').' for ps.rowid = '.$obj->psrowid; - if (GETPOST('clean_product_stock_batch') == 'confirmed') - { + if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error = 0; $db->begin(); @@ -993,13 +939,11 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; $sql2 .= " SET reel = ".($obj->reelbatch ? $obj->reelbatch : '0')." WHERE rowid = ".$obj->psrowid; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { // We update product_stock, so we must fill p.stock into product too. $sql3 = 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; $resql3 = $db->query($sql3); - if (!$resql3) - { + if (!$resql3) { $error++; dol_print_error($db); } @@ -1008,8 +952,11 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) dol_print_error($db); } - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } } } } @@ -1028,8 +975,7 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) // clean_product_stock_negative_if_batch -if ($ok && GETPOST('clean_product_stock_negative_if_batch', 'alpha')) -{ +if ($ok && GETPOST('clean_product_stock_negative_if_batch', 'alpha')) { print '<tr><td colspan="2"><br>Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)</td></tr>'; $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; @@ -1039,15 +985,12 @@ if ($ok && GETPOST('clean_product_stock_negative_if_batch', 'alpha')) $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; $sql .= " HAVING reel != SUM(pb.qty)"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr><td>'.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; @@ -1058,8 +1001,7 @@ if ($ok && GETPOST('clean_product_stock_negative_if_batch', 'alpha')) } // set_empty_time_spent_amount -if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) -{ +if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { print '<tr><td colspan="2"><br>*** Set value of time spent without amount</td></tr>'; $sql = "SELECT COUNT(ptt.rowid) as nb, u.rowid as user_id, u.login, u.thm as user_thm"; @@ -1069,38 +1011,38 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) $sql .= " GROUP BY u.rowid, u.login, u.thm"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr><td>'.$obj->login.'-'.$obj->user_id.' ('.$obj->nb.' lines to fix) -> '.$obj->user_thm; $db->begin(); - if (GETPOST('set_empty_time_spent_amount') == 'confirmed') - { + if (GETPOST('set_empty_time_spent_amount') == 'confirmed') { $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } } - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } print'</td></tr>'; - if ($error) break; + if ($error) { + break; + } $i++; } @@ -1114,28 +1056,23 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) // force_disable_of_modules_not_found -if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) -{ +if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) { print '<tr><td colspan="2"><br>*** Force modules not found physicaly to be disabled (only modules adding js, css or hooks can be detected as removed physicaly)</td></tr>'; $arraylistofkey = array('hooks', 'js', 'css'); - foreach ($arraylistofkey as $key) - { + foreach ($arraylistofkey as $key) { $sql = "SELECT DISTINCT name, value"; $sql .= " FROM ".MAIN_DB_PREFIX."const as c"; $sql .= " WHERE name LIKE 'MAIN_MODULE_%_".strtoupper($key)."'"; $sql .= " ORDER BY name"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $constantname = $obj->name; // Name of constant for hook or js or css declaration @@ -1145,62 +1082,58 @@ if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) $db->begin(); $reg = array(); - if (preg_match('/MAIN_MODULE_(.*)_'.strtoupper($key).'/i', $constantname, $reg)) - { + if (preg_match('/MAIN_MODULE_(.*)_'.strtoupper($key).'/i', $constantname, $reg)) { $name = strtolower($reg[1]); - if ($name) // An entry for key $key and module $name was found in database. - { + if ($name) { // An entry for key $key and module $name was found in database. $reloffile = ''; $result = 'found'; - if ($key == 'hooks') $reloffile = $name.'/class/actions_'.$name.'.class.php'; - if ($key == 'js') - { + if ($key == 'hooks') { + $reloffile = $name.'/class/actions_'.$name.'.class.php'; + } + if ($key == 'js') { $value = $obj->value; $valuearray = json_decode($value); $reloffile = $valuearray[0]; $reloffile = preg_replace('/^\//', '', $valuearray[0]); } - if ($key == 'css') - { + if ($key == 'css') { $value = $obj->value; $valuearray = json_decode($value); - if ($value && count($valuearray) == 0) $valuearray[0] = $value; // If value was not a json array but a string + if ($value && count($valuearray) == 0) { + $valuearray[0] = $value; // If value was not a json array but a string + } $reloffile = preg_replace('/^\//', '', $valuearray[0]); } - if ($reloffile) - { + if ($reloffile) { //var_dump($key.' - '.$value.' - '.$reloffile); try { $result = dol_buildpath($reloffile, 0, 2); - } catch (Exception $e) - { + } catch (Exception $e) { // No catch yet $result = 'found'; // If error, we force lke if we found to avoid any deletion } } - if (!$result) - { + if (!$result) { print ' - File of '.$key.' ('.$reloffile.') NOT found, we disable the module.'; - if (GETPOST('force_disable_of_modules_not_found') == 'confirmed') - { + if (GETPOST('force_disable_of_modules_not_found') == 'confirmed') { $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_".strtoupper($key)."'"; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'"; $resql3 = $db->query($sql3); - if (!$resql3) - { + if (!$resql3) { $error++; dol_print_error($db); - } else print ' - <span class="warning">Cleaned</span>'; + } else { + print ' - <span class="warning">Cleaned</span>'; + } } else { print ' - <span class="warning">Canceled (test mode)</span>'; } @@ -1209,13 +1142,18 @@ if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) } } - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } } print'</td></tr>'; - if ($error) break; + if ($error) { + break; + } $i++; } @@ -1230,35 +1168,27 @@ if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) // clean_old_module_entries: Clean data into const when files of module were removed without being -if ($ok && GETPOST('clean_perm_table', 'alpha')) -{ +if ($ok && GETPOST('clean_perm_table', 'alpha')) { print '<tr><td colspan="2"><br>*** Clean table user_rights from lines of external modules no more enabled</td></tr>'; $listofmods = ''; - foreach ($conf->modules as $key => $val) - { + foreach ($conf->modules as $key => $val) { $listofmods .= ($listofmods ? ',' : '')."'".$val."'"; } $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->id > 0) - { + if ($obj->id > 0) { print '<tr><td>Found line with id '.$obj->id.', label "'.$obj->label.'" of module "'.$obj->module.'" to delete'; - if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') - { + if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') { $sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id; $resqldelete = $db->query($sqldelete); - if (!$resqldelete) - { + if (!$resqldelete) { dol_print_error($db); } print ' - deleted'; @@ -1278,44 +1208,42 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) // force utf8 on tables -if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) -{ +if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { print '<tr><td colspan="2"><br>*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)</td></tr>'; - if ($db->type == "mysql" || $db->type == "mysqli") - { + if ($db->type == "mysql" || $db->type == "mysqli") { $force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha'); $listoftables = $db->DDLListTables($db->database_name); // Disable foreign key checking for avoid errors - if ($force_utf8_on_tables == 'confirmed') - { + if ($force_utf8_on_tables == 'confirmed') { $sql = 'SET FOREIGN_KEY_CHECKS=0'; print '<!-- '.$sql.' -->'; $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; + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + continue; + } print '<tr><td colspan="2">'; print $table; $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; print '<!-- '.$sql.' -->'; - if ($force_utf8_on_tables == 'confirmed') - { + if ($force_utf8_on_tables == 'confirmed') { $resql = $db->query($sql); print ' - Done ('.($resql ? 'OK' : 'KO').')'; - } else print ' - Disabled'; + } else { + print ' - Disabled'; + } print '</td></tr>'; } // Enable foreign key checking - if ($force_utf8_on_tables == 'confirmed') - { + if ($force_utf8_on_tables == 'confirmed') { $sql = 'SET FOREIGN_KEY_CHECKS=1'; print '<!-- '.$sql.' -->'; $resql = $db->query($sql); @@ -1328,27 +1256,27 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) // if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { /* - * This script is meant to be run when upgrading from a dolibarr version < 3.8 - * to a newer version. - * - * Version 3.8 introduces a new column in llx_commande_fournisseur_dispatch, which - * matches the dispatch to a specific supplier order line (so that if there are - * several with the same product, the user can specifically tell which products of - * which line were dispatched where). - * - * However when migrating, the new column has a default value of 0, which means that - * old supplier orders whose lines were dispatched using the old dolibarr version - * have unspecific dispatch lines, which are not taken into account by the new version, - * thus making the order look like it was never dispatched at all. - * - * This scripts sets this foreign key to the first matching supplier order line whose - * product (and supplier order of course) are the same as the dispatch’s. - * - * If the dispatched quantity is more than indicated on the order line (this happens if - * there are several order lines for the same product), it creates new dispatch lines - * pointing to the other order lines accordingly, until all the dispatched quantity is - * accounted for. - */ + * This script is meant to be run when upgrading from a dolibarr version < 3.8 + * to a newer version. + * + * Version 3.8 introduces a new column in llx_commande_fournisseur_dispatch, which + * matches the dispatch to a specific supplier order line (so that if there are + * several with the same product, the user can specifically tell which products of + * which line were dispatched where). + * + * However when migrating, the new column has a default value of 0, which means that + * old supplier orders whose lines were dispatched using the old dolibarr version + * have unspecific dispatch lines, which are not taken into account by the new version, + * thus making the order look like it was never dispatched at all. + * + * This scripts sets this foreign key to the first matching supplier order line whose + * product (and supplier order of course) are the same as the dispatch’s. + * + * If the dispatched quantity is more than indicated on the order line (this happens if + * there are several order lines for the same product), it creates new dispatch lines + * pointing to the other order lines accordingly, until all the dispatched quantity is + * accounted for. + */ $repair_link_dispatch_lines_supplier_order_lines = GETPOST('repair_link_dispatch_lines_supplier_order_lines', 'alpha'); @@ -1384,9 +1312,13 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $n_processed_rows++; continue; } - if ($db->num_rows($resql_line) == 0) continue; + if ($db->num_rows($resql_line) == 0) { + continue; + } while ($obj_line = $db->fetch_object($resql_line)) { - if (!$remaining_qty) break; + if (!$remaining_qty) { + break; + } if (!$obj_line->rowid) { continue; } @@ -1419,8 +1351,7 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $sql_attach .= ' VALUES ('.$sql_attach_values.')'; } - if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') - { + if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') { $resql_attach = $db->query($sql_attach); } else { $resql_attach = true; // Force success in test mode @@ -1466,13 +1397,11 @@ print '</table>'; -if (empty($actiondone)) -{ +if (empty($actiondone)) { print '<div class="error">'.$langs->trans("ErrorWrongParameters").'</div>'; } -if ($oneoptionset) -{ +if ($oneoptionset) { print '<div class="center" style="padding-top: 10px"><a href="../index.php?mainmenu=home&leftmenu=home'.(GETPOSTISSET("login") ? '&username='.urlencode(GETPOST("login")) : '').'">'; print $langs->trans("GoToDolibarr"); print '</a></div>'; @@ -1485,7 +1414,11 @@ if ($oneoptionset) dolibarr_install_syslog("--- repair: end"); pFooter(1, $setuplang); -if ($db->connected) $db->close(); +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/intracommreport/admin/intracommreport.php b/htdocs/intracommreport/admin/intracommreport.php index 16e24503959..c696dddcabd 100644 --- a/htdocs/intracommreport/admin/intracommreport.php +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "intracommreport")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -46,10 +48,8 @@ $list_DES = array( if ($action == 'update') { $error = 0; - if (!$error) - { - foreach ($list_DEB as $constname) - { + if (!$error) { + foreach ($list_DEB as $constname) { $constvalue = GETPOST($constname, 'alpha'); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { @@ -57,8 +57,7 @@ if ($action == 'update') { } } - foreach ($list_DES as $constname) - { + foreach ($list_DES as $constname) { $constvalue = GETPOST($constname, 'alpha'); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { @@ -110,8 +109,7 @@ print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Value").'</td>'; print '</tr>'; -foreach ($list_DEB as $key) -{ +foreach ($list_DEB as $key) { print '<tr class="oddeven value">'; // Param @@ -175,8 +173,7 @@ print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Value").'</td>'; print '</tr>'; -foreach ($list_DES as $key) -{ +foreach ($list_DES as $key) { print '<tr class="oddeven value">'; // Param diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index d5f9704addc..5c6260dec84 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -24,9 +24,15 @@ * \brief File to calculate loan monthly payments */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 1143fbcd474..9e9e1a0a992 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -28,8 +28,12 @@ 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'; @@ -45,7 +49,9 @@ $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); @@ -60,16 +66,15 @@ $error = 0; */ $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)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { // Classify paid - if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) - { + if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setPaid($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); } else { setEventMessages($loan->error, null, 'errors'); @@ -77,12 +82,10 @@ if (empty($reshook)) } // Delete loan - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) - { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) { $object->fetch($id); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); header("Location: list.php"); exit; @@ -92,44 +95,37 @@ if (empty($reshook)) } // Add loan - if ($action == 'add' && $user->rights->loan->write) - { - if (!$cancel) - { + if ($action == 'add' && $user->rights->loan->write) { + if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int')); $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int')); $capital = price2num(GETPOST('capital')); $rate = GETPOST('rate'); - if (!$capital) - { + if (!$capital) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); } - if (!$datestart) - { + if (!$datestart) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); } - if (!$dateend) - { + if (!$dateend) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); } - if ($rate == '') - { + if ($rate == '') { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors'); } - if (!$error) - { + if (!$error) { $object->label = GETPOST('label'); - $object->fk_bank = GETPOST('accountid'); - $object->capital = $capital; + $object->fk_bank = GETPOST('accountid'); + $object->capital = $capital; $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = GETPOST('nbterm'); + $object->dateend = $dateend; + $object->nbterm = GETPOST('nbterm'); $object->rate = $rate; $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -140,13 +136,24 @@ if (empty($reshook)) $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); $accountancy_account_interest = GETPOST('accountancy_account_interest'); - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + if ($accountancy_account_capital <= 0) { + $object->account_capital = ''; + } else { + $object->account_capital = $accountancy_account_capital; + } + if ($accountancy_account_insurance <= 0) { + $object->account_insurance = ''; + } else { + $object->account_insurance = $accountancy_account_insurance; + } + if ($accountancy_account_interest <= 0) { + $object->account_interest = ''; + } else { + $object->account_interest = $accountancy_account_interest; + } $id = $object->create($user); - if ($id <= 0) - { + if ($id <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; @@ -156,21 +163,16 @@ if (empty($reshook)) header("Location: list.php"); exit(); } - } - - // Update record - elseif ($action == 'update' && $user->rights->loan->write) - { - if (!$cancel) - { + } elseif ($action == 'update' && $user->rights->loan->write) { + // Update record + if (!$cancel) { $result = $object->fetch($id); $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int')); $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int')); $capital = price2num(GETPOST('capital')); - if (!$capital) - { + if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); $action = 'edit'; } else { @@ -185,15 +187,26 @@ if (empty($reshook)) $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); $accountancy_account_interest = GETPOST('accountancy_account_interest'); - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + if ($accountancy_account_capital <= 0) { + $object->account_capital = ''; + } else { + $object->account_capital = $accountancy_account_capital; + } + if ($accountancy_account_insurance <= 0) { + $object->account_insurance = ''; + } else { + $object->account_insurance = $accountancy_account_insurance; + } + if ($accountancy_account_interest <= 0) { + $object->account_interest = ''; + } else { + $object->account_interest = $accountancy_account_interest; + } } $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -207,20 +220,20 @@ if (empty($reshook)) } // Link to a project - if ($action == 'classin' && $user->rights->loan->write) - { + if ($action == 'classin' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setProject($projectid); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } - if ($action == 'setlabel' && $user->rights->loan->write) - { + if ($action == 'setlabel' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } } @@ -231,7 +244,9 @@ if (empty($reshook)) $form = new Form($db); $formproject = new FormProjets($db); -if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); +} $title = $langs->trans("Loan").' - '.$langs->trans("Card"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; @@ -239,8 +254,7 @@ llxHeader("", $title, $help_url); // Create mode -if ($action == 'create') -{ +if ($action == 'create') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -260,8 +274,7 @@ if ($action == 'create') print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth300" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'" autofocus="autofocus"></td></tr>'; // Bank account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>'; $form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant print '</td></tr>'; @@ -296,8 +309,7 @@ if ($action == 'create') print '<tr><td>'.$langs->trans("Insurance").'</td><td><input name="insurance_amount" size="10" value="'.dol_escape_htmltag(GETPOST("insurance_amount")).'" placeholder="'.$langs->trans('Amount').'"></td></tr>'; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); // Projet associe @@ -329,8 +341,7 @@ if ($action == 'create') print '</td></tr>'; // Accountancy - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_account_capital print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LoanAccountancyCapitalCode").'</td>'; print '<td>'; @@ -379,32 +390,27 @@ if ($action == 'create') } // View -if ($id > 0) -{ +if ($id > 0) { $object = new Loan($db); $result = $object->fetch($id); - if ($result > 0) - { + if ($result > 0) { $head = loan_prepare_head($object); $totalpaid = $object->getSumPayment(); // Confirm for loan - if ($action == 'paid') - { + if ($action == 'paid') { $text = $langs->trans('ConfirmPayLoan'); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayLoan'), $text, "confirm_paid", '', '', 2); } - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteLoan'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteLoan'), $text, 'confirm_delete', '', '', 2); } - if ($action == 'edit') - { + if ($action == 'edit') { print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; @@ -422,14 +428,13 @@ if ($id > 0) $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($user->rights->loan->write) - { - if ($action != 'classify') + if ($user->rights->loan->write) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -466,8 +471,7 @@ if ($id > 0) print '<table class="border centpercent tableforfield">'; // Capital - if ($action == 'edit') - { + if ($action == 'edit') { print '<tr><td class="fieldrequired titlefield">'.$langs->trans("LoanCapital").'</td><td>'; print '<input name="capital" size="10" value="'.$object->capital.'"></td></tr>'; print '</td></tr>'; @@ -476,8 +480,7 @@ if ($id > 0) } // Insurance - if ($action == 'edit') - { + if ($action == 'edit') { print '<tr><td class="titlefield">'.$langs->trans("Insurance").'</td><td>'; print '<input name="insurance_amount" size="10" value="'.$object->insurance_amount.'"></td></tr>'; print '</td></tr>'; @@ -488,8 +491,7 @@ if ($id > 0) // Date start print '<tr><td>'.$langs->trans("DateStart")."</td>"; print "<td>"; - if ($action == 'edit') - { + if ($action == 'edit') { print $form->selectDate($object->datestart, 'start', 0, 0, 0, 'update', 1, 0); } else { print dol_print_date($object->datestart, "day"); @@ -499,8 +501,7 @@ if ($id > 0) // Date end print '<tr><td>'.$langs->trans("DateEnd")."</td>"; print "<td>"; - if ($action == 'edit') - { + if ($action == 'edit') { print $form->selectDate($object->dateend, 'end', 0, 0, 0, 'update', 1, 0); } else { print dol_print_date($object->dateend, "day"); @@ -510,8 +511,7 @@ if ($id > 0) // Nbterms print '<tr><td>'.$langs->trans("Nbterms").'</td>'; print '<td>'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<input name="nbterm" size="4" value="'.$object->nbterm.'">'; } else { print $object->nbterm; @@ -521,8 +521,7 @@ if ($id > 0) // Rate print '<tr><td>'.$langs->trans("Rate").'</td>'; print '<td>'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<input name="rate" size="4" value="'.$object->rate.'">%'; } else { print price($object->rate).'%'; @@ -531,14 +530,12 @@ if ($id > 0) // Accountancy account capital print '<tr>'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<td class="nowrap fieldrequired">'; print $langs->trans("LoanAccountancyCapitalCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1); } else { print '<input name="accountancy_account_capital" size="16" value="'.$object->account_capital.'">'; @@ -549,8 +546,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_capital, 1); @@ -565,14 +561,12 @@ if ($id > 0) // Accountancy account insurance print '<tr>'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<td class="nowrap fieldrequired">'; print $langs->trans("LoanAccountancyInsuranceCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1); } else { print '<input name="accountancy_account_insurance" size="16" value="'.$object->account_insurance.'">'; @@ -583,8 +577,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInsuranceCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_insurance, 1); @@ -599,14 +592,12 @@ if ($id > 0) // Accountancy account interest print '<tr>'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<td class="nowrap fieldrequired">'; print $langs->trans("LoanAccountancyInterestCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1); } else { print '<input name="accountancy_account_interest" size="16" value="'.$object->account_interest.'">'; @@ -617,8 +608,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print '</td><td>'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_interest, 1); @@ -653,8 +643,7 @@ if ($id > 0) //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $total_insurance = 0; @@ -672,8 +661,7 @@ if ($id > 0) print '<td class="right">'.$langs->trans("LoanCapital").'</td>'; print '</tr>'; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -690,8 +678,7 @@ if ($id > 0) $totalpaid = $total_capital; - if ($object->paid == 0 || $object->paid == 2) - { + if ($object->paid == 0 || $object->paid == 2) { print '<tr><td colspan="5" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td colspan="5" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; @@ -718,8 +705,7 @@ if ($id > 0) print dol_get_fiche_end(); - if ($action == 'edit') - { + if ($action == 'edit') { print '<div class="center">'; print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; @@ -732,34 +718,28 @@ if ($id > 0) /* * Buttons actions */ - if ($action != 'edit') - { + if ($action != 'edit') { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { print '<div class="tabsAction">'; // Edit - if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) { print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'; } // Emit payment - if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&amp;action=create">'.$langs->trans("DoPayment").'</a></div>'; } // Classify 'paid' - if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) { print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=paid&amp;token='.newToken().'">'.$langs->trans("ClassifyPaid").'</a></div>'; } // Delete - if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) - { + if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) { print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans("Delete").'</a></div>'; } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 9f2d8297edc..c82be7848a6 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -135,10 +135,8 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -188,36 +186,52 @@ class Loan extends CommonObject // clean parameters $newcapital = price2num($this->capital, 'MT'); - if (empty($this->insurance_amount)) $this->insurance_amount = 0; + if (empty($this->insurance_amount)) { + $this->insurance_amount = 0; + } $newinsuranceamount = price2num($this->insurance_amount, 'MT'); - 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->account_capital)) $this->account_capital = trim($this->account_capital); - if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance); - if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest); - 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; - if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project; + 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->account_capital)) { + $this->account_capital = trim($this->account_capital); + } + if (isset($this->account_insurance)) { + $this->account_insurance = trim($this->account_insurance); + } + if (isset($this->account_interest)) { + $this->account_interest = trim($this->account_interest); + } + 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; + } + if (isset($this->fk_project)) { + $this->fk_project = (int) $this->fk_project; + } // Check parameters - if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) - { + if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) { $this->error = "ErrorBadParameter"; return -2; } - if (($conf->accounting->enabled) && empty($this->account_capital)) - { + if (($conf->accounting->enabled) && empty($this->account_capital)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode")); return -2; } - if (($conf->accounting->enabled) && empty($this->account_insurance)) - { + if (($conf->accounting->enabled) && empty($this->account_insurance)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode")); return -2; } - if (($conf->accounting->enabled) && empty($this->account_interest)) - { + if (($conf->accounting->enabled) && empty($this->account_interest)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode")); return -2; } @@ -248,8 +262,7 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan"); //dol_syslog("Loans::create this->id=".$this->id); @@ -281,47 +294,39 @@ class Loan extends CommonObject $lines_url = $account->get_url('', $this->id, 'loan'); // Delete bank urls - foreach ($lines_url as $line_url) - { - if (!$error) - { + foreach ($lines_url as $line_url) { + if (!$error) { $accountline = new AccountLine($this->db); $accountline->fetch($line_url['fk_bank']); $result = $accountline->delete_urls($user); - if ($result < 0) - { + if ($result < 0) { $error++; } } } // Delete payments - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -341,8 +346,7 @@ class Loan extends CommonObject { $this->db->begin(); - if (!is_numeric($this->nbterm)) - { + if (!is_numeric($this->nbterm)) { $this->error = 'BadValueForParameterForNbTerm'; return -1; } @@ -364,8 +368,7 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -512,22 +515,29 @@ class Loan extends CommonObject $langs->loadLangs(array("customers", "bills")); unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); $this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); - if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) { + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); $this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); - if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) { + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } } $statusType = 'status1'; - if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) $statusType = 'status3'; - if ($status == 1) $statusType = 'status6'; + if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) { + $statusType = 'status3'; + } + if ($status == 1) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -560,33 +570,40 @@ class Loan extends CommonObject $url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; $linkend = '</a>'; $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 .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $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 .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + } $result .= $linkend; return $result; @@ -638,12 +655,13 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $amount = 0; $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + if ($obj) { + $amount = $obj->amount ? $obj->amount : 0; + } $this->db->free($resql); return $amount; @@ -668,26 +686,24 @@ class Loan extends CommonObject dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_modif) - { + if ($obj->fk_user_modif) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } $this->date_creation = $this->db->jdate($obj->datec); - if (empty($obj->fk_user_modif)) $obj->tms = ""; + if (empty($obj->fk_user_modif)) { + $obj->tms = ""; + } $this->date_modification = $this->db->jdate($obj->tms); $this->db->free($result); diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 50339359a9d..4f6f1423aa7 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -129,21 +129,36 @@ class LoanSchedule extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datep) - { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameter'; return -1; } // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0); - if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0); - if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0); - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - 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; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + if (isset($this->amount_capital)) { + $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0); + } + if (isset($this->amount_interest)) { + $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0); + } + if (isset($this->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + 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; + } $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; $totalamount = price2num($totalamount); @@ -157,8 +172,7 @@ class LoanSchedule extends CommonObject $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; $sql .= " fk_typepayment, fk_user_creat, fk_bank)"; $sql .= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',"; @@ -172,8 +186,7 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); } else { $this->error = $this->db->lasterror(); @@ -181,8 +194,7 @@ class LoanSchedule extends CommonObject } } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount_capital = $totalamount; $this->db->commit(); return $this->id; @@ -280,14 +292,30 @@ class LoanSchedule extends CommonObject $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->fk_payment_loan)) $this->fk_payment_loan = (int) $this->fk_payment_loan; + 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->fk_payment_loan)) { + $this->fk_payment_loan = (int) $this->fk_payment_loan; + } // Check parameters // Put here code to add control on parameters values @@ -317,11 +345,12 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { + if ($error) { $this->db->rollback(); return -1 * $error; } else { @@ -351,14 +380,14 @@ class LoanSchedule extends CommonObject 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -423,10 +452,8 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $line = new LoanSchedule($this->db); $line->id = $obj->rowid; $line->ref = $obj->rowid; @@ -537,14 +564,15 @@ class LoanSchedule extends CommonObject $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; $sql .= " WHERE p.fk_loan = ".$loanid; - if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; } + if (!empty($datemax)) { + $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; + } $sql .= " AND p.datep <= '".$this->db->idate(dol_now())."'"; $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $result[] = $obj->rowid; } } diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index aa3f895f314..1ca8e1c0a4d 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -126,36 +126,58 @@ class PaymentLoan extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datep) - { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameter'; return -1; } // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - if (isset($this->amount_capital)) $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); - if (isset($this->amount_insurance)) $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); - if (isset($this->amount_interest)) $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - if (isset($this->num_payment)) $this->num_payment = (int) $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 = (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; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + if (isset($this->amount_capital)) { + $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); + } + if (isset($this->amount_interest)) { + $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); + } + if (isset($this->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + if (isset($this->num_payment)) { + $this->num_payment = (int) $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 = (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; + } $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null + if ($totalamount == 0) { + return -1; // Negative amounts are accepted for reject prelevement but not null + } $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; $sql .= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)"; $sql .= " VALUES (".$this->chid.", '".$this->db->idate($now)."',"; @@ -168,8 +190,7 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); } else { $this->error = $this->db->lasterror(); @@ -177,8 +198,7 @@ class PaymentLoan extends CommonObject } } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount_capital = $totalamount; $this->db->commit(); return $this->id; @@ -223,10 +243,8 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -276,17 +294,39 @@ class PaymentLoan extends CommonObject $error = 0; // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - 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->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment; - if (isset($this->note_private)) $this->note = trim($this->note_private); - if (isset($this->note_public)) $this->note = 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; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + 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->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + if (isset($this->num_payment)) { + $this->num_payment = (int) $this->num_payment; + } + if (isset($this->note_private)) { + $this->note = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note = 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; + } // Check parameters @@ -314,13 +354,13 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -347,35 +387,35 @@ class PaymentLoan extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; $sql .= " WHERE type='payment_loan' AND url_id=".$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_loan"; $sql .= " WHERE rowid=".$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(); + } } // Set loan unpaid if loan has no other payment - if (!$error) - { + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $loan = new Loan($this->db); $loan->fetch($this->fk_loan); $sum_payment = $loan->getSumPayment(); - if ($sum_payment == 0) - { + if ($sum_payment == 0) { dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); if ($loan->setUnpaid($user) < 1) { $error++; @@ -401,10 +441,8 @@ class PaymentLoan extends CommonObject //} // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -461,15 +499,16 @@ class PaymentLoan extends CommonObject $error = 0; $this->db->begin(); - 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->amount_capital; - if ($mode == 'payment_loan') $total = -$total; + if ($mode == 'payment_loan') { + $total = -$total; + } // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -486,23 +525,21 @@ class PaymentLoan extends CommonObject // Update fk_bank into llx_paiement. // We know the payment who generated the account write - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment_loan' in bank_url between payment and bank transaction $url = ''; - if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; - if ($url) - { + if ($mode == 'payment_loan') { + $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; + } + if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } @@ -510,10 +547,11 @@ class PaymentLoan extends CommonObject // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - if ($mode == 'payment_loan') - { + if ($mode == 'payment_loan') { $result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan'); - if ($result <= 0) dol_print_error($this->db); + if ($result <= 0) { + dol_print_error($this->db); + } } } else { $this->error = $acc->error; @@ -523,28 +561,23 @@ class PaymentLoan extends CommonObject // Set loan payment started if no set - if (!$error) - { + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $loan = new Loan($this->db); $loan->fetch($fk_loan); - if ($loan->paid == $loan::STATUS_UNPAID) - { + if ($loan->paid == $loan::STATUS_UNPAID) { dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); - if ($loan->setStarted($user) < 1) - { + if ($loan->setStarted($user) < 1) { $error++; dol_print_error($this->db); } } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; - } - else { + } else { $this->db->rollback(); return -1; } @@ -565,8 +598,7 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->fk_bank = $id_bank; return 1; } else { @@ -589,27 +621,39 @@ class PaymentLoan extends CommonObject { global $langs, $conf; - 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 = '<u>'.$langs->trans("Loan").'</u>'; if (!empty($this->id)) { $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id; } - if ($moretitle) $label .= ' - '.$moretitle; + if ($moretitle) { + $label .= ' - '.$moretitle; + } $url = DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id; $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'; + 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 = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; return $result; diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index a7811dfa04a..545d2ddfabf 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -40,7 +40,9 @@ $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 @@ -54,11 +56,17 @@ if (empty($page) || $page == -1) { $offset = $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 Loan($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart = 'loan'; @@ -81,8 +89,7 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Documents"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); -if ($object->id) -{ +if ($object->id) { $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); @@ -138,8 +145,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 0d9306aa71f..7ecc41fe4d6 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -38,7 +38,9 @@ $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/list.php b/htdocs/loan/list.php index 744a6929fc8..9040d140149 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -32,14 +32,18 @@ $langs->loadLangs(array("loan", "compta", "banks", "bills")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'loan', '', '', ''); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -48,8 +52,12 @@ $pagenext = $page + 1; $loan_static = new Loan($db); $extrafields = new ExtraFields($db); -if (!$sortfield) $sortfield = "l.rowid"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "l.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); @@ -63,18 +71,22 @@ $optioncss = GETPOST('optioncss', 'alpha'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +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 - { + 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_ref = ""; $search_label = ""; $search_amount = ""; @@ -97,35 +109,39 @@ $sql .= " SUM(pl.amount_capital) as alreadypaid"; $sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql .= " ON l.rowid = pl.fk_loan"; $sql .= " WHERE l.entity = ".$conf->entity; -if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); -if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); -if ($search_label) $sql .= natural_search("l.label", $search_label); +if ($search_amount) { + $sql .= natural_search("l.capital", $search_amount, 1); +} +if ($search_ref) { + $sql .= " AND l.rowid = ".$db->escape($search_ref); +} +if ($search_label) { + $sql .= natural_search("l.label", $search_label); +} $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -138,24 +154,39 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit llxHeader('', $title, $help_url); -if ($resql) -{ +if ($resql) { $i = 0; $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_ref) $param .= "&search_ref=".urlencode($search_ref); - if ($search_label) $param .= "&search_label=".urlencode($search_label); - if ($search_amount) $param .= "&search_amount=".urlencode($search_amount); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($search_ref) { + $param .= "&search_ref=".urlencode($search_ref); + } + if ($search_label) { + $param .= "&search_label=".urlencode($search_label); + } + if ($search_amount) { + $param .= "&search_amount=".urlencode($search_amount); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } $url = DOL_URL_ROOT.'/loan/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -201,10 +232,11 @@ if ($resql) // -------------------------------------------------------------------- $i = 0; $totalarray = array(); - while ($i < ($limit ? min($num, $limit) : $num)) - { + while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $loan_static->id = $obj->rowid; $loan_static->ref = $obj->rowid; @@ -240,8 +272,7 @@ if ($resql) } // If no record found - if ($num == 0) - { + if ($num == 0) { $colspan = 7; //foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 91f32679699..f7930b64c9a 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -44,7 +44,9 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'loan', $id, '&loan'); $object = new Loan($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php @@ -66,11 +68,10 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Notes"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); -if ($id > 0) -{ +if ($id > 0) { /* - * Affichage onglets - */ + * Affichage onglets + */ $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index ac76dbf9053..cf4466bb0da 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -24,7 +24,9 @@ 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")); @@ -33,15 +35,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "loan")); $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -if ($user->socid) $socid = $user->socid; +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) -{ +if ($id > 0) { $result = $payment->fetch($id); - if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); + if (!$result) { + dol_print_error($db, 'Failed to get payment id '.$id); + } } @@ -50,8 +55,7 @@ if ($id > 0) */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank; @@ -60,8 +64,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del $fk_loan = $payment->fk_loan; $result = $payment->delete($user); - if ($result > 0) - { + if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan); exit; @@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), -1, 'p /* * Confirm deletion of the payment */ -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } @@ -127,10 +129,8 @@ print '<tr><td>'.$langs->trans('NotePrivate').'</td><td>'.nl2br($payment->note_p print '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.nl2br($payment->note_public).'</td></tr>'; // Bank account -if (!empty($conf->banque->enabled)) -{ - if ($payment->bank_account) - { +if (!empty($conf->banque->enabled)) { + if ($payment->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($payment->bank_line); @@ -161,8 +161,7 @@ $sql .= ' AND pl.rowid = '.$payment->id; dol_syslog("loan/payment/card.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -176,10 +175,8 @@ if ($resql) print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>'; print "</tr>\n"; - if ($num > 0) - { - while ($i < $num) - { + if ($num > 0) { + while ($i < $num) { $objp = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -199,8 +196,7 @@ if ($resql) print '<td class="right">'.price($amount_payed).'</td>'; print "</tr>\n"; - if ($objp->paid == 1) // If at least one invoice is paid, disable delete - { + if ($objp->paid == 1) { // If at least one invoice is paid, disable delete $disable_delete = 1; } $total = $total + $objp->amount_capital; @@ -224,10 +220,8 @@ print '</div>'; print '<div class="tabsAction">'; -if (empty($action) && !empty($user->rights->loan->delete)) -{ - if (!$disable_delete) - { +if (empty($action) && !empty($user->rights->loan->delete)) { + if (!$disable_delete) { print '<a class="butActionDelete" href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>'; diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 0c0574c15b4..eec24d9b3e2 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -39,10 +39,14 @@ $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'in // Security check $socid = 0; -if ($user->socid > 0) +if ($user->socid > 0) { $socid = $user->socid; -elseif (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); -if (empty($user->rights->loan->write)) accessforbidden(); +} elseif (GETPOSTISSET('socid')) { + $socid = GETPOST('socid', 'int'); +} +if (empty($user->rights->loan->write)) { + accessforbidden(); +} $loan = new Loan($db); $loan->fetch($chid); @@ -51,35 +55,31 @@ $echance = 0; $ls = new LoanSchedule($db); // grab all loanschedule $res = $ls->fetchAll($chid); -if ($res > 0) -{ - foreach ($ls->lines as $l) - { +if ($res > 0) { + foreach ($ls->lines as $l) { $echance++; // Count term pos // last unpaid term - if (empty($l->fk_bank)) - { + if (empty($l->fk_bank)) { $line_id = $l->id; break; - } - // If line_id provided, only count temp pos - elseif ($line_id == $l->id) - { + } elseif ($line_id == $l->id) { + // If line_id provided, only count temp pos break; } } } // Set current line with last unpaid line (only if shedule is used) -if (!empty($line_id)) -{ +if (!empty($line_id)) { $line = new LoanSchedule($db); $res = $line->fetch($line_id); if ($res > 0) { $amount_capital = price($line->amount_capital); $amount_insurance = price($line->amount_insurance); $amount_interest = price($line->amount_interest); - if (empty($datepaid)) $ts_temppaid = $line->datep; + if (empty($datepaid)) { + $ts_temppaid = $line->datep; + } } } @@ -88,66 +88,59 @@ if (!empty($line_id)) * Actions */ -if ($action == 'add_payment') -{ +if ($action == 'add_payment') { $error = 0; - if ($cancel) - { + if ($cancel) { $loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid; header("Location: ".$loc); exit; } - if (!GETPOST('paymenttype', 'int') > 0) - { + if (!GETPOST('paymenttype', 'int') > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } - if ($datepaid == '') - { + if ($datepaid == '') { 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; $pay_amount_capital = price2num(GETPOST('amount_capital')); $pay_amount_insurance = price2num(GETPOST('amount_insurance')); // User can't set interest him self if schedule is set (else value in schedule can be incoherent) - if (!empty($line)) $pay_amount_interest = $line->amount_interest; - else $pay_amount_interest = price2num(GETPOST('amount_interest')); + if (!empty($line)) { + $pay_amount_interest = $line->amount_interest; + } else { + $pay_amount_interest = price2num(GETPOST('amount_interest')); + } $remaindertopay = price2num(GETPOST('remaindertopay')); $amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest; // This term is allready paid - if (!empty($line) && !empty($line->fk_bank)) - { + if (!empty($line) && !empty($line->fk_bank)) { setEventMessages($langs->trans('TermPaidAllreadyPaid'), null, 'errors'); $error++; } - if (empty($remaindertopay)) - { + if (empty($remaindertopay)) { setEventMessages('Empty sumpaid', null, 'errors'); $error++; } - if ($amount == 0) - { + if ($amount == 0) { setEventMessages($langs->trans('ErrorNoPaymentDefined'), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); // Create a line of payments @@ -164,38 +157,30 @@ if ($action == 'add_payment') $payment->note_private = GETPOST('note_private', 'restricthtml'); $payment->note_public = GETPOST('note_public', 'restricthtml'); - if (!$error) - { + if (!$error) { $paymentid = $payment->create($user); - if ($paymentid < 0) - { + if ($paymentid < 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', $payment->fk_bank, '', ''); - if (!$result > 0) - { + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } } // Update loan schedule with payment value - if (!$error && !empty($line)) - { + if (!$error && !empty($line)) { // If payment values are modified, recalculate schedule - if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) - { + if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) { $arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm); - foreach ($arr_term as $k=>$v) - { + foreach ($arr_term as $k => $v) { // Update fk_bank for current line - if ($k == $echance) - { + if ($k == $echance) { $ls->lines[$k - 1]->fk_bank = $payment->fk_bank; $ls->lines[$k - 1]->fk_payment_loan = $payment->id; } @@ -204,29 +189,25 @@ if ($action == 'add_payment') $ls->lines[$k - 1]->tms = dol_now(); $ls->lines[$k - 1]->fk_user_modif = $user->id; $result = $ls->lines[$k - 1]->update($user, 0); - if ($result < 1) - { + if ($result < 1) { setEventMessages(null, $ls->errors, 'errors'); $error++; break; } } - } - else // Only add fk_bank bank to schedule line (mark as paid) + } else // Only add fk_bank bank to schedule line (mark as paid) { $line->fk_bank = $payment->fk_bank; $line->fk_payment_loan = $payment->id; $result = $line->update($user, 0); - if ($result < 1) - { + if ($result < 1) { setEventMessages(null, $line->errors, 'errors'); $error++; } } } - if (!$error) - { + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid; header('Location: '.$loc); @@ -251,8 +232,7 @@ $form = new Form($db); // Form to create loan's payment -if ($action == 'create') -{ +if ($action == 'create') { $total = $loan->capital; print load_fiche_titre($langs->trans("DoPayment")); @@ -261,8 +241,7 @@ if ($action == 'create') $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan"; $sql .= " WHERE fk_loan = ".$chid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); @@ -282,10 +261,10 @@ if ($action == 'create') print '<table class="border centpercent">'; print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$chid.'">'.$chid.'</a></td></tr>'; - if ($echance > 0) - { - print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n"; - } + if ($echance > 0) + { + print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n"; + } print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="2">'.dol_print_date($loan->datestart, 'day')."</td></tr>\n"; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$loan->label."</td></tr>\n"; print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($loan->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; @@ -300,108 +279,106 @@ if ($action == 'create') print '<table class="border centpercent">'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">'; - if (empty($datepaid)) - if (empty($ts_temppaid)) $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now(); - else $datepayment = $ts_temppaid; - else $datepayment = $datepaid; - print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); - print "</td>"; - print '</tr>'; + if (empty($datepaid)) { + if (empty($ts_temppaid)) { + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now(); + } else { + $datepayment = $ts_temppaid; + } + } else { + $datepayment = $datepaid; + } + print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); + print "</td>"; + print '</tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">'; - $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype"); - print "</td>\n"; - print '</tr>'; + print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">'; + $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype"); + print "</td>\n"; + print '</tr>'; - print '<tr>'; - print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>'; - print '<td colspan="2">'; - $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list - print '</td></tr>'; + print '<tr>'; + print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>'; + print '<td colspan="2">'; + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list + print '</td></tr>'; // Number - print '<tr><td>'.$langs->trans('Numero'); - print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; - print '</td>'; - print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n"; - print "</tr>"; + print '<tr><td>'.$langs->trans('Numero'); + print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; + print '</td>'; + print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n"; + print "</tr>"; - print '<tr>'; - print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>'; - print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>'; - print '</tr>'; + print '<tr>'; + print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>'; + print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>'; + print '</tr>'; - print '<tr>'; - print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>'; - print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>'; - print '</tr>'; + print '<tr>'; + print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>'; + print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>'; + print '</tr>'; - print '</table>'; + print '</table>'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print '<td class="left">'.$langs->trans("DateDue").'</td>'; - print '<td class="right">'.$langs->trans("LoanCapital").'</td>'; - print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>'; - print '<td class="right">'.$langs->trans("RemainderToPay").'</td>'; - print '<td class="right">'.$langs->trans("Amount").'</td>'; - print "</tr>\n"; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print '<td class="left">'.$langs->trans("DateDue").'</td>'; + print '<td class="right">'.$langs->trans("LoanCapital").'</td>'; + print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>'; + print '<td class="right">'.$langs->trans("RemainderToPay").'</td>'; + print '<td class="right">'.$langs->trans("Amount").'</td>'; + print "</tr>\n"; - print '<tr class="oddeven">'; + print '<tr class="oddeven">'; - if ($loan->datestart > 0) - { + if ($loan->datestart > 0) { print '<td class="left" valign="center">'.dol_print_date($loan->datestart, 'day').'</td>'; } else { print '<td class="center" valign="center"><b>!!!</b></td>'; } - print '<td class="right" valign="center">'.price($loan->capital)."</td>"; + print '<td class="right" valign="center">'.price($loan->capital)."</td>"; - print '<td class="right" valign="center">'.price($sumpaid)."</td>"; + print '<td class="right" valign="center">'.price($sumpaid)."</td>"; - print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>"; + print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>"; - print '<td class="right">'; - if ($sumpaid < $loan->capital) - { + print '<td class="right">'; + if ($sumpaid < $loan->capital) { print $langs->trans("LoanCapital").': <input type="text" size="8" name="amount_capital" value="'.(GETPOSTISSET('amount_capital') ?GETPOST('amount_capital') : $amount_capital).'">'; - } - else { + } else { print '-'; } - print '<br>'; - if ($sumpaid < $loan->capital) - { + print '<br>'; + if ($sumpaid < $loan->capital) { print $langs->trans("Insurance").': <input type="text" size="8" name="amount_insurance" value="'.(GETPOSTISSET('amount_insurance') ?GETPOST('amount_insurance') : $amount_insurance).'">'; - } - else { + } else { print '-'; } - print '<br>'; - if ($sumpaid < $loan->capital) - { + print '<br>'; + if ($sumpaid < $loan->capital) { print $langs->trans("Interest").': <input type="text" size="8" name="amount_interest" value="'.(GETPOSTISSET('amount_interest') ?GETPOST('amount_interest') : $amount_interest).'" '.(!empty($line) ? 'disabled title="'.$langs->trans('CantModifyInterestIfScheduleIsUsed').'"' : '').'>'; - } - else { + } else { print '-'; } - print "</td>"; + print "</td>"; - print "</tr>\n"; + print "</tr>\n"; - print '</table>'; + print '</table>'; - print '<br><div class="center">'; - print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; - print '&nbsp; &nbsp;'; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</div>'; + print '<br><div class="center">'; + print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; + print '&nbsp; &nbsp;'; + print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '</div>'; - print "</form>\n"; + print "</form>\n"; } llxFooter(); diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index b9e6783ceca..2969d6958b5 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -35,9 +35,15 @@ $action = GETPOST('action', 'aZ09'); // Security check $socid = 0; -if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; -if (empty($user->rights->loan->calc)) accessforbidden(); +if (GETPOSTISSET('socid')) { + $socid = GETPOST('socid', 'int'); +} +if ($user->socid) { + $socid = $user->socid; +} +if (empty($user->rights->loan->calc)) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "loan")); @@ -120,7 +126,9 @@ if ($action == 'updateecheancier' && empty($pay_without_schedule)) { $echeances->lines[$i - 1] = $new_echeance; $i++; } - if ($result > 0) $db->commit(); + if ($result > 0) { + $db->commit(); + } } /* @@ -141,24 +149,23 @@ $morehtmlref = '<div class="refidno">'; $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); $morehtmlref .= '<br>'.$langs->trans('Project').' : '; - if ($user->rights->loan->write) - { - if ($action != 'classify') + if ($user->rights->loan->write) { + if ($action != 'classify') { //$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref .= '<input type="hidden" name="action" value="classin">'; - $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref .= '</form>'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; + } else { + $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)) { @@ -212,14 +219,14 @@ $(document).ready(function() { </script> <?php -if ($pay_without_schedule == 1) +if ($pay_without_schedule == 1) { print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n"; +} print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="loanid" value="'.$loanid.'">'; -if (count($echeances->lines) > 0) -{ +if (count($echeances->lines) > 0) { print '<input type="hidden" name="action" value="updateecheancier">'; } else { print '<input type="hidden" name="action" value="createecheancier">'; @@ -229,7 +236,9 @@ print '<div class="div-table-responsive-no-min">'; print '<table class="border centpercent">'; print '<tr class="liste_titre">'; $colspan = 6; -if (count($echeances->lines) > 0) $colspan++; +if (count($echeances->lines) > 0) { + $colspan++; +} print '<th class="center" colspan="'.$colspan.'">'; print $langs->trans("FinancialCommitment"); print '</th>'; @@ -245,18 +254,18 @@ print '<th class="center">'.$langs->trans("CapitalRemain"); print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; print '</th>'; -if (count($echeances->lines) > 0) print '<th class="center">'.$langs->trans('DoPayment').'</th>'; +if (count($echeances->lines) > 0) { + print '<th class="center">'.$langs->trans('DoPayment').'</th>'; +} print '</tr>'."\n"; -if ($object->nbterm > 0 && count($echeances->lines) == 0) -{ +if ($object->nbterm > 0 && count($echeances->lines) == 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; $insurance = price2num($insurance, 'MT'); $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); - while ($i < $object->nbterm + 1) - { + while ($i < $object->nbterm + 1) { $mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); $int = ($capital * ($object->rate / 12)) / 100; $int = price2num($int, 'MT'); @@ -273,8 +282,7 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) $i++; $capital = $cap_rest; } -} elseif (count($echeances->lines) > 0) -{ +} elseif (count($echeances->lines) > 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; @@ -300,14 +308,12 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) print '<td class="center" id="capital'.$i.'">'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">'; print '<td class="center">'; - if (!empty($line->fk_bank)) - { + if (!empty($line->fk_bank)) { print $langs->trans('Paid'); - if (!empty($line->fk_payment_loan)) + if (!empty($line->fk_payment_loan)) { print '&nbsp;<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>'; - } - elseif (!$printed) - { + } + } elseif (!$printed) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&amp;action=create">'.$langs->trans('DoPayment').'</a>'; $printed = true; } @@ -323,8 +329,11 @@ print '</div>'; print '</br>'; -if (count($echeances->lines) == 0) $label = $langs->trans("Create"); -else $label = $langs->trans("Save"); +if (count($echeances->lines) == 0) { + $label = $langs->trans("Create"); +} else { + $label = $langs->trans("Save"); +} print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1) ? 'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"' : '').'title=""></div>'; print '</form>'; From f73c0abec1fd5fa4097a7be0feb82f1ac2dae5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 18:26:44 +0100 Subject: [PATCH 156/173] code syntax m... directories --- .../mailmanspip/class/mailmanspip.class.php | 168 ++- htdocs/margin/admin/margin.php | 63 +- htdocs/margin/agentMargins.php | 114 +- htdocs/margin/checkMargins.php | 93 +- htdocs/margin/customerMargins.php | 144 ++- htdocs/margin/lib/margins.lib.php | 15 +- htdocs/margin/productMargins.php | 113 +- htdocs/margin/tabs/productMargins.php | 77 +- htdocs/margin/tabs/thirdpartyMargins.php | 101 +- htdocs/modulebuilder/admin/setup.php | 12 +- htdocs/modulebuilder/index.php | 1069 ++++++++--------- htdocs/modulebuilder/template/admin/about.php | 28 +- .../template/admin/myobject_extrafields.php | 28 +- htdocs/modulebuilder/template/admin/setup.php | 28 +- .../template/class/actions_mymodule.class.php | 17 +- .../template/class/api_mymodule.class.php | 57 +- .../template/class/myobject.class.php | 226 ++-- .../mailinglist_mymodule_myobject.modules.php | 23 +- .../doc/doc_generic_myobject_odt.modules.php | 121 +- .../doc/pdf_standard_myobject.modules.php | 425 +++---- .../mymodule/mod_myobject_advanced.php | 6 +- .../mymodule/mod_myobject_standard.php | 27 +- .../modules/mymodule/modules_myobject.php | 16 +- .../tpl/linkedobjectblock_myobject.tpl.php | 10 +- ..._99_modMyModule_MyModuleTriggers.class.php | 4 +- .../template/css/mymodule.css.php | 52 +- .../modulebuilder/template/js/mymodule.js.php | 68 +- .../template/lib/mymodule_myobject.lib.php | 19 +- .../modulebuilder/template/mymoduleindex.php | 32 +- .../template/myobject_agenda.php | 32 +- .../modulebuilder/template/myobject_card.php | 36 +- .../template/myobject_contact.php | 32 +- .../template/myobject_document.php | 32 +- .../modulebuilder/template/myobject_list.php | 71 +- .../modulebuilder/template/myobject_note.php | 32 +- .../template/scripts/mymodule.php | 31 +- htdocs/mrp/ajax/ajax_bom.php | 29 +- htdocs/mrp/class/mo.class.php | 280 ++--- htdocs/mrp/index.php | 61 +- htdocs/mrp/js/lib_dispatch.js.php | 35 +- htdocs/mrp/lib/mrp_mo.lib.php | 19 +- htdocs/mrp/mo_agenda.php | 76 +- htdocs/mrp/mo_card.php | 183 +-- htdocs/mrp/mo_document.php | 31 +- htdocs/mrp/mo_list.php | 318 +++-- htdocs/mrp/mo_movements.php | 349 +++--- htdocs/mrp/mo_note.php | 16 +- htdocs/mrp/mo_production.php | 177 +-- htdocs/mrp/tpl/originproductline.tpl.php | 11 +- .../class/multicurrency.class.php | 157 +-- htdocs/multicurrency/multicurrency_rate.php | 175 ++- htdocs/opensurvey/card.php | 123 +- .../class/opensurveysondage.class.php | 107 +- htdocs/opensurvey/exportcsv.php | 38 +- htdocs/opensurvey/fonctions.php | 9 +- htdocs/opensurvey/index.php | 11 +- htdocs/opensurvey/list.php | 203 ++-- htdocs/opensurvey/results.php | 469 ++++---- htdocs/opensurvey/wizard/choix_autre.php | 25 +- htdocs/opensurvey/wizard/choix_date.php | 85 +- htdocs/opensurvey/wizard/create_survey.php | 64 +- htdocs/opensurvey/wizard/index.php | 8 +- 62 files changed, 3649 insertions(+), 2832 deletions(-) diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index a0a636dd136..d08f6f65094 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -77,8 +77,7 @@ class MailmanSpip */ public function isSpipEnabled() { - if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) - { + if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) { return true; } @@ -92,10 +91,8 @@ class MailmanSpip */ public function checkSpipConfig() { - if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) - { - if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') - { + if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) { + if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') { return true; } } @@ -112,8 +109,7 @@ class MailmanSpip { $resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT); - if ($resource->ok) - { + if ($resource->ok) { return $resource; } @@ -165,8 +161,7 @@ class MailmanSpip dol_syslog('result curl_exec='.$result); //An error was found, we store it in $this->error for later - if ($result === false || curl_errno($ch) > 0) - { + if ($result === false || curl_errno($ch) > 0) { $this->error = curl_errno($ch).' '.curl_error($ch); dol_syslog('Error using curl '.$this->error, LOG_ERR); } @@ -188,14 +183,11 @@ class MailmanSpip // phpcs:enable dol_syslog(get_class($this)."::add_to_spip"); - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $mdpass = dol_hash($object->pass); $htpass = crypt($object->pass, makesalt()); @@ -205,13 +197,20 @@ class MailmanSpip $mydb->close(); - if ($result) - { + if ($result) { return 1; - } else $this->error = $mydb->lasterror(); - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = $mydb->lasterror(); + } + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return 0; } @@ -228,27 +227,31 @@ class MailmanSpip // phpcs:enable dol_syslog(get_class($this)."::del_to_spip"); - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { $query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'"; $result = $mydb->query($query); $mydb->close(); - if ($result) - { + if ($result) { return 1; - } else $this->error = $mydb->lasterror(); - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = $mydb->lasterror(); + } + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return 0; } @@ -263,22 +266,17 @@ class MailmanSpip public function is_in_spip($object) { // phpcs:enable - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { $query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'"; $result = $mydb->query($query); - if ($result) - { - if ($mydb->num_rows($result)) - { + if ($result) { + if ($mydb->num_rows($result)) { // nous avons au moins une reponse $mydb->close($result); return 1; @@ -291,9 +289,15 @@ class MailmanSpip $this->error = $mydb->lasterror(); $mydb->close(); } - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return -1; } @@ -316,36 +320,32 @@ class MailmanSpip $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"); return -1; } - if ($conf->adherent->enabled) // Synchro for members - { - 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 ($conf->adherent->enabled) { // Synchro for members + 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); + } $categstatic = new Categorie($this->db); - foreach ($lists as $list) - { + 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])) - { + if (!empty($tmp[2])) { $list = $tmp[2]; - if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label - { + 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; } @@ -354,11 +354,12 @@ class MailmanSpip //We call Mailman to subscribe the user $result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_URL, $list); - if ($result === false) - { + if ($result === false) { $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 { @@ -387,36 +388,32 @@ class MailmanSpip $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"); return -1; } - if ($conf->adherent->enabled) // Synchro for members - { - 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 ($conf->adherent->enabled) { // Synchro for members + 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); + } $categstatic = new Categorie($this->db); - foreach ($lists as $list) - { + 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])) - { + if (!empty($tmp[2])) { $list = $tmp[2]; - if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label - { + 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; } @@ -425,11 +422,12 @@ class MailmanSpip //We call Mailman to unsubscribe the user $result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list); - if ($result === false) - { + if ($result === false) { $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 { diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index d9c470b7acd..c041700fa18 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; $langs->loadLangs(array("admin", "bills", "margins", "stocks")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -40,11 +42,9 @@ $action = GETPOST('action', 'aZ09'); * Action */ -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -52,11 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) } } -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -64,30 +62,24 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) } } -if ($action == 'remises') -{ - if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'remises') { + if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); } } -if ($action == 'typemarges') -{ - if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'typemarges') { + if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); } } -if ($action == 'contact') -{ - if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'contact') { + if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); @@ -126,18 +118,23 @@ print '<tr class="oddeven">'; print '<td>'.$langs->trans("MARGIN_TYPE").'</td>'; print '<td>'; print ' <input type="radio" name="MARGIN_TYPE" value="1" '; -if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') { print 'checked '; +} print '/> '; print $langs->trans('MargeType1'); print '<br>'; print ' <input type="radio" name="MARGIN_TYPE" value="pmp" '; -if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') print 'checked '; +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') { + print 'checked '; +} print '/> '; print $langs->trans('MargeType2'); print '<br>'; print ' <input type="radio" name="MARGIN_TYPE" value="costprice" '; -if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') print 'checked '; +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') { + print 'checked '; +} print '/> '; print $langs->trans('MargeType3'); print '</td>'; @@ -153,12 +150,10 @@ print '</form>'; print '<tr class="oddeven">'; print '<td>'.$langs->trans("DisplayMarginRates").'</td>'; print '<td colspan="2">'; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARGIN_RATES'); } else { - if (empty($conf->global->DISPLAY_MARGIN_RATES)) - { + if (empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; } else { print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; @@ -172,12 +167,10 @@ print '</tr>'; print '<tr class="oddeven">'; print '<td>'.$langs->trans("DisplayMarkRates").'</td>'; print '<td colspan="2">'; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARK_RATES'); } else { - if (empty($conf->global->DISPLAY_MARK_RATES)) - { + if (empty($conf->global->DISPLAY_MARK_RATES)) { print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; } else { print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; @@ -191,12 +184,10 @@ print '</tr>'; print '<tr class="oddeven">'; print '<td>'.$langs->trans("ForceBuyingPriceIfNull").'</td>'; print '<td colspan="2">'; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('ForceBuyingPriceIfNull'); } else { - if (empty($conf->global->ForceBuyingPriceIfNull)) - { + if (empty($conf->global->ForceBuyingPriceIfNull)) { print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; } else { print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index d97d992b99d..717e2d02c1b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -39,16 +39,21 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) -{ - if ($agentid > 0) +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + if ($agentid > 0) { $sortfield = "s.nom"; - else $sortfield = "u.lastname"; + } else { + $sortfield = "u.lastname"; + } } $startdate = $enddate = ''; @@ -60,10 +65,12 @@ $enddateday = GETPOST('enddateday', 'int'); $enddatemonth = GETPOST('enddatemonth', 'int'); $enddateyear = GETPOST('enddateyear', 'int'); -if (!empty($startdatemonth)) +if (!empty($startdatemonth)) { $startdate = dol_mktime(0, 0, 0, $startdatemonth, $startdateday, $startdateyear); -if (!empty($enddatemonth)) +} +if (!empty($enddatemonth)) { $enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear); +} // Security check if ($user->rights->margins->read->all) { @@ -154,23 +161,31 @@ $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND sc.fk_soc = f.fk_soc"; $sql .= " AND (d.product_type = 0 OR d.product_type = 1)"; -if (!empty($conf->global->AGENT_CONTACT_TYPE)) +if (!empty($conf->global->AGENT_CONTACT_TYPE)) { $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; -else $sql .= " AND sc.fk_user = u.rowid"; +} else { + $sql .= " AND sc.fk_user = u.rowid"; +} $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= ' AND s.entity IN ('.getEntity('societe').')'; $sql .= " AND d.fk_facture = f.rowid"; if ($agentid > 0) { - if (!empty($conf->global->AGENT_CONTACT_TYPE)) - $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; - else $sql .= " AND sc.fk_user = ".$agentid; + if (!empty($conf->global->AGENT_CONTACT_TYPE)) { + $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; + } else { + $sql .= " AND sc.fk_user = ".$agentid; + } +} +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; } -if (!empty($startdate)) - $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) - $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; +} //if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; //else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname"; $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; @@ -183,28 +198,42 @@ print '<br>'; print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'<br>'; $param = ''; -if (!empty($agentid)) $param .= "&amp;agentid=".urlencode($agentid); -if (!empty($startdateday)) $param .= "&amp;startdateday=".urlencode($startdateday); -if (!empty($startdatemonth)) $param .= "&amp;startdatemonth=".urlencode($startdatemonth); -if (!empty($startdateyear)) $param .= "&amp;startdateyear=".urlencode($startdateyear); -if (!empty($enddateday)) $param .= "&amp;enddateday=".urlencode($enddateday); -if (!empty($enddatemonth)) $param .= "&amp;enddatemonth=".urlencode($enddatemonth); -if (!empty($enddateyear)) $param .= "&amp;enddateyear=".urlencode($enddateyear); +if (!empty($agentid)) { + $param .= "&amp;agentid=".urlencode($agentid); +} +if (!empty($startdateday)) { + $param .= "&amp;startdateday=".urlencode($startdateday); +} +if (!empty($startdatemonth)) { + $param .= "&amp;startdatemonth=".urlencode($startdatemonth); +} +if (!empty($startdateyear)) { + $param .= "&amp;startdateyear=".urlencode($startdateyear); +} +if (!empty($enddateday)) { + $param .= "&amp;enddateday=".urlencode($enddateday); +} +if (!empty($enddatemonth)) { + $param .= "&amp;enddatemonth=".urlencode($enddatemonth); +} +if (!empty($enddateyear)) { + $param .= "&amp;enddateyear=".urlencode($enddateyear); +} dol_syslog('margin::agentMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); print '<br>'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -213,21 +242,24 @@ if ($result) print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre">'; - if ($agentid > 0) + if ($agentid > 0) { print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + } else { + print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + } print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + } print "</tr>\n"; - if ($num > 0) - { + if ($num > 0) { $group_list = array(); while ($objp = $db->fetch_object($result)) { if ($agentid > 0) { @@ -295,10 +327,12 @@ if ($result) print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print "</tr>\n"; $i++; @@ -319,10 +353,12 @@ if ($result) print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print '</tr>'; print '</table>'; diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5d019b2693a..f61d8d02e55 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -44,12 +44,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = 'f.ref'; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = 'f.ref'; +} $startdate = $enddate = ''; @@ -73,15 +79,20 @@ if (GETPOST("button_search_x") || GETPOST("button_search")) { * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -108,23 +119,22 @@ 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 - { + 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_ref = ''; $search_array_options = array(); } // Mass actions /* - $objectclass='Product'; - if ((string) $type == '1') { $objectlabel='Services'; } - if ((string) $type == '0') { $objectlabel='Products'; } + $objectclass='Product'; + if ((string) $type == '1') { $objectlabel='Services'; } + if ((string) $type == '0') { $objectlabel='Products'; } - $permissiontoread = $user->rights->produit->lire; - $permissiontodelete = $user->rights->produit->supprimer; - $uploaddir = $conf->product->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - */ + $permissiontoread = $user->rights->produit->lire; + $permissiontodelete = $user->rights->produit->supprimer; + $uploaddir = $conf->product->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ } @@ -146,12 +156,24 @@ llxHeader('', $title); // print load_fiche_titre($text); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); -if (!empty($startdate)) $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int'); -if (!empty($enddate)) $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int'); -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} +if ($search_ref != '') { + $param .= '&search_ref='.urlencode($search_ref); +} +if (!empty($startdate)) { + $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int'); +} +if (!empty($enddate)) { + $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') { + $param .= '&optioncss='.$optioncss; +} // Show tabs $head = marges_prepare_head($user); @@ -194,9 +216,15 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowi $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql .= " WHERE f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= " AND f.entity IN (".getEntity('invoice').") "; -if (!empty($startdate)) $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; -if ($search_ref) $sql .= natural_search('f.ref', $search_ref); +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} +if ($search_ref) { + $sql .= natural_search('f.ref', $search_ref); +} $sql .= " AND d.buy_price_ht IS NOT NULL"; $sql .= $db->order($sortfield, $sortorder); @@ -205,8 +233,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -221,10 +248,11 @@ if ($result) { print '<br>'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -260,8 +288,7 @@ if ($result) { print "</tr>\n"; $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); print '<tr class="oddeven">'; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 1693462b749..05d5aa1ca5c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -36,7 +36,9 @@ $socid = GETPOST('socid', 'int'); $TSelectedProducts = GETPOST('products', 'array'); $TSelectedCats = GETPOST('categories', 'array'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'margins'); @@ -48,19 +50,27 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "s.nom"; // Set here default search field -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "s.nom"; // Set here default search field +} +if (!$sortorder) { + $sortorder = "ASC"; +} $startdate = $enddate = ''; -if (!empty($_POST['startdatemonth'])) - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); -if (!empty($_POST['enddatemonth'])) - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (!empty($_POST['startdatemonth'])) { + $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +} +if (!empty($_POST['enddatemonth'])) { + $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); @@ -98,16 +108,19 @@ if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - if ($soc->client) - { + if ($soc->client) { print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; print '<td class="maxwidthonsmartphone" colspan="4">'; print img_picto('', 'company').$form->select_company($socid, 'socid', '(client=1 OR client=3)', 1, 0, 0); print '</td></tr>'; $client = true; - if (!$sortorder) $sortorder = "DESC"; - if (!$sortfield) $sortfield = "f.datef"; + if (!$sortorder) { + $sortorder = "DESC"; + } + if (!$sortfield) { + $sortfield = "f.datef"; + } } } else { print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>'; @@ -118,11 +131,11 @@ if ($socid > 0) { $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) -{ - if ($client) - { +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + if ($client) { $sortfield = "f.datef"; $sortorder = "DESC"; } else { @@ -202,7 +215,9 @@ $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABAND $sql = "SELECT"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; -if ($client) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +if ($client) { + $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +} $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) $sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; @@ -214,10 +229,16 @@ if (!empty($TSelectedCats)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product'; } -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE f.fk_soc = s.rowid"; -if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid > 0) { + $sql .= ' AND s.rowid = '.$socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= ' AND s.entity IN ('.getEntity('societe').')'; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; @@ -229,32 +250,38 @@ if (!empty($TSelectedProducts)) { if (!empty($TSelectedCats)) { $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; } -if (!empty($startdate)) -$sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) -$sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) -$sql .= " AND d.buy_price_ht <> 0"; -if ($client) $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; -else $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; +} +if ($client) { + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; +} else { + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; +} $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin::customerMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); - print '<br>'; + print '<br>'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -264,33 +291,34 @@ if ($result) print '<tr class="liste_titre">'; if (!empty($client)) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;socid=".$socid, 'align="center"', $sortfield, $sortorder); - } else print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;socid=".$socid, 'align="center"', $sortfield, $sortorder); + } else { + print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); + } print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); + } print "</tr>\n"; $cumul_achat = 0; $cumul_vente = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $pa = $objp->buying_price; $pv = $objp->selling_price; $marge = $objp->marge; - if ($marge < 0) - { + if ($marge < 0) { $marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : ''; $markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : ''; } else { @@ -307,20 +335,22 @@ if ($result) print '</td>'; print '<td class="center">'; print dol_print_date($db->jdate($objp->datef), 'day').'</td>'; - } else { + } else { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - print '<td>'.$companystatic->getNomUrl(1, 'margin').'</td>'; - } + print '<td>'.$companystatic->getNomUrl(1, 'margin').'</td>'; + } print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print "</tr>\n"; $i++; @@ -344,17 +374,21 @@ if ($result) //} print '<tr class="liste_total">'; - if ($client) + if ($client) { print '<td colspan=2>'; - else print '<td>'; - print $langs->trans('TotalMargin')."</td>"; + } else { + print '<td>'; + } + print $langs->trans('TotalMargin')."</td>"; print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print '</tr>'; print '</table>'; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 6161ba2b6e4..802541b98ca 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -124,8 +124,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta if ($fk_pa > 0 && empty($paht)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product = new ProductFournisseur($db); - if ($product->fetch_product_fournisseur_price($fk_pa)) - { + if ($product->fetch_product_fournisseur_price($fk_pa)) { $paht_ret = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); } else { $paht_ret = $paht; @@ -141,16 +140,20 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta $pu_ht_remise = price2num($pu_ht_remise, 'MU'); // calcul marge - if ($pu_ht_remise < 0) + if ($pu_ht_remise < 0) { $marge = -1 * (abs($pu_ht_remise) - $paht_ret); - else $marge = $pu_ht_remise - $paht_ret; + } else { + $marge = $pu_ht_remise - $paht_ret; + } // calcul taux marge - if ($paht_ret != 0) + if ($paht_ret != 0) { $marge_tx_ret = (100 * $marge) / $paht_ret; + } // calcul taux marque - if ($pu_ht_remise != 0) + if ($pu_ht_remise != 0) { $marque_tx_ret = (100 * $marge) / $pu_ht_remise; + } return array($paht_ret, $marge_tx_ret, $marque_tx_ret); } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 3bb7eff8e23..0ac47243723 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -41,9 +41,13 @@ $TSelectedCats = GETPOST('categories', 'array'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->margins->liretous)) accessforbidden(); +if (empty($user->rights->margins->liretous)) { + accessforbidden(); +} $mesg = ''; @@ -52,14 +56,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) -{ - if ($id > 0) - { +if (!$sortfield) { + if ($id > 0) { $sortfield = "f.datef"; $sortorder = "DESC"; } else { @@ -70,10 +74,12 @@ if (!$sortfield) $startdate = $enddate = ''; -if (!empty($_POST['startdatemonth'])) - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); -if (!empty($_POST['enddatemonth'])) - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (!empty($_POST['startdatemonth'])) { + $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +} +if (!empty($_POST['enddatemonth'])) { + $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Product($db); @@ -169,8 +175,12 @@ print '</form>'; $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; -if ($id > 0) $sql .= " d.fk_product,"; -if ($id > 0) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +if ($id > 0) { + $sql .= " d.fk_product,"; +} +if ($id > 0) { + $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +} $sql .= " SUM(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) $sql .= " SUM(d.qty) as product_qty,"; @@ -187,38 +197,45 @@ $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= " AND d.fk_facture = f.rowid"; -if ($id > 0) +if ($id > 0) { $sql .= " AND d.fk_product =".$id; +} if (!empty($TSelectedCats)) { $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; } -if (!empty($startdate)) - $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) - $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { $sql .= " AND d.buy_price_ht <> 0"; -if ($id > 0) $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; -else $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; +} +if ($id > 0) { + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; +} else { + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; +} $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin::productMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); print '<br>'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -228,37 +245,36 @@ if ($result) print '<tr class="liste_titre">'; if ($id > 0) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'center '); - } else { - print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); - } + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'center '); + } else { + print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); + } print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); + } print "</tr>\n"; $cumul_achat = 0; $cumul_vente = 0; $cumul_qty = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $qty = $objp->product_qty; $pa = $objp->buying_price; $pv = $objp->selling_price; $marge = $objp->marge; - if ($marge < 0) - { + if ($marge < 0) { $marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : ''; $markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : ''; } else { @@ -277,8 +293,7 @@ if ($result) print dol_print_date($db->jdate($objp->datef), 'day')."</td>"; } else { print '<td>'; - if ($objp->rowid > 0) - { + if ($objp->rowid > 0) { $product_static->type = $objp->fk_product_type; $product_static->id = $objp->rowid; $product_static->ref = $objp->ref; @@ -296,10 +311,12 @@ if ($result) print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print "</tr>\n"; $i++; @@ -317,18 +334,22 @@ if ($result) $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : ''; print '<tr class="liste_total">'; - if ($id > 0) + if ($id > 0) { print '<td colspan=2>'; - else print '<td>'; + } else { + print '<td>'; + } print $langs->trans('TotalMargin').'</td>'; print '<td class="center">'.$cumul_qty.'</td>'; print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>'; print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>'; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>'; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>'; + } print "</tr>\n"; print "</table>"; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 5fcec11c93b..031c49e4cd0 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -36,9 +36,13 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->margins->liretous)) accessforbidden(); +if (empty($user->rights->margins->liretous)) { + accessforbidden(); +} $object = new Product($db); @@ -46,12 +50,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} /* @@ -62,20 +72,17 @@ $invoicestatic = new Facture($db); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) - { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos'; } - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) - { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios'; } @@ -85,8 +92,7 @@ if ($id > 0 || !empty($ref)) /* * En mode visu */ - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -133,7 +139,9 @@ if ($id > 0 || !empty($ref)) $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " sc.fk_soc, sc.fk_user,"; + } $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // not always positive in case of Credit note @@ -141,18 +149,28 @@ if ($id > 0 || !empty($ref)) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.fk_statut > 0"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND d.fk_product =".$object->id; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if (!empty($socid)) $sql .= " AND f.fk_soc = $socid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if (!empty($socid)) { + $sql .= " AND f.fk_soc = $socid"; + } $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; + } $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user"; + } $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -177,10 +195,12 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right '); print "</tr>\n"; @@ -209,10 +229,12 @@ if ($id > 0 || !empty($ref)) print "<td class=\"right\">".price(price2num($objp->buying_price, 'MT'))."</td>\n"; print "<td class=\"right\">".price(price2num($objp->qty, 'MT'))."</td>\n"; print "<td class=\"right\">".price(price2num($objp->marge, 'MT'))."</td>\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n"; + } print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).'</td>'; print "</tr>\n"; $i++; @@ -225,8 +247,7 @@ if ($id > 0 || !empty($ref)) // affichage totaux marges $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) - { + if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { @@ -239,10 +260,12 @@ if ($id > 0 || !empty($ref)) print '<td class="right">'.price(price2num($cumul_achat, 'MT'))."</td>\n"; print '<td class="right">'.price(price2num($cumul_qty, 'MT'))."</td>\n"; print '<td class="right">'.price(price2num($totalMargin, 'MT'))."</td>\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print '<td class="right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n"; + } print '<td class="right">&nbsp;</td>'; print "</tr>\n"; print "</table>"; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bfa5ac15811..054f2ae5f93 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -30,7 +30,9 @@ $langs->loadLangs(array("companies", "bills", "products", "margins")); // Security check $socid = GETPOST('socid', 'int'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'societe', '', ''); @@ -38,15 +40,23 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} $object = new Societe($db); -if ($socid > 0) $object->fetch($socid); +if ($socid > 0) { + $object->fetch($socid); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartymargins', 'globalcard')); @@ -58,7 +68,9 @@ $hookmanager->initHooks(array('thirdpartymargins', 'globalcard')); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} @@ -70,18 +82,19 @@ $invoicestatic = new Facture($db); $form = new Form($db); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Margins"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->name.' - '.$langs->trans("Files"); +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($socid > 0) -{ +if ($socid > 0) { $object = new Societe($db); $object->fetch($socid); /* - * Affichage onglets - */ + * Affichage onglets + */ $head = societe_prepare_head($object); @@ -96,27 +109,25 @@ if ($socid > 0) print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; - if ($object->client) - { - print '<tr><td class="titlefield">'; - print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; - } - print '</td></tr>'; - } + if ($object->client) { + print '<tr><td class="titlefield">'; + print $langs->trans('CustomerCode').'</td><td colspan="3">'; + print $object->code_client; + $tmpcheck = $object->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; + } + print '</td></tr>'; + } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; - } + $tmpcheck = $object->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; + } print '</td></tr>'; } @@ -163,7 +174,9 @@ if ($socid > 0) $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND f.fk_soc = $socid"; $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; + } $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination @@ -171,8 +184,7 @@ if ($socid > 0) dol_syslog('margin:tabs:thirdpartyMargins.php', LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&amp;socid=".$object->id, $sortfield, $sortorder, '', $num, $num, ''); @@ -187,20 +199,20 @@ if ($socid > 0) print_liste_field_titre("SoldAmount", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PurchasedAmount", $_SERVER["PHP_SELF"], "buying_price", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&amp;socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print "</tr>\n"; $cumul_achat = 0; $cumul_vente = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : ''; @@ -222,10 +234,12 @@ if ($socid > 0) print "<td class=\"right\">".price(price2num($objp->selling_price, 'MT'))."</td>\n"; print "<td class=\"right\">".price(price2num(($objp->type == 2 ? -1 : 1) * $objp->buying_price, 'MT'))."</td>\n"; print "<td class=\"right\">".$sign.price(price2num($objp->marge, 'MT'))."</td>\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : $sign.price(price2num($marginRate, 'MT'))."%")."</td>\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n"; + } print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).'</td>'; print "</tr>\n"; $i++; @@ -237,8 +251,7 @@ if ($socid > 0) // affichage totaux marges $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) - { + if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { @@ -252,10 +265,12 @@ if ($socid > 0) print "<td class=\"right\">".price(price2num($cumul_vente, 'MT'))."</td>\n"; print "<td class=\"right\">".price(price2num($cumul_achat, 'MT'))."</td>\n"; print "<td class=\"right\">".price(price2num($totalMargin, 'MT'))."</td>\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n"; + } print '<td class="right">&nbsp;</td>'; print "</tr>\n"; } else { diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index c5b41ac9390..e9e3ea752f5 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -26,8 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; global $conf, $langs, $user, $db; $langs->loadLangs(array("admin", "other", "modulebuilder")); -if (!$user->admin || empty($conf->modulebuilder->enabled)) +if (!$user->admin || empty($conf->modulebuilder->enabled)) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -35,8 +36,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ -if ($action == "update") -{ +if ($action == "update") { $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); @@ -58,8 +58,9 @@ $reg = array(); if (preg_match('/set_(.*)/', $action, $reg)) { $code = $reg[1]; $values = GETPOST($code); - if (is_array($values)) + if (is_array($values)) { $values = implode(',', $values); + } if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -112,8 +113,7 @@ print '<td>'.$langs->trans("Value").'</td>'; print "</tr>\n"; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // What is use case of this 2 options ? print '<tr class="oddeven">'; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index cbd0dc69375..101aa6db09c 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -27,7 +27,9 @@ * into the dirins directory. */ -if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test +if (!defined('NOSCANPOSTFORINJECTION')) { + define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test +} require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -48,17 +50,27 @@ $module = GETPOST('module', 'alpha'); $tab = GETPOST('tab', 'aZ09'); $tabobj = GETPOST('tabobj', 'alpha'); $propertykey = GETPOST('propertykey', 'alpha'); -if (empty($module)) $module = 'initmodule'; -if (empty($tab)) $tab = 'description'; -if (empty($tabobj)) $tabobj = 'newobjectifnoobj'; +if (empty($module)) { + $module = 'initmodule'; +} +if (empty($tab)) { + $tab = 'description'; +} +if (empty($tabobj)) { + $tabobj = 'newobjectifnoobj'; +} $file = GETPOST('file', 'alpha'); $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); // Security check -if (empty($conf->modulebuilder->enabled)) accessforbidden(); -if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden($langs->trans('ModuleBuilderNotAllowed')); +if (empty($conf->modulebuilder->enabled)) { + accessforbidden(); +} +if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) { + accessforbidden($langs->trans('ModuleBuilderNotAllowed')); +} // Dir for custom dirs @@ -68,14 +80,12 @@ $dirread = $dirins; $forceddirread = 0; $tmpdir = explode('@', $module); -if (!empty($tmpdir[1])) -{ +if (!empty($tmpdir[1])) { $module = $tmpdir[0]; $dirread = $tmpdir[1]; $forceddirread = 1; } -if (GETPOST('dirins', 'alpha')) -{ +if (GETPOST('dirins', 'alpha')) { $dirread = $dirins = GETPOST('dirins', 'alpha'); $forceddirread = 1; } @@ -84,9 +94,10 @@ $FILEFLAG = 'modulebuilder.txt'; $now = dol_now(); $newmask = 0; -if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; -if (empty($newmask)) // This should no happen -{ +if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) { + $newmask = $conf->global->MAIN_UMASK; +} +if (empty($newmask)) { // This should no happen $newmask = '0664'; } @@ -99,14 +110,15 @@ $form = new Form($db); // Define $listofmodules $dirsrootforscan = array($dirread); // Add also the core modules into the list of modules to show/edit -if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { $dirsrootforscan[] = DOL_DOCUMENT_ROOT; } +if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { + $dirsrootforscan[] = DOL_DOCUMENT_ROOT; +} // Search modules to edit $textforlistofdirs = '<!-- Directory scanned -->'."\n"; $listofmodules = array(); $i = 0; -foreach ($dirsrootforscan as $dirread) -{ +foreach ($dirsrootforscan as $dirread) { $moduletype = 'external'; if ($dirread == DOL_DOCUMENT_ROOT) { $moduletype = 'internal'; @@ -116,14 +128,12 @@ foreach ($dirsrootforscan as $dirread) if (is_array($dirsincustom) && count($dirsincustom) > 0) { foreach ($dirsincustom as $dircustomcursor) { $fullname = $dircustomcursor['fullname']; - if (dol_is_file($fullname.'/'.$FILEFLAG)) - { + if (dol_is_file($fullname.'/'.$FILEFLAG)) { // Get real name of module (MyModule instead of mymodule) $dirtoscanrel = basename($fullname).'/core/modules/'; $descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$'); - if (empty($descriptorfiles)) // If descriptor not found into module dir, we look into main module dir. - { + if (empty($descriptorfiles)) { // If descriptor not found into module dir, we look into main module dir. $dirtoscanrel = 'core/modules/'; $descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$'); } @@ -138,8 +148,7 @@ foreach ($dirsrootforscan as $dirread) $moduledescriptorfullpath = $descriptorcursor['fullname']; //var_dump($descriptorcursor); } - if ($modulenamewithcase) - { + if ($modulenamewithcase) { $listofmodules[$dircustomcursor['name']] = array( 'modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, @@ -153,8 +162,7 @@ foreach ($dirsrootforscan as $dirread) } } - if ($forceddirread && empty($listofmodules)) // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir - { + if ($forceddirread && empty($listofmodules)) { // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir $listofmodules[strtolower($module)] = array( 'modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', @@ -165,15 +173,24 @@ foreach ($dirsrootforscan as $dirread) // Show description of content $newdircustom = $dirins; - if (empty($newdircustom)) $newdircustom = img_warning(); + if (empty($newdircustom)) { + $newdircustom = img_warning(); + } // If dirread was forced to somewhere else, by using URL // htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product - if (empty($i)) $textforlistofdirs .= $langs->trans("DirScanned").' : '; - else $textforlistofdirs .= ', '; + if (empty($i)) { + $textforlistofdirs .= $langs->trans("DirScanned").' : '; + } else { + $textforlistofdirs .= ', '; + } $textforlistofdirs .= '<strong class="wordbreakimp">'.$dirread.'</strong>'; if ($dirread == DOL_DOCUMENT_ROOT) { - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL")); - if (!empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT)) $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MODULEBUILDER_ADD_DOCUMENT_ROOT")); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL")); + } + if (!empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT)) { + $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MODULEBUILDER_ADD_DOCUMENT_ROOT")); + } } $i++; } @@ -183,18 +200,15 @@ foreach ($dirsrootforscan as $dirread) * Actions */ -if ($dirins && $action == 'initmodule' && $modulename) -{ +if ($dirins && $action == 'initmodule' && $modulename) { $modulename = ucfirst($modulename); // Force first letter in uppercase - if (preg_match('/[^a-z0-9_]/i', $modulename)) - { + if (preg_match('/[^a-z0-9_]/i', $modulename)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($modulename); @@ -205,10 +219,8 @@ if ($dirins && $action == 'initmodule' && $modulename) $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); //dol_mkdir($destfile); - if ($result <= 0) - { - if ($result < 0) - { + if ($result <= 0) { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); @@ -218,8 +230,7 @@ if ($dirins && $action == 'initmodule' && $modulename) } } - if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) - { + if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } @@ -274,11 +285,9 @@ if ($dirins && $action == 'initmodule' && $modulename) } // Edit PHP files - if (!$error) - { + if (!$error) { $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); - foreach ($listofphpfilestoedit as $phpfileval) - { + foreach ($listofphpfilestoedit as $phpfileval) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -293,39 +302,45 @@ if ($dirins && $action == 'initmodule' && $modulename) ); if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) { + $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) { + $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) { + $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) { + $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) { + $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; + } } $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README)) - { + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README)) { setEventMessages($langs->trans("ContentOfREADMECustomized"), null, 'warnings'); dol_delete_file($destdir.'/README.md'); file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); } } - if (!$error) - { + if (!$error) { setEventMessages('ModuleInitialized', null); $module = $modulename; $modulename = ''; } } -if ($dirins && $action == 'initapi' && !empty($module)) -{ +if ($dirins && $action == 'initapi' && !empty($module)) { $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; @@ -336,8 +351,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -360,8 +374,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initphpunit' && !empty($module)) -{ +if ($dirins && $action == 'initphpunit' && !empty($module)) { $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; @@ -371,8 +384,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php'; $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -410,8 +422,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { //var_dump($srcfile);var_dump($destfile); $result2 = dol_copy($srcfile2, $destfile2, 0, 0); - if ($result1 > 0 && $result2 > 0) - { + if ($result1 > 0 && $result2 > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -439,8 +450,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { } // TODO Enable in class the property $isextrafieldmanaged = 1 } -if ($dirins && $action == 'inithook' && !empty($module)) -{ +if ($dirins && $action == 'inithook' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/class'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/class/actions_mymodule.class.php'; @@ -448,8 +458,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -471,8 +480,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'inittrigger' && !empty($module)) -{ +if ($dirins && $action == 'inittrigger' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/core/triggers'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php'; @@ -480,8 +488,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -503,8 +510,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initwidget' && !empty($module)) -{ +if ($dirins && $action == 'initwidget' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/core/boxes'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/core/boxes/mymodulewidget1.php'; @@ -534,8 +540,7 @@ if ($dirins && $action == 'initwidget' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initcss' && !empty($module)) -{ +if ($dirins && $action == 'initcss' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/css'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/css/mymodule.css.php'; @@ -543,8 +548,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -572,8 +576,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) } } -if ($dirins && $action == 'initjs' && !empty($module)) -{ +if ($dirins && $action == 'initjs' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/js'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/js/mymodule.js.php'; @@ -581,8 +584,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -609,8 +611,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initcli' && !empty($module)) -{ +if ($dirins && $action == 'initcli' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/scripts'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/scripts/mymodule.php'; @@ -618,8 +619,7 @@ if ($dirins && $action == 'initcli' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -694,19 +694,16 @@ if ($dirins && $action == 'initdoc' && !empty($module)) { } } -if ($dirins && $action == 'addlanguage' && !empty($module)) -{ +if ($dirins && $action == 'addlanguage' && !empty($module)) { $newlangcode = GETPOST('newlangcode', 'aZ09'); $srcfile = $dirins.'/'.strtolower($module).'/langs/en_US'; $destfile = $dirins.'/'.strtolower($module).'/langs/'.$newlangcode; $result = dolCopyDir($srcfile, $destfile, 0, 0); } -if ($dirins && $action == 'confirm_removefile' && !empty($module)) -{ +if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $relativefilename = dol_sanitizePathName(GETPOST('file', 'none')); - if ($relativefilename) - { + if ($relativefilename) { $dirnametodelete = dirname($relativefilename); $filetodelete = $dirins.'/'.$relativefilename; $dirtodelete = $dirins.'/'.$dirnametodelete; @@ -715,11 +712,12 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { - if (dol_is_dir_empty($dirtodelete)) dol_delete_dir($dirtodelete); + if (dol_is_dir_empty($dirtodelete)) { + dol_delete_dir($dirtodelete); + } // Update descriptor file to comment file - if (in_array($tab, array('css', 'js'))) - { + if (in_array($tab, array('css', 'js'))) { $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); @@ -729,12 +727,10 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) } // Build the $fields array from SQL table (initfromtablename) -if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) -{ +if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) { $tablename = GETPOST('initfromtablename', 'alpha'); $_results = $db->DDLDescTable($tablename); - if (empty($_results)) - { + if (empty($_results)) { setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors'); } else { /** @@ -780,66 +776,133 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $string = 'public $fields=array('."\n"; $string .= "<br>"; $i = 10; - while ($obj = $db->fetch_object($_results)) - { + while ($obj = $db->fetch_object($_results)) { // fieldname $fieldname = $obj->Field; // type $type = $obj->Type; - if ($type == 'int(11)') $type = 'integer'; - if ($type == 'float') $type = 'real'; - if (strstr($type, 'tinyint')) $type = 'integer'; - if ($obj->Field == 'fk_soc') $type = 'integer:Societe:societe/class/societe.class.php'; - if (preg_match('/^fk_proj/', $obj->Field)) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; - if (preg_match('/^fk_prod/', $obj->Field)) $type = 'integer:Product:product/class/product.class.php:1'; - if ($obj->Field == 'fk_warehouse') $type = 'integer:Entrepot:product/stock/class/entrepot.class.php'; - if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) $type = 'integer:User:user/class/user.class.php'; + if ($type == 'int(11)') { + $type = 'integer'; + } + if ($type == 'float') { + $type = 'real'; + } + if (strstr($type, 'tinyint')) { + $type = 'integer'; + } + if ($obj->Field == 'fk_soc') { + $type = 'integer:Societe:societe/class/societe.class.php'; + } + if (preg_match('/^fk_proj/', $obj->Field)) { + $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; + } + if (preg_match('/^fk_prod/', $obj->Field)) { + $type = 'integer:Product:product/class/product.class.php:1'; + } + if ($obj->Field == 'fk_warehouse') { + $type = 'integer:Entrepot:product/stock/class/entrepot.class.php'; + } + if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) { + $type = 'integer:User:user/class/user.class.php'; + } // notnull $notnull = ($obj->Null == 'YES' ? 0 : 1); - if ($fieldname == 'fk_user_modif') $notnull = -1; + if ($fieldname == 'fk_user_modif') { + $notnull = -1; + } // label $label = preg_replace('/_/', '', ucfirst($fieldname)); - if ($fieldname == 'rowid') $label = 'TechnicalID'; - if ($fieldname == 'import_key') $label = 'ImportId'; - if ($fieldname == 'fk_soc') $label = 'ThirdParty'; - if ($fieldname == 'tms') $label = 'DateModification'; - if ($fieldname == 'datec') $label = 'DateCreation'; - if ($fieldname == 'date_valid') $label = 'DateValidation'; - if ($fieldname == 'datev') $label = 'DateValidation'; - if ($fieldname == 'note_private') $label = 'NotePublic'; - if ($fieldname == 'note_public') $label = 'NotePrivate'; - if ($fieldname == 'fk_user_creat') $label = 'UserAuthor'; - if ($fieldname == 'fk_user_modif') $label = 'UserModif'; - if ($fieldname == 'fk_user_valid') $label = 'UserValidation'; + if ($fieldname == 'rowid') { + $label = 'TechnicalID'; + } + if ($fieldname == 'import_key') { + $label = 'ImportId'; + } + if ($fieldname == 'fk_soc') { + $label = 'ThirdParty'; + } + if ($fieldname == 'tms') { + $label = 'DateModification'; + } + if ($fieldname == 'datec') { + $label = 'DateCreation'; + } + if ($fieldname == 'date_valid') { + $label = 'DateValidation'; + } + if ($fieldname == 'datev') { + $label = 'DateValidation'; + } + if ($fieldname == 'note_private') { + $label = 'NotePublic'; + } + if ($fieldname == 'note_public') { + $label = 'NotePrivate'; + } + if ($fieldname == 'fk_user_creat') { + $label = 'UserAuthor'; + } + if ($fieldname == 'fk_user_modif') { + $label = 'UserModif'; + } + if ($fieldname == 'fk_user_valid') { + $label = 'UserValidation'; + } // visible $visible = -1; - if ($fieldname == 'entity') $visible = -2; - if ($fieldname == 'import_key') $visible = -2; - if ($fieldname == 'fk_user_creat') $visible = -2; - if ($fieldname == 'fk_user_modif') $visible = -2; - if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) $visible = 0; + if ($fieldname == 'entity') { + $visible = -2; + } + if ($fieldname == 'import_key') { + $visible = -2; + } + if ($fieldname == 'fk_user_creat') { + $visible = -2; + } + if ($fieldname == 'fk_user_modif') { + $visible = -2; + } + if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) { + $visible = 0; + } // enabled $enabled = 1; // default $default = ''; - if ($fieldname == 'entity') $default = 1; + if ($fieldname == 'entity') { + $default = 1; + } // position $position = $i; - if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) $position = 500; - if ($fieldname == 'import_key') $position = 900; + if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) { + $position = 500; + } + if ($fieldname == 'import_key') { + $position = 900; + } // index $index = 0; - if ($fieldname == 'entity') $index = 1; + if ($fieldname == 'entity') { + $index = 1; + } $string .= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; - if ($default != '') $string .= " 'default'=>".$default.","; + if ($default != '') { + $string .= " 'default'=>".$default.","; + } $string .= " 'enabled'=>".$enabled.","; $string .= " 'visible'=>".$visible; - if ($notnull) $string .= ", 'notnull'=>".$notnull; - if ($fieldname == 'ref') $string .= ", 'showoncombobox'=>1"; + if ($notnull) { + $string .= ", 'notnull'=>".$notnull; + } + if ($fieldname == 'ref') { + $string .= ", 'showoncombobox'=>1"; + } $string .= ", 'position'=>".$position; - if ($index) $string .= ", 'index'=>".$index; + if ($index) { + $string .= ", 'index'=>".$index; + } $string .= "),\n"; $string .= "<br>"; $i += 5; @@ -851,15 +914,13 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', } } -if ($dirins && $action == 'initobject' && $module && $objectname) -{ +if ($dirins && $action == 'initobject' && $module && $objectname) { $objectname = ucfirst($objectname); $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; $moduletype = $listofmodules[strtolower($module)]['moduletype']; - if (preg_match('/[^a-z0-9_]/i', $objectname)) - { + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); $tabobj = 'newobject'; @@ -882,15 +943,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) dol_mkdir($destdir.'/sql'); // Scan dir class to find if an object with same name already exists. - if (!$error) - { + if (!$error) { $dirlist = dol_dir_list($destdir.'/class', 'files', 0, '\.txt$'); $alreadyfound = false; - foreach ($dirlist as $key => $val) - { + foreach ($dirlist as $key => $val) { $filefound = preg_replace('/\.txt$/', '', $val['name']); - if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) - { + if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) { $alreadyfound = true; $error++; setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); @@ -899,8 +957,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (!$error) - { + if (!$error) { // Copy some files $filetogenerate = array( 'myobject_card.php'=>strtolower($objectname).'_card.php', @@ -922,8 +979,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php', ); - if (GETPOST('includerefgeneration', 'aZ09')) - { + if (GETPOST('includerefgeneration', 'aZ09')) { dol_mkdir($destdir.'/core/modules/'.strtolower($module)); $filetogenerate += array( @@ -932,8 +988,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'core/modules/mymodule/modules_myobject.php'=>'core/modules/'.strtolower($module).'/modules_'.strtolower($objectname).'.php', ); } - if (GETPOST('includedocgeneration', 'aZ09')) - { + if (GETPOST('includedocgeneration', 'aZ09')) { dol_mkdir($destdir.'/core/modules/'.strtolower($module)); dol_mkdir($destdir.'/core/modules/'.strtolower($module).'/doc'); @@ -943,13 +998,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) ); } - foreach ($filetogenerate as $srcfile => $destfile) - { + foreach ($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); - if ($result <= 0) - { - if ($result < 0) - { + if ($result <= 0) { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); @@ -999,17 +1051,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); $firstobjectname = ''; - foreach ($listofobject as $fileobj) - { - if (preg_match('/^api_/', $fileobj['name'])) continue; - if (preg_match('/^actions_/', $fileobj['name'])) continue; + foreach ($listofobject as $fileobj) { + if (preg_match('/^api_/', $fileobj['name'])) { + continue; + } + if (preg_match('/^actions_/', $fileobj['name'])) { + continue; + } $tmpcontent = file_get_contents($fileobj['fullname']); $reg = array(); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) - { + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { $objectnameloop = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectnameloop; + if (empty($firstobjectname)) { + $firstobjectname = $objectnameloop; + } } // Regenerate left menu entry in descriptor for $objectname @@ -1070,11 +1126,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (!$error) - { + if (!$error) { // Edit PHP files to make replacement - foreach ($filetogenerate as $destfile) - { + foreach ($filetogenerate as $destfile) { $phpfileval['fullname'] = $destdir.'/'.$destfile; //var_dump($phpfileval['fullname']); @@ -1094,75 +1148,71 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } } - if (!$error) - { + if (!$error) { // Edit the class file to write properties $object = rebuildObjectClass($destdir, $module, $objectname, $newmask); - if (is_numeric($object) && $object < 0) $error++; + if (is_numeric($object) && $object < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Edit sql with new properties $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); $tabobj = $objectname; } } -if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) -{ +if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) { $objectname = $tabobj; $arrayoftables = array(); - if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); - if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; + if ($action == 'droptable') { + $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); + } + if ($action == 'droptableextrafields') { + $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; + } - foreach ($arrayoftables as $tabletodrop) - { + foreach ($arrayoftables as $tabletodrop) { $nb = -1; $sql = "SELECT COUNT(*) as nb FROM ".$tabletodrop; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $nb = $obj->nb; } } else { - if ($db->lasterrno() == 'DB_ERROR_NOSUCHTABLE') - { + if ($db->lasterrno() == 'DB_ERROR_NOSUCHTABLE') { setEventMessages($langs->trans("TableDoesNotExists", $tabletodrop), null, 'warnings'); } else { dol_print_error($db); } } - if ($nb == 0) - { + if ($nb == 0) { $resql = $db->DDLDropTable($tabletodrop); //var_dump($resql); setEventMessages($langs->trans("TableDropped", $tabletodrop), null, 'mesgs'); - } elseif ($nb > 0) - { + } elseif ($nb > 0) { setEventMessages($langs->trans("TableNotEmptyDropCanceled", $tabletodrop), null, 'warnings'); } } } -if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) -{ +if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { $error = 0; $objectname = $tabobj; @@ -1175,26 +1225,21 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) dol_mkdir($destdir); // We click on add property - if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) - { - if (!GETPOST('propname', 'aZ09')) - { + if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { + if (!GETPOST('propname', 'aZ09')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name")), null, 'errors'); } - if (!GETPOST('proplabel', 'alpha')) - { + if (!GETPOST('proplabel', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!GETPOST('proptype', 'alpha')) - { + if (!GETPOST('proptype', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - if (!$error) - { + if (!$error) { $addfieldentry = array( 'name'=>GETPOST('propname', 'aZ09'), 'label'=>GETPOST('proplabel', 'alpha'), 'type'=>GETPOST('proptype', 'alpha'), 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' @@ -1203,8 +1248,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha') ); - if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) - { + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); } } @@ -1217,31 +1261,26 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) }*/ // Edit the class file to write properties - if (!$error) - { + if (!$error) { $moduletype = 'external'; $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry, $moduletype); - if (is_numeric($object) && $object <= 0) - { + if (is_numeric($object) && $object <= 0) { $error++; } } // Edit sql with new properties - if (!$error) - { + if (!$error) { $moduletype = 'external'; $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype); - if ($result <= 0) - { + if ($result <= 0) { $error++; } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); @@ -1253,8 +1292,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) } } -if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) -{ +if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) { $objectname = $tabobj; $srcdir = $dirread.'/'.strtolower($module); @@ -1262,21 +1300,22 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) dol_mkdir($destdir); // Edit the class file to write properties - if (!$error) - { + if (!$error) { $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); - if (is_numeric($object) && $object <= 0) $error++; + if (is_numeric($object) && $object <= 0) { + $error++; + } } // Edit sql with new properties - if (!$error) - { + if (!$error) { $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); - if ($result <= 0) $error++; + if ($result <= 0) { + $error++; + } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); @@ -1288,16 +1327,13 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) } } -if ($dirins && $action == 'confirm_deletemodule') -{ - if (preg_match('/[^a-z0-9_]/i', $module)) - { +if ($dirins && $action == 'confirm_deletemodule') { + if (preg_match('/[^a-z0-9_]/i', $module)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $modulelowercase = strtolower($module); // Dir for module @@ -1305,8 +1341,7 @@ if ($dirins && $action == 'confirm_deletemodule') $result = dol_delete_dir_recursive($dir); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); } else { setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); @@ -1317,16 +1352,13 @@ if ($dirins && $action == 'confirm_deletemodule') $module = 'deletemodule'; } -if ($dirins && $action == 'confirm_deleteobject' && $objectname) -{ - if (preg_match('/[^a-z0-9_]/i', $objectname)) - { +if ($dirins && $action == 'confirm_deleteobject' && $objectname) { + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $modulelowercase = strtolower($module); $objectlowercase = strtolower($objectname); @@ -1360,15 +1392,15 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) ); $resultko = 0; - foreach ($filetodelete as $filetodelete) - { + foreach ($filetodelete as $filetodelete) { $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); $resulttmp = dol_delete_file($dir.'/'.$filetodelete.'.back', 0, 0, 1); - if (!$resulttmp) $resultko++; + if (!$resulttmp) { + $resultko++; + } } - if ($resultko == 0) - { + if ($resultko == 0) { setEventMessages($langs->trans("FilesDeleted"), null); } else { setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); @@ -1380,8 +1412,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) } -if ($dirins && $action == 'generatepackage') -{ +if ($dirins && $action == 'generatepackage') { $modulelowercase = strtolower($module); // Dir for module @@ -1393,12 +1424,10 @@ if ($dirins && $action == 'generatepackage') dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); $class = 'mod'.$module; - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); - } catch (Exception $e) - { + } catch (Exception $e) { $error++; dol_print_error($e->getMessage()); } @@ -1410,22 +1439,21 @@ if ($dirins && $action == 'generatepackage') } $arrayversion = explode('.', $moduleobj->version, 3); - if (count($arrayversion)) - { + if (count($arrayversion)) { $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; - if ($dirofmodule) - { - if (!dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); + if ($dirofmodule) { + if (!dol_is_dir($dirofmodule)) { + dol_mkdir($dirofmodule); + } $result = dol_compress_dir($dir, $outputfilezip, 'zip', '', $modulelowercase); } else { $result = -1; } - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); } else { $error++; @@ -1439,16 +1467,14 @@ if ($dirins && $action == 'generatepackage') } } -if ($dirins && $action == 'generatedoc') -{ +if ($dirins && $action == 'generatedoc') { $FILENAMEDOC = strtolower($module).'.html'; $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc'; $util = new Utils($db); $result = $util->generateDoc($module); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null); } else { setEventMessages($util->error, $util->errors, 'errors'); @@ -1457,39 +1483,42 @@ if ($dirins && $action == 'generatedoc') // Save file -if ($action == 'savefile' && empty($cancel)) -{ +if ($action == 'savefile' && empty($cancel)) { $relofcustom = basename($dirins); - if ($relofcustom) - { + if ($relofcustom) { // Check that relative path ($file) start with name 'custom' - if (!preg_match('/^'.$relofcustom.'/', $file)) $file = $relofcustom.'/'.$file; + if (!preg_match('/^'.$relofcustom.'/', $file)) { + $file = $relofcustom.'/'.$file; + } $pathoffile = dol_buildpath($file, 0); $pathoffilebackup = dol_buildpath($file.'.back', 0); // Save old version - if (dol_is_file($pathoffile)) - { + if (dol_is_file($pathoffile)) { dol_copy($pathoffile, $pathoffilebackup, 0, 1); } $check = 'restricthtml'; $srclang = dol_mimetype($pathoffile, '', 3); - if ($srclang == 'md') $check = 'restricthtml'; - if ($srclang == 'lang') $check = 'restricthtml'; - if ($srclang == 'php') $check = 'none'; + if ($srclang == 'md') { + $check = 'restricthtml'; + } + if ($srclang == 'lang') { + $check = 'restricthtml'; + } + if ($srclang == 'php') { + $check = 'none'; + } $content = GETPOST('editfilecontent', $check); // Save file on disk - if ($content) - { + if ($content) { dol_delete_file($pathoffile); $result = file_put_contents($pathoffile, $content); - if ($result) - { + if ($result) { @chmod($pathoffile, octdec($newmask)); setEventMessages($langs->trans("FileSaved"), null); @@ -1505,32 +1534,37 @@ if ($action == 'savefile' && empty($cancel)) } // Enable module -if ($action == 'set' && $user->admin) -{ +if ($action == 'set' && $user->admin) { $param = ''; - if ($module) $param .= '&module='.urlencode($module); - if ($tab) $param .= '&tab='.urlencode($tab); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $value = GETPOST('value', 'alpha'); $resarray = activateModule($value); - if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); - else { + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { //var_dump($resarray);exit; - if ($resarray['nbperms'] > 0) - { + if ($resarray['nbperms'] > 0) { $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; $resqltmp = $db->query($tmpsql); - if ($resqltmp) - { + if ($resqltmp) { $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; - if ($obj && $obj->nb > 1) - { + if ($obj && $obj->nb > 1) { $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); setEventMessages($msg, null, 'warnings'); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } } header("Location: ".$_SERVER["PHP_SELF"]."?".$param); @@ -1538,16 +1572,23 @@ if ($action == 'set' && $user->admin) } // Disable module -if ($action == 'reset' && $user->admin) -{ +if ($action == 'reset' && $user->admin) { $param = ''; - if ($module) $param .= '&module='.urlencode($module); - if ($tab) $param .= '&tab='.urlencode($tab); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $value = GETPOST('value', 'alpha'); $result = unActivateModule($value); - if ($result) setEventMessages($result, null, 'errors'); + if ($result) { + setEventMessages($result, null, 'errors'); + } header("Location: ".$_SERVER["PHP_SELF"]."?".$param); exit; } @@ -1562,8 +1603,7 @@ $form = new Form($db); $formadmin = new FormAdmin($db); // Set dir where external modules are installed -if (!dol_is_dir($dirins)) -{ +if (!dol_is_dir($dirins)) { dol_mkdir($dirins); } $dirins_ok = (dol_is_dir($dirins)); @@ -1592,15 +1632,12 @@ print '<br>'; $message = ''; -if (!$dirins) -{ +if (!$dirins) { $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); $allowfromweb = -1; } else { - if ($dirins_ok) - { - if (!is_writable(dol_osencode($dirins))) - { + if ($dirins_ok) { + if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins)); $allowfromweb = 0; @@ -1610,8 +1647,7 @@ if (!$dirins) $allowfromweb = 0; } } -if ($message) -{ +if ($message) { print $message; } @@ -1624,8 +1660,7 @@ $error = 0; $moduleobj = null; -if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') -{ +if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $modulelowercase = strtolower($module); $loadclasserrormessage = ''; @@ -1643,8 +1678,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') $loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n"; } - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); } catch (Exception $e) { @@ -1652,7 +1686,9 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') print $e->getMessage(); } } else { - if (empty($forceddirread)) $error++; + if (empty($forceddirread)) { + $error++; + } $langs->load("errors"); print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; print $loadclasserrormessage; @@ -1680,13 +1716,18 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $const_name = 'MAIN_MODULE_'.strtoupper($module); $param = ''; - if ($tab) $param .= '&tab='.urlencode($tab); - if ($module) $param .= '&module='.urlencode($module); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $urltomodulesetup = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($module).'">'.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").'</a>'; - if (!empty($conf->global->$const_name)) // If module is already activated - { + if (!empty($conf->global->$const_name)) { // If module is already activated $linktoenabledisable .= '<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=reset&value=mod'.$module.$param.'">'; $linktoenabledisable .= img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); $linktoenabledisable .= '</a>'; @@ -1694,22 +1735,21 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $objMod = $moduleobj; $backtourlparam = ''; $backtourlparam .= ($backtourlparam ? '&' : '?').'module='.$module; // No urlencode here, done later - if ($tab) $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later + if ($tab) { + $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later + } $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; $regs = array(); - if (is_array($objMod->config_page_url)) - { + if (is_array($objMod->config_page_url)) { $i = 0; - foreach ($objMod->config_page_url as $page) - { + foreach ($objMod->config_page_url as $page) { $urlpage = $page; if ($i++) { $linktoenabledisable .= ' <a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page), "setup").'</a>'; // print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;'; } else { - if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); $linktoenabledisable .= ' &nbsp; <a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>'; } else { @@ -1729,14 +1769,12 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $linktoenabledisable .= "</a>\n"; } - if (!empty($conf->$modulelowercase->enabled)) - { + if (!empty($conf->$modulelowercase->enabled)) { $modulestatusinfo = $form->textwithpicto('', $langs->trans("Warning").' : '.$langs->trans("ModuleIsLive"), -1, 'warning'); } // Loop to show tab of each module - foreach ($listofmodules as $tmpmodule => $tmpmodulearray) - { + foreach ($listofmodules as $tmpmodule => $tmpmodulearray) { $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); $head[$h][1] = $tmpmodulearray['modulenamewithcase']; $head[$h][2] = $tmpmodulearray['modulenamewithcase']; @@ -1757,8 +1795,7 @@ $h++; print dol_get_fiche_head($head, $module, '', -1, '', 0, $infomodulesfound, '', 8); // Modules -if ($module == 'initmodule') -{ +if ($module == 'initmodule') { // New module print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -1787,8 +1824,7 @@ if ($module == 'initmodule') print '</form>'; } elseif (!empty($module)) { // Tabs for module - if (!$error) - { + if (!$error) { $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; $head2 = array(); @@ -1877,20 +1913,17 @@ if ($module == 'initmodule') // Note module is inside $dirread - if ($tab == 'description') - { + if ($tab == 'description') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $pathtofilereadme = $modulelowercase.'/README.md'; $pathtochangelog = $modulelowercase.'/ChangeLog.md'; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Description - level 2 print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc".$tab).'</span>'; $infoonmodulepath = ''; - if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) - { + if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) { $infoonmodulepath = '<span class="opacitymedium">'.$langs->trans("RealPathOfModule").' :</span> <strong>'.realpath($dirread.'/'.$modulelowercase).'</strong><br>'; print ' '.$infoonmodulepath; } @@ -1916,8 +1949,7 @@ if ($module == 'initmodule') print load_fiche_titre($langs->trans("DescriptorFile"), '', ''); - if (!empty($moduleobj)) - { + if (!empty($moduleobj)) { print '<div class="underbanner clearboth"></div>'; print '<div class="fichecenter">'; @@ -1978,16 +2010,18 @@ if ($module == 'initmodule') print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>'; } - if (!empty($moduleobj)) - { + if (!empty($moduleobj)) { print '<br><br>'; // Readme file print load_fiche_titre($langs->trans("ReadmeFile"), '', ''); print '<!-- readme file -->'; - if (dol_is_file($dirread.'/'.$pathtofilereadme)) print '<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().'</div>'; - else print '<span class="opacitymedium">'.$langs->trans("ErrorFileNotFound", $pathtofilereadme).'</span>'; + if (dol_is_file($dirread.'/'.$pathtofilereadme)) { + print '<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().'</div>'; + } else { + print '<span class="opacitymedium">'.$langs->trans("ErrorFileNotFound", $pathtofilereadme).'</span>'; + } print '<br><br>'; @@ -1995,16 +2029,18 @@ if ($module == 'initmodule') print load_fiche_titre($langs->trans("ChangeLog"), '', ''); print '<!-- changelog file -->'; - if (dol_is_file($dirread.'/'.$pathtochangelog)) print '<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().'</div>'; - else print '<span class="opacitymedium">'.$langs->trans("ErrorFileNotFound", $pathtochangelog).'</span>'; + if (dol_is_file($dirread.'/'.$pathtochangelog)) { + print '<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().'</div>'; + } else { + print '<span class="opacitymedium">'.$langs->trans("ErrorFileNotFound", $pathtochangelog).'</span>'; + } } print dol_get_fiche_end(); } else { // Edit text file $fullpathoffile = dol_buildpath($file, 0, 1); // Description - level 2 - if ($fullpathoffile) - { + if ($fullpathoffile) { $content = file_get_contents($fullpathoffile); } @@ -2035,10 +2071,8 @@ if ($module == 'initmodule') print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Level 2 } - if ($tab == 'languages') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'languages') { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("LanguageDefDesc").'</span><br>'; print '<br>'; @@ -2059,8 +2093,7 @@ if ($module == 'initmodule') $langfiles = dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); print '<table class="none">'; - foreach ($langfiles as $langfile) - { + foreach ($langfiles as $langfile) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; print '<tr><td><span class="fa fa-file-o"></span> '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : <strong>'.$pathtofile.'</strong>'; print '</td><td><a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=txt&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; @@ -2098,14 +2131,12 @@ if ($module == 'initmodule') } } - if ($tab == 'dictionaries') - { + if ($tab == 'dictionaries') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $dicts = $moduleobj->dictionaries; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'; $htmlhelp = $langs->trans("DictionariesDefDescTooltip", '<a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').'</a>'); print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'<br>'; @@ -2146,12 +2177,10 @@ if ($module == 'initmodule') print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "</tr>\n"; - if (is_array($dicts) && is_array($dicts['tabname'])) - { + if (is_array($dicts) && is_array($dicts['tabname'])) { $i = 0; $maxi = count($dicts['tabname']); - while ($i < $maxi) - { + while ($i < $maxi) { print '<tr class="oddeven">'; print '<td>'; @@ -2231,8 +2260,7 @@ if ($module == 'initmodule') } } - if ($tab == 'objects') - { + if ($tab == 'objects') { $head3 = array(); $h = 0; @@ -2248,17 +2276,21 @@ if ($module == 'initmodule') $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); $firstobjectname = ''; - foreach ($listofobject as $fileobj) - { - if (preg_match('/^api_/', $fileobj['name'])) continue; - if (preg_match('/^actions_/', $fileobj['name'])) continue; + foreach ($listofobject as $fileobj) { + if (preg_match('/^api_/', $fileobj['name'])) { + continue; + } + if (preg_match('/^actions_/', $fileobj['name'])) { + continue; + } $tmpcontent = file_get_contents($fileobj['fullname']); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) - { + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); $objectname = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectname; + if (empty($firstobjectname)) { + $firstobjectname = $objectname; + } $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname; $head3[$h][1] = $objectname; @@ -2273,16 +2305,17 @@ if ($module == 'initmodule') $h++; // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. - if ($tabobj == 'newobjectifnoobj') - { - if ($firstobjectname) $tabobj = $firstobjectname; - else $tabobj = 'newobject'; + if ($tabobj == 'newobjectifnoobj') { + if ($firstobjectname) { + $tabobj = $firstobjectname; + } else { + $tabobj = 'newobject'; + } } print dol_get_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 - if ($tabobj == 'newobject') - { + if ($tabobj == 'newobject') { // New object tab print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -2324,19 +2357,22 @@ if ($module == 'initmodule') print '</form>'; } else { // tabobj = module - if ($action == 'deleteproperty') - { + if ($action == 'deleteproperty') { $formconfirm = $form->formconfirm( $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey', 'alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), - $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey', 'alpha')), 'confirm_deleteproperty', '', 0, 1 - ); + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey', 'alpha')), + 'confirm_deleteproperty', + '', + 0, + 1 + ); // Print form confirm print $formconfirm; } - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { try { //$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; @@ -2377,8 +2413,7 @@ if ($module == 'initmodule') $realpathtopicto = $dirread.'/'.$pathtopicto; $realpathtoscript = $dirread.'/'.$pathtoscript; - if (empty($realpathtoapi)) // For compatibility with some old modules - { + if (empty($realpathtoapi)) { // For compatibility with some old modules $pathtoapi = strtolower($module).'/class/api_'.strtolower($module).'s.class.php'; $realpathtoapi = $dirread.'/'.$pathtoapi; } @@ -2392,15 +2427,14 @@ if ($module == 'initmodule') print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong>'.($realpathtoapi ? '' : '<strike>').$pathtoapi.($realpathtoapi ? '' : '</strike>').'</strong>'; if (dol_is_file($realpathtoapi)) { print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; - print ' '; - print '<a class="reposition editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; - print ' &nbsp; '; - if (empty($conf->global->$const_name)) // If module is not activated - { - print '<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans("ModuleMustBeEnabled", $module).'"><strike>'.$langs->trans("GoToApiExplorer").'</strike></a>'; - } else { - print '<a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>'; - } + print ' '; + print '<a class="reposition editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; + print ' &nbsp; '; + if (empty($conf->global->$const_name)) { // If module is not activated + print '<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans("ModuleMustBeEnabled", $module).'"><strike>'.$langs->trans("GoToApiExplorer").'</strike></a>'; + } else { + print '<a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>'; + } } else { //print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span> '; print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=initapi&format=php&file='.urlencode($pathtoapi).'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans("Generate").'"></a>'; @@ -2514,26 +2548,24 @@ if ($module == 'initmodule') print '<br><br><br>'; - if (function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! + if (function_exists('opcache_invalidate')) { + opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! + } - if (empty($forceddirread) && empty($dirread)) - { + if (empty($forceddirread) && empty($dirread)) { $result = dol_include_once($pathtoclass); } else { $result = @include_once $dirread.'/'.$pathtoclass; } - if (class_exists($tabobj)) - { + if (class_exists($tabobj)) { try { $tmpobjet = @new $tabobj($db); - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); } } - if (!empty($tmpobjet)) - { + if (!empty($tmpobjet)) { $reflector = new ReflectionClass($tabobj); $reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars $reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars @@ -2588,8 +2620,7 @@ if ($module == 'initmodule') //$properties = dol_sort_array($tmpobjet->fields, 'position'); $properties = dol_sort_array($reflectorpropdefault['fields'], 'position'); - if (!empty($properties)) - { + if (!empty($properties)) { // Line to add a property print '<tr>'; print '<td><input class="text maxwidth75" name="propname" value="'.dol_escape_htmltag(GETPOST('propname', 'alpha')).'"></td>'; @@ -2617,8 +2648,7 @@ if ($module == 'initmodule') print '</td></tr>'; // List of existing properties - foreach ($properties as $propkey => $propval) - { + foreach ($properties as $propkey => $propval) { /* If from Reflection if ($propval->class == $tabobj) { @@ -2723,8 +2753,7 @@ if ($module == 'initmodule') print '</span>'; print '</td>'; print '<td class="center">'; - if ($propname != 'rowid') - { + if ($propname != 'rowid') { print '<a href="'.$_SERVER["PHP_SELF"].'?action=deleteproperty&token='.newToken().'&propertykey='.urlencode($propname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>'; } print '</td>'; @@ -2732,20 +2761,19 @@ if ($module == 'initmodule') print '</tr>'; } } else { - if ($tab == 'specifications') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'specifications') { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("SpecDefDesc").'</span><br>'; print '<br>'; $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); - foreach ($specs as $spec) - { + foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; $format = 'asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; + if (preg_match('/\.md$/i', $spec['name'])) { + $format = 'markdown'; + } print '<span class="fa fa-file-o"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; print '<br>'; @@ -2788,13 +2816,11 @@ if ($module == 'initmodule') } else { print '<tr><td><span class="warning">'.$langs->trans('Failed to init the object with the new.').'</warning></td></tr>'; } - } catch (Exception $e) - { + } catch (Exception $e) { print $e->getMessage(); } } else { - if (empty($forceddirread)) - { + if (empty($forceddirread)) { $fullpathoffile = dol_buildpath($file, 0); } else { $fullpathoffile = $dirread.'/'.$file; @@ -2827,14 +2853,12 @@ if ($module == 'initmodule') print dol_get_fiche_end(); // Level 3 } - if ($tab == 'menus') - { + if ($tab == 'menus') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $menus = $moduleobj->menu; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'; $htmlhelp = $langs->trans("MenusDefDescTooltip", '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php">'.$langs->trans('Setup').' - '.$langs->trans('Menus').'</a>'); print $form->textwithpicto($langs->trans("MenusDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'<br>'; @@ -2873,10 +2897,8 @@ if ($module == 'initmodule') print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'right '); print "</tr>\n"; - if (count($menus)) - { - foreach ($menus as $menu) - { + if (count($menus)) { + foreach ($menus as $menu) { print '<tr class="oddeven">'; print '<td>'; @@ -2930,7 +2952,7 @@ if ($module == 'initmodule') print '</tr>'; } } else { - print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>'; + print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>'; } print '</table>'; @@ -2963,14 +2985,12 @@ if ($module == 'initmodule') } } - if ($tab == 'permissions') - { + if ($tab == 'permissions') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $perms = $moduleobj->rights; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'; $htmlhelp = $langs->trans("PermissionsDefDescTooltip", '<a href="'.DOL_URL_ROOT.'/admin/perms.php">'.$langs->trans('DefaultPermissions').'</a>'); print $form->textwithpicto($langs->trans("PermissionsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'<br>'; @@ -3001,10 +3021,8 @@ if ($module == 'initmodule') print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "</tr>\n"; - if (count($perms)) - { - foreach ($perms as $perm) - { + if (count($perms)) { + foreach ($perms as $perm) { print '<tr class="oddeven">'; print '<td>'; @@ -3059,10 +3077,8 @@ if ($module == 'initmodule') } } - if ($tab == 'hooks') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'hooks') { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("HooksDefDesc").'</span><br>'; print '<br>'; @@ -3078,8 +3094,7 @@ if ($module == 'initmodule') print '<tr><td>'; $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; print '<span class="fa fa-file-o"></span> '.$langs->trans("HooksFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print '<strong>'.$pathtohook.'</strong>'; print '</td>'; print '<td><a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a> '; @@ -3116,15 +3131,13 @@ if ($module == 'initmodule') } } - if ($tab == 'triggers') - { + if ($tab == 'triggers') { require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("TriggerDefDesc").'</span><br>'; print '<br>'; @@ -3137,10 +3150,8 @@ if ($module == 'initmodule') print '<a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; print '</td></tr>'; - if (!empty($triggers)) - { - foreach ($triggers as $trigger) - { + if (!empty($triggers)) { + foreach ($triggers as $trigger) { $pathtofile = $trigger['relpath']; print '<tr><td>'; @@ -3184,10 +3195,8 @@ if ($module == 'initmodule') } } - if ($tab == 'css') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'css') { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("CSSDesc").'</span><br>'; print '<br>'; @@ -3196,8 +3205,7 @@ if ($module == 'initmodule') print '<tr><td>'; $pathtohook = strtolower($module).'/css/'.strtolower($module).'.css.php'; print '<span class="fa fa-file-o"></span> '.$langs->trans("CSSFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print '<strong>'.$pathtohook.'</strong>'; print '</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a></td>'; print '</td><td><a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&format='.$format.'&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Delete"), 'delete').'</a></td>'; @@ -3232,10 +3240,8 @@ if ($module == 'initmodule') } } - if ($tab == 'js') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'js') { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("JSDesc").'</span><br>'; print '<br>'; @@ -3244,8 +3250,7 @@ if ($module == 'initmodule') print '<tr><td>'; $pathtohook = strtolower($module).'/js/'.strtolower($module).'.js.php'; print '<span class="fa fa-file-o"></span> '.$langs->trans("JSFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print '<strong>'.$pathtohook.'</strong>'; print '</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a></td>'; print '</td><td><a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&format='.$format.'&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Delete"), 'delete').'</a></td>'; @@ -3280,22 +3285,18 @@ if ($module == 'initmodule') } } - if ($tab == 'widgets') - { + if ($tab == 'widgets') { require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("WidgetDesc").'</span><br>'; print '<br>'; print '<table>'; - if (!empty($widgets)) - { - foreach ($widgets as $widget) - { + if (!empty($widgets)) { + foreach ($widgets as $widget) { $pathtofile = $widget['relpath']; print '<tr><td><span class="fa fa-file-o"></span> '.$langs->trans("WidgetFile").' : <strong>'.$pathtofile.'</strong>'; @@ -3335,29 +3336,28 @@ if ($module == 'initmodule') } } - if ($tab == 'cli') - { + if ($tab == 'cli') { $clifiles = array(); $i = 0; $dircli = array('/'.strtolower($module).'/scripts'); - foreach ($dircli as $reldir) - { + foreach ($dircli as $reldir) { $dir = dol_buildpath($reldir, 0); $newdir = dol_osencode($dir); // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) - if (!is_dir($newdir)) continue; + if (!is_dir($newdir)) { + continue; + } $handle = opendir($newdir); - if (is_resource($handle)) - { - while (($tmpfile = readdir($handle)) !== false) - { - if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) - { - if (preg_match('/\.back$/', $tmpfile)) continue; + if (is_resource($handle)) { + while (($tmpfile = readdir($handle)) !== false) { + if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) { + if (preg_match('/\.back$/', $tmpfile)) { + continue; + } $clifiles[$i]['relpath'] = preg_replace('/^\//', '', $reldir).'/'.$tmpfile; @@ -3368,16 +3368,13 @@ if ($module == 'initmodule') } } - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("CLIDesc").'</span><br>'; print '<br>'; print '<table>'; - if (!empty($clifiles)) - { - foreach ($clifiles as $clifile) - { + if (!empty($clifiles)) { + foreach ($clifiles as $clifile) { $pathtofile = $clifile['relpath']; print '<tr><td><span class="fa fa-file-o"></span> '.$langs->trans("CLIFile").' : <strong>'.$pathtofile.'</strong>'; @@ -3417,14 +3414,12 @@ if ($module == 'initmodule') } } - if ($tab == 'cron') - { + if ($tab == 'cron') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $cronjobs = $moduleobj->cronjobs; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/cron/list.php">'.$langs->transnoentities('CronList').'</a>', $langs->trans("CronJobDefDesc", '{s1}')).'</span><br>'; print '<br>'; @@ -3453,10 +3448,8 @@ if ($module == 'initmodule') print_liste_field_titre("Comment", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); print "</tr>\n"; - if (count($cronjobs)) - { - foreach ($cronjobs as $cron) - { + if (count($cronjobs)) { + foreach ($cronjobs as $cron) { print '<tr class="oddeven">'; print '<td>'; @@ -3464,8 +3457,7 @@ if ($module == 'initmodule') print '</td>'; print '<td>'; - if ($cron['jobtype'] == 'method') - { + if ($cron['jobtype'] == 'method') { $text = $langs->trans("CronClass"); $texttoshow = $langs->trans('CronModule').': '.$module.'<br>'; $texttoshow .= $langs->trans('CronClass').': '.$cron['class'].'<br>'; @@ -3473,8 +3465,7 @@ if ($module == 'initmodule') $texttoshow .= $langs->trans('CronMethod').': '.$cron['method']; $texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$cron['parameters']; $texttoshow .= '<br>'.$langs->trans('Comment').': '.$langs->trans($cron['comment']); - } elseif ($cron['jobtype'] == 'command') - { + } elseif ($cron['jobtype'] == 'command') { $text = $langs->trans('CronCommand'); $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($cron['command']); $texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$cron['parameters']; @@ -3484,10 +3475,18 @@ if ($module == 'initmodule') print '</td>'; print '<td>'; - if ($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if ($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if ($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if ($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + if ($cron['unitfrequency'] == "60") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); + } + if ($cron['unitfrequency'] == "3600") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); + } + if ($cron['unitfrequency'] == "86400") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); + } + if ($cron['unitfrequency'] == "604800") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + } print '</td>'; print '<td>'; @@ -3495,7 +3494,9 @@ if ($module == 'initmodule') print '</td>'; print '<td>'; - if (!empty($cron['comment'])) {print $cron['comment']; } + if (!empty($cron['comment'])) { + print $cron['comment']; + } print '</td>'; print '</tr>'; @@ -3534,23 +3535,21 @@ if ($module == 'initmodule') } } - if ($tab == 'specifications') - { + if ($tab == 'specifications') { $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print '<span class="opacitymedium">'.$langs->trans("SpecDefDesc").'</span><br>'; print '<br>'; print '<table>'; - if (is_array($specs) && !empty($specs)) - { - foreach ($specs as $spec) - { + if (is_array($specs) && !empty($specs)) { + foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; $format = 'asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; + if (preg_match('/\.md$/i', $spec['name'])) { + $format = 'markdown'; + } print '<tr><td>'; print '<span class="fa fa-file-o"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; print '</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a></td>'; @@ -3604,8 +3603,9 @@ if ($module == 'initmodule') // HTML print '<span class="fa fa-file-o"></span> '.$langs->trans("PathToModuleDocumentation", "HTML").' : '; - if (!dol_is_file($outputfiledoc)) print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; - else { + if (!dol_is_file($outputfiledoc)) { + print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; + } else { print '<strong>'; print '<a href="'.$outputfiledocurl.'" target="_blank">'; print $outputfiledoc; @@ -3617,8 +3617,9 @@ if ($module == 'initmodule') // PDF print '<span class="fa fa-file-o"></span> '.$langs->trans("PathToModuleDocumentation", "PDF").' : '; - if (!dol_is_file($outputfiledocpdf)) print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; - else { + if (!dol_is_file($outputfiledocpdf)) { + print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; + } else { print '<strong>'; print '<a href="'.$outputfiledocurlpdf.'" target="_blank">'; print $outputfiledocpdf; @@ -3636,18 +3637,18 @@ if ($module == 'initmodule') print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; print '<input type="submit" class="button" name="generatedoc" value="'.$langs->trans("BuildDocumentation").'"'; - if (!is_array($specs) || empty($specs)) print ' disabled="disabled"'; + if (!is_array($specs) || empty($specs)) { + print ' disabled="disabled"'; + } print '>'; print '</form>'; } - if ($tab == 'buildpackage') - { + if ($tab == 'buildpackage') { print '<span class="opacitymedium">'.$langs->trans("BuildPackageDesc").'</span>'; print '<br>'; - if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP')) - { + if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP')) { print img_warning().' '.$langs->trans("ErrNoZipEngine"); print '<br>'; } @@ -3662,8 +3663,7 @@ if ($module == 'initmodule') dol_include_once($pathtofile); $class = 'mod'.$module; - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); } catch (Exception $e) { @@ -3678,8 +3678,7 @@ if ($module == 'initmodule') } $arrayversion = explode('.', $moduleobj->version, 3); - if (count($arrayversion)) - { + if (count($arrayversion)) { $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; } @@ -3687,8 +3686,9 @@ if ($module == 'initmodule') print '<br>'; print '<span class="fa fa-file-o"></span> '.$langs->trans("PathToModulePackage").' : '; - if (!dol_is_file($outputfilezip)) print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; - else { + if (!dol_is_file($outputfilezip)) { + print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span>'; + } else { $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; print '<strong><a href="'.DOL_URL_ROOT.'/document.php?modulepart=packages&file='.urlencode($relativepath).'">'.$outputfilezip.'</a></strong>'; print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; @@ -3706,8 +3706,7 @@ if ($module == 'initmodule') print '</form>'; } - if ($tab != 'description') - { + if ($tab != 'description') { print dol_get_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index d527f1978a9..30cc93a6d51 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -25,16 +25,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} // Libraries require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/modulebuilder/template/admin/myobject_extrafields.php b/htdocs/modulebuilder/template/admin/myobject_extrafields.php index 41ca86a0ce2..cd2125547e8 100644 --- a/htdocs/modulebuilder/template/admin/myobject_extrafields.php +++ b/htdocs/modulebuilder/template/admin/myobject_extrafields.php @@ -29,16 +29,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/mymodule.lib.php'; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 93bbc8a6612..06b169863f5 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -25,16 +25,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} global $langs, $user; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 13a2b8e895c..f29f6eeb45a 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -99,9 +99,8 @@ class ActionsMyModule $error = 0; // Error counter /* 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' - { - // Do what you want here... + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + // Do what you want here... // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. } @@ -132,10 +131,8 @@ class ActionsMyModule $error = 0; // Error counter /* 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' - { - foreach ($parameters['toselect'] as $objectid) - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } } @@ -168,8 +165,7 @@ class ActionsMyModule $disabled = 1; /* 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' - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' $this->resprints = '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>'.$langs->trans("MyModuleMassAction").'</option>'; } @@ -204,8 +200,7 @@ class ActionsMyModule 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' - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' } return $ret; diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 2e04e34dcac..da616de0d82 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -119,29 +119,42 @@ class MyModuleApi extends DolibarrApi // 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) + 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"; - 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 + 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($tmpobject->element).')'; - 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($tmpobject->element).')'; + } + 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) { $sql .= " AND sc.fk_user = ".$search_sale; } - if ($sqlfilters) - { + if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } @@ -161,11 +174,9 @@ class MyModuleApi extends DolibarrApi $result = $this->db->query($sql); $i = 0; - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $tmp_object = new MyObject($this->db); if ($tmp_object->fetch($obj->rowid)) { @@ -236,12 +247,13 @@ class MyModuleApi extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->myobject->$field = $value; } - if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) - { + if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); } else { throw new RestException(500, $this->myobject->error); @@ -272,8 +284,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->myobject->delete(DolibarrApiAccess::$user)) - { + if (!$this->myobject->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error); } @@ -338,8 +349,7 @@ class MyModuleApi extends DolibarrApi // If object has lines, remove $db property 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]); unset($object->lines[$i]->lines); @@ -362,9 +372,12 @@ class MyModuleApi extends DolibarrApi { $myobject = array(); foreach ($this->myobject->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 (!isset($data[$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]; } return $myobject; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e07e7757751..2b17b0f84f8 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -232,8 +232,12 @@ class MyObject 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; + } // Example to show how to set values of fields definition dynamically /*if ($user->rights->mymodule->myobject->read) { @@ -242,23 +246,17 @@ class MyObject extends CommonObject }*/ // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -298,7 +296,9 @@ class MyObject extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } // get lines so they will be clone //foreach($this->lines as $line) @@ -310,21 +310,28 @@ class MyObject extends CommonObject unset($object->import_key); // Clear fields - if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; - if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; - if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; } - if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); } - if (property_exists($object, 'date_modification')) { $object->date_modification = null; } + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -340,22 +347,19 @@ class MyObject extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { - if ($this->copy_linked_contact($object, 'external') < 0) + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { $error++; + } } } @@ -381,7 +385,9 @@ class MyObject extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -421,8 +427,11 @@ class MyObject extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -455,8 +464,7 @@ class MyObject extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) - { + while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -512,8 +520,7 @@ class MyObject extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -538,8 +545,7 @@ class MyObject extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -557,8 +563,7 @@ class MyObject extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef(); } else { $num = $this->ref; @@ -570,57 +575,58 @@ class MyObject extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " status = ".self::STATUS_VALIDATED; - if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; - if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MYOBJECT_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'myobject/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'myobject/".$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($num); $dirsource = $conf->mymodule->dir_output.'/myobject/'.$oldref; $dirdest = $conf->mymodule->dir_output.'/myobject/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->mymodule->dir_output.'/myobject/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -633,14 +639,12 @@ class MyObject extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -660,8 +664,7 @@ class MyObject extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->status <= self::STATUS_DRAFT) - { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -685,8 +688,7 @@ class MyObject extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_VALIDATED) - { + if ($this->status != self::STATUS_VALIDATED) { return 0; } @@ -710,8 +712,7 @@ class MyObject extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_CANCELED) { return 0; } @@ -739,7 +740,9 @@ class MyObject extends CommonObject { global $conf, $langs, $hookmanager; - 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 = ''; @@ -752,25 +755,28 @@ class MyObject extends CommonObject $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } if ($option == 'nolink') { $linkstart = '<span'; @@ -787,7 +793,9 @@ class MyObject extends CommonObject $result .= $linkstart; if (empty($this->showphoto_on_popup)) { - 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) { + $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); + } } else { if ($withpicto) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -813,7 +821,9 @@ class MyObject extends CommonObject } } - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -822,8 +832,11 @@ class MyObject extends CommonObject $hookmanager->initHooks(array('myobjectdao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -850,8 +863,7 @@ class MyObject extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule@mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -864,7 +876,9 @@ class MyObject extends CommonObject $statusType = 'status'.$status; //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_CANCELED) $statusType = 'status6'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -882,28 +896,23 @@ class MyObject extends CommonObject $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)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -943,8 +952,7 @@ class MyObject extends CommonObject $objectline = new MyObjectLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); - if (is_numeric($result)) - { + if (is_numeric($result)) { $this->error = $this->error; $this->errors = $this->errors; return $result; @@ -968,8 +976,7 @@ class MyObject extends CommonObject $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard'; } - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) - { + if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) { $mybool = false; $file = $conf->global->MYMODULE_MYOBJECT_ADDON.".php"; @@ -977,16 +984,14 @@ class MyObject extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/mymodule/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -995,8 +1000,7 @@ class MyObject extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($this); - if ($numref != '' && $numref != '-1') - { + if ($numref != '' && $numref != '-1') { return $numref; } else { $this->error = $obj->error; diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index cb6e15695c1..dc797b99a94 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -48,8 +48,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets global $conf; $this->db = $db; - if (is_array($conf->modules)) - { + if (is_array($conf->modules)) { $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0; } } @@ -73,8 +72,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $s .= $langs->trans("Status").': '; $s .= '<select name="filter" class="flat">'; $s .= '<option value="none">&nbsp;</option>'; - foreach ($arraystatus as $status) - { + foreach ($arraystatus as $status) { $s .= '<option value="'.$status.'">'.$status.'</option>'; } $s .= '</select>'; @@ -112,24 +110,23 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $sql = " select rowid as id, email, firstname, lastname, plan, partner"; $sql .= " from ".MAIN_DB_PREFIX."myobject"; $sql .= " where email IS NOT NULL AND email != ''"; - if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; + if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') { + $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; + } $sql .= " ORDER BY email"; // Stocke destinataires dans target $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); $old = ''; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { + if ($old <> $obj->email) { $target[$j] = array( 'email' => $obj->email, 'name' => $obj->lastname, @@ -197,7 +194,9 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets { $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); - if ($a < 0) return -1; + if ($a < 0) { + return -1; + } return $a; } } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index d6cb191a405..3e389c1757f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -98,7 +98,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Recupere emetteur $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } @@ -129,8 +131,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texttitle = $langs->trans("ListOfDirectories"); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))); $listoffiles = array(); - foreach ($listofdir as $key=>$tmpdir) - { + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { @@ -140,7 +141,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); } else { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); + if (count($tmpfiles)) { + $listoffiles = array_merge($listoffiles, $tmpfiles); + } } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); @@ -159,8 +162,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Scan directories $nbofiles = count($listoffiles); - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) - { + if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) { $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'; //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; $texte .= count($listoffiles); @@ -168,11 +170,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= '</b>'; } - if ($nbofiles) - { + if ($nbofiles) { $texte .= '<div id="div_'.get_class($this).'" class="hidden">'; - foreach ($listoffiles as $file) - { + foreach ($listoffiles as $file) { $texte .= $file['name'].'<br>'; } $texte .= '</div>'; @@ -208,37 +208,34 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; - if (empty($srctemplatepath)) - { + if (empty($srctemplatepath)) { dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); return -1; } // Add odtgeneration hook - if (!is_object($hookmanager)) - { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (!is_object($outputlangs)) $outputlangs = $langs; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->commande->dir_output) - { + if ($conf->commande->dir_output) { // If $object is id instead of object - if (!is_object($object)) - { + if (!is_object($object)) { $id = $object; $object = new Commande($this->db); $result = $object->fetch($id); - if ($result < 0) - { + if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } @@ -246,20 +243,19 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $dir = $conf->commande->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + if (!preg_match('/specimen/i', $objectref)) { + $dir .= "/".$objectref; + } $file = $dir."/".$objectref.".odt"; - if (!file_exists($dir)) - { - if (dol_mkdir($dir) < 0) - { + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); @@ -269,10 +265,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) - { + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { $format = $conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format = '%Y%m%d%H%M%S'; + if ($format == '1') { + $format = '%Y%m%d%H%M%S'; + } $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { $filename = $newfiletmp.'.'.$newfileformat; @@ -289,16 +286,14 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // If CUSTOMER contact defined on order, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usecontact = true; $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name $contactobject = null; - if (!empty($usecontact)) - { + if (!empty($usecontact)) { if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { @@ -326,8 +321,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; $paramfreetext = 'ORDER_FREE_TEXT'; - if (!empty($conf->global->$paramfreetext)) - { + if (!empty($conf->global->$paramfreetext)) { $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } @@ -343,8 +337,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject 'DELIMITER_RIGHT' => '}' ) ); - } catch (Exception $e) - { + } catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; @@ -359,8 +352,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Make substitutions into odt of freetext try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -374,7 +366,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) { + $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + } $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); @@ -383,19 +377,20 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach ($tmparray as $key=>$value) - { + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image - if (file_exists($value)) $odfHandler->setImage($key, $value); - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + if (file_exists($value)) { + $odfHandler->setImage($key, $value); + } else { + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } } else { // Text $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -404,32 +399,26 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $foundtagforlines = 1; try { $listlines = $odfHandler->setSegment('lines'); - } catch (OdfException $e) - { + } catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; dol_syslog($e->getMessage(), LOG_INFO); } - if ($foundtagforlines) - { + if ($foundtagforlines) { $linenumber = 0; - foreach ($object->lines as $line) - { + foreach ($object->lines as $line) { $linenumber++; $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) - { + } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -437,8 +426,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } $odfHandler->mergeSegment($listlines); } - } catch (OdfException $e) - { + } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; @@ -446,12 +434,10 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Replace labels translated $tmparray = $outputlangs->get_translations_for_substitutions(); - foreach ($tmparray as $key=>$value) - { + foreach ($tmparray as $key => $value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -483,8 +469,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 4546d7044bd..3d900bc06e7 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -163,7 +163,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // Get source company $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff @@ -201,9 +203,13 @@ class pdf_standard_myobject extends ModelePDFMyObject dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); - if (!is_object($outputlangs)) $outputlangs = $langs; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) { + $outputlangs->charset_output = 'ISO-8859-1'; + } // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); @@ -226,67 +232,65 @@ class pdf_standard_myobject extends ModelePDFMyObject $realpatharray = array(); $this->atleastonephoto = false; /* - if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) - { - $objphoto = new Product($this->db); + if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) + { + $objphoto = new Product($this->db); - for ($i = 0; $i < $nblines; $i++) - { - if (empty($object->lines[$i]->fk_product)) continue; + for ($i = 0; $i < $nblines; $i++) + { + if (empty($object->lines[$i]->fk_product)) continue; - $objphoto->fetch($object->lines[$i]->fk_product); - //var_dump($objphoto->ref);exit; - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; - } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative - } + $objphoto->fetch($object->lines[$i]->fk_product); + //var_dump($objphoto->ref);exit; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + } else { + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative + } - $arephoto = false; - foreach ($pdir as $midir) - { - if (!$arephoto) - { - $dir = $conf->product->dir_output.'/'.$midir; + $arephoto = false; + foreach ($pdir as $midir) + { + if (!$arephoto) + { + $dir = $conf->product->dir_output.'/'.$midir; - foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) - { - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo - { - if ($obj['photo_vignette']) - { - $filename = $obj['photo_vignette']; - } else { - $filename = $obj['photo']; - } - } else { - $filename = $obj['photo']; - } + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) + { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + { + if ($obj['photo_vignette']) + { + $filename = $obj['photo_vignette']; + } else { + $filename = $obj['photo']; + } + } else { + $filename = $obj['photo']; + } - $realpath = $dir.$filename; - $arephoto = true; - $this->atleastonephoto = true; - } - } - } + $realpath = $dir.$filename; + $arephoto = true; + $this->atleastonephoto = true; + } + } + } - if ($realpath && $arephoto) $realpatharray[$i] = $realpath; - } - } + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; + } + } */ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->mymodule->dir_output.'/myobject') - { + if ($conf->mymodule->dir_output.'/myobject') { $object->fetch_thirdparty(); // Definition of $dir and $file - if ($object->specimen) - { + if ($object->specimen) { $dir = $conf->mymodule->dir_output.'/myobject'; $file = $dir."/SPECIMEN.pdf"; } else { @@ -294,20 +298,16 @@ class pdf_standard_myobject extends ModelePDFMyObject $dir = $conf->mymodule->dir_output.'/myobject/'.$objectref; $file = $dir."/".$objectref.".pdf"; } - if (!file_exists($dir)) - { - if (dol_mkdir($dir) < 0) - { + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { // Add pdfgeneration hook - if (!is_object($hookmanager)) - { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } @@ -328,16 +328,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) - if (class_exists('TCPDF')) - { + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) - { + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } @@ -351,7 +349,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } // Set certificate $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT; @@ -374,7 +374,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // New page $pdf->AddPage(); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); @@ -386,7 +388,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_height = 130 - $top_shift; $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $tab_height_newpage -= $top_shift; + } $nexY = $tab_top - 1; @@ -394,14 +398,12 @@ class pdf_standard_myobject extends ModelePDFMyObject $notetoshow = empty($object->note_public) ? '' : $object->note_public; // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) - { + if (!empty($extranote)) { $notetoshow = dol_concatdesc($notetoshow, $extranote); } $pagenb = $pdf->getPage(); - if ($notetoshow) - { + if ($notetoshow) { $tab_top -= 2; $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; @@ -420,16 +422,19 @@ class pdf_standard_myobject extends ModelePDFMyObject $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if ($pageposafternote > $pageposbeforenote) - { + if ($pageposafternote > $pageposbeforenote) { $pdf->rollbackTransaction(true); // prepare pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); // The only function to edit the bottom margin of current page to set it. @@ -445,8 +450,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; @@ -483,8 +487,12 @@ class pdf_standard_myobject extends ModelePDFMyObject // apply note frame to last page $pdf->setPage($pageposafternote); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } else // No pagebreak @@ -495,15 +503,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // not enough space, need to add page $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; $pdf->setPage($pageposafternote); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } $posyafter = $tab_top_newpage; } @@ -528,15 +539,16 @@ class pdf_standard_myobject extends ModelePDFMyObject // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - for ($i = 0; $i < $nblines; $i++) - { + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it $imglinesize = array(); - if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + if (!empty($realpatharray[$i])) { + $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. @@ -545,25 +557,26 @@ class pdf_standard_myobject extends ModelePDFMyObject $showpricebeforepagebreak = 1; $posYAfterImage = 0; - if ($this->getColumnStatus('photo')) - { + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page - { + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page $pdf->AddPage('', '', true); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { $showpricebeforepagebreak = 1; - else $showpricebeforepagebreak = 0; + } else { + $showpricebeforepagebreak = 0; + } } - if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) - { + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; @@ -571,15 +584,13 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Description of product line - if ($this->getColumnStatus('desc')) - { + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); - if ($pageposafter > $pageposbefore) // There is a pagebreak - { + if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. @@ -588,20 +599,22 @@ class pdf_standard_myobject extends ModelePDFMyObject $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text - { - if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pdf->setPage($pageposafter + 1); } } else { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { $showpricebeforepagebreak = 1; - else $showpricebeforepagebreak = 0; + } else { + $showpricebeforepagebreak = 0; + } } } else // No pagebreak { @@ -624,8 +637,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Quantity // Enough for 6 chars - if ($this->getColumnStatus('qty')) - { + if ($this->getColumnStatus('qty')) { $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $this->printStdColumnContent($pdf, $curY, 'qty', $qty); $nexY = max($pdf->GetY(), $nexY); @@ -634,8 +646,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Extrafields if (!empty($object->lines[$i]->array_options)) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { - if ($this->getColumnStatus($extrafieldColKey)) - { + if ($this->getColumnStatus($extrafieldColKey)) { $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey); $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); $nexY = max($pdf->GetY(), $nexY); @@ -659,13 +670,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $sign = 1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); - if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation - { - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; - else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) { + $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + } else { + $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + } } else { - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva; - else $tvaligne = $sign * $object->lines[$i]->total_tva; + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) { + $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva; + } else { + $tvaligne = $sign * $object->lines[$i]->total_tva; + } } $localtax1ligne = $object->lines[$i]->total_localtax1; @@ -675,16 +691,21 @@ class pdf_standard_myobject extends ModelePDFMyObject $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; - if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; - if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; + if ($object->remise_percent) { + $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + } + if ($object->remise_percent) { + $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + } + if ($object->remise_percent) { + $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; + } $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined - && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax - { + && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : ''; $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : ''; @@ -698,8 +719,12 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; - if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { + $vatrate .= '*'; + } + if (!isset($this->tva[$vatrate])) { + $this->tva[$vatrate] = 0; + } $this->tva[$vatrate] += $tvaligne; $nexY = max($nexY, $posYAfterImage); @@ -725,7 +750,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { @@ -737,15 +764,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } } } // Show square - if ($pagenb == $pageposbeforeprintlines) - { + if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { @@ -761,15 +791,17 @@ class pdf_standard_myobject extends ModelePDFMyObject // Display payment area /* - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) - { - $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); - } - */ + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) + { + $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); + } + */ // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); + if (method_exists($pdf, 'AliasNbPages')) { + $pdf->AliasNbPages(); + } $pdf->Close(); @@ -780,14 +812,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) - { + if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $this->result = array('fullpath'=>$file); @@ -837,7 +869,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // Force to disable hidetop and hidebottom $hidebottom = 0; - if ($hidetop) $hidetop = -1; + if ($hidetop) { + $hidetop = -1; + } $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -846,8 +880,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - if (empty($hidetop)) - { + if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); @@ -899,8 +932,7 @@ class pdf_standard_myobject extends ModelePDFMyObject pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) - { + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); } @@ -915,20 +947,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) - { - if ($this->emetteur->logo) - { + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { + if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) - { + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; } - if (is_readable($logo)) - { + if (is_readable($logo)) { $height = pdf_getHeightForLogo($logo); $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -959,8 +989,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); - if ($object->statut == $object::STATUS_DRAFT) - { + if ($object->statut == $object::STATUS_DRAFT) { $pdf->SetTextColor(128, 0, 0); $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); } @@ -969,19 +998,16 @@ class pdf_standard_myobject extends ModelePDFMyObject $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); - if ($object->ref_client) - { + if ($object->ref_client) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) - { + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (!empty($object->project->ref)) - { + if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -989,11 +1015,9 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) - { + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (!empty($object->project->ref)) - { + if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -1011,8 +1035,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); - if ($object->thirdparty->code_client) - { + if ($object->thirdparty->code_client) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -1020,11 +1043,9 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) - { + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); $posy += 4; @@ -1040,13 +1061,11 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show list of linked objects $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) - { + if ($current_y < $pdf->getY()) { $top_shift = $pdf->getY() - $current_y; } - if ($showaddress) - { + if ($showaddress) { // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); @@ -1054,7 +1073,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posy += $top_shift; $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->page_largeur - $this->marge_droite - 80; + } $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; @@ -1084,8 +1105,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // If BILLING contact defined on invoice, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'BILLING'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usecontact = true; $result = $object->fetch_contact($arrayidcontact[0]); } @@ -1105,11 +1125,15 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + if ($this->page_largeur < 210) { + $widthrecbox = 84; // To work with US executive format + } $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->marge_gauche; + } // Show recipient frame $pdf->SetTextColor(0, 0, 0); @@ -1179,22 +1203,22 @@ class pdf_standard_myobject extends ModelePDFMyObject ); /* - * For exemple - $this->cols['theColKey'] = array( - 'rank' => $rank, // int : use for ordering columns - 'width' => 20, // the column width in mm - 'title' => array( - 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - 'label' => ' ', // the final label : used fore final generated text - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'content' => array( - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - */ + * For exemple + $this->cols['theColKey'] = array( + 'rank' => $rank, // int : use for ordering columns + 'width' => 20, // the column width in mm + 'title' => array( + 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + 'label' => ' ', // the final label : used fore final generated text + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + */ $rank = 0; // do not use negative rank $this->cols['desc'] = array( @@ -1230,8 +1254,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) - { + if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1247,8 +1270,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) - { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->cols['vat']['status'] = true; } @@ -1285,8 +1307,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if ($this->situationinvoice) - { + if ($this->situationinvoice) { $this->cols['progress']['status'] = true; } @@ -1344,11 +1365,9 @@ class pdf_standard_myobject extends ModelePDFMyObject ); $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook - if ($reshook < 0) - { + if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } elseif (empty($reshook)) - { + } elseif (empty($reshook)) { $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys } else { $this->cols = $hookmanager->resArray; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index ae5f5d1e876..9c685e65d9a 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -113,8 +113,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject /*$mysoc->code_client = $old_code_client; $mysoc->typent_code = $old_code_type;*/ - if (!$numExample) - { + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } return $numExample; @@ -135,8 +134,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject // We get cursor rule $mask = $conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; - if (!$mask) - { + if (!$mask) { $this->error = 'NotConfigured'; return 0; } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index 6f1a5da7dd3..75068cf8d57 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -96,13 +96,13 @@ class mod_myobject_standard extends ModeleNumRefMyObject } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + if ($row) { + $coyymm = substr($row[0], 0, 6); $max = $row[0]; + } } - if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) - { + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; @@ -133,11 +133,13 @@ class mod_myobject_standard extends ModeleNumRefMyObject } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = intval($obj->max); - else $max = 0; + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } else { dol_syslog("mod_myobject_standard::getNextValue", LOG_DEBUG); return -1; @@ -147,8 +149,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject $date = $object->date_creation; $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max + 1); + if ($max >= (pow(10, 4) - 1)) { + $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + } else { + $num = sprintf("%04s", $max + 1); + } dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php index 78711e33a4d..8f0d86e3823 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php @@ -141,10 +141,18 @@ abstract class ModeleNumRefMyObject global $langs; $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + if ($this->version == 'development') { + return $langs->trans("VersionDevelopment"); + } + if ($this->version == 'experimental') { + return $langs->trans("VersionExperimental"); + } + if ($this->version == 'dolibarr') { + return DOL_VERSION; + } + if ($this->version) { + return $this->version; + } return $langs->trans("NotAvailable"); } } diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php index 06e3498fca0..67aac8c0e98 100644 --- a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php @@ -16,8 +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; } @@ -36,12 +35,13 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("mymodule"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?> <tr class="<?php echo $trclass; ?>"> <td><?php echo $langs->trans("MyObject"); ?></td> diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 8c0f39927bd..94365ae2c61 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -92,7 +92,9 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->mymodule->enabled)) return 0; // If module is not enabled, we do nothing + if (empty($conf->mymodule->enabled)) { + return 0; // If module is not enabled, we do nothing + } // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index ecffe5dcf97..985cbe6aa18 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -23,14 +23,26 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled. Language code is found on url. -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); // File must be accessed by logon page so without login +} //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} session_cache_limiter('public'); // false or '' = keep cache instruction added by server @@ -40,16 +52,30 @@ session_cache_limiter('public'); // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index fea88d695ec..fe04cdc2ad9 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -17,16 +17,36 @@ * Library javascript to enable Browser notifications */ -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); -if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '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('NOLOGIN')) define('NOLOGIN', 1); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREUSER')) { + define('NOREQUIREUSER', '1'); +} +if (!defined('NOREQUIREDB')) { + define('NOREQUIREDB', '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('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} /** @@ -38,16 +58,30 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} // Define js type header('Content-Type: application/javascript'); diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index ebd5b837e3d..e3117d88303 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -41,14 +41,19 @@ function myobjectPrepareHead($object) $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) - { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $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_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); + if ($nbNote > 0) { + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); + } $head[$h][2] = 'note'; $h++; } @@ -60,7 +65,9 @@ function myobjectPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + } $head[$h][2] = 'document'; $h++; diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index ee2fe6b28f0..2d262aeeb36 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -27,17 +27,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index fbd156f2a97..0bb3244ebdd 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 0a5e23cb07a..e99acc0b913 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -464,7 +480,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } if (empty($reshook)) { // Send diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 35e5be2716a..6d6345d9b99 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -25,17 +25,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index f1424906dd6..c0765394135 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 2cbccd1523b..ee8c2e6677e 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -132,7 +148,9 @@ foreach ($object->fields as $key => $val) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns @@ -161,7 +179,9 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; $permissiontodelete = $user->rights->mymodule->myobject->delete; // Security check -if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled'); +if (empty($conf->mymodule->enabled)) { + accessforbidden('Module not enabled'); +} $socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; @@ -260,14 +280,21 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} foreach ($search as $key => $val) { if (in_array($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) continue; + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } if ($search[$key] != '') { @@ -330,7 +357,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if (!$resql) { @@ -550,7 +579,9 @@ print '</tr>'."\n"; $needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -618,11 +649,15 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print '<td class="nowrap center">'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index abe8daf7622..0868cd3918d 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 0b8d7abfdfe..0dab19d7ae6 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -46,13 +46,25 @@ define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to $res = 0; // Try master.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/master.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/master.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/master.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/master.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php"; +} // Try master.inc.php using relative path -if (!$res && file_exists("../master.inc.php")) $res = @include "../master.inc.php"; -if (!$res && file_exists("../../master.inc.php")) $res = @include "../../master.inc.php"; -if (!$res && file_exists("../../../master.inc.php")) $res = @include "../../../master.inc.php"; +if (!$res && file_exists("../master.inc.php")) { + $res = @include "../master.inc.php"; +} +if (!$res && file_exists("../../master.inc.php")) { + $res = @include "../../master.inc.php"; +} +if (!$res && file_exists("../../../master.inc.php")) { + $res = @include "../../../master.inc.php"; +} if (!$res) { print "Include of master fails"; exit(-1); @@ -65,7 +77,9 @@ $langs->load("main"); // To load language file for default language // Load user and its permissions $result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. -if (!$result > 0) { dol_print_error('', $user->error); exit; } +if (!$result > 0) { + dol_print_error('', $user->error); exit; +} $user->getrights(); @@ -162,8 +176,7 @@ else // -------------------- END OF YOUR CODE -------------------- -if (!$error) -{ +if (!$error) { $db->commit(); print '--- end ok'."\n"; } else { diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php index adf4a8f4ee7..280a0c98cdd 100644 --- a/htdocs/mrp/ajax/ajax_bom.php +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -22,13 +22,25 @@ //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_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; @@ -43,12 +55,11 @@ $action = GETPOST('action', 'aZ09'); $object = new BOM($db); $result = $object->fetch($idbom); -if ($result > 0) -{ +if ($result > 0) { // We remove properties we don't need in answer unset($object->fields); unset($object->db); echo json_encode($object); } else { - echo 'Failed to load category with id='.$idbom; + echo 'Failed to load category with id='.$idbom; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 121909eb28a..f2f8a5bae3d 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -208,25 +208,24 @@ class Mo 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; + } // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -305,7 +304,9 @@ class Mo extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } // get lines so they will be clone //foreach($this->lines as $line) @@ -322,14 +323,11 @@ class Mo extends CommonObject $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -345,22 +343,19 @@ class Mo extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { - if ($this->copy_linked_contact($object, 'external') < 0) + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { $error++; + } } } @@ -386,7 +381,9 @@ class Mo extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -426,8 +423,11 @@ class Mo extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -458,8 +458,7 @@ class Mo extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($limit, $num)) - { + while ($i < min($limit, $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -496,8 +495,11 @@ class Mo extends CommonObject $sql .= $mostatic->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$mostatic->table_element.' as t'; $sql .= " WHERE t.role = '".$this->db->escape($role)."'"; - if ($lineid > 0) $sql .= ' AND t.fk_mrp_production = '.$lineid; - else $sql .= 'AND t.fk_mo = '.$this->id; + if ($lineid > 0) { + $sql .= ' AND t.fk_mrp_production = '.$lineid; + } else { + $sql .= 'AND t.fk_mo = '.$this->id; + } $resql = $this->db->query($sql); if ($resql) { @@ -618,8 +620,7 @@ class Mo extends CommonObject $this->db->begin(); // Insert lines in mrp_production table from BOM data - if (!$error) - { + if (!$error) { // TODO Check that production has not started. If yes, we stop here. $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'mrp_production WHERE fk_mo = '.$this->id; @@ -646,12 +647,10 @@ class Mo extends CommonObject include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; $bom = new Bom($this->db); $bom->fetch($this->fk_bom); - if ($bom->id > 0) - { + if ($bom->id > 0) { // Lines to consume if (!$error) { - foreach ($bom->lines as $line) - { + foreach ($bom->lines as $line) { $moline = new MoLine($this->db); $moline->fk_mo = $this->id; @@ -719,8 +718,7 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -741,8 +739,7 @@ class Mo extends CommonObject global $langs, $conf; $langs->load("mrp"); - if (!empty($conf->global->MRP_MO_ADDON)) - { + if (!empty($conf->global->MRP_MO_ADDON)) { $mybool = false; $file = $conf->global->MRP_MO_ADDON.".php"; @@ -750,16 +747,14 @@ class Mo extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/mrp/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -767,8 +762,7 @@ class Mo extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($prod, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -797,8 +791,7 @@ class Mo extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -816,8 +809,7 @@ class Mo extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $this->fetch_product(); $num = $this->getNextNumRef($this->product); } else { @@ -835,50 +827,47 @@ class Mo extends CommonObject dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MRP_MO_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + 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 = 'mrp/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'mrp/".$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($num); $dirsource = $conf->mrp->dir_output.'/'.$oldref; $dirdest = $conf->mrp->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->mrp->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -891,14 +880,12 @@ class Mo extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -917,8 +904,7 @@ class Mo extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->status <= self::STATUS_DRAFT) - { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -942,8 +928,7 @@ class Mo extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_VALIDATED && $this->status != self::STATUS_INPROGRESS) - { + if ($this->status != self::STATUS_VALIDATED && $this->status != self::STATUS_INPROGRESS) { return 0; } @@ -967,8 +952,7 @@ class Mo extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED) { return 0; } @@ -996,7 +980,9 @@ class Mo extends CommonObject { global $conf, $langs, $hookmanager; - 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 = ''; @@ -1008,35 +994,44 @@ class Mo extends CommonObject $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; - if ($option == 'production') $url = dol_buildpath('/mrp/mo_production.php', 1).'?id='.$this->id; + if ($option == 'production') { + $url = dol_buildpath('/mrp/mo_production.php', 1).'?id='.$this->id; + } - if ($option != 'nolink') - { + 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMo"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; $linkend = '</a>'; $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)) : ''); @@ -1044,8 +1039,11 @@ class Mo extends CommonObject $hookmanager->initHooks(array('modao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -1072,8 +1070,7 @@ class Mo extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus)) - { + if (empty($this->labelStatus)) { global $langs; //$langs->load("mrp"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); @@ -1090,10 +1087,18 @@ class Mo extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_INPROGRESS) $statusType = 'status4'; - if ($status == self::STATUS_PRODUCED) $statusType = 'status6'; - if ($status == self::STATUS_CANCELED) $statusType = 'status9'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status1'; + } + if ($status == self::STATUS_INPROGRESS) { + $statusType = 'status4'; + } + if ($status == self::STATUS_PRODUCED) { + $statusType = 'status6'; + } + if ($status == self::STATUS_CANCELED) { + $statusType = 'status9'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -1111,28 +1116,23 @@ class Mo extends CommonObject $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)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -1172,8 +1172,7 @@ class Mo extends CommonObject $objectline = new MoLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); - if (is_numeric($result)) - { + if (is_numeric($result)) { $this->error = $this->error; $this->errors = $this->errors; return $result; @@ -1213,7 +1212,9 @@ class Mo extends CommonObject $modelpath = "core/modules/mrp/doc/"; - if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists. + if (empty($modele)) { + return 1; // Remove this once a pdf_standard.php exists. + } return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } @@ -1273,10 +1274,8 @@ class Mo extends CommonObject print '</tr>'; $i = 0; - if (!empty($this->lines)) - { - foreach ($this->lines as $line) - { + if (!empty($this->lines)) { + foreach ($this->lines as $line) { /*if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) @@ -1317,8 +1316,7 @@ class Mo extends CommonObject $this->tpl['id'] = $line->id; $this->tpl['label'] = ''; - if (!empty($line->fk_product)) - { + if (!empty($line->fk_product)) { $productstatic = new Product($this->db); $productstatic->fetch($line->fk_product); $this->tpl['label'] .= $productstatic->getNomUrl(1); @@ -1432,27 +1430,25 @@ class MoLine extends CommonObjectLine $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; + } // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -1487,7 +1483,9 @@ class MoLine extends CommonObjectLine public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -1513,8 +1511,11 @@ class MoLine extends CommonObjectLine $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -1545,8 +1546,7 @@ class MoLine extends CommonObjectLine if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($limit, $num)) - { + while ($i < min($limit, $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index b84a77c2288..f86a52f4aae 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -61,16 +61,14 @@ print '<div class="fichecenter"><div class="fichethirdleft">'; * Statistics */ -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { $sql = "SELECT COUNT(t.rowid) as nb, status"; $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t"; $sql .= " GROUP BY t.status"; $sql .= " ORDER BY t.status ASC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -81,14 +79,12 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $vals[$obj->status] = $obj->nb; - $totalnb += $obj->nb; + $totalnb += $obj->nb; } $i++; } @@ -98,25 +94,32 @@ if ($conf->use_javascript_ajax) print '<table class="noborder nohover centpercent">'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th></tr>'."\n"; $listofstatus = array(0, 1, 2, 3, 9); - foreach ($listofstatus as $status) - { + foreach ($listofstatus as $status) { $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Mo::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Mo::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Mo::STATUS_INPROGRESS) $colorseries[$status] = $badgeStatus4; - if ($status == Mo::STATUS_PRODUCED) $colorseries[$status] = $badgeStatus6; - if ($status == Mo::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + if ($status == Mo::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Mo::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Mo::STATUS_INPROGRESS) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Mo::STATUS_PRODUCED) { + $colorseries[$status] = $badgeStatus6; + } + if ($status == Mo::STATUS_CANCELED) { + $colorseries[$status] = $badgeStatus9; + } - if (empty($conf->use_javascript_ajax)) - { + if (empty($conf->use_javascript_ajax)) { print '<tr class="oddeven">'; print '<td>'.$staticmo->LibStatut($status, 0).'</td>'; print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>'; print "</tr>\n"; } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr><td class="center" colspan="2">'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -159,19 +162,16 @@ $sql .= $db->order("a.tms", "DESC"); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="4">'.$langs->trans("LatestBOMModified", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $staticbom->id = $obj->rowid; @@ -210,19 +210,16 @@ $sql .= $db->order("a.tms", "DESC"); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="4">'.$langs->trans("LatestMOModified", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $staticmo->id = $obj->rowid; diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index a02bb0e8f84..179c7a15129 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -21,13 +21,27 @@ * \brief File that include javascript functions used for dispatching qty/stock/lot */ -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'); @@ -36,8 +50,11 @@ require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} ?> /** diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index eb61c42e83d..62f74ce016e 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -59,14 +59,19 @@ function moPrepareHead($object) $head[$h][2] = 'stockmovement'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) - { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $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_buildpath('/mrp/mo_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; + if ($nbNote > 0) { + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; + } $head[$h][2] = 'note'; $h++; } @@ -78,7 +83,9 @@ function moPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; + } $head[$h][2] = 'document'; $h++; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 0fe9ba63e08..69c64b1a027 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -44,10 +44,11 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -57,12 +58,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Initialize technical objects $object = new Mo($db); @@ -75,7 +82,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -90,20 +99,19 @@ $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'row $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // 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 $actioncode = ''; $search_agenda_label = ''; } @@ -120,14 +128,15 @@ $contactstatic = new Contact($db); $form = new Form($db); $formproject = new FormProjets($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $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; $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = moPrepareHead($object); @@ -144,14 +153,13 @@ if ($object->id > 0) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -196,10 +204,11 @@ if ($object->id > 0) $out = '&origin='.$object->element.'&originid='.$object->id; $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; - if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id; + if (get_class($objthirdparty) == 'Societe') { + $out .= '&amp;socid='.$objthirdparty->id; + } $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); @@ -209,10 +218,8 @@ if ($object->id > 0) print '<div class="tabsAction">'; - if (!empty($conf->agenda->enabled)) - { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { + if (!empty($conf->agenda->enabled)) { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>'; @@ -221,11 +228,14 @@ if ($object->id > 0) print '</div>'; - 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); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } //print load_fiche_titre($langs->trans("ActionsOnMo"), '', ''); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index a95d92d67a1..9afbbaf9acf 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -61,18 +61,20 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -if (GETPOST('fk_bom', 'int')) -{ +if (GETPOST('fk_bom', 'int')) { $objectbom->fetch(GETPOST('fk_bom', 'int')); if ($action != 'add') { @@ -103,18 +105,22 @@ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->enti $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } } } if ($cancel && !empty($backtopageforcancel)) { @@ -141,28 +147,27 @@ if (empty($reshook)) // Action to move up and down lines of object //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'set_thirdparty' && $permissiontoadd) - { + if ($action == 'set_thirdparty' && $permissiontoadd) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); } - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } // Action close produced - if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) - { + if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -208,15 +213,18 @@ jQuery(document).ready(function() { // Part to create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'mrp'); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } + if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + } print dol_get_fiche_head(array(), ''); @@ -234,7 +242,7 @@ if ($action == 'create') ?> <script> - $(document).ready(function () { + $(document).ready(function () { jQuery('#fk_bom').change(function() { console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val()); if (jQuery('#fk_bom').val() > 0) @@ -280,7 +288,7 @@ if ($action == 'create') $('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed */ } - }); + }); //jQuery('#fk_bom').trigger('change'); }) @@ -312,16 +320,19 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("ManufacturingOrder"), '', 'mrp'); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; - if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + if ($backtopage) { + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + } + if ($backtopageforcancel) { + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; + } print dol_get_fiche_head(); @@ -347,8 +358,7 @@ if (($id || $ref) && $action == 'edit') } // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_thirdparty(); $res = $object->fetch_optionals(); @@ -359,19 +369,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = ''; // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line - if ($action == 'deleteline') - { + if ($action == 'deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Confirmation of validation - if ($action == 'validate') - { + if ($action == 'validate') { // We check that object has a temporary ref $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { @@ -391,13 +398,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ $formquestion = array(); - if (!empty($conf->mrp->enabled)) - { + if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $forcecombo = 0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), @@ -418,8 +426,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -438,14 +449,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= $langs->trans('ThirdParty').' '; $morehtmlref .= ': '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -500,8 +510,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Lines */ - if (!empty($object->table_element_line)) - { + if (!empty($object->table_element_line)) { // Show object lines //$result = $object->getLinesArray(); $object->fetchLines(); @@ -514,11 +523,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; /*if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - }*/ + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + }*/ - if (!empty($object->lines)) - { + if (!empty($object->lines)) { print '<div class="div-table-responsive-no-min">'; print '<table id="tablelines" class="noborder noshadow" width="100%">'; @@ -530,12 +538,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr class="oddeven">'; print '<td>'.$langs->trans("ProductsToConsume").'</td>'; print '<td>'; - if (!empty($object->lines)) - { + if (!empty($object->lines)) { $i = 0; foreach ($object->lines as $line) { if ($line->role == 'toconsume') { - if ($i) print ', '; + if ($i) { + print ', '; + } $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); print $tmpproduct->getNomUrl(1); @@ -549,12 +558,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr class="oddeven">'; print '<td>'.$langs->trans("ProductsToProduce").'</td>'; print '<td>'; - if (!empty($object->lines)) - { + if (!empty($object->lines)) { $i = 0; foreach ($object->lines as $line) { if ($line->role == 'toproduce') { - if ($i) print ', '; + if ($i) { + print ', '; + } $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); print $tmpproduct->getNomUrl(1); @@ -579,20 +589,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<div class="tabsAction">'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Send //if (empty($user->socid)) { // print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; //} // Back to draft - if ($object->status == $object::STATUS_VALIDATED) - { - if ($permissiontoadd) - { + if ($object->status == $object::STATUS_VALIDATED) { + if ($permissiontoadd) { // TODO Add test that production has not started print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>'; } @@ -600,8 +609,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Modify if ($object->status == $object::STATUS_DRAFT) { - if ($permissiontoadd) - { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; @@ -609,12 +617,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Validate - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) - { + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; } else { $langs->load("errors"); @@ -624,16 +629,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - if ($permissiontoadd) - { + if ($permissiontoadd) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->fk_soc.'&action=clone&object=mo">'.$langs->trans("ToClone").'</a>'; } // Cancel - Reopen - if ($permissiontoadd) - { - if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) - { + if ($permissiontoadd) { + if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { $arrayproduced = $object->fetchLinesLinked('produced', 0); $nbProduced = 0; foreach ($arrayproduced as $lineproduced) { @@ -648,15 +650,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n"; } - if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) - { + if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("ReOpen").'</a>'."\n"; } } // Delete (need delete permission, or if draft, just need create/modify permission) - if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) - { + if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n"; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; @@ -671,8 +671,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre @@ -707,7 +706,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } //Select mail models is same action as presend - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) { + $action = 'presend'; + } // Presend form $modelmail = 'mo'; diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index d3040918aae..920f69b01af 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -47,12 +47,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects @@ -67,7 +73,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity ? $object->entity : $conf->entity]."/mo/".get_exdir(0, 0, 0, 1, $object); +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mrp->multidir_output[$object->entity ? $object->entity : $conf->entity]."/mo/".get_exdir(0, 0, 0, 1, $object); +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -95,8 +103,7 @@ $help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($object->id) -{ +if ($object->id) { /* * Show tabs */ @@ -107,8 +114,7 @@ if ($object->id) // 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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -123,14 +129,13 @@ if ($object->id) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index beeefbd19ff..972fb2cb770 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -54,7 +54,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -73,15 +75,20 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check -if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); +if (empty($conf->mrp->enabled)) { + accessforbidden('Module not enabled'); +} $socid = 0; -if ($user->socid > 0) // Protection if external user -{ - //$socid = $user->socid; +if ($user->socid > 0) { // Protection if external user +//$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'mrp', $id, ''); @@ -90,30 +97,31 @@ if ($user->socid > 0) // Protection if external user // Initialize array of search criterias $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of fields for list $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -136,31 +144,33 @@ $permissiontodelete = $user->rights->mrp->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - { - foreach ($object->fields as $key => $val) - { + 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 + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -189,13 +199,14 @@ $title = $langs->trans('ListOfManufacturingOrders'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // 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.', ' : ''); + 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(); @@ -203,20 +214,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +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 (t.rowid = ef.fk_object)"; +} +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -246,26 +269,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -274,8 +295,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/mrp/mo_card.php', 1).'?id='.$id); @@ -306,14 +326,24 @@ jQuery(document).ready(function() { $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) -{ - 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 (!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 ($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'; @@ -324,12 +354,18 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -348,9 +384,10 @@ $objecttmp = new Mo($db); $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } @@ -361,11 +398,13 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -382,20 +421,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; + } print '</td>'; } } @@ -417,15 +462,18 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -442,11 +490,11 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -455,38 +503,53 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); // Show here line of result print '<tr class="oddeven">'; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) { + $cssforfield = 'tdoverflowmax100'; + } - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; - if ($key == 'status') print $object->getLibStatut(5); - else print $object->showOutputField($val, $key, $object->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -499,14 +562,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; @@ -518,10 +584,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -537,10 +606,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index b4dbed059bc..31dbd2e6e64 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -66,10 +66,16 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (!$sortfield) $sortfield = "m.datem"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "m.datem"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Initialize technical objects $object = new Mo($db); @@ -85,12 +91,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = trim(GETPOST("search_all", 'alpha')); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -145,18 +154,23 @@ $permissiontoproduce = $permissiontoadd; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click 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 -{ +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 $year = ''; $month = ''; $search_ref = ''; @@ -174,16 +188,18 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options = array(); } -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { //var_dump($backurlforlist);exit; - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + } } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record @@ -205,12 +221,10 @@ if (empty($reshook)) // Action to move up and down lines of object //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'set_thirdparty' && $permissiontoadd) - { + if ($action == 'set_thirdparty' && $permissiontoadd) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); } - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } @@ -236,8 +250,7 @@ $userstatic = new User($db); llxHeader('', $langs->trans('Mo'), ''); // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_thirdparty(); $res = $object->fetch_optionals(); @@ -248,13 +261,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = ''; // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line - if ($action == 'deleteline') - { + if ($action == 'deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation @@ -265,27 +276,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of action xxxx - if ($action == 'xxx') - { + if ($action == 'xxx') { $formquestion = array(); /* $forcecombo=0; if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -303,14 +316,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -403,7 +415,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields if (!empty($extrafields->attributes[$objectlist->table_element]['label'])) { - foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + } } // Add fields from hooks $parameters = array(); @@ -412,26 +426,52 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; - if (is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; + if (is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; $sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id; - if ($msid > 0) $sql .= " AND m.rowid = ".$msid; + if ($msid > 0) { + $sql .= " AND m.rowid = ".$msid; + } $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND p.fk_product_type = 0"; + } $sql .= dolSqlDateFilter('m.datem', 0, $month, $year); - if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); - if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); - if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); - if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); - if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); - if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); - if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); - if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); - if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); - if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); + if (!empty($search_ref)) { + $sql .= natural_search('m.rowid', $search_ref, 1); + } + if (!empty($search_movement)) { + $sql .= natural_search('m.label', $search_movement); + } + if (!empty($search_inventorycode)) { + $sql .= natural_search('m.inventorycode', $search_inventorycode); + } + if (!empty($search_product_ref)) { + $sql .= natural_search('p.ref', $search_product_ref); + } + if (!empty($search_product)) { + $sql .= natural_search('p.label', $search_product); + } + if ($search_warehouse != '' && $search_warehouse != '-1') { + $sql .= natural_search('e.rowid', $search_warehouse, 2); + } + if (!empty($search_user)) { + $sql .= natural_search('u.login', $search_user); + } + if (!empty($search_batch)) { + $sql .= natural_search('m.batch', $search_batch); + } + if ($search_qty != '') { + $sql .= natural_search('m.value', $search_qty, 1); + } + if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { + $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); + } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -441,12 +481,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -454,17 +492,39 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= $db->plimit($limit + 1, $offset); $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($id > 0) $param .= '&id='.urlencode($id); - if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param .= '&search_product='.urlencode($search_product); - if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); - if ($search_user) $param .= '&search_user='.urlencode($search_user); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($id > 0) { + $param .= '&id='.urlencode($id); + } + if ($search_movement) { + $param .= '&search_movement='.urlencode($search_movement); + } + if ($search_inventorycode) { + $param .= '&search_inventorycode='.urlencode($search_inventorycode); + } + if ($search_type_mouvement) { + $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + } + if ($search_product_ref) { + $param .= '&search_product_ref='.urlencode($search_product_ref); + } + if ($search_product) { + $param .= '&search_product='.urlencode($search_product); + } + if ($search_batch) { + $param .= '&search_batch='.urlencode($search_batch); + } + if ($search_warehouse > 0) { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_user) { + $param .= '&search_user='.urlencode($search_user); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -475,11 +535,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -487,20 +551,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; - if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">'; + if ($id > 0) { + print '<input type="hidden" name="id" value="'.$id.'">'; + } - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + if ($id > 0) { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + } else { + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + } $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; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -514,84 +585,74 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Fields title search print '<tr class="liste_titre_filter">'; - if (!empty($arrayfields['m.rowid']['checked'])) - { + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (!empty($arrayfields['m.datem']['checked'])) - { + if (!empty($arrayfields['m.datem']['checked'])) { print '<td class="liste_titre nowraponall">'; print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">'; - if (empty($conf->productbatch->enabled)) print '&nbsp;'; + if (empty($conf->productbatch->enabled)) { + print '&nbsp;'; + } //else print '<br>'; $syear = $year ? $year : -1; print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">'; //print $formother->selectyear($syear,'year',1, 20, 5); print '</td>'; } - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">'; print '</td>'; } - if (!empty($arrayfields['p.label']['checked'])) - { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td class="liste_titre left">'; print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">'; print '</td>'; } // Batch - if (!empty($arrayfields['m.batch']['checked'])) - { + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>'; } - if (!empty($arrayfields['pl.eatby']['checked'])) - { + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } - if (!empty($arrayfields['pl.sellby']['checked'])) - { + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) - { + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone left">'; //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">'; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['m.fk_user_author']['checked'])) - { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">'; print '</td>'; } - if (!empty($arrayfields['m.inventorycode']['checked'])) - { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">'; print '</td>'; } - if (!empty($arrayfields['m.label']['checked'])) - { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">'; print '</td>'; } - if (!empty($arrayfields['m.type_mouvement']['checked'])) - { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print '<td class="liste_titre center">'; //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">'; @@ -607,22 +668,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (!empty($arrayfields['origin']['checked'])) - { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="liste_titre left">'; print '&nbsp; '; print '</td>'; } - if (!empty($arrayfields['m.value']['checked'])) - { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">'; print '</td>'; } - if (!empty($arrayfields['m.price']['checked'])) - { + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="liste_titre left">'; print '&nbsp; '; @@ -638,14 +696,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['m.datec']['checked'])) - { + if (!empty($arrayfields['m.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (!empty($arrayfields['m.tms']['checked'])) - { + if (!empty($arrayfields['m.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } @@ -657,38 +713,52 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print "</tr>\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['m.datem']['checked'])) + } + if (!empty($arrayfields['m.datem']['checked'])) { print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) + } + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.label']['checked'])) + } + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['m.batch']['checked'])) + } + if (!empty($arrayfields['m.batch']['checked'])) { print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pl.eatby']['checked'])) + } + if (!empty($arrayfields['pl.eatby']['checked'])) { print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['pl.sellby']['checked'])) + } + if (!empty($arrayfields['pl.sellby']['checked'])) { print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (!empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.inventorycode']['checked'])) + } + if (!empty($arrayfields['m.inventorycode']['checked'])) { print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.label']['checked'])) + } + if (!empty($arrayfields['m.label']['checked'])) { print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.type_mouvement']['checked'])) + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) { print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['origin']['checked'])) + } + if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.value']['checked'])) + } + if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['m.price']['checked'])) + } + if (!empty($arrayfields['m.price']['checked'])) { print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -775,9 +845,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="center nowraponall">'; - if ($productlot->id > 0) + if ($productlot->id > 0) { print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + } else { + print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + } print '</td>'; } if (!empty($arrayfields['pl.eatby']['checked'])) { @@ -834,30 +906,33 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; - if ($objp->qt > 0) + if ($objp->qt > 0) { print '+'; + } print $objp->qty; print '</td>'; } if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="right">'; - if ($objp->price != 0) + if ($objp->price != 0) { print price($objp->price); + } print '</td>'; } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) + if (in_array($obj->rowid, $arrayofselected)) { $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) + if (!$i) { $totalarray['nbfield']++; + } print "</tr>\n"; $i++; diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 564361c4b90..56699e4903f 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -50,7 +50,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -81,8 +83,7 @@ $formproject = new FormProjets($db); $help_url = ''; llxHeader('', $langs->trans('Mo'), $help_url); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); $head = moPrepareHead($object); @@ -100,14 +101,13 @@ if ($id > 0 || !empty($ref)) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index c1b6fa64ec8..bb4ec9f1102 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -65,12 +65,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -96,18 +99,22 @@ $permissiontoproduce = $permissiontoadd; $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { //var_dump($backurlforlist);exit; - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); + } } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record @@ -129,12 +136,10 @@ if (empty($reshook)) // Action to move up and down lines of object //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'set_thirdparty' && $permissiontoadd) - { + if ($action == 'set_thirdparty' && $permissiontoadd) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); } - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } @@ -364,18 +369,19 @@ if (empty($reshook)) } // Action close produced - if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) - { + if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -407,8 +413,7 @@ $help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, array('/mrp/js/lib_dispatch.js.php')); // Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_thirdparty(); $res = $object->fetch_optionals(); @@ -419,13 +424,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = ''; // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line - if ($action == 'deleteline') - { + if ($action == 'deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation @@ -436,8 +439,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of validation - if ($action == 'validate') - { + if ($action == 'validate') { // We check that object has a temporary ref $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { @@ -457,13 +459,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ $formquestion = array(); - if (!empty($conf->mrp->enabled)) - { + if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $forcecombo = 0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), @@ -477,8 +480,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -496,14 +502,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '<br>'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; @@ -554,8 +559,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - if (!in_array($action, array('consumeorproduce', 'consumeandproduceall'))) - { + if (!in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print '<div class="tabsAction">'; $parameters = array(); @@ -563,12 +567,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); if (empty($reshook)) { // Validate - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) - { + if ($object->status == $object::STATUS_DRAFT) { + if ($permissiontoadd) { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; } else { $langs->load("errors"); @@ -600,10 +601,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Cancel - Reopen - if ($permissiontoadd) - { - if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) - { + if ($permissiontoadd) { + if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { $arrayproduced = $object->fetchLinesLinked('produced', 0); $nbProduced = 0; foreach ($arrayproduced as $lineproduced) { @@ -618,8 +617,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n"; } - if ($object->status == $object::STATUS_CANCELED) - { + if ($object->status == $object::STATUS_CANCELED) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n"; } @@ -636,8 +634,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</div>'; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) - { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="confirm_'.$action.'">'; @@ -672,8 +669,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ $collapse = 1; - if (!empty($object->table_element_line)) - { + if (!empty($object->table_element_line)) { // Show object lines $object->fetchLines(); @@ -695,11 +691,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<td class="right">'.$langs->trans("Qty").'</td>'; print '<td class="right">'.$langs->trans("QtyAlreadyConsumed").'</td>'; print '<td>'; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Warehouse"); + } print '</td>'; if ($conf->productbatch->enabled) { print '<td>'; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Batch"); + } print '</td>'; } print '</tr>'; @@ -723,8 +723,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Lines to consume - if (!empty($object->lines)) - { + if (!empty($object->lines)) { $nblinetoconsume = 0; foreach ($object->lines as $line) { if ($line->role == 'toconsume') { @@ -752,8 +751,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</td>'; print '<td class="right nowraponall">'; $help = ''; - if ($line->qty_frozen) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; - if ($line->disable_stock_change) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; + if ($line->qty_frozen) { + $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; + } + if ($line->disable_stock_change) { + $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; + } if ($help) { print $form->textwithpicto($line->qty, $help, -1); } else { @@ -774,9 +777,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }); });'; print '</script>'; - if (empty($conf->use_javascript_ajax)) print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">'; + if (empty($conf->use_javascript_ajax)) { + print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">'; + } print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) print '</a>'; + if (empty($conf->use_javascript_ajax)) { + print '</a>'; + } } else { if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line print '<script>jQuery("#tablelines").removeClass("nobottom");</script>'; @@ -802,7 +809,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<td class="tdoverflowmax150">'; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) print $tmpwarehouse->getNomUrl(1); + if ($result > 0) { + print $tmpwarehouse->getNomUrl(1); + } } print '</td>'; // Lot Batch @@ -821,7 +830,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr>'; print '<td><span class="opacitymedium">'.$langs->trans("ToConsume").'</span></td>'; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) { + $preselected = 0; + } print '<td class="right"><input type="text" class="width50 right" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; print '<td></td>'; print '<td>'; @@ -851,7 +862,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - print '</table>'; + print '</table>'; print '</div>'; // Lines to produce @@ -870,18 +881,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<td class="right">'.$langs->trans("Qty").'</td>'; print '<td class="right">'.$langs->trans("QtyAlreadyProduced").'</td>'; print '<td>'; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Warehouse"); + } print '</td>'; if ($conf->productbatch->enabled) { print '<td>'; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Batch"); + } print '</td>'; print '<td></td>'; } print '</tr>'; - if (!empty($object->lines)) - { + if (!empty($object->lines)) { $nblinetoproduce = 0; foreach ($object->lines as $line) { if ($line->role == 'toproduce') { @@ -930,9 +944,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }); });'; print '</script>'; - if (empty($conf->use_javascript_ajax)) print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">'; + if (empty($conf->use_javascript_ajax)) { + print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">'; + } print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) print '</a>'; + if (empty($conf->use_javascript_ajax)) { + print '</a>'; + } } print ' '.$alreadyproduced; print '</td>'; @@ -955,7 +973,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<td class="tdoverflowmax150">'; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) print $tmpwarehouse->getNomUrl(1); + if ($result > 0) { + print $tmpwarehouse->getNomUrl(1); + } } print '</td>'; if ($conf->productbatch->enabled) { @@ -975,7 +995,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr name="batch_'.$line->id.'_'.$i.'">'; print '<td><span class="opacitymedium">'.$langs->trans("ToProduce").'</span></td>'; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { + $preselected = 0; + } print '<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.'-'.$i.'" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; print '<td></td>'; print '<td>'; @@ -1013,8 +1035,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</div>'; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) - { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { print "</form>\n"; } } diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 6f3b63f6d4e..75147a3c3f9 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -17,13 +17,14 @@ */ // 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; } -if (!is_object($form)) $form = new Form($db); +if (!is_object($form)) { + $form = new Form($db); +} $qtytoconsumeforline = $this->tpl['qty'] / $this->tpl['efficiency']; /*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { @@ -43,7 +44,9 @@ print '<td class="center">'.($this->tpl['disable_stock_change'] ? yn($this->tpl[ //print '<td class="right">'.$this->tpl['efficiency'].'</td>'; $selected = 1; -if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected = 0; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { + $selected = 0; +} print '<td class="center">'; //print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>'; print '</td>'; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index bb4df7060e9..0bf7fc6a252 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -121,14 +121,15 @@ class MultiCurrency extends CommonObject $error = 0; - if (self::checkCodeAlreadyExists($this->code)) - { + if (self::checkCodeAlreadyExists($this->code)) { $error++; $this->errors[] = $langs->trans('multicurrency_code_already_added'); return -1; } - if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + if (empty($this->entity) || $this->entity <= 0) { + $this->entity = $conf->entity; + } $now = date('Y-m-d H:i:s'); // Insert request @@ -163,7 +164,9 @@ class MultiCurrency extends CommonObject if ($trigger) { $result = $this->call_trigger('CURRENCY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } } @@ -194,8 +197,11 @@ class MultiCurrency extends CommonObject $sql = 'SELECT'; $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS c'; - if (!empty($code)) $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity; - else $sql .= ' WHERE c.rowid = '.$id; + if (!empty($code)) { + $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity; + } else { + $sql .= ' WHERE c.rowid = '.$id; + } dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -308,7 +314,9 @@ class MultiCurrency extends CommonObject if (!$error && $trigger) { $result = $this->call_trigger('CURRENCY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Commit or rollback @@ -341,7 +349,9 @@ class MultiCurrency extends CommonObject if ($trigger) { $result = $this->call_trigger('CURRENCY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { @@ -383,10 +393,8 @@ class MultiCurrency extends CommonObject */ public function deleteRates() { - foreach ($this->rates as &$rate) - { - if ($rate->delete() <= 0) - { + foreach ($this->rates as &$rate) { + if ($rate->delete() <= 0) { return false; } } @@ -402,11 +410,10 @@ class MultiCurrency extends CommonObject */ public function addRate($rate) { - $currencyRate = new CurrencyRate($this->db); + $currencyRate = new CurrencyRate($this->db); $currencyRate->rate = price2num($rate); - if ($currencyRate->create($this->id) > 0) - { + if ($currencyRate->create($this->id) > 0) { $this->rate = $currencyRate; return 1; } else { @@ -433,19 +440,20 @@ class MultiCurrency extends CommonObject $sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'"; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && ($line = $db->fetch_object($resql))) - { + if ($resql && ($line = $db->fetch_object($resql))) { $currency->name = $line->label; } - if ($currency->create($user) > 0) - { + if ($currency->create($user) > 0) { $currency->addRate($rate); - if (!empty($line)) return 2; - else return 1; + if (!empty($line)) { + return 2; + } else { + return 1; + } } return -1; @@ -469,7 +477,7 @@ class MultiCurrency extends CommonObject */ public function getRate() { - $sql = 'SELECT cr.rowid'; + $sql = 'SELECT cr.rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; $sql .= ' WHERE cr.fk_multicurrency = '.$this->id; $sql .= ' AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM '.MAIN_DB_PREFIX.$this->table_element_line.' AS cr2 WHERE cr2.fk_multicurrency = '.$this->id.')'; @@ -492,14 +500,17 @@ class MultiCurrency extends CommonObject */ public static function getIdFromCode($db, $code) { - global $conf; + global $conf; - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid; - else return 0; + if ($resql && $obj = $db->fetch_object($resql)) { + return $obj->rowid; + } else { + return 0; + } } /** @@ -516,7 +527,7 @@ class MultiCurrency extends CommonObject { global $conf; - $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; + $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql1 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; $sql1 .= " WHERE m.code = '".$db->escape($code)."'"; @@ -531,12 +542,14 @@ class MultiCurrency extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql1.$sql2.$sql3); - if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); - else { - if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) - { + if ($resql && $obj = $db->fetch_object($resql)) { + return array($obj->rowid, $obj->rate); + } else { + if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) { $resql = $db->query($sql1.$sql3); - if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); + if ($resql && $obj = $db->fetch_object($resql)) { + return array($obj->rowid, $obj->rate); + } } return array(0, 1); @@ -556,11 +569,15 @@ class MultiCurrency extends CommonObject { $multicurrency_tx = self::getInvoiceRate($fk_facture, $table); - if ($multicurrency_tx) - { - if ($way == 'dolibarr') return price2num($amount * $multicurrency_tx, 'MU'); - else return price2num($amount / $multicurrency_tx, 'MU'); - } else return $amount; + if ($multicurrency_tx) { + if ($way == 'dolibarr') { + return price2num($amount * $multicurrency_tx, 'MU'); + } else { + return price2num($amount / $multicurrency_tx, 'MU'); + } + } else { + return $amount; + } } /** @@ -578,8 +595,7 @@ class MultiCurrency extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && ($line = $db->fetch_object($resql))) - { + if ($resql && ($line = $db->fetch_object($resql))) { return $line->multicurrency_tx; } @@ -597,14 +613,11 @@ class MultiCurrency extends CommonObject { global $conf; - if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE) - { + if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE) { $alternate_source = 'USD'.$conf->currency; - if (!empty($TRate->{$alternate_source})) - { + if (!empty($TRate->{$alternate_source})) { $coef = $TRate->USDUSD / $TRate->{$alternate_source}; - foreach ($TRate as $attr => &$rate) - { + foreach ($TRate as $attr => &$rate) { $rate *= $coef; } @@ -642,22 +655,17 @@ class MultiCurrency extends CommonObject $response = $resget['content']; $response = json_decode($response); - if ($response->success) - { + if ($response->success) { $TRate = $response->quotes; $timestamp = $response->timestamp; - if (self::recalculRates($TRate) >= 0) - { - foreach ($TRate as $currency_code => $rate) - { + if (self::recalculRates($TRate) >= 0) { + foreach ($TRate as $currency_code => $rate) { $code = substr($currency_code, 3, 3); $obj = new MultiCurrency($db); - if ($obj->fetch(null, $code) > 0) - { + if ($obj->fetch(null, $code) > 0) { $obj->updateRate($rate); - } elseif ($addifnotfound) - { + } elseif ($addifnotfound) { self::addRateFromDolibarr($code, $rate); } } @@ -681,11 +689,14 @@ class MultiCurrency extends CommonObject */ public static function checkCodeAlreadyExists($code) { - global $db; + global $db; - $currency = new MultiCurrency($db); - if ($currency->fetch('', $code) > 0) return true; - else return false; + $currency = new MultiCurrency($db); + if ($currency->fetch('', $code) > 0) { + return true; + } else { + return false; + } } } @@ -758,7 +769,9 @@ class CurrencyRate extends CommonObjectLine $error = 0; $this->rate = price2num($this->rate); - if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + if (empty($this->entity) || $this->entity <= 0) { + $this->entity = $conf->entity; + } $now = empty($this->date_sync) ? dol_now() : $this->date_sync; // Insert request @@ -791,7 +804,9 @@ class CurrencyRate extends CommonObjectLine if ($trigger) { $result = $this->call_trigger('CURRENCYRATE_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } } @@ -867,8 +882,12 @@ class CurrencyRate extends CommonObjectLine // Update request $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= ' rate='.$this->rate; - if (!empty($this->date_sync)) $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; - if (!empty($this->fk_multicurrency)) $sql .= ', fk_multicurrency='.$this->fk_multicurrency; + if (!empty($this->date_sync)) { + $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; + } + if (!empty($this->fk_multicurrency)) { + $sql .= ', fk_multicurrency='.$this->fk_multicurrency; + } $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); @@ -883,7 +902,9 @@ class CurrencyRate extends CommonObjectLine if (!$error && $trigger) { $result = $this->call_trigger('CURRENCYRATE_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Commit or rollback @@ -916,7 +937,9 @@ class CurrencyRate extends CommonObjectLine if ($trigger) { $result = $this->call_trigger('CURRENCYRATE_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index eae788b0587..da7921fa7fe 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -58,12 +58,18 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = "cr.date_sync"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "cr.date_sync"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -74,7 +80,9 @@ $form = new Form($db); $hookmanager->initHooks(array('EditorRatelist', 'globallist')); -if (empty($action)) $action = 'list'; +if (empty($action)) { + $action = 'list'; +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -184,20 +192,24 @@ if ($action == "confirm_delete") { } -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 $sall = ""; $search_date_sync = ""; $search_rate = ""; @@ -324,10 +336,18 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); -if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); -if ($search_code) $sql .= natural_search('m.code', $search_code); +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_date_sync) { + $sql .= natural_search('cr.date_sync', $search_date_sync); +} +if ($search_rate) { + $sql .= natural_search('cr.rate', $search_rate); +} +if ($search_code) { + $sql .= natural_search('m.code', $search_code); +} $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; // Add where from hooks @@ -345,14 +365,12 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); if ($result) { $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -364,29 +382,46 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $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); - if ($sall) $param .= "&sall=".urlencode($sall); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } - if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); - if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param .= "&search_code=".urlencode($search_code); + if ($search_date_sync) { + $param = "&search_date_sync=".urlencode($search_date_sync); + } + if ($search_rate) { + $param = "&search_rate=".urlencode($search_rate); + } + if ($search_code != '') { + $param .= "&search_code=".urlencode($search_code); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - if ($user->admin) $arrayofmassactions['predelete'] = $langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->admin) { + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -399,9 +434,10 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -411,11 +447,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if ($moreforfilter) - { + if ($moreforfilter) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -423,7 +461,9 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; @@ -432,22 +472,19 @@ if ($resql) print '<tr class="liste_titre_filter">'; // date - if (!empty($arrayfields['cr.date_sync']['checked'])) - { + if (!empty($arrayfields['cr.date_sync']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" name="search_date_sync" size="8" value="'.dol_escape_htmltag($search_date_sync).'">'; print '</td>'; } // code - if (!empty($arrayfields['m.code']['checked'])) - { + if (!empty($arrayfields['m.code']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" name="search_code" size="12" value="'.dol_escape_htmltag($search_code).'">'; print '</td>'; } // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { + if (!empty($arrayfields['cr.rate']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" name="search_rate" size="8" value="'.dol_escape_htmltag($search_rate).'">'; print '</td>'; @@ -466,9 +503,15 @@ if ($resql) print '</tr>'; print '<tr class="liste_titre">'; - if (!empty($arrayfields['cr.date_sync']['checked'])) print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.code']['checked'])) print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['cr.rate']['checked'])) print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.code']['checked'])) { + print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['cr.rate']['checked'])) { + print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); + } // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -480,38 +523,40 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { + if (!empty($arrayfields['cr.date_sync']['checked'])) { print '<td class="tdoverflowmax200">'; print $obj->date_sync; print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // code - if (!empty($arrayfields['m.code']['checked'])) - { + if (!empty($arrayfields['m.code']['checked'])) { print '<td class="tdoverflowmax200">'; print $obj->code." ".$obj->name; print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { + if (!empty($arrayfields['cr.rate']['checked'])) { print '<td class="tdoverflowmax200">'; print $obj->rate; print "</td>\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Fields from hook @@ -521,16 +566,19 @@ if ($resql) // Action print '<td class="nowrap" align="center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=updateRate&amp;id_rate='.$obj->rowid.'">'.img_picto('edit', 'edit').'</a>'; print '<a class="marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=deleteRate&amp;id_rate='.$obj->rowid.'">'.img_picto('delete', 'delete').'</a>'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; $i++; @@ -542,8 +590,7 @@ if ($resql) print "</div>"; print '</form>'; -} -else { +} else { dol_print_error($db); } diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index ef583d08ff5..bbd930b013f 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Initialisation des variables $action = GETPOST('action', 'aZ09'); @@ -62,17 +64,21 @@ $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), $parameters = array('id' => $numsondage); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) $action = ''; +if (empty($reshook)) { + if ($cancel) { + $action = ''; + } // Delete - if ($action == 'delete_confirm') - { + if ($action == 'delete_confirm') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $result = $object->delete($user, '', $numsondage); @@ -81,36 +87,33 @@ if (empty($reshook)) } // Close - if ($action == 'close') - { + if ($action == 'close') { $object->status = Opensurveysondage::STATUS_CLOSED; $object->update($user); } // Reopend - if ($action == 'reopen') - { + if ($action == 'reopen') { $object->status = Opensurveysondage::STATUS_VALIDATED; $object->update($user); } // Update - if ($action == 'update') - { + if ($action == 'update') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $error = 0; - if (!GETPOST('nouveautitre')) - { + if (!GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - if (!$error) - { + if (!$error) { $object->title = (string) GETPOST('nouveautitre', 'alphanohtml'); $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); @@ -128,8 +131,7 @@ if (empty($reshook)) } // Add comment - if (GETPOST('ajoutcomment')) - { + if (GETPOST('ajoutcomment')) { $error = 0; if (!GETPOST('comment')) { @@ -147,8 +149,7 @@ if (empty($reshook)) $resql = $object->addComment($comment, $comment_user); - if (!$resql) - { + if (!$resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } } @@ -156,17 +157,20 @@ if (empty($reshook)) // Delete comment $idcomment = GETPOST('deletecomment', 'int'); - if ($idcomment) - { + if ($idcomment) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $resql = $object->deleteComment($idcomment); } if ($action == 'edit') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } } } @@ -177,8 +181,7 @@ if (empty($reshook)) $form = new Form($db); -if ($object->fk_user_creat) -{ +if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } @@ -193,8 +196,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -232,16 +234,16 @@ print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'</td>< print '<tr><td>'; $adresseadmin = $object->mail_admin; print $langs->trans("Title").'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(dol_htmlentities($object->title)).'">'; -} else print dol_htmlentities($object->title); +} else { + print dol_htmlentities($object->title); +} print '</td></tr>'; // Description print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); } else { @@ -253,17 +255,17 @@ print '</td></tr>'; //If linked user, then emails are going to be sent to users' email if (!$object->fk_user_creat) { print '<tr><td>'.$langs->trans("EMail").'</td><td colspan="2">'; - if ($action == 'edit') - { + if ($action == 'edit') { print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.'">'; - } else print dol_print_email($object->mail_admin, 0, 0, 1); + } else { + print dol_print_email($object->mail_admin, 0, 0, 1); + } print '</td></tr>'; } // Receive an email with each vote print '<tr><td>'.$langs->trans('ToReceiveEMailForEachVote').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="mailsonde" '.($object->mailsonde ? 'checked="checked"' : '').'">'; } else { print yn($object->mailsonde); @@ -279,26 +281,31 @@ print '</td></tr>'; // Users can comment print '<tr><td>'.$langs->trans('CanComment').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="cancomment" '.($object->allow_comments ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_comments); +} else { + print yn($object->allow_comments); +} print '</td></tr>'; // Users can see others vote print '<tr><td>'.$langs->trans('CanSeeOthersVote').'</td><td colspan="2">'; -if ($action == 'edit') -{ +if ($action == 'edit') { print '<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_spy); +} else { + print yn($object->allow_spy); +} print '</td></tr>'; // Expire date print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '</td></tr>'; @@ -322,7 +329,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; print '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">'; -if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url); +if ($action != 'edit') { + print ajax_autoselect("opensurveyurl", $url); +} print '</td></tr>'; @@ -332,8 +341,7 @@ print '</div>'; print dol_get_fiche_end(); -if ($action == 'edit') -{ +if ($action == 'edit') { print '<div class="center">'; print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; print ' &nbsp; '; @@ -354,13 +362,11 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { //Modify button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$numsondage.'">'.$langs->trans("Modify").'</a>'; - if ($object->status == Opensurveysondage::STATUS_VALIDATED) - { + if ($object->status == Opensurveysondage::STATUS_VALIDATED) { //Close button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&id='.$numsondage.'">'.$langs->trans("Close").'</a>'; } - if ($object->status == Opensurveysondage::STATUS_CLOSED) - { + if ($object->status == Opensurveysondage::STATUS_CLOSED) { //Opened button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id='.$numsondage.'">'.$langs->trans("ReOpen").'</a>'; } @@ -371,8 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { print '</div>'; -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?&id='.$numsondage, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll", $id), 'delete_confirm', '', '', 1); } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c635c2430a7..badb3f60149 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -175,7 +175,7 @@ class Opensurveysondage extends CommonObject $sql .= "allow_comments,"; $sql .= "allow_spy,"; $sql .= "sujet,"; - $sql .= "entity"; + $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; @@ -188,21 +188,25 @@ class Opensurveysondage extends CommonObject $sql .= " ".((int) $this->allow_comments).","; $sql .= " ".((int) $this->allow_spy).","; $sql .= " '".$this->db->escape($this->sujet)."',"; - $sql .= " ".((int) $conf->entity); + $sql .= " ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", 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 && !$notrigger) { global $langs, $conf; // Call trigger $result = $this->call_trigger('OPENSURVEY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } @@ -250,10 +254,8 @@ class Opensurveysondage extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; @@ -336,15 +338,15 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -369,8 +371,7 @@ class Opensurveysondage extends CommonObject global $conf, $langs; $error = 0; - if (empty($numsondage)) - { + if (empty($numsondage)) { $numsondage = $this->id_sondage; } @@ -379,12 +380,13 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -397,14 +399,14 @@ class Opensurveysondage extends CommonObject 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(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -431,7 +433,9 @@ class Opensurveysondage 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 = ''; @@ -444,14 +448,16 @@ class Opensurveysondage extends CommonObject // 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -466,8 +472,12 @@ class Opensurveysondage extends CommonObject $linkend = '</a>'; $result .= $linkstart; - 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 .= $this->ref; + 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 .= $this->ref; + } $result .= $linkend; return $result; @@ -488,19 +498,19 @@ class Opensurveysondage extends CommonObject $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); $ret[] = $tmp; $i++; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } $this->lines = $ret; @@ -543,14 +553,11 @@ class Opensurveysondage extends CommonObject $sql .= " ORDER BY id_comment"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($num_rows > 0) { + while ($obj = $this->db->fetch_object($resql)) { $comments[] = $obj; } } @@ -642,8 +649,7 @@ class Opensurveysondage extends CommonObject // phpcs:enable global $langs, $conf; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -656,10 +662,15 @@ class Opensurveysondage extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { - if (0) $statusType = 'status1'; - else $statusType = 'status4'; + if (0) { + $statusType = 'status1'; + } else { + $statusType = 'status4'; + } + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; } - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php index 6f9a699273b..3a4237f83e6 100644 --- a/htdocs/opensurvey/exportcsv.php +++ b/htdocs/opensurvey/exportcsv.php @@ -30,14 +30,15 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; $action = GETPOST('action', 'aZ09'); $numsondage = ''; -if (GETPOST('id')) -{ +if (GETPOST('id')) { $numsondage = GETPOST("id", 'alpha'); } $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} /* @@ -57,10 +58,8 @@ $toutsujet = explode(",", $object->sujet); // affichage des sujets du sondage $input .= $langs->trans("Name").";"; -for ($i = 0; $toutsujet[$i]; $i++) -{ - if ($object->format == "D") - { +for ($i = 0; $toutsujet[$i]; $i++) { + if ($object->format == "D") { $input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';'; } else { $input .= ''.$toutsujet[$i].';'; @@ -69,11 +68,9 @@ for ($i = 0; $toutsujet[$i]; $i++) $input .= "\r\n"; -if (strpos($object->sujet, '@') !== false) -{ +if (strpos($object->sujet, '@') !== false) { $input .= ";"; - for ($i = 0; $toutsujet[$i]; $i++) - { + for ($i = 0; $toutsujet[$i]; $i++) { $heures = explode("@", $toutsujet[$i]); $input .= ''.$heures[1].';'; } @@ -87,12 +84,10 @@ $sql .= ' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage='".$db->escape($numsondage)."'"; $sql .= " ORDER BY id_users"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); // Le name de l'utilisateur @@ -101,15 +96,12 @@ if ($resql) //affichage des resultats $ensemblereponses = $obj->reponses; - for ($k = 0; $k < $nbcolonnes; $k++) - { + for ($k = 0; $k < $nbcolonnes; $k++) { $car = substr($ensemblereponses, $k, 1); - if ($car == "1") - { + if ($car == "1") { $input .= 'OK;'; $somme[$k]++; - } elseif ($car == "2") - { + } elseif ($car == "2") { $input .= 'KO;'; $somme[$k]++; } else { @@ -120,7 +112,9 @@ if ($resql) $input .= "\r\n"; $i++; } -} else dol_print_error($db); +} else { + dol_print_error($db); +} $filesize = strlen($input); diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 0ea701ebf0b..96d9370c10a 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -96,19 +96,16 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $urllogo = ''; $urllogofull = ''; - if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) - { + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - } 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&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); } // Output html code for logo - if ($urllogo) - { + if ($urllogo) { print '<div class="backgreypublicpayment">'; print '<div class="logopublicpayment">'; print '<img id="dolpaymentlogo" src="'.$urllogo.'"'; diff --git a/htdocs/opensurvey/index.php b/htdocs/opensurvey/index.php index 50198e5202f..8ff138b6681 100644 --- a/htdocs/opensurvey/index.php +++ b/htdocs/opensurvey/index.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $langs->load("opensurvey"); // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} $hookmanager = new HookManager($db); @@ -48,11 +50,12 @@ $sql = 'SELECT COUNT(*) as nb'; $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_sondage'; $sql .= ' WHERE entity IN ('.getEntity('survey').')'; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); $nbsondages = $obj->nb; -} else dol_print_error($db, ''); +} else { + dol_print_error($db, ''); +} $title = $langs->trans("OpenSurveyArea"); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index eaee1b696e1..3f0b6011455 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -67,24 +69,29 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "p.date_fin"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "p.date_fin"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Definition of fields for list $arrayfields = array(); -foreach ($arrayfields as $key => $val) -{ +foreach ($arrayfields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + } } // 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) - { +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) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -107,21 +114,25 @@ $permissiontodelete = $user->rights->opensurvey->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_status = ''; $search_title = ''; $search_ref = ''; @@ -129,8 +140,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -160,11 +170,21 @@ $sql .= " u.login, u.firstname, u.lastname"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; $sql .= " WHERE p.entity IN (".getEntity('survey').")"; -if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2); -if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'"; -if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; -if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref); -if ($search_title) $sql .= natural_search("p.titre", $search_title); +if ($search_status != '-1' && $search_status != '') { + $sql .= natural_search("p.status", $search_status, 2); +} +if ($search_expired == 'expired') { + $sql .= " AND p.date_fin < '".$db->idate($now)."'"; +} +if ($search_expired == 'opened') { + $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; +} +if ($search_ref) { + $sql .= natural_search("p.id_sondage", $search_ref); +} +if ($search_title) { + $sql .= natural_search("p.titre", $search_title); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -176,26 +196,22 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) -{ +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -204,8 +220,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id); @@ -221,11 +236,17 @@ llxHeader('', $title, $help_url); $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); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname'; -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'; @@ -234,15 +255,21 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // List of surveys into database print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -261,9 +288,10 @@ $objecttmp = new Opensurveysondage($db); $trackid = 'surv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } @@ -274,11 +302,13 @@ $moreforfilter.= '</div>';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -346,18 +376,20 @@ print '</tr>'."\n"; // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'"; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { $obj2 = $db->fetch_object($resql2); $nbuser = $obj2->nb; - } else dol_print_error($db); + } else { + dol_print_error($db); + } $opensurvey_static->id = $obj->rowid; $opensurvey_static->ref = $obj->rowid; @@ -372,11 +404,15 @@ while ($i < min($num, $limit)) print '<td>'; print $opensurvey_static->getNomUrl(1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Title print '<td>'.dol_htmlentities($obj->title).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Type print '<td>'; @@ -384,7 +420,9 @@ while ($i < min($num, $limit)) print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate"); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td>'; // Author @@ -400,23 +438,35 @@ while ($i < min($num, $limit)) print dol_htmlentities($obj->nom_admin); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Nb of voters print'<td class="right">'.$nbuser.'</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day'); - if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } + if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.dol_print_date($db->jdate($obj->tms), 'dayhour'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -426,14 +476,17 @@ while ($i < min($num, $limit)) print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print '</tr>'."\n"; $i++; @@ -444,10 +497,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 8; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -463,10 +519,11 @@ print '</div>'."\n"; print '</form>'."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index ea07900ba67..cea5cdbcbee 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Init vars @@ -40,7 +42,9 @@ $numsondage = GETPOST("id"); $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} $nblines = $object->fetch_lines(); @@ -58,20 +62,15 @@ if (GETPOST('retoursondage')) { $nbcolonnes = substr_count($object->sujet, ',') + 1; // Add vote -if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox -{ - if (GETPOST('nom')) - { +if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox + if (GETPOST('nom')) { $erreur_prenom = false; $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + for ($i = 0; $i < $nbcolonnes; $i++) { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -87,15 +86,16 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); - if ($num_rows > 0) - { + if ($num_rows > 0) { setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors'); $error++; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } } @@ -104,35 +104,30 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i = 0; $i < $nblines; $i++) -{ - if (isset($_POST['modifierligne'.$i])) - { +for ($i = 0; $i < $nblines; $i++) { + if (isset($_POST['modifierligne'.$i])) { $ligneamodifier = $i; $testligneamodifier = true; } //test pour voir si une ligne est a modifier - if (isset($_POST['validermodifier'.$i])) - { + if (isset($_POST['validermodifier'.$i])) { $modifier = $i; $testmodifier = true; } } -if ($testmodifier) -{ +if ($testmodifier) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { //var_dump($_POST["choix$i"]); - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -145,14 +140,17 @@ if ($testmodifier) $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } // Add column (not for date) -if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") -{ +if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -165,17 +163,19 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } // Add column (with format date) -if (isset($_POST["ajoutercolonne"]) && $object->format == "D") -{ +if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -223,8 +223,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $cleinsertion = count($datesbase); } else { $nbdatesbase = count($datesbase); - for ($i = 0; $i < $nbdatesbase; $i++) - { + for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) { $cleinsertion = $j; @@ -244,14 +243,14 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $dateinsertion = substr("$dateinsertion", 1); // update with new topics into database - if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) - { + if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } @@ -263,12 +262,12 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } // Delete line -for ($i = 0; $i < $nblines; $i++) -{ - if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); +for ($i = 0; $i < $nblines; $i++) { + if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox + // Security check + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $compteur = 0; @@ -278,14 +277,14 @@ for ($i = 0; $i < $nblines; $i++) $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); - if ($compteur == $i) - { + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); @@ -297,13 +296,13 @@ for ($i = 0; $i < $nblines; $i++) } // Delete column -for ($i = 0; $i < $nbcolonnes; $i++) -{ +for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) - && $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox + // Security check + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $db->begin(); @@ -312,12 +311,12 @@ for ($i = 0; $i < $nbcolonnes; $i++) $nouveauxsujets = ''; //parcours de tous les sujets actuels - while (isset($toutsujet[$j])) - { + while (isset($toutsujet[$j])) { //si le sujet n'est pas celui qui a été effacé alors on concatene - if ($i != $j) - { - if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; + if ($i != $j) { + if (!empty($nouveauxsujets)) { + $nouveauxsujets .= ','; + } $nouveauxsujets .= $toutsujet[$j]; } @@ -328,7 +327,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } // Clean current answer to remove deleted columns $compteur = 0; @@ -337,22 +338,19 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; // parcours de toutes les réponses actuelles - for ($j = 0; $j < $nbcolonnes; $j++) - { + for ($j = 0; $j < $nbcolonnes; $j++) { $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { @@ -389,8 +387,7 @@ if ($object->fk_user_creat) { } $result = $object->fetch(0, $numsondage); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -405,8 +402,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -452,10 +448,13 @@ print '</td></tr>'; // Expire date print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '</td></tr>'; @@ -480,8 +479,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; $urllink = '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">'; print $urllink; -if ($action != 'edit') -{ +if ($action != 'edit') { print '<script type="text/javascript"> jQuery(document).ready(function () { jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } ); @@ -511,10 +509,11 @@ print '</div>'; // Show form to add a new field/column -if (GETPOST('ajoutsujet')) -{ +if (GETPOST('ajoutsujet')) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } print '<form name="formulaire" action="" method="POST">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -524,8 +523,7 @@ if (GETPOST('ajoutsujet')) print "<br><br>\n"; // Add new column - if ($object->format == "A") - { + if ($object->format == "A") { print $langs->trans("AddNewColumn").':<br><br>'; print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>'; $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); @@ -628,8 +626,7 @@ print '</tr>'."\n"; // Show choice titles -if ($object->format == "D") -{ +if ($object->format == "D") { //affichage des sujets du sondage print '<tr>'."\n"; print '<td></td>'."\n"; @@ -638,8 +635,7 @@ if ($object->format == "D") //affichage des années $colspan = 1; $nbofsujet = count($toutsujet); - for ($i = 0; $i < $nbofsujet; $i++) - { + for ($i = 0; $i < $nbofsujet; $i++) { $current = $toutsujet[$i]; if (strpos($toutsujet[$i], '@') !== false) { @@ -653,15 +649,20 @@ if ($object->format == "D") } $currenty = 0; - if ($current) $currenty = strftime("%Y", $current); + if ($current) { + $currenty = strftime("%Y", $current); + } $next = 0; - if ($next) $nexty = strftime("%Y", $next); - if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) - { + if ($next) { + $nexty = strftime("%Y", $next); + } + if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) { $colspan++; } else { print '<td colspan='.$colspan.' class="annee">'; - if ($current) print strftime("%Y", $current); + if ($current) { + print strftime("%Y", $current); + } print '</td>'."\n"; $colspan = 1; } @@ -756,8 +757,7 @@ if ($object->format == "D") print '<td></td>'."\n"; print '<td></td>'."\n"; - for ($i = 0; isset($toutsujet[$i]); $i++) - { + for ($i = 0; isset($toutsujet[$i]); $i++) { $tmp = explode('@', $toutsujet[$i]); print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n"; } @@ -776,14 +776,12 @@ $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); -while ($compteur < $num) -{ +while ($compteur < $num) { $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -798,121 +796,167 @@ while ($compteur < $num) print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n"; // si la ligne n'est pas a changer, on affiche les données - if (!$testligneamodifier) - { - for ($i = 0; $i < $nbcolonnes; $i++) - { + if (!$testligneamodifier) { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { - if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; - else print '<td class="non">KO</td>'."\n"; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (((string) $car) == "1") { + print '<td class="ok">OK</td>'."\n"; + } else { + print '<td class="non">KO</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("No").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } } } else { //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs - if ($compteur == $ligneamodifier) - { - for ($i = 0; $i < $nbcolonnes; $i++) - { + if ($compteur == $ligneamodifier) { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); print '<td class="vide">'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print '<input type="checkbox" name="choix'.$i.'" value="1" '; - if ($car == '1') print 'checked'; + if ($car == '1') { + print 'checked'; + } print '>'; } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print '</td>'."\n"; } } else { - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { - if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n"; - else print '<td class="non">KO</td>'."\n"; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + if (((string) $car) == "1") { + print '<td class="ok">OK</td>'."\n"; + } else { + print '<td class="non">KO</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { - if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; - elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; - else print '<td class="vide">&nbsp;</td>'."\n"; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + if (((string) $car) == "1") { + print '<td class="ok">'.$langs->trans("For").'</td>'."\n"; + } elseif (((string) $car) == "0") { + print '<td class="non">'.$langs->trans("Against").'</td>'."\n"; + } else { + print '<td class="vide">&nbsp;</td>'."\n"; + } // Total - if (!isset($sumfor[$i])) $sumfor[$i] = 0; - if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; - if (((string) $car) == "1") $sumfor[$i]++; - if (((string) $car) == "0") $sumagainst[$i]++; + if (!isset($sumfor[$i])) { + $sumfor[$i] = 0; + } + if (!isset($sumagainst[$i])) { + $sumagainst[$i] = 0; + } + if (((string) $car) == "1") { + $sumfor[$i]++; + } + if (((string) $car) == "0") { + $sumagainst[$i]++; + } } } } } // Button edit at end of line - if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) - { + if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) { print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n"; } //demande de confirmation pour modification de ligne - for ($i = 0; $i < $nblines; $i++) - { - if (GETPOSTISSET("modifierligne".$i)) - { - if ($compteur == $i) - { + for ($i = 0; $i < $nblines; $i++) { + if (GETPOSTISSET("modifierligne".$i)) { + if ($compteur == $i) { print '<td class="casevide">'; print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">'; print '<input type="submit" class="button button-save" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; @@ -926,33 +970,27 @@ while ($compteur < $num) } // Add line to add new record -if (empty($testligneamodifier)) -{ +if (empty($testligneamodifier)) { print '<tr>'."\n"; print '<td></td>'."\n"; print '<td class="nom">'."\n"; print '<input type="text" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64" size="24">'."\n"; print '</td>'."\n"; - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { print '<td class="vide">'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print '<input type="checkbox" name="choix'.$i.'" value="1"'; - if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') - { + if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') { print ' checked'; } print '>'; } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice); } - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') - { + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { $arraychoice = array('2'=>'&nbsp;', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice); } @@ -966,18 +1004,15 @@ if (empty($testligneamodifier)) // Select value of best choice (for checkbox columns only) $nbofcheckbox = 0; -for ($i = 0; $i < $nbcolonnes + 1; $i++) -{ - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) - $nbofcheckbox++; - if (isset($sumfor[$i])) - { - if ($i == 0) - { +for ($i = 0; $i < $nbcolonnes + 1; $i++) { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + $nbofcheckbox++; + } + if (isset($sumfor[$i])) { + if ($i == 0) { $meilleurecolonne = $sumfor[$i]; } - if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) - { + if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) { $meilleurecolonne = $sumfor[$i]; } } @@ -988,29 +1023,36 @@ for ($i = 0; $i < $nbcolonnes + 1; $i++) print '<tr>'."\n"; print '<td></td>'."\n"; print '<td class="center">'.$langs->trans("Total").'</td>'."\n"; -for ($i = 0; $i < $nbcolonnes; $i++) -{ +for ($i = 0; $i < $nbcolonnes; $i++) { $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; - if (empty($showsumfor)) $showsumfor = 0; - if (empty($showsumagainst)) $showsumagainst = 0; + if (empty($showsumfor)) { + $showsumfor = 0; + } + if (empty($showsumagainst)) { + $showsumagainst = 0; + } print '<td>'; - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; - if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { + print $showsumfor; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { + print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst; + } + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { + print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst; + } print '</td>'."\n"; } print '</tr>'; // Show picto winner -if ($nbofcheckbox >= 2) -{ +if ($nbofcheckbox >= 2) { print '<tr>'."\n"; print '<td></td>'."\n"; print '<td></td>'."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) - { + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"></td>'."\n"; } else { print '<td class="somme"></td>'."\n"; @@ -1041,10 +1083,8 @@ $toutsujet = explode(",", $object->sujet); // With old versions, this field was $compteursujet = 0; $meilleursujet = ''; -for ($i = 0; $i < $nbcolonnes; $i++) -{ - if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) - { +for ($i = 0; $i < $nbcolonnes; $i++) { + if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { $meilleursujet .= ", "; if ($object->format == "D") { @@ -1068,8 +1108,7 @@ $meilleursujet = substr($meilleursujet, 1); $meilleursujet = str_replace("°", "'", $meilleursujet); // Show best choice -if ($nbofcheckbox >= 2) -{ +if ($nbofcheckbox >= 2) { $vote_str = $langs->trans('votes'); print '<p class="affichageresultats">'."\n"; diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index 42213af2ae2..4919006a5f1 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} @@ -53,20 +55,16 @@ if (isset($_SESSION["nbrecases"])) { $_SESSION["nbrecases"] = 5; } -if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) -{ +if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) { $_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5; } // Create survey into database -if (GETPOSTISSET("confirmecreation")) -{ +if (GETPOSTISSET("confirmecreation")) { //recuperation des données de champs textes $toutchoix = ''; - for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) - { - if (!empty($arrayofchoices[$i])) - { + for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { + if (!empty($arrayofchoices[$i])) { $toutchoix .= ','; $toutchoix .= str_replace(array(",", "@"), " ", $arrayofchoices[$i]).(empty($arrayoftypecolumn[$i]) ? '' : '@'.$arrayoftypecolumn[$i]); } @@ -77,10 +75,8 @@ if (GETPOSTISSET("confirmecreation")) //test de remplissage des cases $testremplissage = ''; - for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) - { - if (isset($arrayofchoices[$i])) - { + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { + if (isset($arrayofchoices[$i])) { $testremplissage = "ok"; } } @@ -107,8 +103,7 @@ $arrayofjs = array(); $arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); -if (empty($_SESSION['title'])) -{ +if (empty($_SESSION['title'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); llxFooter(); exit; diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index ae64c1e6491..ce5f79b1174 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} // Survey type is DATE $_SESSION["formatsondage"] = "D"; @@ -40,19 +42,15 @@ $erreur = false; */ // Insert survey -if (GETPOST('confirmation')) -{ +if (GETPOST('confirmation')) { // We save hours entered - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); $errheure = array(); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { // Show hours choices - for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) - { + for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; $tmphorairesi = GETPOST('horaires'.$i, 'array'); @@ -170,8 +168,7 @@ if (GETPOST('confirmation')) } // Add survey into database - if (!$erreur) - { + if (!$erreur) { $_SESSION["toutchoix"] = substr("$choixdate", 1); ajouter_sondage(); @@ -179,11 +176,9 @@ if (GETPOST('confirmation')) } // Reset days -if (GETPOST('reset')) -{ +if (GETPOST('reset')) { $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { unset($_SESSION["horaires$i"][$j]); } @@ -199,8 +194,7 @@ if (GETPOST('reset')) * View */ -if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) -{ +if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); exit; } @@ -210,11 +204,9 @@ $arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); //nombre de cases par défaut -if (!isset($_SESSION["nbrecaseshoraires"])) -{ +if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; -} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) -{ +} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; } @@ -224,9 +216,15 @@ $moisAJ = date("n"); $anneeAJ = date("Y"); // Initialisation des jour, mois et année -if (!isset($_SESSION['jour'])) $_SESSION['jour'] = date('j'); -if (!isset($_SESSION['mois'])) $_SESSION['mois'] = date('n'); -if (!isset($_SESSION['annee'])) $_SESSION['annee'] = date('Y'); +if (!isset($_SESSION['jour'])) { + $_SESSION['jour'] = date('j'); +} +if (!isset($_SESSION['mois'])) { + $_SESSION['mois'] = date('n'); +} +if (!isset($_SESSION['annee'])) { + $_SESSION['annee'] = date('Y'); +} //mise a jour des valeurs de session si bouton retour a aujourd'hui if (!issetAndNoEmpty('choixjourajout') && !issetAndNoEmpty('choixjourretrait') && (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))) { @@ -245,8 +243,7 @@ if (issetAndNoEmpty('moisavant_x') || issetAndNoEmpty('moisavant')) { } //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -267,11 +264,9 @@ if (issetAndNoEmpty('moisapres_x') || issetAndNoEmpty('moisapres')) { } //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; @@ -285,8 +280,7 @@ if (issetAndNoEmpty('anneeavant_x') || issetAndNoEmpty('anneeavant')) { $_SESSION["annee"] -= 1; //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -302,8 +296,7 @@ if (issetAndNoEmpty('anneeapres_x') || issetAndNoEmpty('anneeapres')) { $_SESSION["annee"] += 1; //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { //affichage des 5 cases horaires @@ -319,8 +312,7 @@ $nbrejourmois = date("t", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee $premierjourmois = date("N", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])) - 1; //traduction de la valeur du mois -if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) -{ +if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) { $motmois = dol_print_date(mktime(0, 0, 0, $_SESSION["mois"], 10), '%B'); } else { $motmois = dol_print_date(dol_now(), '%B'); @@ -356,8 +348,7 @@ print '<table align="center">'."\n"; // The div class=center has no effect on ta print '<tr>'."\n"; //affichage des jours de la semaine en haut du tableau -for ($i = 0; $i < 7; $i++) -{ +for ($i = 0; $i < 7; $i++) { print '<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10), '%A').'</td>'; } @@ -371,8 +362,7 @@ if (issetAndNoEmpty('choixjourajout')) { // Test pour éviter les doublons dans la variable qui contient toutes les dates $journeuf = true; - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])) { @@ -421,10 +411,8 @@ if (issetAndNoEmpty('choixjourretrait')) { } } - for ($i = 0; $i < $nbofchoice; $i++) - { - if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) - { + for ($i = 0; $i < $nbofchoice; $i++) { + if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) { for ($j = $i; $j < $nbofchoice; $j++) { $k = $j + 1; $_SESSION["horaires$j"] = $_SESSION["horaires$k"]; @@ -468,8 +456,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { if ($i < $premierjourmois) { print '<td class="avant"></td>'."\n"; } else { - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) - { + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($j = 0; $j < $nbofchoice; $j++) { // show red buttons @@ -501,8 +488,7 @@ print '</div></div>'."\n"; print '<div class="bodydate"><div class="center">'."\n"; // affichage de tous les jours choisis -if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) -{ +if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { //affichage des jours print '<br>'."\n"; print '<div align="left">'; @@ -528,8 +514,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) //affichage de la liste des jours choisis $nbofchoice = count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + for ($i = 0; $i < $nbofchoice; $i++) { print '<tr>'."\n"; print '<td>'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</td>'; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index cbeb448d2d7..9bf371be2f4 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} $langs->load("opensurvey"); @@ -43,9 +45,10 @@ $creation_sondage_autre = GETPOST('creation_sondage_autre'); // We init some session variable to avoir warning $session_var = array('title', 'description', 'mailsonde'); -foreach ($session_var as $var) -{ - if (isset($_SESSION[$var])) $_SESSION[$var] = null; +foreach ($session_var as $var) { + if (isset($_SESSION[$var])) { + $_SESSION[$var] = null; + } } // On initialise également les autres variables @@ -53,8 +56,7 @@ $cocheplus = ''; $cochemail = ''; // Jump to correct page -if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) -{ +if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) { $_SESSION["title"] = $title; $_SESSION["description"] = $description; @@ -79,11 +81,9 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) $testdate = false; $champdatefin = dol_mktime(0, 0, 0, GETPOST('champdatefinmonth'), GETPOST('champdatefinday'), GETPOST('champdatefinyear')); - if ($champdatefin && ($champdatefin > 0)) // A date was provided - { - // Expire date is not before today - if ($champdatefin >= dol_now()) - { + if ($champdatefin && ($champdatefin > 0)) { // A date was provided + // Expire date is not before today + if ($champdatefin >= dol_now()) { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); } else { @@ -99,16 +99,13 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors'); } - if ($title && $testdate) - { - if (!empty($creation_sondage_date)) - { + if ($title && $testdate) { + if (!empty($creation_sondage_date)) { header("Location: choix_date.php"); exit(); } - if (!empty($creation_sondage_autre)) - { + if (!empty($creation_sondage_autre)) { header("Location: choix_autre.php"); exit(); } @@ -140,8 +137,7 @@ print dol_get_fiche_head(); print '<table class="border centpercent">'."\n"; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td><td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION["title"].'"></td>'."\n"; -if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) -{ +if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); } @@ -170,22 +166,34 @@ print '<br>'."\n"; // Check or not -if ($_SESSION["mailsonde"]) $cochemail = "checked"; +if ($_SESSION["mailsonde"]) { + $cochemail = "checked"; +} print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '.$langs->trans("ToReceiveEMailForEachVote").'<br>'."\n"; -if ($_SESSION['allow_comments']) $allow_comments = 'checked'; -if (GETPOSTISSET('allow_comments')) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; +if ($_SESSION['allow_comments']) { + $allow_comments = 'checked'; +} +if (GETPOSTISSET('allow_comments')) { + $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; +} print '<input type="checkbox" name="allow_comments" '.$allow_comments.'"> '.$langs->trans('CanComment').'<br>'."\n"; -if ($_SESSION['allow_spy']) $allow_spy = 'checked'; -if (GETPOSTISSET('allow_spy')) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; +if ($_SESSION['allow_spy']) { + $allow_spy = 'checked'; +} +if (GETPOSTISSET('allow_spy')) { + $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; +} print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br>'."\n"; -if (GETPOST('choix_sondage')) -{ - if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">'; - else print '<input type="hidden" name="creation_sondage_autre" value="autre">'; +if (GETPOST('choix_sondage')) { + if (GETPOST('choix_sondage') == 'date') { + print '<input type="hidden" name="creation_sondage_date" value="date">'; + } else { + print '<input type="hidden" name="creation_sondage_autre" value="autre">'; + } print '<input type="hidden" name="choix_sondage" value="'.GETPOST('choix_sondage').'">'; print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date' ? $langs->trans("TypeDate") : $langs->trans("TypeClassic")).')">'; } else { diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index 68d660dff3d..fa3d734a488 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -19,7 +19,9 @@ */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -27,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/opensurvey/fonctions.php'; // Security check -if (!$user->rights->opensurvey->write) accessforbidden(); +if (!$user->rights->opensurvey->write) { + accessforbidden(); +} $langs->load("opensurvey"); From 6aaf1c2962a0492be20e763b8c0d3e77d5c6b586 Mon Sep 17 00:00:00 2001 From: stickler-ci <support@stickler-ci.com> Date: Fri, 26 Feb 2021 17:28:25 +0000 Subject: [PATCH 157/173] Fixing style errors. --- .../modulebuilder/template/class/actions_mymodule.class.php | 2 +- htdocs/mrp/mo_list.php | 2 +- htdocs/opensurvey/results.php | 4 ++-- htdocs/opensurvey/wizard/create_survey.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index f29f6eeb45a..8559411a3d4 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -100,7 +100,7 @@ class ActionsMyModule /* 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' - // Do what you want here... + // Do what you want here... // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. } diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 972fb2cb770..ed78c46f133 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -88,7 +88,7 @@ if (empty($conf->mrp->enabled)) { } $socid = 0; if ($user->socid > 0) { // Protection if external user -//$socid = $user->socid; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'mrp', $id, ''); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index cea5cdbcbee..36228939092 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -264,7 +264,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { // Delete line for ($i = 0; $i < $nblines; $i++) { if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox - // Security check + // Security check if (!$user->rights->opensurvey->write) { accessforbidden(); } @@ -299,7 +299,7 @@ for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox - // Security check + // Security check if (!$user->rights->opensurvey->write) { accessforbidden(); } diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 9bf371be2f4..30e662be7ea 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -82,7 +82,7 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) { $champdatefin = dol_mktime(0, 0, 0, GETPOST('champdatefinmonth'), GETPOST('champdatefinday'), GETPOST('champdatefinyear')); if ($champdatefin && ($champdatefin > 0)) { // A date was provided - // Expire date is not before today + // Expire date is not before today if ($champdatefin >= dol_now()) { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); From 16ea342904ba747bb2e6d8c2f2ed2aa527200b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 18:37:22 +0100 Subject: [PATCH 158/173] code syntax --- htdocs/mrp/mo_production.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index e1b221a1ea6..0b50bcf8e9a 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -706,7 +706,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Product").'</td>'; print '<td class="right">'.$langs->trans("Qty").'</td>'; - if ($permissiontoupdatecost) print '<td class="right">'.$langs->trans("UnitCost").'</td>'; + if ($permissiontoupdatecost) { + print '<td class="right">'.$langs->trans("UnitCost").'</td>'; + } print '<td class="right">'.$langs->trans("QtyAlreadyConsumed").'</td>'; print '<td>'; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { @@ -729,7 +731,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); print '</td>'; print '<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>'; - if ($permissiontoupdatecost) print '<td></td>'; + if ($permissiontoupdatecost) { + print '<td></td>'; + } print '<td class="right"></td>'; print '<td>'; print '<input type="submit" class="button buttongen" name="addconsumelinebutton" value="'.$langs->trans("Add").'">'; @@ -765,7 +769,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($costprice)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($db); - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0){ + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { $costprice = $productFournisseur->fourn_unitprice; } else { $costprice = 0; @@ -853,7 +857,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</td>'; print '<td></td>'; print '<td class="right">'.$line2['qty'].'</td>'; - if ($permissiontoupdatecost) print '<td></td>'; + if ($permissiontoupdatecost) { + print '<td></td>'; + } print '<td class="tdoverflowmax150">'; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); @@ -882,7 +888,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $preselected = 0; } print '<td class="right"><input type="text" class="width50 right" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; - if ($permissiontoupdatecost) print '<td></td>'; + if ($permissiontoupdatecost) { + print '<td></td>'; + } print '<td></td>'; print '<td>'; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -1035,7 +1043,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</td>'; print '<td></td>'; print '<td class="right">'.$line2['qty'].'</td>'; - if ($permissiontoupdatecost) print '<td></td>'; + if ($permissiontoupdatecost) { + print '<td></td>'; + } print '<td class="tdoverflowmax150">'; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); From a82df7e6ea2efee2b04f6e3fec755b05f85c1b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic.france@free.fr> Date: Fri, 26 Feb 2021 18:49:22 +0100 Subject: [PATCH 159/173] code syntax project --- htdocs/projet/activity/index.php | 271 +++--- htdocs/projet/activity/perday.php | 293 +++--- htdocs/projet/activity/permonth.php | 230 +++-- htdocs/projet/activity/perweek.php | 363 ++++--- htdocs/projet/admin/project.php | 352 +++---- htdocs/projet/admin/project_extrafields.php | 17 +- .../projet/admin/project_task_extrafields.php | 17 +- htdocs/projet/admin/website.php | 17 +- htdocs/projet/ajax/projects.php | 32 +- htdocs/projet/card.php | 513 +++++----- htdocs/projet/class/api_projects.class.php | 250 ++--- htdocs/projet/class/api_tasks.class.php | 317 ++++--- htdocs/projet/class/project.class.php | 625 ++++++------ htdocs/projet/class/projectstats.class.php | 94 +- htdocs/projet/class/task.class.php | 804 ++++++++-------- htdocs/projet/class/taskstats.class.php | 34 +- htdocs/projet/comment.php | 26 +- htdocs/projet/contact.php | 112 ++- htdocs/projet/document.php | 40 +- htdocs/projet/element.php | 705 ++++++++------ htdocs/projet/event.php | 90 +- htdocs/projet/ganttchart.inc.php | 39 +- htdocs/projet/ganttview.php | 104 +- htdocs/projet/graph_opportunities.inc.php | 63 +- htdocs/projet/index.php | 116 ++- htdocs/projet/info.php | 62 +- htdocs/projet/jsgantt_language.js.php | 58 +- htdocs/projet/list.php | 834 ++++++++++------ htdocs/projet/note.php | 17 +- htdocs/projet/stats/index.php | 80 +- htdocs/projet/tasks.php | 314 ++++--- htdocs/projet/tasks/comment.php | 94 +- htdocs/projet/tasks/contact.php | 166 ++-- htdocs/projet/tasks/document.php | 92 +- htdocs/projet/tasks/list.php | 828 ++++++++++------ htdocs/projet/tasks/note.php | 77 +- htdocs/projet/tasks/stats/index.php | 50 +- htdocs/projet/tasks/task.php | 202 ++-- htdocs/projet/tasks/time.php | 887 ++++++++++-------- 39 files changed, 5067 insertions(+), 4218 deletions(-) diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 2ca149a18ca..c49ca736bbb 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -32,13 +32,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $search_project_user = GETPOST('search_project_user', 'int'); $mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0; -if ($search_project_user == $user->id) $mine = 1; +if ($search_project_user == $user->id) { + $mine = 1; +} // Security check $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} //$result = restrictedArea($user, 'projet', $projectid); -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $hookmanager = new HookManager($db); @@ -73,8 +79,11 @@ llxHeader("", $title); // Title for combo list see all projects $titleall = $langs->trans("AllAllowedProjects"); -if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects"); -else $titleall = $langs->trans("AllAllowedProjects").'<br><br>'; +if (!empty($user->rights->projet->all->lire) && !$socid) { + $titleall = $langs->trans("AllProjects"); +} else { + $titleall = $langs->trans("AllAllowedProjects").'<br><br>'; +} $morehtml = ''; @@ -85,10 +94,14 @@ $morehtml .= '<option name="mine" value="'.$user->id.'"'.(($search_project_user $morehtml .= '</SELECT>'; $morehtml .= '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">'; -if ($mine) $tooltiphelp = $langs->trans("MyTasksDesc"); -else { - if ($user->rights->projet->all->lire && !$socid) $tooltiphelp = $langs->trans("TasksDesc"); - else $tooltiphelp = $langs->trans("TasksPublicDesc"); +if ($mine) { + $tooltiphelp = $langs->trans("MyTasksDesc"); +} else { + if ($user->rights->projet->all->lire && !$socid) { + $tooltiphelp = $langs->trans("TasksDesc"); + } else { + $tooltiphelp = $langs->trans("TasksPublicDesc"); + } } print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'projecttask', 0, $morehtml); @@ -96,27 +109,27 @@ print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_S print '<div class="fichecenter"><div class="fichethirdleft">'; -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 // Search project - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) - { + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $listofsearchfields['search_task'] = array('text'=>'Task'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + } print '<tr '.$bc[false].'>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + if ($i == 0) { + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + } print '</tr>'; $i++; } @@ -149,12 +162,10 @@ $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $total = 0; - while ($row = $db->fetch_object($resql)) - { + while ($row = $db->fetch_object($resql)) { print '<tr class="oddeven">'; print '<td>'; $projectstatic->id = $row->rowid; @@ -204,12 +215,10 @@ $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $total = 0; - while ($row = $db->fetch_object($resql)) - { + while ($row = $db->fetch_object($resql)) { print '<tr class="oddeven">'; print '<td>'; $projectstatic->id = $row->rowid; @@ -239,66 +248,65 @@ print '</div>'; /* if ($db->type != 'pgsql') { - print '<br>'; + print '<br>'; - // Affichage de la liste des projets de la semaine - print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>'; - print '<td class="right">'.$langs->trans("Time").'</td>'; - print "</tr>\n"; + // Affichage de la liste des projets de la semaine + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>'; + print '<td class="right">'.$langs->trans("Time").'</td>'; + print "</tr>\n"; - $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " , ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ..."; - $sql.= " AND p.rowid in (".$db->sanitize($projectsListId).")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title"; + $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " , ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql.= " WHERE t.fk_projet = p.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND tt.fk_task = t.rowid"; + $sql.= " AND tt.fk_user = ".$user->id; + $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ..."; + $sql.= " AND p.rowid in (".$db->sanitize($projectsListId).")"; + $sql.= " GROUP BY p.rowid, p.ref, p.title"; - $resql = $db->query($sql); - if ( $resql ) - { - $total = 0; + $resql = $db->query($sql); + if ( $resql ) + { + $total = 0; - while ($row = $db->fetch_object($resql)) - { - print '<tr class="oddeven">'; - print '<td>'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; - print $projectstatic->getNomUrl(1, '', 1); - print '</td>'; - print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>'; - print "</tr>\n"; - $total += $row->nb; - } + while ($row = $db->fetch_object($resql)) + { + print '<tr class="oddeven">'; + print '<td>'; + $projectstatic->id=$row->rowid; + $projectstatic->ref=$row->ref; + $projectstatic->title=$row->title; + $projectstatic->public=$row->public; + print $projectstatic->getNomUrl(1, '', 1); + print '</td>'; + print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>'; + print "</tr>\n"; + $total += $row->nb; + } - $db->free($resql); - } - else - { - dol_print_error($db); - } - print '<tr class="liste_total">'; - print '<td>'.$langs->trans('Total').'</td>'; - print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>'; - print "</tr>\n"; - print "</table></div><br>"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print '<tr class="liste_total">'; + print '<td>'.$langs->trans('Total').'</td>'; + print '<td class="right">'.convertSecondToTime($total, 'allhourmin').'</td>'; + print "</tr>\n"; + print "</table></div><br>"; } */ /* Affichage de la liste des projets du mois */ -if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) -{ +if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; @@ -319,10 +327,8 @@ if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ($resql) - { - while ($row = $db->fetch_object($resql)) - { + if ($resql) { + while ($row = $db->fetch_object($resql)) { print '<tr class="oddeven">'; print '<td>'; $projectstatic->id = $row->rowid; @@ -346,8 +352,7 @@ if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) } /* Affichage de la liste des projets de l'annee */ -if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) -{ +if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) { print '<div class="div-table-responsive-no-min">'; print '<br><table class="noborder centpercent">'; print '<tr class="liste_titre">'; @@ -368,10 +373,8 @@ if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ($resql) - { - while ($row = $db->fetch_object($resql)) - { + if ($resql) { + while ($row = $db->fetch_object($resql)) { print '<tr class="oddeven">'; print '<td>'; $projectstatic->id = $row->rowid; @@ -395,36 +398,39 @@ if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) print '</div>'; } -if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) -{ +if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) { // Get id of types of contacts for projects (This list never contains a lot of elements) $listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $listofprojectcontacttype[$obj->rowid] = $obj->code; } - } else dol_print_error($db); - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found + } else { + dol_print_error($db); + } + if (count($listofprojectcontacttype) == 0) { + $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found + } // Get id of types of contacts for tasks (This list never contains a lot of elements) $listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql .= " WHERE ctc.element = '".$db->escape($taskstatic->element)."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $listoftaskcontacttype[$obj->rowid] = $obj->code; } - } else dol_print_error($db); - if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found + } else { + dol_print_error($db); + } + if (count($listoftaskcontacttype) == 0) { + $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found + } // Tasks for all resources of all opened projects and time spent for each task/resource @@ -440,17 +446,19 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; - if ($mine) - { + if ($mine) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; } $sql .= " WHERE p.entity IN (".getEntity('project').")"; - if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on - if ($mine) // this may duplicate record if we are contact twice - { + if ($mine || empty($user->rights->projet->all->lire)) { + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on + } + if ($mine) { // this may duplicate record if we are contact twice $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; } - if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } $sql .= " AND p.fk_statut=1"; $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; $sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; @@ -458,8 +466,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -470,7 +477,9 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH print '<tr class="liste_titre">'; //print '<th>'.$langs->trans('TaskRessourceLinks').'</th>'; print '<th>'.$langs->trans('OpenedProjects').'</th>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '<th>'.$langs->trans('OpportunityStatus').'</th>'; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print '<th>'.$langs->trans('OpportunityStatus').'</th>'; + } print '<th>'.$langs->trans('Task').'</th>'; print '<th class="center">'.$langs->trans('DateStart').'</th>'; print '<th class="center">'.$langs->trans('DateEnd').'</th>'; @@ -480,8 +489,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH print '<th class="right">'.$langs->trans("ProgressDeclared").'</td>'; print '</tr>'; - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); $projectstatic->id = $obj->projectid; @@ -499,37 +507,44 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH $taskstatic->datee = $db->jdate($obj->datee); $username = ''; - if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user - { + if ($obj->userid && $userstatic->id != $obj->userid) { // We have a user and it is not last loaded user $result = $userstatic->fetch($obj->userid); - if (!$result) $userstatic->id = 0; + if (!$result) { + $userstatic->id = 0; + } + } + if ($userstatic->id) { + $username = $userstatic->getNomUrl(0, 0); } - if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0); print '<tr class="oddeven">'; //print '<td>'.$username.'</td>'; print '<td>'; print $projectstatic->getNomUrl(1, '', 0, '', '<br>'); print '</td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td>'; $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td>'; } print '<td>'; - if (!empty($obj->taskid)) - { + if (!empty($obj->taskid)) { $tasktmp->id = $obj->taskid; $tasktmp->ref = $obj->ref; $tasktmp->label = $obj->label; print $tasktmp->getNomUrl(1, 'withproject', 'task', 1, '<br>'); - } else print $langs->trans("NoTasks"); + } else { + print $langs->trans("NoTasks"); + } print '</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->dateo), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->datee), 'day'); - if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); + if ($taskstatic->hasDelay()) { + print img_warning($langs->trans("Late")); + } print '</td>'; print '<td class="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">'; print convertSecondToTime($obj->planned_workload, 'allhourmin'); @@ -538,8 +553,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH print convertSecondToTime($obj->timespent, 'allhourmin'); print '</a></td>'; print '<td class="right">'; - if (!empty($obj->taskid)) - { + if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { @@ -556,10 +570,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH $i++; } - if ($num > $max) - { + if ($num > $max) { $colspan = 6; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + $colspan++; + } print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>'; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c6b38390ac9..1bc0d49d424 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -46,7 +46,9 @@ $taskid = GETPOST('taskid', 'int'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'perdaycard'; $mine = 0; -if ($mode == 'mine') $mine = 1; +if ($mode == 'mine') { + $mine = 1; +} $projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); @@ -84,16 +86,17 @@ $dayofday = GETPOST('addtimeday'); $yearofday = GETPOST('addtimeyear'); $daytoparse = $now; -if ($yearofday && $monthofday && $dayofday) $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' -elseif ($year && $month && $day) $daytoparse = dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +if ($yearofday && $monthofday && $dayofday) { + $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' +} elseif ($year && $month && $day) { + $daytoparse = dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +} -if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) -{ +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; $search_usertoprocessid = $usertoprocess->id; -} elseif ($search_usertoprocessid > 0) -{ +} elseif ($search_usertoprocessid > 0) { $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); $search_usertoprocessid = $usertoprocess->id; @@ -124,12 +127,11 @@ $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'e ); */ // 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) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) +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) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["efpt.".$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((int) $extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } } $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -145,10 +147,11 @@ $search_array_options_task = $extrafields->getOptionalsFromPost($object->table_e $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Purge 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 $action = ''; $search_categ = ''; $search_usertoprocessid = $user->id; @@ -164,15 +167,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' // We redefine $usertoprocess $usertoprocess = $user; } -if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) -{ +if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { $action = ''; } -if (GETPOST('submitdateselect')) -{ - if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) - { +if (GETPOST('submitdateselect')) { + if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) { $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); } @@ -181,46 +181,40 @@ if (GETPOST('submitdateselect')) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') -{ +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $action = 'assigntask'; - if ($taskid > 0) - { + if ($taskid > 0) { $result = $object->fetch($taskid, $ref); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } else { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (!GETPOST('type')) - { + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (!$error) - { + if (!$error) { $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); - if ($result >= 0 || $result == -2) // Contact add ok or already contact of task - { + if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if (!$obj) // User is not already linked to project, so we will create link to first type - { + if (!$obj) { // User is not already linked to project, so we will create link to first type $project = new Project($db); $project->fetch($object->fk_project); // Get type $listofprojcontact = $project->liste_type_contact('internal'); - if (count($listofprojcontact)) - { + if (count($listofprojcontact)) { $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } @@ -231,11 +225,9 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if ($result < 0) - { + if ($result < 0) { $error++; - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings'); } else { @@ -243,8 +235,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (!$error) - { + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); $taskid = 0; } @@ -252,49 +243,47 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action = ''; } -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') -{ +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $timespent_duration = array(); - if (is_array($_POST)) - { - foreach ($_POST as $key => $time) - { - if (intval($time) > 0) - { + if (is_array($_POST)) { + foreach ($_POST as $key => $time) { + if (intval($time) > 0) { $matches = array(); // Hours or minutes of duration - if (preg_match("/([0-9]+)duration(hour|min)/", $key, $matches)) - { + if (preg_match("/([0-9]+)duration(hour|min)/", $key, $matches)) { $id = $matches[1]; - if ($id > 0) - { + if ($id > 0) { // We store HOURS in seconds - if ($matches[2] == 'hour') $timespent_duration[$id] += $time * 60 * 60; + if ($matches[2] == 'hour') { + $timespent_duration[$id] += $time * 60 * 60; + } // We store MINUTES in seconds - if ($matches[2] == 'min') $timespent_duration[$id] += $time * 60; + if ($matches[2] == 'min') { + $timespent_duration[$id] += $time * 60; + } } } } } } - if (count($timespent_duration) > 0) - { - foreach ($timespent_duration as $key => $val) - { + if (count($timespent_duration) > 0) { + foreach ($timespent_duration as $key => $val) { $object->fetch($key); $taskid = $object->id; - if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); - else unset($object->progress); + if (GETPOSTISSET($taskid.'progress')) { + $object->progress = GETPOST($taskid.'progress', 'int'); + } else { + unset($object->progress); + } $object->timespent_duration = $val; $object->timespent_fk_user = $usertoprocess->id; $object->timespent_note = GETPOST($key.'note'); - if (GETPOST($key."hour", 'int') != '' && GETPOST($key."hour", 'int') >= 0) // If hour was entered - { + if (GETPOST($key."hour", 'int') != '' && GETPOST($key."hour", 'int') >= 0) { // If hour was entered $object->timespent_datehour = dol_mktime(GETPOST($key."hour", 'int'), GETPOST($key."min", 'int'), 0, $monthofday, $dayofday, $yearofday); $object->timespent_withhour = 1; } else { @@ -302,8 +291,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } $object->timespent_date = $object->timespent_datehour; - if ($object->timespent_date > 0) - { + if ($object->timespent_date > 0) { $result = $object->addTimeSpent($user); } else { setEventMessages("ErrorBadDate", null, 'errors'); @@ -311,16 +299,14 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac break; } - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back @@ -328,7 +314,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac exit; } } else { - setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); + setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } } @@ -362,8 +348,7 @@ $title = $langs->trans("TimeSpent"); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project -if ($id) -{ +if ($id) { $project->fetch($id); $project->fetch_thirdparty(); } @@ -371,11 +356,21 @@ if ($id) $onlyopenedproject = 1; // or -1 $morewherefilter = ''; -if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) { + $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +} +if ($search_task_ref) { + $morewherefilter .= natural_search("t.ref", $search_task_ref); +} +if ($search_task_label) { + $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +} +if ($search_thirdparty) { + $morewherefilter .= natural_search("s.nom", $search_thirdparty); +} +if ($search_declared_progress) { + $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +} $sql = &$morewherefilter; @@ -392,8 +387,7 @@ $extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. -if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks -{ +if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); @@ -451,16 +445,18 @@ print dol_get_fiche_head($head, 'inputperday', $langs->trans('TimeSpent'), -1, $ // Show description of content print '<div class="hideonsmartphone opacitymedium">'; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; -else { - if (empty($usertoprocess->id) || $usertoprocess->id < 0) - { - if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +if ($mine || ($usertoprocess->id == $user->id)) { + print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +} else { + if (empty($usertoprocess->id) || $usertoprocess->id < 0) { + if ($user->rights->projet->all->lire && !$socid) { + print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } else { + print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } } } -if ($mine || ($usertoprocess->id == $user->id)) -{ +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'<br>'; } else { print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>'; @@ -474,7 +470,9 @@ print '<div class="floatright right'.($conf->dol_optimize_smallscreen ? ' centpe print '<div class="colorbacktimesheet float valignmiddle">'; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); -if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +if ($usertoprocess->id != $user->id) { + $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +} print '<div class="taskiddiv inline-block">'; print img_picto('', 'projecttask'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); @@ -503,12 +501,13 @@ $moreforfilter = ''; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>'; $includeonly = 'hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); $moreforfilter .= '</div>'; -if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) -{ +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block"></div>'; $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').'<input type="text" size="4" name="search_project_ref" class="marginleftonly" value="'.dol_escape_htmltag($search_project_ref).'">'; @@ -520,8 +519,7 @@ if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) $moreforfilter .= '</div>'; } -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -535,19 +533,28 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi // This must be after the $selectedfields $addcolspan = 0; -if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; -foreach ($arrayfields as $key => $val) -{ - if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; +if (!empty($arrayfields['t.planned_workload']['checked'])) { + $addcolspan++; +} +if (!empty($arrayfields['t.progress']['checked'])) { + $addcolspan++; +} +foreach ($arrayfields as $key => $val) { + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') { + $addcolspan++; + } } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<tr class="liste_titre_filter">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +} print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; // TASK fields $search_options_pattern = 'search_task_options_'; @@ -555,12 +562,10 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.planned_workload']['checked'])) -{ +if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>'; } -if (!empty($arrayfields['t.progress']['checked'])) -{ +if (!empty($arrayfields['t.progress']['checked'])) { print '<td class="liste_titre"></td>'; } print '<td class="liste_titre"></td>'; @@ -575,19 +580,21 @@ print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("Project").'</th>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("ThirdParty").'</th>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<th>'.$langs->trans("Project").'</th>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<th>'.$langs->trans("ThirdParty").'</th>'; +} print '<th>'.$langs->trans("Task").'</th>'; // TASK fields $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (!empty($arrayfields['t.planned_workload']['checked'])) -{ +if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<th class="right leftborder plannedworkload maxwidth100">'.$langs->trans("PlannedWorkload").'</th>'; } -if (!empty($arrayfields['t.progress']['checked'])) -{ +if (!empty($arrayfields['t.progress']['checked'])) { print '<th class="right maxwidth100">'.$langs->trans("ProgressDeclared").'</th>'; } /*print '<td class="right maxwidth100">'.$langs->trans("TimeSpent").'</td>'; @@ -602,11 +609,9 @@ $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSI // Get if user is available or not for each day $isavailable = array(); -if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) -{ +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); - if (count($tmparray) >= 2) - { + if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; $numendworkingday = $tmparray[1]; } @@ -617,24 +622,29 @@ $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoproces $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day $test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code); -if ($test) $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); +if ($test) { + $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); +} $tmparray = dol_getdate($daytoparse, true); // detail of current day // For monday, must be 0 for monday if MAIN_START_WEEK = 1, must be 1 for monday if MAIN_START_WEEK = 0 $idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1)); // numstartworkingday and numendworkingday are default start and end date of working days (1 means sunday if MAIN_START_WEEK is 0, 1 means monday if MAIN_START_WEEK is 1) $cssweekend = ''; -if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. -{ +if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } $tmpday = dol_time_plus_duree($daytoparse, $idw, 'd'); $cssonholiday = ''; -if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; -elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; -elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; +if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) { + $cssonholiday .= 'onholidayallday '; +} elseif (!$isavailable[$daytoparse]['morning']) { + $cssonholiday .= 'onholidaymorning '; +} elseif (!$isavailable[$daytoparse]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; +} print '<th class="center'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'.$langs->trans("Duration").'</th>'; print '<th class="center">'.$langs->trans("Note").'</th>'; @@ -645,8 +655,7 @@ print "</tr>\n"; $colspan = 4 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print '<tr class="liste_total">'; print '<td class="liste_total" colspan="'.($colspan - 1 + $addcolspan).'">'; print $langs->trans("Total"); @@ -663,8 +672,7 @@ if ($conf->use_javascript_ajax) } -if (count($tasksarray) > 0) -{ +if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); @@ -678,21 +686,17 @@ if (count($tasksarray) > 0) // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) - { - foreach ($tasksarraywithoutfilter as $tmptask) - { + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); $totalforeachday = array(); - foreach ($listofdistinctprojectid as $tmpprojectid) - { + foreach ($listofdistinctprojectid as $tmpprojectid) { $projectstatic->id = $tmpprojectid; $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - for ($idw = 0; $idw < 7; $idw++) - { + for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($daytoparse, $idw, 'd'); $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } @@ -701,18 +705,15 @@ if (count($tasksarray) > 0) // Is there a diff between selected/filtered tasks and all tasks ? $isdiff = 0; - if (count($totalforeachday)) - { + if (count($totalforeachday)) { $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); - if ($timeonothertasks) - { + if ($timeonothertasks) { $isdiff = 1; } } // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user - if ($isdiff) - { + if ($isdiff) { print '<tr class="oddeven othertaskwithtime">'; print '<td colspan="'.($colspan - 1).'" class="opacitymedium">'; print $langs->trans("OtherFilteredTasks"); @@ -723,7 +724,9 @@ if (count($tasksarray) > 0) //if ($timeonothertasks) //{ print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled="" id="timespent[-1][0]" name="task[-1][0]" value="'; - if ($timeonothertasks) print convertSecondToTime($timeonothertasks, 'allhourmin'); + if ($timeonothertasks) { + print convertSecondToTime($timeonothertasks, 'allhourmin'); + } print '"></span>'; //} print '</td>'; @@ -732,8 +735,7 @@ if (count($tasksarray) > 0) print '</tr>'; } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr class="liste_total">'; print '<td class="liste_total" colspan="'.($colspan - 1 + $addcolspan).'">'; print $langs->trans("Total"); @@ -764,8 +766,7 @@ print '</form>'; $modeinput = 'hours'; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n"; print '<script type="text/javascript">'."\n"; print "jQuery(document).ready(function () {\n"; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 626634b13cd..3902cd83ed0 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -44,7 +44,9 @@ $id = GETPOST('id', 'int'); $taskid = GETPOST('taskid', 'int'); $mine = 0; -if ($mode == 'mine') $mine = 1; +if ($mode == 'mine') { + $mine = 1; +} $projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); @@ -91,12 +93,10 @@ $TFirstDays = getFirstDayOfEachWeek($TWeek, $year); $TFirstDays[reset($TWeek)] = '01'; //first day of month $TLastDays = getLastDayOfEachWeek($TWeek, $year); $TLastDays[end($TWeek)] = date("t", strtotime($year.'-'.$month.'-'.$day)); //last day of month -if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) -{ +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; $search_usertoprocessid = $usertoprocess->id; -} elseif ($search_usertoprocessid > 0) -{ +} elseif ($search_usertoprocessid > 0) { $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); $search_usertoprocessid = $usertoprocess->id; @@ -112,11 +112,12 @@ $object = new Task($db); */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid, 'TWeek' => $TWeek, 'TFirstDays' => $TFirstDays, 'TLastDays' => $TLastDays); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Purge 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 $action = ''; $search_categ = ''; $search_usertoprocessid = $user->id; @@ -126,58 +127,50 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_thirdparty = ''; $search_declared_progress = ''; } -if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) -{ +if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { $action = ''; } -if (GETPOST('submitdateselect')) -{ +if (GETPOST('submitdateselect')) { $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $action = ''; } -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) -{ +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) { $action = 'assigntask'; - if ($taskid > 0) - { + if ($taskid > 0) { $result = $object->fetch($taskid, $ref); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } else { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (!GETPOST('type')) - { + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (!$error) - { + if (!$error) { $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); - if ($result >= 0 || $result == -2) // Contact add ok or already contact of task - { + if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if (!$obj) // User is not already linked to project, so we will create link to first type - { + if (!$obj) { // User is not already linked to project, so we will create link to first type $project = new Project($db); $project->fetch($object->fk_project); // Get type $listofprojcontact = $project->liste_type_contact('internal'); - if (count($listofprojcontact)) - { + if (count($listofprojcontact)) { $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } @@ -188,11 +181,9 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if ($result < 0) - { + if ($result < 0) { $error++; - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings'); } else { @@ -200,8 +191,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (!$error) - { + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); $taskid = 0; } @@ -209,29 +199,29 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action = ''; } -if ($action == 'addtime' && $user->rights->projet->lire) -{ +if ($action == 'addtime' && $user->rights->projet->lire) { $timetoadd = $_POST['task']; - if (empty($timetoadd)) - { + if (empty($timetoadd)) { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } else { - foreach ($timetoadd as $taskid => $value) // Loop on each task - { + foreach ($timetoadd as $taskid => $value) { // Loop on each task $updateoftaskdone = 0; - foreach ($value as $key => $val) // Loop on each day - { + foreach ($value as $key => $val) { // Loop on each day $amountoadd = $timetoadd[$taskid][$key]; - if (!empty($amountoadd)) - { + if (!empty($amountoadd)) { $tmpduration = explode(':', $amountoadd); $newduration = 0; - if (!empty($tmpduration[0])) $newduration += ($tmpduration[0] * 3600); - if (!empty($tmpduration[1])) $newduration += ($tmpduration[1] * 60); - if (!empty($tmpduration[2])) $newduration += ($tmpduration[2]); + if (!empty($tmpduration[0])) { + $newduration += ($tmpduration[0] * 3600); + } + if (!empty($tmpduration[1])) { + $newduration += ($tmpduration[1] * 60); + } + if (!empty($tmpduration[2])) { + $newduration += ($tmpduration[2]); + } - if ($newduration > 0) - { + if ($newduration > 0) { $object->fetch($taskid); $object->progress = GETPOST($taskid.'progress', 'int'); $object->timespent_duration = $newduration; @@ -240,8 +230,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $object->timespent_datehour = $object->timespent_date; $result = $object->addTimeSpent($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; @@ -252,16 +241,13 @@ if ($action == 'addtime' && $user->rights->projet->lire) } } - if (!$updateoftaskdone) // Check to update progress if no update were done on task. - { + if (!$updateoftaskdone) { // Check to update progress if no update were done on task. $object->fetch($taskid); //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; - if ($object->progress != GETPOST($taskid.'progress', 'int')) - { + if ($object->progress != GETPOST($taskid.'progress', 'int')) { $object->progress = GETPOST($taskid.'progress', 'int'); $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; @@ -270,8 +256,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $param = ''; @@ -313,8 +298,7 @@ $title = $langs->trans("TimeSpent"); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); -if ($id) -{ +if ($id) { $project->fetch($id); $project->fetch_thirdparty(); } @@ -322,15 +306,24 @@ if ($id) $onlyopenedproject = 1; // or -1 $morewherefilter = ''; -if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) { + $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +} +if ($search_task_ref) { + $morewherefilter .= natural_search("t.ref", $search_task_ref); +} +if ($search_task_label) { + $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +} +if ($search_thirdparty) { + $morewherefilter .= natural_search("s.nom", $search_thirdparty); +} +if ($search_declared_progress) { + $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +} $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. -if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks -{ +if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); @@ -376,16 +369,18 @@ print dol_get_fiche_head($head, 'inputpermonth', $langs->trans('TimeSpent'), -1, // Show description of content print '<div class="hideonsmartphone opacitymedium">'; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; -else { - if (empty($usertoprocess->id) || $usertoprocess->id < 0) - { - if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +if ($mine || ($usertoprocess->id == $user->id)) { + print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +} else { + if (empty($usertoprocess->id) || $usertoprocess->id < 0) { + if ($user->rights->projet->all->lire && !$socid) { + print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } else { + print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } } } -if ($mine || ($usertoprocess->id == $user->id)) -{ +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'<br>'; } else { print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>'; @@ -398,7 +393,9 @@ print '<div class="floatright right'.($conf->dol_optimize_smallscreen ? ' centpe print '<div class="colorbacktimesheet float valignmiddle">'; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); -if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +if ($usertoprocess->id != $user->id) { + $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +} print '<div class="taskiddiv inline-block">'; print img_picto('', 'projecttask'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1); @@ -428,12 +425,13 @@ if (! empty($conf->categorie->enabled)) $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>'; $includeonly = 'hierachyme'; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; -if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) -{ +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block"></div>'; $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').'<input type="text" size="4" name="search_project_ref" class="marginleftonly" value="'.dol_escape_htmltag($search_project_ref).'">'; @@ -445,8 +443,7 @@ if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) $moreforfilter .= '</div>'; } -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -460,15 +457,18 @@ print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<tr class="liste_titre_filter">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +} print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; print '<td class="liste_titre"></td>'; print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>'; print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>'; -foreach ($TWeek as $week_number) -{ +foreach ($TWeek as $week_number) { print '<td class="liste_titre"></td>'; } // Action column @@ -479,8 +479,12 @@ print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("Project").'</td>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("ThirdParty").'</td>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td>'.$langs->trans("Project").'</td>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td>'.$langs->trans("ThirdParty").'</td>'; +} print '<td>'.$langs->trans("Task").'</td>'; print '<td align="right" class="leftborder plannedworkload maxwidth75">'.$langs->trans("PlannedWorkload").'</td>'; print '<td align="right" class="maxwidth75">'.$langs->trans("ProgressDeclared").'</td>'; @@ -490,8 +494,7 @@ print '<td align="right" class="maxwidth75">'.$langs->trans("ProgressDeclared"). print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'<br><span class="opacitymedium">'.$langs->trans("Everybody").'</span></td>'; print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").($usertoprocess->firstname ? '<br>'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span>' : '').'</td>'; -foreach ($TWeek as $week_number) -{ +foreach ($TWeek as $week_number) { print '<td width="6%" align="center" class="bold hide">'.$langs->trans("Week").' '.$week_number.'<br>('.$TFirstDays[$week_number].'...'.$TLastDays[$week_number].')</td>'; } print '<td></td>'; @@ -507,8 +510,7 @@ $isavailable = array(); // TODO See code into perweek.php to initialize isavailable array -if (count($tasksarray) > 0) -{ +if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); @@ -522,21 +524,17 @@ if (count($tasksarray) > 0) // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) - { - foreach ($tasksarraywithoutfilter as $tmptask) - { + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); $totalforeachweek = array(); - foreach ($listofdistinctprojectid as $tmpprojectid) - { + foreach ($listofdistinctprojectid as $tmpprojectid) { $projectstatic->id = $tmpprojectid; $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - foreach ($TWeek as $weekNb) - { + foreach ($TWeek as $weekNb) { $totalforeachweek[$weekNb] += $projectstatic->monthWorkLoad[$weekNb]; } } @@ -546,13 +544,10 @@ if (count($tasksarray) > 0) // Is there a diff between selected/filtered tasks and all tasks ? $isdiff = 0; - if (count($totalforeachweek)) - { - foreach ($TWeek as $weekNb) - { + if (count($totalforeachweek)) { + foreach ($TWeek as $weekNb) { $timeonothertasks = ($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); - if ($timeonothertasks) - { + if ($timeonothertasks) { $isdiff = 1; break; } @@ -560,19 +555,16 @@ if (count($tasksarray) > 0) } // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user - if ($isdiff) - { + if ($isdiff) { print '<tr class="oddeven othertaskwithtime">'; print '<td colspan="'.$colspan.'" class="opacitymedium">'; print $langs->trans("OtherFilteredTasks"); print '</td>'; - foreach ($TWeek as $weekNb) - { + foreach ($TWeek as $weekNb) { print '<td class="center hide">'; $timeonothertasks = ($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); - if ($timeonothertasks) - { + if ($timeonothertasks) { print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$weekNb.']" name="task[-1]['.$weekNb.']" value="'; print convertSecondToTime($timeonothertasks, 'allhourmin'); print '"></span>'; @@ -583,16 +575,14 @@ if (count($tasksarray) > 0) print '</tr>'; } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr class="liste_total"> <td class="liste_total" colspan="'.$colspan.'">'; print $langs->trans("Total"); print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>'; print '</td>'; - foreach ($TWeek as $weekNb) - { + foreach ($TWeek as $weekNb) { print '<td class="liste_total hide'.$weekNb.'" align="center"><div class="totalDay'.$weekNb.'">'.convertSecondToTime($totalforvisibletasks[$weekNb], 'allhourmin').'</div></td>'; } print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td> @@ -615,8 +605,7 @@ print '</form>'."\n\n"; $modeinput = 'hours'; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n"; print '<script type="text/javascript">'."\n"; print "jQuery(document).ready(function () {\n"; @@ -629,8 +618,7 @@ if ($conf->use_javascript_ajax) } });'."\n"; - foreach ($TWeek as $week_number) - { + foreach ($TWeek as $week_number) { print ' updateTotal('.$week_number.',\''.$modeinput.'\');'; } print "\n});\n"; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index f001a73d0f4..69866e1da2f 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -46,7 +46,9 @@ $taskid = GETPOST('taskid', 'int'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'perweekcard'; $mine = 0; -if ($mode == 'mine') $mine = 1; +if ($mode == 'mine') { + $mine = 1; +} $projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); @@ -99,12 +101,10 @@ $next_day = $next['day']; $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); -if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) -{ +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; $search_usertoprocessid = $usertoprocess->id; -} elseif ($search_usertoprocessid > 0) -{ +} elseif ($search_usertoprocessid > 0) { $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); $search_usertoprocessid = $usertoprocess->id; @@ -122,28 +122,27 @@ $extrafields->fetch_name_optionals_label($object->table_element); $arrayfields = array(); /*$arrayfields=array( - // Project - 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), - 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104), - 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105), - 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), - 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), + // Project + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104), + 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105), + 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), + 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ $arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*foreach($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); }*/ // Definition of fields for list // Extra fields -if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) -{ - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) - { - if (!empty($extrafields->attributes['projet_task']['list'][$key])) +if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { + if (!empty($extrafields->attributes['projet_task']['list'][$key])) { $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); + } } } $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -160,10 +159,11 @@ $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', ' $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Purge 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 $action = ''; $search_categ = ''; $search_usertoprocessid = $user->id; @@ -179,13 +179,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' // We redefine $usertoprocess $usertoprocess = $user; } -if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) -{ +if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { $action = ''; } -if (GETPOST('submitdateselect')) -{ +if (GETPOST('submitdateselect')) { $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $action = ''; @@ -193,47 +191,41 @@ if (GETPOST('submitdateselect')) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') -{ +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $action = 'assigntask'; - if ($taskid > 0) - { + if ($taskid > 0) { $result = $object->fetch($taskid, $ref); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } else { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (!GETPOST('type')) - { + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (!$error) - { + if (!$error) { $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); - if ($result >= 0 || $result == -2) // Contact add ok or already contact of task - { + if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if (!$obj) // User is not already linked to project, so we will create link to first type - { + if (!$obj) { // User is not already linked to project, so we will create link to first type $project = new Project($db); $project->fetch($object->fk_project); // Get type $listofprojcontact = $project->liste_type_contact('internal'); - if (count($listofprojcontact)) - { + if (count($listofprojcontact)) { $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } @@ -244,11 +236,9 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if ($result < 0) - { + if ($result < 0) { $error++; - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings'); } else { @@ -256,8 +246,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (!$error) - { + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); $taskid = 0; } @@ -265,33 +254,36 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action = ''; } -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') -{ +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $timetoadd = $_POST['task']; - if (empty($timetoadd)) - { + if (empty($timetoadd)) { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } else { - foreach ($timetoadd as $taskid => $value) // Loop on each task - { + foreach ($timetoadd as $taskid => $value) { // Loop on each task $updateoftaskdone = 0; - foreach ($value as $key => $val) // Loop on each day - { + foreach ($value as $key => $val) { // Loop on each day $amountoadd = $timetoadd[$taskid][$key]; - if (!empty($amountoadd)) - { + if (!empty($amountoadd)) { $tmpduration = explode(':', $amountoadd); $newduration = 0; - if (!empty($tmpduration[0])) $newduration += ($tmpduration[0] * 3600); - if (!empty($tmpduration[1])) $newduration += ($tmpduration[1] * 60); - if (!empty($tmpduration[2])) $newduration += ($tmpduration[2]); + if (!empty($tmpduration[0])) { + $newduration += ($tmpduration[0] * 3600); + } + if (!empty($tmpduration[1])) { + $newduration += ($tmpduration[1] * 60); + } + if (!empty($tmpduration[2])) { + $newduration += ($tmpduration[2]); + } - if ($newduration > 0) - { - $object->fetch($taskid); + if ($newduration > 0) { + $object->fetch($taskid); - if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); - else unset($object->progress); + if (GETPOSTISSET($taskid.'progress')) { + $object->progress = GETPOST($taskid.'progress', 'int'); + } else { + unset($object->progress); + } $object->timespent_duration = $newduration; $object->timespent_fk_user = $usertoprocess->id; @@ -300,8 +292,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $object->timespent_note = $object->description; $result = $object->addTimeSpent($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; @@ -312,16 +303,13 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (!$updateoftaskdone) // Check to update progress if no update were done on task. - { + if (!$updateoftaskdone) { // Check to update progress if no update were done on task. $object->fetch($taskid); //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; - if ($object->progress != GETPOST($taskid.'progress', 'int')) - { + if ($object->progress != GETPOST($taskid.'progress', 'int')) { $object->progress = GETPOST($taskid.'progress', 'int'); $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; @@ -330,8 +318,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $param = ''; @@ -347,18 +334,18 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; - $search_options_pattern='search_options_'; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - */ + $search_options_pattern='search_options_'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + */ $search_array_options = $search_array_options_task; $search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); - exit; - } + // Redirect to avoid submit twice on back + header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); + exit; + } } } @@ -381,8 +368,7 @@ $title = $langs->trans("TimeSpent"); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); -if ($id) -{ +if ($id) { $project->fetch($id); $project->fetch_thirdparty(); } @@ -390,11 +376,21 @@ if ($id) $onlyopenedproject = 1; // or -1 $morewherefilter = ''; -if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) { + $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +} +if ($search_task_ref) { + $morewherefilter .= natural_search("t.ref", $search_task_ref); +} +if ($search_task_label) { + $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +} +if ($search_thirdparty) { + $morewherefilter .= natural_search("s.nom", $search_thirdparty); +} +if ($search_declared_progress) { + $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); +} $sql = &$morewherefilter; @@ -411,8 +407,7 @@ $extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. -if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks -{ +if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); @@ -468,16 +463,18 @@ print dol_get_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, // Show description of content print '<div class="hideonsmartphone opacitymedium">'; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; -else { - if (empty($usertoprocess->id) || $usertoprocess->id < 0) - { - if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +if ($mine || ($usertoprocess->id == $user->id)) { + print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; +} else { + if (empty($usertoprocess->id) || $usertoprocess->id < 0) { + if ($user->rights->projet->all->lire && !$socid) { + print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } else { + print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>'; + } } } -if ($mine || ($usertoprocess->id == $user->id)) -{ +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'<br>'; } else { print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>'; @@ -490,7 +487,9 @@ print '<div class="floatright right'.($conf->dol_optimize_smallscreen ? ' centpe print '<div class="colorbacktimesheet float valignmiddle">'; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); -if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +if ($usertoprocess->id != $user->id) { + $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); +} print '<div class="taskiddiv inline-block">'; print img_picto('', 'projecttask'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); @@ -507,18 +506,15 @@ $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray[' // Get if user is available or not for each day $isavailable = array(); -if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) -{ +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); - if (count($tmparray) >= 2) - { + if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; $numendworkingday = $tmparray[1]; } } -for ($idw = 0; $idw < 7; $idw++) -{ +for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); @@ -535,7 +531,9 @@ for ($idw = 0; $idw < 7; $idw++) $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day $test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code); - if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); + if ($test) { + $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); + } } //var_dump($isavailable); @@ -558,12 +556,13 @@ if (! empty($conf->categorie->enabled)) $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>'; $includeonly = 'hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; -if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) -{ +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="inline-block"></div>'; $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').'<input type="text" size="4" name="search_project_ref" class="marginleftonly" value="'.dol_escape_htmltag($search_project_ref).'">'; @@ -575,8 +574,7 @@ if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) $moreforfilter .= '</div>'; } -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -592,19 +590,28 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi // This must be after the $selectedfields $addcolspan = 0; -if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; -foreach ($arrayfields as $key => $val) -{ - if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; +if (!empty($arrayfields['t.planned_workload']['checked'])) { + $addcolspan++; +} +if (!empty($arrayfields['t.progress']['checked'])) { + $addcolspan++; +} +foreach ($arrayfields as $key => $val) { + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') { + $addcolspan++; + } } print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<tr class="liste_titre_filter">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>'; +} print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; // TASK fields $search_options_pattern = 'search_task_options_'; @@ -612,17 +619,14 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.planned_workload']['checked'])) -{ +if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>'; } -if (!empty($arrayfields['t.progress']['checked'])) -{ +if (!empty($arrayfields['t.progress']['checked'])) { print '<td class="liste_titre"></td>'; } print '<td class="liste_titre"></td>'; -for ($idw = 0; $idw < 7; $idw++) -{ +for ($idw = 0; $idw < 7; $idw++) { print '<td class="liste_titre"></td>'; } // Action column @@ -633,19 +637,21 @@ print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("Project").'</th>'; -if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("ThirdParty").'</th>'; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<th>'.$langs->trans("Project").'</th>'; +} +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { + print '<th>'.$langs->trans("ThirdParty").'</th>'; +} print '<th>'.$langs->trans("Task").'</th>'; // TASK fields $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (!empty($arrayfields['t.planned_workload']['checked'])) -{ +if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<th class="leftborder plannedworkload maxwidth75 right">'.$langs->trans("PlannedWorkload").'</th>'; } -if (!empty($arrayfields['t.progress']['checked'])) -{ +if (!empty($arrayfields['t.progress']['checked'])) { print '<th class="maxwidth75 right">'.$langs->trans("ProgressDeclared").'</th>'; } /*print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").'</td>'; @@ -654,23 +660,25 @@ if (!empty($arrayfields['t.progress']['checked'])) print '<th class="maxwidth75 right">'.$langs->trans("TimeSpent").'<br><span class="opacitymedium">'.$langs->trans("Everybody").'</span></th>'; print '<th class="maxwidth75 right">'.$langs->trans("TimeSpent").($usertoprocess->firstname ? '<br>'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span>' : '').'</th>'; -for ($idw = 0; $idw < 7; $idw++) -{ +for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); $cssweekend = ''; - if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $cssonholiday = ''; - if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$tmpday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } print '<th width="6%" align="center" class="bold hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</th>'; } @@ -682,28 +690,29 @@ print "</tr>\n"; $colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print '<tr class="liste_total">'; print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">'; print $langs->trans("Total"); print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>'; print '</td>'; - for ($idw = 0; $idw < 7; $idw++) - { + for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; - if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $cssonholiday = ''; - if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$tmpday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>'; } print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>'; @@ -714,8 +723,7 @@ if ($conf->use_javascript_ajax) // By default, we can edit only tasks we are assigned to $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); -if (count($tasksarray) > 0) -{ +if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); @@ -729,21 +737,17 @@ if (count($tasksarray) > 0) // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) - { - foreach ($tasksarraywithoutfilter as $tmptask) - { + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); $totalforeachday = array(); - foreach ($listofdistinctprojectid as $tmpprojectid) - { + foreach ($listofdistinctprojectid as $tmpprojectid) { $projectstatic->id = $tmpprojectid; $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - for ($idw = 0; $idw < 7; $idw++) - { + for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } @@ -754,14 +758,11 @@ if (count($tasksarray) > 0) // Is there a diff between selected/filtered tasks and all tasks ? $isdiff = 0; - if (count($totalforeachday)) - { - for ($idw = 0; $idw < 7; $idw++) - { + if (count($totalforeachday)) { + for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); - if ($timeonothertasks) - { + if ($timeonothertasks) { $isdiff = 1; break; } @@ -769,25 +770,21 @@ if (count($tasksarray) > 0) } // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user - if ($isdiff) - { + if ($isdiff) { print '<tr class="oddeven othertaskwithtime">'; print '<td colspan="'.($colspan + $addcolspan).'" class="opacitymedium">'; print $langs->trans("OtherFilteredTasks"); print '</td>'; - for ($idw = 0; $idw < 7; $idw++) - { + for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; - if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } print '<td class="center hide'.$idw.' '.($cssweekend ? ' '.$cssweekend : '').'">'; $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); - if ($timeonothertasks) - { + if ($timeonothertasks) { print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.']" name="task[-1]['.$idw.']" value="'; print convertSecondToTime($timeonothertasks, 'allhourmin'); print '"></span>'; @@ -798,8 +795,7 @@ if (count($tasksarray) > 0) print '</tr>'; } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr class="liste_total"> <td class="liste_total" colspan="'.($colspan + $addcolspan).'">'; print $langs->trans("Total"); @@ -808,17 +804,20 @@ if (count($tasksarray) > 0) for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; - if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. - { + if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; } $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $cssonholiday = ''; - if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; - elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; - elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayallday '; + } elseif (!$isavailable[$tmpday]['morning']) { + $cssonholiday .= 'onholidaymorning '; + } elseif (!$isavailable[$tmpday]['afternoon']) { + $cssonholiday .= 'onholidayafternoon '; + } print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>'; } @@ -841,8 +840,7 @@ print '</form>'."\n\n"; $modeinput = 'hours'; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n"; print '<script type="text/javascript">'."\n"; print "jQuery(document).ready(function () {\n"; @@ -856,8 +854,7 @@ if ($conf->use_javascript_ajax) });'."\n"; $idw = 0; - while ($idw < 7) - { + while ($idw < 7) { print ' updateTotal('.$idw.',\''.$modeinput.'\');'; $idw++; } diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 45e62eafbe9..e0018aa0e4b 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'other', 'projects')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $value = GETPOST('value', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -51,40 +53,43 @@ $type = 'project'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconstproject = GETPOST('maskconstproject', 'alpha'); $maskproject = GETPOST('maskproject', 'alpha'); - if ($maskconstproject) $res = dolibarr_set_const($db, $maskconstproject, $maskproject, 'chaine', 0, '', $conf->entity); + if ($maskconstproject) { + $res = dolibarr_set_const($db, $maskconstproject, $maskproject, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } } -if ($action == 'updateMaskTask') -{ +if ($action == 'updateMaskTask') { $maskconstmasktask = GETPOST('maskconsttask', 'alpha'); $masktaskt = GETPOST('masktask', 'alpha'); - if ($maskconstmasktask) $res = dolibarr_set_const($db, $maskconstmasktask, $masktaskt, 'chaine', 0, '', $conf->entity); + if ($maskconstmasktask) { + $res = dolibarr_set_const($db, $maskconstmasktask, $masktaskt, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') -{ +} elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); $project = new Project($db); @@ -93,25 +98,21 @@ if ($action == 'updateMaskTask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/project/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($project, $langs) > 0) - { + if ($module->write_file($project, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf"); return; } else { @@ -122,8 +123,7 @@ if ($action == 'updateMaskTask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} elseif ($action == 'specimentask') -{ +} elseif ($action == 'specimentask') { $modele = GETPOST('module', 'alpha'); $project = new Project($db); @@ -132,25 +132,21 @@ if ($action == 'updateMaskTask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($project, $langs) > 0) - { + if ($module->write_file($project, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf"); return; } else { @@ -161,49 +157,37 @@ if ($action == 'updateMaskTask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} -// Activate a model for task -elseif ($action == 'settask') -{ +} elseif ($action == 'settask') { + // Activate a model for task $ret = addDocumentModel($value, 'project_task', $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->PROJECT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'PROJECT_ADDON_PDF', $conf->entity); + } } -} -if ($action == 'deltask') -{ +} elseif ($action == 'deltask') { $ret = delDocumentModel($value, 'project_task'); - if ($ret > 0) - { - if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ +} elseif ($action == 'setdoc') { + // Set default model dolibarr_set_const($db, "PROJECT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity); // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setdoctask') -{ - if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoctask') { + if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->PROJECT_TASK_ADDON_PDF = $value; @@ -211,41 +195,32 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, 'project_task'); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, 'project_task', $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "PROJECT_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'setmodtask') -{ +} elseif ($action == 'setmodtask') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "PROJECT_TASK_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'updateoptions') -{ - if (GETPOST('PROJECT_USE_SEARCH_TO_SELECT')) - { +} elseif ($action == 'updateoptions') { + if (GETPOST('PROJECT_USE_SEARCH_TO_SELECT')) { $companysearch = GETPOST('activate_PROJECT_USE_SEARCH_TO_SELECT', 'alpha'); - if (dolibarr_set_const($db, "PROJECT_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity)) - { + if (dolibarr_set_const($db, "PROJECT_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity)) { $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch; } } - if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) - { + if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) { $projectToSelect = GETPOST('projectToSelect', 'alpha'); dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value } -} - -// Set boolean (on/off) constants -elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) { +} elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) { + // Set boolean (on/off) constants if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -323,19 +298,14 @@ print "</tr>\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/project/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { $file = $reg[1]; $classname = substr($file, 4); @@ -344,11 +314,14 @@ foreach ($dirmodels as $reldir) $module = new $file; // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) 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()) - { + if ($module->isEnabled()) { print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print $module->info(); print '</td>'; @@ -359,13 +332,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '</td>'."\n"; print '<td class="center">'; - if ($conf->global->PROJECT_ADDON == 'mod_'.$classname) - { + if ($conf->global->PROJECT_ADDON == 'mod_'.$classname) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; @@ -379,11 +354,9 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $nextval = $module->getNextValue($mysoc, $project); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) - { + if ($nextval) { $htmltooltip .= $nextval.'<br>'; } else { $htmltooltip .= $langs->trans($module->error).'<br>'; @@ -406,8 +379,7 @@ foreach ($dirmodels as $reldir) print '</table><br>'; -if (empty($conf->global->PROJECT_HIDE_TASKS)) -{ +if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Task numbering module print load_fiche_titre($langs->trans("TasksNumberingModules"), '', ''); @@ -422,19 +394,14 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) clearstatcache(); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/project/task/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { $file = $reg[1]; $classname = substr($file, 4); @@ -443,11 +410,14 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) $module = new $file; // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) 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()) - { + if ($module->isEnabled()) { print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print $module->info(); print '</td>'; @@ -458,13 +428,15 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '</td>'."\n"; print '<td class="center">'; - if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname) - { + if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; @@ -478,11 +450,9 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $nextval = $module->getNextValue($mysoc, $project); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) - { + if ($nextval) { $htmltooltip .= $nextval.'<br>'; } else { $htmltooltip .= $langs->trans($module->error).'<br>'; @@ -522,12 +492,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -548,30 +516,22 @@ print "</tr>\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/project/".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -579,21 +539,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print '<tr class="oddeven"><td width="100">'; print (empty($module->name) ? $name : $module->name); print "</td><td>\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print "</td>\n"; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print "<td class=\"center\">\n"; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -607,8 +572,7 @@ foreach ($dirmodels as $reldir) // Default print "<td class=\"center\">"; - if ($conf->global->PROJECT_ADDON_PDF == "$name") - { + if ($conf->global->PROJECT_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; @@ -618,8 +582,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; @@ -631,8 +594,7 @@ foreach ($dirmodels as $reldir) // Preview print '<td class="center">'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -653,8 +615,7 @@ print '</table><br/>'; -if (empty($conf->global->PROJECT_HIDE_TASKS)) -{ +if (empty($conf->global->PROJECT_HIDE_TASKS)) { /* * Modeles documents for Task */ @@ -671,12 +632,10 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -697,30 +656,22 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) clearstatcache(); - foreach ($dirmodels as $reldir) - { - foreach (array('', '/doc') as $valdir) - { + foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/project/task/".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -728,21 +679,26 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print '<tr class="oddeven"><td width="100">'; print (empty($module->name) ? $name : $module->name); print "</td><td>\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print "</td>\n"; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print "<td class=\"center\">\n"; print '<a href="'.$_SERVER["PHP_SELF"].'?action=deltask&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -756,8 +712,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) // Defaut print "<td class=\"center\">"; - if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") - { + if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; @@ -767,8 +722,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; @@ -780,8 +734,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) // Preview print '<td class="center">'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -818,8 +771,7 @@ print '<td width="80">&nbsp;</td></tr>'."\n"; print '<tr class="oddeven">'; print '<td width="80%">'.$langs->trans("UseSearchToSelectProject").'</td>'; -if (!$conf->use_javascript_ajax) -{ +if (!$conf->use_javascript_ajax) { print '<td class="nowrap right" colspan="2">'; print $langs->trans("NotAvailableWhenAjaxDisabled"); print "</td>"; diff --git a/htdocs/projet/admin/project_extrafields.php b/htdocs/projet/admin/project_extrafields.php index 6c92e6d66c9..e011b1a02c3 100644 --- a/htdocs/projet/admin/project_extrafields.php +++ b/htdocs/projet/admin/project_extrafields.php @@ -38,13 +38,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'projet'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -77,8 +81,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; print "</div>"; @@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "<br>"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -104,8 +106,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/projet/admin/project_task_extrafields.php b/htdocs/projet/admin/project_task_extrafields.php index 9f7efbb7096..5222706d7d0 100644 --- a/htdocs/projet/admin/project_task_extrafields.php +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -39,13 +39,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'projet_task'; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -77,8 +81,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '<div class="tabsAction">'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; print "</div>"; @@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "<br>"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -104,8 +106,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "<br>"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/projet/admin/website.php b/htdocs/projet/admin/website.php index e84cceb68a8..04acbaa44aa 100644 --- a/htdocs/projet/admin/website.php +++ b/htdocs/projet/admin/website.php @@ -35,7 +35,9 @@ $langs->loadLangs(array("admin", "members")); $action = GETPOST('action', 'aZ09'); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -43,8 +45,11 @@ if (!$user->admin) accessforbidden(); */ if ($action == 'setPROJECT_ENABLE_PUBLIC') { - if (GETPOST('value')) dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity); - else dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity); + if (GETPOST('value')) { + dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity); + } else { + dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity); + } } if ($action == 'update') { @@ -52,9 +57,11 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 0036ae64353..74d9236d26d 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -23,13 +23,27 @@ * \brief File to return Ajax response on product 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 (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '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'); +} +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} require '../../main.inc.php'; @@ -49,7 +63,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; top_httphead(); -if (empty($htmlname) && !GETPOST('mode', 'aZ09')) return; +if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { + return; +} // Mode to get list of projects if (!GETPOST('mode', 'aZ09') || GETPOST('mode', 'aZ09') != 'gettasks') { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 5370dcfa8f9..e83a4c86a10 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -52,7 +52,9 @@ $status = GETPOST('status', 'int'); $opp_status = GETPOST('opp_status', 'int'); $opp_percent = price2num(GETPOST('opp_percent', 'alpha')); -if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !$_POST["cancel"])) accessforbidden(); +if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !$_POST["cancel"])) { + accessforbidden(); +} $mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects @@ -65,12 +67,13 @@ $extrafields = new ExtraFields($db); // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref. -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $id = $object->id; } } @@ -93,18 +96,16 @@ $date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('proj $parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if ($cancel) - { - if (GETPOST("comefromclone") == 1) - { + if ($cancel) { + if (GETPOST("comefromclone") == 1) { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { header("Location: index.php"); exit; } else { @@ -112,8 +113,7 @@ if (empty($reshook)) setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors'); } } - if ($backtopage) - { + if ($backtopage) { header("Location: ".$backtopage); exit; } @@ -121,34 +121,28 @@ if (empty($reshook)) $action = ''; } - if ($action == 'add' && $user->rights->projet->creer) - { + if ($action == 'add' && $user->rights->projet->creer) { $error = 0; - if (!GETPOST('ref')) - { + if (!GETPOST('ref')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); $error++; } - if (!GETPOST('title')) - { + if (!GETPOST('title')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors'); $error++; } - if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) - { + if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) { $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } // Create with status validated immediatly - if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) - { + if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) { $status = Project::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $error = 0; $db->begin(); @@ -173,16 +167,16 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } $result = $object->create($user); - if (!$error && $result > 0) - { + if (!$error && $result > 0) { // Add myself as project leader $typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error. $result = $object->add_contact($user->id, $typeofcontact, 'internal'); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -192,8 +186,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (!$error && !empty($object->id) > 0) - { + if (!$error && !empty($object->id) > 0) { // Category association $categories = GETPOST('categories', 'array'); $result = $object->setCategories($categories); @@ -204,12 +197,10 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->commit(); - if (!empty($backtopage)) - { + if (!empty($backtopage)) { $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation $backtopage = $backtopage.'&projectid='.$object->id; // Old method header("Location: ".$backtopage); @@ -228,18 +219,15 @@ if (empty($reshook)) } } - if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) - { + if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) { $error = 0; - if (empty($ref)) - { + if (empty($ref)) { $error++; //$_GET["id"]=$_POST["id"]; // We return on the project card setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (empty($_POST["title"])) - { + if (empty($_POST["title"])) { $error++; //$_GET["id"]=$_POST["id"]; // We return on the project card setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors'); @@ -247,8 +235,7 @@ if (empty($reshook)) $db->begin(); - if (!$error) - { + if (!$error) { $object->oldcopy = clone $object; $old_start_date = $object->date_start; @@ -261,10 +248,18 @@ if (empty($reshook)) $object->public = GETPOST('public', 'alpha'); $object->date_start = (!GETPOST('projectstart')) ? '' : $date_start; $object->date_end = (!GETPOST('projectend')) ? '' : $date_end; - if (GETPOSTISSET('opp_amount')) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); - if (GETPOSTISSET('budget_amount')) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); - if (GETPOSTISSET('opp_status')) $object->opp_status = $opp_status; - if (GETPOSTISSET('opp_percent')) $object->opp_percent = $opp_percent; + if (GETPOSTISSET('opp_amount')) { + $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); + } + if (GETPOSTISSET('budget_amount')) { + $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); + } + if (GETPOSTISSET('opp_status')) { + $object->opp_status = $opp_status; + } + if (GETPOSTISSET('opp_percent')) { + $object->opp_percent = $opp_percent; + } $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); @@ -272,42 +267,40 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if ($object->opp_amount && ($object->opp_status <= 0)) - { - $error++; + if ($object->opp_amount && ($object->opp_status <= 0)) { + $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { $error++; - if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); - else setEventMessages($object->error, $object->errors, 'errors'); + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { // Category association $categories = GETPOST('categories', 'array'); $result = $object->setCategories($categories); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - if (!$error) - { - if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) - { + if (!$error) { + if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) { $result = $object->shiftTaskDate($old_start_date); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($langs->trans("ErrorShiftTaskDate").':'.$object->error, $object->errors, 'errors'); } @@ -315,101 +308,92 @@ if (empty($reshook)) } // Check if we must change status - if (GETPOST('closeproject')) - { + if (GETPOST('closeproject')) { $resclose = $object->setClose($user); - if ($resclose < 0) - { + if ($resclose < 0) { $error++; setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors'); } } - if ($error) - { + if ($error) { $db->rollback(); $action = 'edit'; } else { $db->commit(); - if (GETPOST('socid', 'int') > 0) $object->fetch_thirdparty(GETPOST('socid', 'int')); - else unset($object->thirdparty); + if (GETPOST('socid', 'int') > 0) { + $object->fetch_thirdparty(GETPOST('socid', 'int')); + } else { + unset($object->thirdparty); + } } } // Build doc - if ($action == 'builddoc' && $user->rights->projet->creer) - { + if ($action == 'builddoc' && $user->rights->projet->creer) { // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); + if (GETPOST('model')) { + $object->setDocModel($user, GETPOST('model', 'alpha')); + } $outputlangs = $langs; - if (GETPOST('lang_id', 'aZ09')) - { + if (GETPOST('lang_id', 'aZ09')) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } $result = $object->generateDocument($object->model_pdf, $outputlangs); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } // Delete file in doc form - if ($action == 'remove_file' && $user->rights->projet->creer) - { - if ($object->id > 0) - { + if ($action == 'remove_file' && $user->rights->projet->creer) { + if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $conf->projet->dir_output; $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) + if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + } $action = ''; } } - if ($action == 'confirm_validate' && $confirm == 'yes') - { + if ($action == 'confirm_validate' && $confirm == 'yes') { $result = $object->setValid($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_close' && $confirm == 'yes') - { + if ($action == 'confirm_close' && $confirm == 'yes') { $result = $object->setClose($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_reopen' && $confirm == 'yes') - { + if ($action == 'confirm_reopen' && $confirm == 'yes') { $result = $object->setValid($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) - { + if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { $object->fetch($id); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: list.php?restore_lastsearch_values=1"); exit; @@ -419,8 +403,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') - { + if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; @@ -430,8 +413,7 @@ if (empty($reshook)) $clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0; $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { // Load new object @@ -464,7 +446,9 @@ $formproject = new FormProjets($db); $userstatic = new User($db); $title = $langs->trans("Project").' - '.$object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) { + $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url); @@ -480,14 +464,15 @@ if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only $titlenew = $langs->trans("NewLead"); } -if ($action == 'create' && $user->rights->projet->creer) -{ +if ($action == 'create' && $user->rights->projet->creer) { /* - * Create - */ + * Create + */ $thirdparty = new Societe($db); - if ($socid > 0) $thirdparty->fetch($socid); + if ($socid > 0) { + $thirdparty->fetch($socid); + } print load_fiche_titre($titlenew, '', 'project'); @@ -506,26 +491,25 @@ if ($action == 'create' && $user->rights->projet->creer) // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = $modele; break; } } - if ($filefound) - { + if ($filefound) { $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; $defaultref = $modProject->getNextValue($thirdparty, $object); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + if (is_numeric($defaultref) && $defaultref <= 0) { + $defaultref = ''; + } // Ref $suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref); @@ -560,23 +544,20 @@ if ($action == 'create' && $user->rights->projet->creer) print '</script>'; print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ' checked="checked"').'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>'; print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '').'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>'; print '<br>'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print '<input type="checkbox" name="usage_organize_event"'.(GETPOST('usage_organize_event', 'alpha')!=''?' checked="checked"':'').'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -586,28 +567,31 @@ if ($action == 'create' && $user->rights->projet->creer) print '</tr>'; // Thirdparty - if ($conf->societe->enabled) - { + if ($conf->societe->enabled) { print '<tr><td>'; print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">'); print $langs->trans("ThirdParty"); print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>'); print '</td><td class="maxwidthonsmartphone">'; $filteronlist = ''; - if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); - if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) - { + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) { + $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + } + $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); + if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); - } else print $text; - if (!GETPOSTISSET('backtopage')) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>'; + } else { + print $text; + } + if (!GETPOSTISSET('backtopage')) { + print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>'; + } print '</td></tr>'; } // Status - if ($status != '') - { + if ($status != '') { print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<input type="hidden" name="status" value="'.$status.'">'; print $object->LibStatut($status, 4); @@ -617,8 +601,12 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '<tr><td>'.$langs->trans("Visibility").'</td><td class="maxwidthonsmartphone">'; $array = array(); - if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); - if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); + if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) { + $array[0] = $langs->trans("PrivateProject"); + } + if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) { + $array[1] = $langs->trans("SharedProject"); + } print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); print '</td></tr>'; @@ -632,8 +620,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0); print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityStatus").'</td>'; print '<td class="maxwidthonsmartphone">'; @@ -678,8 +665,7 @@ if ($action == 'create' && $user->rights->projet->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'create'); } @@ -689,8 +675,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '<div class="center">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { print ' &nbsp; &nbsp; '; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; } else { @@ -731,11 +716,10 @@ if ($action == 'create' && $user->rights->projet->creer) }); }); </script>'; -} elseif ($object->id > 0) -{ +} elseif ($object->id > 0) { /* - * Show or edit - */ + * Show or edit + */ $res = $object->fetch_optionals(); @@ -747,34 +731,31 @@ if ($action == 'create' && $user->rights->projet->creer) // Confirmation validation - if ($action == 'validate') - { + if ($action == 'validate') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate', '', 0, 1); } // Confirmation close - if ($action == 'close') - { + if ($action == 'close') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloseAProject"), $langs->trans("ConfirmCloseAProject"), "confirm_close", '', '', 1); } // Confirmation reopen - if ($action == 'reopen') - { + if ($action == 'reopen') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ReOpenAProject"), $langs->trans("ConfirmReOpenAProject"), "confirm_reopen", '', '', 1); } // Confirmation delete - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans("ConfirmDeleteAProject"); $task = new Task($db); $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0); $nboftask = count($taskarray); - if ($nboftask) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + if ($nboftask) { + $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1); } // Clone confirmation - if ($action == 'clone') - { + if ($action == 'clone') { $formquestion = array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), @@ -798,8 +779,7 @@ if ($action == 'create' && $user->rights->projet->creer) $head = project_prepare_head($object); - if ($action == 'edit' && $userWrite > 0) - { + if ($action == 'edit' && $userWrite > 0) { print dol_get_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); print '<table class="border centpercent">'; @@ -818,8 +798,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Status print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>'; print '<select class="flat" name="status">'; - foreach ($object->statuts_short as $key => $val) - { + foreach ($object->statuts_short as $key => $val) { print '<option value="'.$key.'"'.((GETPOSTISSET('status') ?GETPOST('status') : $object->statut) == $key ? ' selected="selected"' : '').'>'.$langs->trans($val).'</option>'; } print '</select>'; @@ -830,8 +809,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); @@ -850,22 +828,19 @@ if ($action == 'create' && $user->rights->projet->creer) print '</script>'; print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '<br>'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print '<input type="checkbox" name="usage_organize_event"'.(GETPOST('usage_organize_event', 'alpha')!=''?' checked="checked"':'').'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -873,34 +848,39 @@ if ($action == 'create' && $user->rights->projet->creer) print '</td></tr>'; // Thirdparty - if ($conf->societe->enabled) - { + if ($conf->societe->enabled) { print '<tr><td>'; print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">'); print $langs->trans("ThirdParty"); print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>'); print '</td><td>'; $filteronlist = ''; - if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) { + $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + } $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); - if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) - { + if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); - } else print $text; + } else { + print $text; + } print '</td></tr>'; } // Visibility print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; $array = array(); - if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); - if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); + if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) { + $array[0] = $langs->trans("PrivateProject"); + } + if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) { + $array[1] = $langs->trans("SharedProject"); + } print $form->selectarray('public', $array, $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $classfortr = ($object->usage_opportunity ? '' : ' hideobject'); // Opportunity status print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityStatus").'</td>'; @@ -930,7 +910,9 @@ if ($action == 'create' && $user->rights->projet->creer) print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print ' &nbsp; &nbsp; <input type="checkbox" class="valignmiddle" name="reportdate" value="yes" '; - if ($comefromclone) {print ' checked '; } + if ($comefromclone) { + print ' checked '; + } print '/> '.$langs->trans("ProjectReportDate"); print '</td></tr>'; @@ -952,8 +934,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '</td></tr>'; // Tags-Categories - if ($conf->categorie->enabled) - { + if ($conf->categorie->enabled) { print '<tr><td>'.$langs->trans("Categories").'</td><td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -969,8 +950,7 @@ if ($action == 'create' && $user->rights->projet->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -987,15 +967,13 @@ if ($action == 'create' && $user->rights->projet->creer) $morehtmlref .= dol_escape_htmltag($object->title); // Thirdparty $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '; - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -1014,30 +992,26 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '<br>'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -1046,35 +1020,45 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td></tr>'; // Opportunity percent print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, 0, $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($object->opp_percent, 0, $langs, 1, 0).' %'; + } print '</td></tr>'; // Opportunity Amount print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; /*if ($object->opp_status) - { - print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); - }*/ - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($object->opp_amount, '')) { + print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + } print '</td></tr>'; // Opportunity Weighted Amount print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>'; - if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) { + print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + } print '</td></tr>'; } @@ -1085,12 +1069,16 @@ if ($action == 'create' && $user->rights->projet->creer) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -1129,8 +1117,7 @@ if ($action == 'create' && $user->rights->projet->creer) print dol_get_fiche_end(); - if ($action == 'edit' && $userWrite > 0) - { + if ($action == 'edit' && $userWrite > 0) { print '<div class="center">'; print '<input name="update" class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp; &nbsp; &nbsp;'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; @@ -1140,11 +1127,12 @@ if ($action == 'create' && $user->rights->projet->creer) print '</form>'; // Change probability from status - if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. $defaultcheckedwhenoppclose = 1; - if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0; + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + $defaultcheckedwhenoppclose = 0; + } print '<!-- Javascript to manage opportunity status change -->'; print '<script type="text/javascript" language="javascript"> @@ -1203,16 +1191,14 @@ if ($action == 'create' && $user->rights->projet->creer) } /* - * Actions Buttons - */ + * Actions Buttons + */ print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { - if ($action != "edit" && $action != 'presend') - { + if (empty($reshook)) { + if ($action != "edit" && $action != 'presend') { // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on @@ -1223,17 +1209,14 @@ if ($action == 'create' && $user->rights->projet->creer) // Send if (empty($user->socid)) { - if ($object->statut != Project::STATUS_CLOSED) - { + if ($object->statut != Project::STATUS_CLOSED) { print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'; } } // Modify - if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) - { - if ($userWrite > 0) - { + if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { + if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>'; @@ -1241,10 +1224,8 @@ if ($action == 'create' && $user->rights->projet->creer) } // Validate - if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) - { - if ($userWrite > 0) - { + if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Validate').'</a>'; @@ -1252,10 +1233,8 @@ if ($action == 'create' && $user->rights->projet->creer) } // Close - if ($object->statut == Project::STATUS_VALIDATED && $user->rights->projet->creer) - { - if ($userWrite > 0) - { + if ($object->statut == Project::STATUS_VALIDATED && $user->rights->projet->creer) { + if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=close">'.$langs->trans("Close").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a>'; @@ -1263,10 +1242,8 @@ if ($action == 'create' && $user->rights->projet->creer) } // Reopen - if ($object->statut == Project::STATUS_CLOSED && $user->rights->projet->creer) - { - if ($userWrite > 0) - { + if ($object->statut == Project::STATUS_CLOSED && $user->rights->projet->creer) { + if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>'; @@ -1274,65 +1251,52 @@ if ($action == 'create' && $user->rights->projet->creer) } // Add button to create objects from project - if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) - { - if (!empty($conf->propal->enabled) && $user->rights->propal->creer) - { + if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { + if (!empty($conf->propal->enabled) && $user->rights->propal->creer) { $langs->load("propal"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddProp").'</a>'; } - if (!empty($conf->commande->enabled) && $user->rights->commande->creer) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->creer) { $langs->load("orders"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateOrder").'</a>'; } - if (!empty($conf->facture->enabled) && $user->rights->facture->creer) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->creer) { $langs->load("bills"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; } - if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) - { + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierProposal").'</a>'; } - if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer) - { + if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer) { $langs->load("suppliers"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierOrder").'</a>'; } - if (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer) - { + if (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer) { $langs->load("suppliers"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierInvoice").'</a>'; } - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) - { + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { $langs->load("interventions"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddIntervention").'</a>'; } - if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) - { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) { $langs->load("contracts"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddContract").'</a>'; } - if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) - { + if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) { $langs->load("trips"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddTrip").'</a>'; } - if (!empty($conf->don->enabled) && $user->rights->don->creer) - { + if (!empty($conf->don->enabled) && $user->rights->don->creer) { $langs->load("donations"); print '<a class="butAction" href="'.DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddDonation").'</a>'; } } // Clone - if ($user->rights->projet->creer) - { - if ($userWrite > 0) - { + if ($user->rights->projet->creer) { + if ($userWrite > 0) { print '<a class="butAction" href="card.php?id='.$object->id.'&action=clone">'.$langs->trans('ToClone').'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ToClone').'</a>'; @@ -1340,10 +1304,8 @@ if ($action == 'create' && $user->rights->projet->creer) } // Delete - if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) - { - if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) - { + if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { + if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { print '<a class="butActionDelete" href="card.php?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans("Delete").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a>'; @@ -1358,14 +1320,13 @@ if ($action == 'create' && $user->rights->projet->creer) $action = 'presend'; } - if ($action != 'presend') - { + if ($action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre /* - * Documents generes - */ + * Documents generes + */ $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index c8ca952f9ed..c650512c5dd 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -33,7 +33,7 @@ class Projects extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'ref', 'title' ); @@ -110,23 +110,34 @@ class Projects 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) + 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."projet as t"; if ($category > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_project as c"; } - 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('project').')'; - 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 + 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) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Select projects of given category @@ -134,10 +145,8 @@ class Projects extends DolibarrApi $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_project = t.rowid "; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -157,8 +166,7 @@ class Projects extends DolibarrApi dol_syslog("API Rest request"); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; @@ -197,12 +205,12 @@ class Projects extends DolibarrApi $this->project->$field = $value; } /*if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->project->lines = $lines; - }*/ + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->project->lines = $lines; + }*/ if ($this->project->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating project", array_merge(array($this->project->error), $this->project->errors)); } @@ -236,14 +244,11 @@ class Projects extends DolibarrApi } $this->project->getLinesArray(DolibarrApiAccess::$user); $result = array(); - foreach ($this->project->lines as $line) // $line is a task - { - if ($includetimespent == 1) - { + foreach ($this->project->lines as $line) { // $line is a task + if ($includetimespent == 1) { $timespent = $line->getSummaryOfTimeSpent(0); } - if ($includetimespent == 1) - { + if ($includetimespent == 1) { // TODO // Add class for timespent records and loop and fill $line->lines with records of timespent } @@ -283,8 +288,7 @@ class Projects extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); $userp = DolibarrApiAccess::$user; - if ($userid > 0) - { + if ($userid > 0) { $userp = new User($this->db); $userp->fetch($userid); } @@ -308,56 +312,56 @@ class Projects extends DolibarrApi * @return int */ /* - public function postLine($id, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->projet->creer) { - throw new RestException(401); - } + public function postLine($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } - $result = $this->project->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Project not found'); - } + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->project->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, - 'HT', - 0, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->rang, - $request_data->special_code, - $fk_parent_line, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->array_options, - $request_data->fk_unit, - $this->element, - $request_data->id - ); + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); - if ($updateRes > 0) { - return $updateRes; + if ($updateRes > 0) { + return $updateRes; - } - return false; - } - */ + } + return false; + } + */ /** * Update a task to given project @@ -371,52 +375,52 @@ class Projects extends DolibarrApi * @return object */ /* - public function putLine($id, $lineid, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->projet->creer) { - throw new RestException(401); - } + public function putLine($id, $lineid, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } - $result = $this->project->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Project not found'); - } + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->project->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->fk_unit - ); + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; - }*/ + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + }*/ @@ -443,12 +447,13 @@ class Projects extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->project->$field = $value; } - if ($this->project->update(DolibarrApiAccess::$user) >= 0) - { + if ($this->project->update(DolibarrApiAccess::$user) >= 0) { return $this->get($id); } else { throw new RestException(500, $this->project->error); @@ -600,8 +605,9 @@ class Projects extends DolibarrApi { $object = array(); foreach (self::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $object[$field] = $data[$field]; } return $object; diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index e7bf2c67ce8..518b3576e34 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -33,7 +33,7 @@ class Tasks extends DolibarrApi /** * @var array $FIELDS Mandatory fields, checked when create and update object */ - static $FIELDS = array( + public static $FIELDS = array( 'ref', 'label', 'fk_project' @@ -80,12 +80,10 @@ class Tasks extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if ($includetimespent == 1) - { + if ($includetimespent == 1) { $timespent = $this->task->getSummaryOfTimeSpent(0); } - if ($includetimespent == 1) - { + if ($includetimespent == 1) { // TODO // Add class for timespent records and loop and fill $line->lines with records of timespent } @@ -118,28 +116,37 @@ class Tasks 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) + 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."projet_task 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('project').')'; - 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 + 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) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -148,8 +155,7 @@ class Tasks extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -160,13 +166,11 @@ class Tasks extends DolibarrApi dol_syslog("API Rest request"); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); $i = 0; - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $task_static = new Task($this->db); if ($task_static->fetch($obj->rowid)) { @@ -201,12 +205,12 @@ class Tasks extends DolibarrApi $this->task->$field = $value; } /*if (isset($request_data["lines"])) { - $lines = array(); - foreach ($request_data["lines"] as $line) { - array_push($lines, (object) $line); - } - $this->project->lines = $lines; - }*/ + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->project->lines = $lines; + }*/ if ($this->task->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating task", array_merge(array($this->task->error), $this->task->errors)); } @@ -223,38 +227,38 @@ class Tasks extends DolibarrApi // * @url GET {id}/tasks // */ /* - public function getLines($id, $includetimespent=0) - { - if(! DolibarrApiAccess::$user->rights->projet->lire) { - throw new RestException(401); - } + public function getLines($id, $includetimespent=0) + { + if(! DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } - $result = $this->project->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Project not found'); - } + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->project->getLinesArray(DolibarrApiAccess::$user); - $result = array(); - foreach ($this->project->lines as $line) // $line is a task - { - if ($includetimespent == 1) - { - $timespent = $line->getSummaryOfTimeSpent(0); - } - if ($includetimespent == 1) - { - // TODO - // Add class for timespent records and loop and fill $line->lines with records of timespent - } - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; - } - */ + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->project->getLinesArray(DolibarrApiAccess::$user); + $result = array(); + foreach ($this->project->lines as $line) // $line is a task + { + if ($includetimespent == 1) + { + $timespent = $line->getSummaryOfTimeSpent(0); + } + if ($includetimespent == 1) + { + // TODO + // Add class for timespent records and loop and fill $line->lines with records of timespent + } + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ /** * Get roles a user is assigned to a task with @@ -284,8 +288,7 @@ class Tasks extends DolibarrApi } $usert = DolibarrApiAccess::$user; - if ($userid > 0) - { + if ($userid > 0) { $usert = new User($this->db); $usert->fetch($userid); } @@ -309,56 +312,56 @@ class Tasks extends DolibarrApi // * @return int // */ /* - public function postLine($id, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->projet->creer) { - throw new RestException(401); - } + public function postLine($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } - $result = $this->project->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Project not found'); - } + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->project->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, - 'HT', - 0, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->rang, - $request_data->special_code, - $fk_parent_line, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->array_options, - $request_data->fk_unit, - $this->element, - $request_data->id - ); + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); - if ($updateRes > 0) { - return $updateRes; + if ($updateRes > 0) { + return $updateRes; - } - return false; - } - */ + } + return false; + } + */ // /** // * Update a task to given project @@ -372,52 +375,52 @@ class Tasks extends DolibarrApi // * @return object // */ /* - public function putLine($id, $lineid, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->projet->creer) { - throw new RestException(401); - } + public function putLine($id, $lineid, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } - $result = $this->project->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Project not found'); - } + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->project->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->fk_unit - ); + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; - }*/ + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + }*/ /** @@ -443,12 +446,13 @@ class Tasks extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->task->$field = $value; } - if ($this->task->update(DolibarrApiAccess::$user) > 0) - { + if ($this->task->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { throw new RestException(500, $this->task->error); @@ -519,7 +523,9 @@ class Tasks extends DolibarrApi } $uid = $user_id; - if (empty($uid)) $uid = DolibarrApiAccess::$user->id; + if (empty($uid)) { + $uid = DolibarrApiAccess::$user->id; + } $newdate = dol_stringtotime($date, 1); $this->task->timespent_date = $newdate; @@ -607,8 +613,9 @@ class Tasks extends DolibarrApi { $object = array(); foreach (self::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $object[$field] = $data[$field]; } return $object; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d693bb94468..f28eccf3982 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -245,7 +245,9 @@ class Project extends CommonObject global $conf; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + $this->fields['rowid']['visible'] = 0; + } if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $this->fields['fk_opp_status']['enabled'] = 0; @@ -289,14 +291,12 @@ class Project extends CommonObject $this->note_public = dol_substr($this->note_public, 0, 65535); // Check parameters - if (!trim($this->ref)) - { + if (!trim($this->ref)) { $this->error = 'ErrorFieldsRequired'; dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); return -1; } - if (!empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && !($this->socid > 0)) - { + if (!empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && !($this->socid > 0)) { $this->error = 'ErrorFieldsRequired'; dol_syslog(get_class($this)."::create error -1 thirdparty not defined and option PROJECT_THIRDPARTY_REQUIRED is set", LOG_ERR); return -1; @@ -363,16 +363,16 @@ class Project extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet"); $ret = $this->id; - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('PROJECT_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } else { @@ -384,20 +384,19 @@ class Project extends CommonObject // Update extrafield if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) - { + if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { $res = $this->setValid($user); - if ($res < 0) $error++; + if ($res < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $this->db->commit(); return $ret; } else { @@ -422,10 +421,13 @@ class Project extends CommonObject // Clean parameters $this->title = trim($this->title); $this->description = trim($this->description); - if ($this->opp_amount < 0) $this->opp_amount = ''; - if ($this->opp_percent < 0) $this->opp_percent = ''; - if ($this->date_end && $this->date_end < $this->date_start) - { + if ($this->opp_amount < 0) { + $this->opp_amount = ''; + } + if ($this->opp_percent < 0) { + $this->opp_percent = ''; + } + if ($this->date_end && $this->date_end < $this->date_start) { $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); $this->errors[] = $this->error; $this->db->rollback(); @@ -433,8 +435,7 @@ class Project extends CommonObject return -3; } - if (dol_strlen(trim($this->ref)) > 0) - { + if (dol_strlen(trim($this->ref)) > 0) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet SET"; @@ -466,39 +467,33 @@ class Project extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Update extrafield - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('PROJECT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) - { + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory - if ($conf->projet->dir_output) - { + if ($conf->projet->dir_output) { $olddir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); $newdir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->ref); - if (file_exists($olddir)) - { + if (file_exists($olddir)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $res = @rename($olddir, $newdir); - if (!$res) - { + if (!$res) { $langs->load("errors"); $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; @@ -506,8 +501,7 @@ class Project extends CommonObject } } } - if (!$error) - { + if (!$error) { $this->db->commit(); $result = 1; } else { @@ -518,8 +512,7 @@ class Project extends CommonObject $this->error = $this->db->lasterror(); $this->errors[] = $this->error; $this->db->rollback(); - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $result = -4; } else { $result = -2; @@ -547,15 +540,16 @@ class Project extends CommonObject { global $conf; - if (empty($id) && empty($ref)) return -1; + if (empty($id) && empty($ref)) { + return -1; + } $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; - if (!empty($id)) - { + if (!empty($id)) { $sql .= " WHERE rowid = ".$id; } else { $sql .= " WHERE entity IN (".getEntity('project').")"; @@ -570,12 +564,10 @@ class Project extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows) - { + if ($num_rows) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -653,27 +645,23 @@ class Project extends CommonObject $elements = array(); - if ($this->id <= 0) return $elements; + if ($this->id <= 0) { + return $elements; + } $ids = $this->id; - if ($type == 'agenda') - { + if ($type == 'agenda') { $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project IN (".$ids.") AND entity IN (".getEntity('agenda').")"; - } elseif ($type == 'expensereport') - { + } elseif ($type == 'expensereport') { $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$ids.")"; - } elseif ($type == 'project_task') - { + } elseif ($type == 'project_task') { $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$ids.")"; - } elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user - { + } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$ids.")"; - } elseif ($type == 'stock_mouvement') - { + } elseif ($type == 'stock_mouvement') { $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1"; - } elseif ($type == 'loan') - { + } elseif ($type == 'loan') { $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$ids.")"; } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")"; @@ -681,19 +669,25 @@ class Project extends CommonObject if ($dates > 0 && $type == 'loan') { $sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)"; - } elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table - { - if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; - if (empty($datefieldname)) return 'Error this object has no date field defined'; + } elseif ($dates > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table + if (empty($datefieldname) && !empty($this->table_element_date)) { + $datefieldname = $this->table_element_date; + } + if (empty($datefieldname)) { + return 'Error this object has no date field defined'; + } $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0 && $type == 'loan') { $sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)"; - } elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table - { - if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; - if (empty($datefieldname)) return 'Error this object has no date field defined'; + } elseif ($datee > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table + if (empty($datefieldname) && !empty($this->table_element_date)) { + $datefieldname = $this->table_element_date; + } + if (empty($datefieldname)) { + return 'Error this object has no date field defined'; + } $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } @@ -707,22 +701,24 @@ class Project extends CommonObject 'fk_projet' => $projectkey ); $reshook = $hookmanager->executeHooks('getElementList', $parameters, $object, $action); - if ($reshook > 0) $sql = $hookmanager->resPrint; - else $sql .= $hookmanager->resPrint; + if ($reshook > 0) { + $sql = $hookmanager->resPrint; + } else { + $sql .= $hookmanager->resPrint; + } - if (!$sql) return -1; + if (!$sql) { + return -1; + } //print $sql; dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $nump = $this->db->num_rows($result); - if ($nump) - { + if ($nump) { $i = 0; - while ($i < $nump) - { + while ($i < $nump) { $obj = $this->db->fetch_object($result); $elements[$i] = $obj->rowid.(empty($obj->fk_user) ? '' : '_'.$obj->fk_user); @@ -755,12 +751,10 @@ class Project extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); - if ($res < 0) - { + if ($res < 0) { $this->error = 'ErrorFailToDeleteLinkedContact'; //$error++; $this->db->rollback(); @@ -775,12 +769,10 @@ class Project extends CommonObject 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet', 'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project' ); - foreach ($listoftables as $key => $value) - { + foreach ($listoftables as $key => $value) { $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; break; @@ -804,14 +796,15 @@ class Project extends CommonObject // Delete tasks $ret = $this->deleteTasks($user); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } // Delete all child tables if (!$error) { $elements = array('categorie_project'); // elements to delete. TODO Make goodway to delete - foreach ($elements as $table) - { + foreach ($elements as $table) { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE fk_project = ".$this->id; @@ -825,28 +818,24 @@ class Project extends CommonObject } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_extrafields"; $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; } } // Delete project - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet"; $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")); $error++; } @@ -868,8 +857,7 @@ class Project extends CommonObject } } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('PROJECT_DELETE', $user); @@ -880,13 +868,11 @@ class Project extends CommonObject } } - if (empty($error)) - { + if (empty($error)) { $this->db->commit(); return 1; } else { - 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); } @@ -906,7 +892,9 @@ class Project extends CommonObject */ public function getElementCount($type, $tablename, $projectkey = 'fk_projet') { - if ($this->id <= 0) return 0; + if ($this->id <= 0) { + return 0; + } if ($type == 'agenda') { $sql = "SELECT COUNT(id) as nb FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project = ".$this->id." AND entity IN (".getEntity('agenda').")"; @@ -926,7 +914,9 @@ class Project extends CommonObject $result = $this->db->query($sql); - if (!$result) return 0; + if (!$result) { + return 0; + } $obj = $this->db->fetch_object($result); @@ -945,15 +935,12 @@ class Project extends CommonObject { $countTasks = count($this->lines); $deleted = false; - if ($countTasks) - { - foreach ($this->lines as $task) - { + if ($countTasks) { + foreach ($this->lines as $task) { if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) $deleted = true; $ret = $task->delete($user); - if ($ret <= 0) - { + if ($ret <= 0) { $this->errors[] = $this->db->lasterror(); return -1; } @@ -961,9 +948,10 @@ class Project extends CommonObject } } $this->getLinesArray($user); - if ($deleted && count($this->lines) < $countTasks) - { - if (count($this->lines)) $this->deleteTasks($this->lines); + if ($deleted && count($this->lines) < $countTasks) { + if (count($this->lines)) { + $this->deleteTasks($this->lines); + } } return 1; @@ -982,11 +970,9 @@ class Project extends CommonObject $error = 0; - if ($this->statut != 1) - { + if ($this->statut != 1) { // Check parameters - if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) - { + if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) { $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); return -1; } @@ -1000,18 +986,17 @@ class Project extends CommonObject dol_syslog(get_class($this)."::setValid", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger - if (empty($notrigger)) - { + if (empty($notrigger)) { $result = $this->call_trigger('PROJECT_VALIDATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->statut = 1; $this->db->commit(); return 1; @@ -1043,8 +1028,7 @@ class Project extends CommonObject $error = 0; - if ($this->statut != self::STATUS_CLOSED) - { + if ($this->statut != self::STATUS_CLOSED) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; @@ -1052,22 +1036,21 @@ class Project extends CommonObject $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' } dol_syslog(get_class($this)."::setClose", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // Call trigger $result = $this->call_trigger('PROJECT_CLOSE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->statut = 2; $this->db->commit(); return 1; @@ -1142,7 +1125,9 @@ class Project extends CommonObject { global $conf, $langs, $user, $hookmanager; - 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 = ''; if (!empty($conf->global->PROJECT_OPEN_ALWAYS_ON_TAB)) { @@ -1150,7 +1135,9 @@ class Project extends CommonObject } $label = ''; - if ($option != 'nolink') $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Project").'</u>'; + if ($option != 'nolink') { + $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Project").'</u>'; + } if (isset($this->status)) { $label .= ' '.$this->getLibStatut(5); } @@ -1168,60 +1155,73 @@ class Project extends CommonObject if (!empty($this->datee)) { $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('DateEnd').': </b>'.dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto } - if ($moreinpopup) $label .= '<br>'.$moreinpopup; + if ($moreinpopup) { + $label .= '<br>'.$moreinpopup; + } $url = ''; - if ($option != 'nolink') - { + if ($option != 'nolink') { if (preg_match('/\.php$/', $option)) { $url = dol_buildpath($option, 1).'?id='.$this->id; - } elseif ($option == 'task') - { + } elseif ($option == 'task') { $url = DOL_URL_ROOT.'/projet/tasks.php?id='.$this->id; - } elseif ($option == 'preview') - { + } elseif ($option == 'preview') { $url = DOL_URL_ROOT.'/projet/element.php?id='.$this->id; } else { $url = DOL_URL_ROOT.'/projet/card.php?id='.$this->id; } // 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'; + 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 = ''; - if (empty($notooltip) && $user->rights->projet->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip) && $user->rights->projet->lire) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowProject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $picto = 'projectpub'; - if (!$this->public) $picto = 'project'; + if (!$this->public) { + $picto = 'project'; + } $linkstart = '<a href="'.$url.'"'; $linkstart .= $linkclose.'>'; $linkend = '</a>'; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($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), $picto, ($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->title) ? $sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) { + $result .= (($addlabel && $this->title) ? $sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); + } global $action; $hookmanager->initHooks(array('projectdao')); $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; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -1285,32 +1285,38 @@ class Project extends CommonObject { // To verify role of users $userAccess = 0; - if (($mode == 'read' && !empty($user->rights->projet->all->lire)) || ($mode == 'write' && !empty($user->rights->projet->all->creer)) || ($mode == 'delete' && !empty($user->rights->projet->all->supprimer))) - { + if (($mode == 'read' && !empty($user->rights->projet->all->lire)) || ($mode == 'write' && !empty($user->rights->projet->all->creer)) || ($mode == 'delete' && !empty($user->rights->projet->all->supprimer))) { $userAccess = 1; - } elseif ($this->public && (($mode == 'read' && !empty($user->rights->projet->lire)) || ($mode == 'write' && !empty($user->rights->projet->creer)) || ($mode == 'delete' && !empty($user->rights->projet->supprimer)))) - { + } elseif ($this->public && (($mode == 'read' && !empty($user->rights->projet->lire)) || ($mode == 'write' && !empty($user->rights->projet->creer)) || ($mode == 'delete' && !empty($user->rights->projet->supprimer)))) { $userAccess = 1; } else { // No access due to permission to read all projects, so we check if we are a contact of project - foreach (array('internal', 'external') as $source) - { + foreach (array('internal', 'external') as $source) { $userRole = $this->liste_contact(4, $source); $num = count($userRole); $nblinks = 0; - while ($nblinks < $num) - { - if ($source == 'internal' && $user->id == $userRole[$nblinks]['id']) // $userRole[$nblinks]['id'] is id of user (llx_user) for internal contacts - { - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; - if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; + while ($nblinks < $num) { + if ($source == 'internal' && $user->id == $userRole[$nblinks]['id']) { // $userRole[$nblinks]['id'] is id of user (llx_user) for internal contacts + if ($mode == 'read' && $user->rights->projet->lire) { + $userAccess++; + } + if ($mode == 'write' && $user->rights->projet->creer) { + $userAccess++; + } + if ($mode == 'delete' && $user->rights->projet->supprimer) { + $userAccess++; + } } - if ($source == 'external' && $user->socid > 0 && $user->socid == $userRole[$nblinks]['socid']) // $userRole[$nblinks]['id'] is id of contact (llx_socpeople) or external contacts - { - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; - if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; + if ($source == 'external' && $user->socid > 0 && $user->socid == $userRole[$nblinks]['socid']) { // $userRole[$nblinks]['id'] is id of contact (llx_socpeople) or external contacts + if ($mode == 'read' && $user->rights->projet->lire) { + $userAccess++; + } + if ($mode == 'write' && $user->rights->projet->creer) { + $userAccess++; + } + if ($mode == 'delete' && $user->rights->projet->supprimer) { + $userAccess++; + } } $nblinks++; } @@ -1344,20 +1350,19 @@ class Project extends CommonObject $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - if ($mode == 0) - { + if ($mode == 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = p.rowid"; - } elseif ($mode == 1) - { + } elseif ($mode == 1) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; - } elseif ($mode == 2) - { + } elseif ($mode == 2) { // No filter. Use this if user has permission to see all project } $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Internal users must see project he is contact to even if project linked to a third party he can't see. //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid > 0) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid > 0) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } // Get id of types of contacts for projects (This list never contains a lot of elements) $listofprojectcontacttype = array(); @@ -1365,30 +1370,29 @@ class Project extends CommonObject $sql2 .= " WHERE ctc.element = '".$this->db->escape($this->element)."'"; $sql2 .= " AND ctc.source = 'internal'"; $resql = $this->db->query($sql2); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $listofprojectcontacttype[$obj->rowid] = $obj->code; } - } else dol_print_error($this->db); - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid syntax error if not found + } else { + dol_print_error($this->db); + } + if (count($listofprojectcontacttype) == 0) { + $listofprojectcontacttype[0] = '0'; // To avoid syntax error if not found + } - if ($mode == 0) - { + if ($mode == 0) { $sql .= " AND ( p.public = 1"; $sql .= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; $sql .= " AND ec.fk_socpeople = ".$user->id.")"; $sql .= " )"; - } elseif ($mode == 1) - { + } elseif ($mode == 1) { $sql .= " AND ec.element_id = p.rowid"; $sql .= " AND ("; $sql .= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; $sql .= " AND ec.fk_socpeople = ".$user->id.")"; $sql .= " )"; - } elseif ($mode == 2) - { + } elseif ($mode == 2) { // No filter. Use this if user has permission to see all project } @@ -1396,12 +1400,10 @@ class Project extends CommonObject //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $this->db->fetch_row($resql); $projects[$row[0]] = $row[1]; $temp[] = $row[0]; @@ -1410,9 +1412,10 @@ class Project extends CommonObject $this->db->free($resql); - if ($list) - { - if (empty($temp)) return '0'; + if ($list) { + if (empty($temp)) { + return '0'; + } $result = implode(',', $temp); return $result; } @@ -1457,7 +1460,9 @@ class Project extends CommonObject // Load source object $clone_project->fetch($fromid); $clone_project->fetch_optionals(); - if ($newthirdpartyid > 0) $clone_project->socid = $newthirdpartyid; + if ($newthirdpartyid > 0) { + $clone_project->socid = $newthirdpartyid; + } $clone_project->fetch_thirdparty(); $orign_dt_start = $clone_project->date_start; @@ -1466,16 +1471,14 @@ class Project extends CommonObject $clone_project->id = 0; if ($move_date) { $clone_project->date_start = $now; - if (!(empty($clone_project->date_end))) - { + if (!(empty($clone_project->date_end))) { $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); } } $clone_project->datec = $now; - if (!$clone_note) - { + if (!$clone_note) { $clone_project->note_private = ''; $clone_project->note_public = ''; } @@ -1486,11 +1489,9 @@ class Project extends CommonObject // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/project/".$obj.'.php', 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; dol_include_once($reldir."core/modules/project/".$obj.'.php'); $modProject = new $obj; @@ -1498,7 +1499,9 @@ class Project extends CommonObject break; } } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + if (is_numeric($defaultref) && $defaultref <= 0) { + $defaultref = ''; + } $clone_project->ref = $defaultref; $clone_project->title = $langs->trans("CopyOf").' '.$clone_project->title; @@ -1507,27 +1510,23 @@ class Project extends CommonObject $result = $clone_project->create($user, $notrigger); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error .= $clone_project->error; $error++; } - if (!$error) - { + if (!$error) { //Get the new project id $clone_project_id = $clone_project->id; //Note Update - if (!$clone_note) - { + if (!$clone_note) { $clone_project->note_private = ''; $clone_project->note_public = ''; } else { $this->db->begin(); $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES | ENT_HTML5), '_public'); - if ($res < 0) - { + if ($res < 0) { $this->error .= $clone_project->error; $error++; $this->db->rollback(); @@ -1537,8 +1536,7 @@ class Project extends CommonObject $this->db->begin(); $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES | ENT_HTML5), '_private'); - if ($res < 0) - { + if ($res < 0) { $this->error .= $clone_project->error; $error++; $this->db->rollback(); @@ -1548,26 +1546,21 @@ class Project extends CommonObject } //Duplicate contact - if ($clone_contact) - { + if ($clone_contact) { $origin_project = new Project($this->db); $origin_project->fetch($fromid); - foreach (array('internal', 'external') as $source) - { + foreach (array('internal', 'external') as $source) { $tab = $origin_project->liste_contact(-1, $source); - foreach ($tab as $contacttoadd) - { + foreach ($tab as $contacttoadd) { $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'], $notrigger); - if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { - if ($clone_project->error != '') - { + if ($clone_project->error != '') { $this->error .= $clone_project->error; $error++; } @@ -1577,21 +1570,17 @@ class Project extends CommonObject } //Duplicate file - if ($clone_project_file) - { + if ($clone_project_file) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $clone_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($defaultref); $ori_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($orign_project_ref); - if (dol_mkdir($clone_project_dir) >= 0) - { + if (dol_mkdir($clone_project_dir) >= 0) { $filearray = dol_dir_list($ori_project_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - foreach ($filearray as $key => $file) - { + foreach ($filearray as $key => $file) { $rescopy = dol_copy($ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name'], 0, 1); - if (is_numeric($rescopy) && $rescopy < 0) - { + if (is_numeric($rescopy) && $rescopy < 0) { $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name']); $error++; } @@ -1603,26 +1592,25 @@ class Project extends CommonObject } //Duplicate task - if ($clone_task) - { + if ($clone_task) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); // Security check $socid = 0; - if ($user->socid > 0) $socid = $user->socid; + if ($user->socid > 0) { + $socid = $user->socid; + } $tasksarray = $taskstatic->getTasksArray(0, 0, $fromid, $socid, 0); $tab_conv_child_parent = array(); // Loop on each task, to clone it - foreach ($tasksarray as $tasktoclone) - { + foreach ($tasksarray as $tasktoclone) { $result_clone = $taskstatic->createFromClone($user, $tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); - if ($result_clone <= 0) - { + if ($result_clone <= 0) { $this->error .= $result_clone->error; $error++; } else { @@ -1631,8 +1619,7 @@ class Project extends CommonObject //manage new parent clone task id // if the current task has child we store the original task id and the equivalent clone task id - if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id, $tab_conv_child_parent)) - { + if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id, $tab_conv_child_parent)) { $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; } } @@ -1640,16 +1627,13 @@ class Project extends CommonObject //Parse all clone node to be sure to update new parent $tasksarray = $taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); - foreach ($tasksarray as $task_cloned) - { + foreach ($tasksarray as $task_cloned) { $taskstatic->fetch($task_cloned->id); - if ($taskstatic->fk_task_parent != 0) - { + if ($taskstatic->fk_task_parent != 0) { $taskstatic->fk_task_parent = $tab_conv_child_parent[$taskstatic->fk_task_parent]; } $res = $taskstatic->update($user, $notrigger); - if ($result_clone <= 0) - { + if ($result_clone <= 0) { $this->error .= $taskstatic->error; $error++; } @@ -1659,8 +1643,7 @@ class Project extends CommonObject unset($clone_project->context['createfromclone']); - if (!$error) - { + if (!$error) { $this->db->commit(); return $clone_project_id; } else { @@ -1687,22 +1670,21 @@ class Project extends CommonObject // Security check $socid = 0; - if ($user->socid > 0) $socid = $user->socid; + if ($user->socid > 0) { + $socid = $user->socid; + } $tasksarray = $taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); - foreach ($tasksarray as $tasktoshiftdate) - { + foreach ($tasksarray as $tasktoshiftdate) { $to_update = false; // Fetch only if update of date will be made - if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end))) - { + if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end))) { //dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG); $to_update = true; $task = new Task($this->db); $result = $task->fetch($tasktoshiftdate->id); - if (!$result) - { + if (!$result) { $error++; $this->error .= $task->error; } @@ -1710,29 +1692,24 @@ class Project extends CommonObject //print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit; //Calcultate new task start date with difference between old proj start date and origin task start date - if (!empty($tasktoshiftdate->date_start)) - { + if (!empty($tasktoshiftdate->date_start)) { $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); } //Calcultate new task end date with difference between origin proj end date and origin task end date - if (!empty($tasktoshiftdate->date_end)) - { + if (!empty($tasktoshiftdate->date_end)) { $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); } - if ($to_update) - { + if ($to_update) { $result = $task->update($user); - if (!$result) - { + if (!$result) { $error++; $this->error .= $task->error; } } } - if ($error != 0) - { + if ($error != 0) { return -1; } return $result; @@ -1752,8 +1729,7 @@ class Project extends CommonObject // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; - if ($tableName == "actioncomm") - { + if ($tableName == "actioncomm") { $sql .= " SET fk_project=".$this->id; $sql .= " WHERE id=".$elementSelectId; } else { @@ -1786,8 +1762,7 @@ class Project extends CommonObject // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; - if ($tableName == "actioncomm") - { + if ($tableName == "actioncomm") { $sql .= " SET fk_project=NULL"; $sql .= " WHERE id=".$elementSelectId; } else { @@ -1853,7 +1828,9 @@ class Project extends CommonObject $this->weekWorkLoad = array(); $this->weekWorkLoadPerTask = array(); - if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty'); + if (empty($datestart)) { + dol_print_error('', 'Error datestart parameter is empty'); + } $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; @@ -1861,24 +1838,25 @@ class Project extends CommonObject $sql .= " AND pt.fk_projet = ".$this->id; $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')"; - if ($taskid) $sql .= " AND ptt.fk_task=".$taskid; - if (is_numeric($userid)) $sql .= " AND ptt.fk_user=".$userid; + if ($taskid) { + $sql .= " AND ptt.fk_task=".$taskid; + } + if (is_numeric($userid)) { + $sql .= " AND ptt.fk_user=".$userid; + } //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $daylareadyfound = array(); $num = $this->db->num_rows($resql); $i = 0; // Loop on each record found, so each couple (project id, task id) - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $day = $this->db->jdate($obj->task_date); // task_date is date without hours - if (empty($daylareadyfound[$day])) - { + if (empty($daylareadyfound[$day])) { $this->weekWorkLoad[$day] = $obj->task_duration; $this->weekWorkLoadPerTask[$day][$obj->fk_task] = $obj->task_duration; } else { @@ -1913,7 +1891,9 @@ class Project extends CommonObject $this->monthWorkLoad = array(); $this->monthWorkLoadPerTask = array(); - if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty'); + if (empty($datestart)) { + dol_print_error('', 'Error datestart parameter is empty'); + } $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; @@ -1921,27 +1901,28 @@ class Project extends CommonObject $sql .= " AND pt.fk_projet = ".$this->id; $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; - if ($task_id) $sql .= " AND ptt.fk_task=".$taskid; - if (is_numeric($userid)) $sql .= " AND ptt.fk_user=".$userid; + if ($task_id) { + $sql .= " AND ptt.fk_task=".$taskid; + } + if (is_numeric($userid)) { + $sql .= " AND ptt.fk_user=".$userid; + } //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $weekalreadyfound = array(); $num = $this->db->num_rows($resql); $i = 0; // Loop on each record found, so each couple (project id, task id) - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); if (!empty($obj->task_date)) { $date = explode('-', $obj->task_date); $week_number = getWeekNumber($date[2], $date[1], $date[0]); } - if (empty($weekalreadyfound[$week_number])) - { + if (empty($weekalreadyfound[$week_number])) { $this->monthWorkLoad[$week_number] = $obj->task_duration; $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] = $obj->task_duration; } else { @@ -1977,7 +1958,9 @@ class Project extends CommonObject //$socid=$user->socid; $projectsListId = null; - if (!$user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); + if (!$user->rights->projet->all->lire) { + $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); + } $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql .= " FROM (".MAIN_DB_PREFIX."projet as p"; @@ -1987,7 +1970,9 @@ class Project extends CommonObject //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql .= " WHERE p.fk_statut = 1"; $sql .= " AND p.entity IN (".getEntity('project').')'; - if (!empty($projectsListId)) $sql .= " AND p.rowid IN (".$projectsListId.")"; + if (!empty($projectsListId)) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; + } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; // For external user, no check is done on company permission because readability is managed by public status of project and assignement. @@ -1995,21 +1980,22 @@ class Project extends CommonObject //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $project_static = new Project($this->db); $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("OpenedProjects"); $response->labelShort = $langs->trans("Opened"); - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; - else $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; + if ($user->rights->projet->all->lire) { + $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; + } else { + $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; + } $response->img = img_object('', "projectpub"); // 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)) { $response->nbtodo++; $project_static->statut = $obj->status; @@ -2064,17 +2050,14 @@ class Project extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " WHERE"; $sql .= " p.entity IN (".getEntity('project').")"; - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); $sql .= "AND p.rowid IN (".$projectsListId.")"; } $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["projects"] = $obj->nb; } $this->db->free($resql); @@ -2096,8 +2079,12 @@ class Project extends CommonObject { global $conf; - if (!($this->statut == self::STATUS_VALIDATED)) return false; - if (!$this->datee && !$this->date_end) return false; + if (!($this->statut == self::STATUS_VALIDATED)) { + return false; + } + if (!$this->datee && !$this->date_end) { + return false; + } $now = dol_now(); @@ -2119,21 +2106,17 @@ class Project extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as c'; $sql .= ' WHERE c.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index e1a19e293f0..3ec82edf366 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -85,21 +85,23 @@ class ProjectStats extends Stats $other = 0; while ($i < $num) { $row = $this->db->fetch_row($resql); - if ($i < $limit || $num == $limit) - { + if ($i < $limit || $num == $limit) { $label = (($langs->trans("OppStatus".$row[2]) != "OppStatus".$row[2]) ? $langs->trans("OppStatus".$row[2]) : $row[2]); $result[$i] = array( $label.' ('.price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency).')', $row[0] ); - } else $other += $row[1]; + } else { + $other += $row[1]; + } $i++; } - if ($num > $limit) + if ($num > $limit) { $result[$i] = array( $langs->transnoentitiesnoconv("Other"), $other ); + } $this->db->free($resql); } else { $this->error = "Error ".$this->db->lasterror(); @@ -156,25 +158,34 @@ class ProjectStats extends Stats // Get list of project id allowed to user (in a string list separated by coma) $object = new Project($this->db); $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); + if (!$user->rights->projet->all->lire) { + $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); + } $sqlwhere[] = ' t.entity IN ('.getEntity('project').')'; - if (!empty($this->userid)) + if (!empty($this->userid)) { $sqlwhere[] = ' t.fk_user_resp='.$this->userid; + } // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project - if (!empty($this->socid)) + if (!empty($this->socid)) { $sqlwhere[] = ' t.fk_soc='.$this->socid; - if (!empty($this->year) && empty($this->yearmonth)) + } + if (!empty($this->year) && empty($this->yearmonth)) { $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; - if (!empty($this->yearmonth)) + } + if (!empty($this->yearmonth)) { $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; + } - if (!empty($this->status)) + if (!empty($this->status)) { $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; + } - if (!$user->rights->projet->all->lire) $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + if (!$user->rights->projet->all->lire) { + $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + } if (count($sqlwhere) > 0) { $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere); @@ -254,13 +265,14 @@ class ProjectStats extends Stats { global $conf, $user, $langs; - if ($startyear > $endyear) return -1; + if ($startyear > $endyear) { + return -1; + } $datay = array(); // Search into cache - if (!empty($cachedelay)) - { + if (!empty($cachedelay)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; } @@ -271,11 +283,9 @@ class ProjectStats extends Stats $nowgmt = dol_now(); $foundintocache = 0; - if ($cachedelay > 0) - { + if ($cachedelay > 0) { $filedate = dol_filemtime($newpathofdestfile); - if ($filedate >= ($nowgmt - $cachedelay)) - { + if ($filedate >= ($nowgmt - $cachedelay)) { $foundintocache = 1; $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate; @@ -285,26 +295,22 @@ class ProjectStats extends Stats } // Load file into $data - if ($foundintocache) // Cache file found and is not too old - { + if ($foundintocache) { // Cache file found and is not too old dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); $data = json_decode(file_get_contents($newpathofdestfile), true); } else { $year = $startyear; - while ($year <= $endyear) - { + while ($year <= $endyear) { $datay[$year] = $this->getWeightedAmountByMonth($year, $wonlostfilter); $year++; } $data = array(); // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) - for ($i = 0; $i < 12; $i++) - { + for ($i = 0; $i < 12; $i++) { $data[$i][] = $datay[$endyear][$i][0]; // set label $year = $startyear; - while ($year <= $endyear) - { + while ($year <= $endyear) { $data[$i][] = $datay[$year][$i][1]; // set yval for x=i $year++; } @@ -312,18 +318,22 @@ class ProjectStats extends Stats } // Save cache file - if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) - { + if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) { dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); - if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); + if (!dol_is_dir($conf->user->dir_temp)) { + dol_mkdir($conf->user->dir_temp); + } $fp = fopen($newpathofdestfile, 'w'); - if ($fp) - { + if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; + if (!empty($conf->global->MAIN_UMASK)) { + $newmask = $conf->global->MAIN_UMASK; + } @chmod($newpathofdestfile, octdec($newmask)); - } else dol_syslog("Failed to write cache file", LOG_ERR); + } else { + dol_syslog("Failed to write cache file", LOG_ERR); + } $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } @@ -371,13 +381,14 @@ class ProjectStats extends Stats { global $conf, $user, $langs; - if ($startyear > $endyear) return -1; + if ($startyear > $endyear) { + return -1; + } $datay = array(); // Search into cache - if (!empty($cachedelay)) - { + if (!empty($cachedelay)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; } @@ -400,8 +411,7 @@ class ProjectStats extends Stats } // Load file into $data - if ($foundintocache) // Cache file found and is not too old - { + if ($foundintocache) { // Cache file found and is not too old dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); $data = json_decode(file_get_contents($newpathofdestfile), true); } else { @@ -426,13 +436,15 @@ class ProjectStats extends Stats // Save cache file if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) { dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); - if (!dol_is_dir($conf->user->dir_temp)) + if (!dol_is_dir($conf->user->dir_temp)) { dol_mkdir($conf->user->dir_temp); + } $fp = fopen($newpathofdestfile, 'w'); fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { $newmask = $conf->global->MAIN_UMASK; + } @chmod($newpathofdestfile, octdec($newmask)); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; @@ -483,7 +495,7 @@ class ProjectStats extends Stats $res = array(); - foreach ($res_total as $key=>$total_row) { + foreach ($res_total as $key => $total_row) { //var_dump($total_row); if (!empty($total_row[1])) { $res[$key] = array($total_row[0], (100 * $res_only_wined[$key][1]) / $total_row[1]); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 39a572e6510..586839f3c69 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -190,39 +190,36 @@ class Task extends CommonObject dol_syslog(get_class($this)."::create", 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) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Update extrafield - if (!$error) - { - if (!$error) - { + if (!$error) { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -267,13 +264,14 @@ class Task extends CommonObject $sql .= " t.note_private,"; $sql .= " t.note_public,"; $sql .= " t.rang"; - if (!empty($loadparentdata)) - { + if (!empty($loadparentdata)) { $sql .= ", t2.ref as task_parent_ref"; $sql .= ", t2.rang as task_parent_position"; } $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; - if (!empty($loadparentdata)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; + if (!empty($loadparentdata)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; + } $sql .= " WHERE "; if (!empty($ref)) { $sql .= "t.ref = '".$this->db->escape($ref)."'"; @@ -283,12 +281,10 @@ class Task extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows) - { + if ($num_rows) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -311,8 +307,7 @@ class Task extends CommonObject $this->note_public = $obj->note_public; $this->rang = $obj->rang; - if (!empty($loadparentdata)) - { + if (!empty($loadparentdata)) { $this->task_parent_ref = $obj->task_parent_ref; $this->task_parent_position = $obj->task_parent_position; } @@ -323,8 +318,7 @@ class Task extends CommonObject $this->db->free($resql); - if ($num_rows) - { + if ($num_rows) { return 1; } else { return 0; @@ -349,13 +343,27 @@ class Task extends CommonObject $error = 0; // Clean parameters - if (isset($this->fk_project)) $this->fk_project = trim($this->fk_project); - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->fk_task_parent)) $this->fk_task_parent = (int) $this->fk_task_parent; - if (isset($this->label)) $this->label = trim($this->label); - if (isset($this->description)) $this->description = trim($this->description); - if (isset($this->duration_effective)) $this->duration_effective = trim($this->duration_effective); - if (isset($this->planned_workload)) $this->planned_workload = trim($this->planned_workload); + if (isset($this->fk_project)) { + $this->fk_project = trim($this->fk_project); + } + if (isset($this->ref)) { + $this->ref = trim($this->ref); + } + if (isset($this->fk_task_parent)) { + $this->fk_task_parent = (int) $this->fk_task_parent; + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->duration_effective)) { + $this->duration_effective = trim($this->duration_effective); + } + if (isset($this->planned_workload)) { + $this->planned_workload = trim($this->planned_workload); + } // Check parameters // Put here code to add control on parameters values @@ -379,13 +387,14 @@ class Task extends CommonObject dol_syslog(get_class($this)."::update", 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(); + } // Update extrafield if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } @@ -415,33 +424,29 @@ class Task extends CommonObject } } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) - { + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory - if ($conf->projet->dir_output) - { + if ($conf->projet->dir_output) { $project = new Project($this->db); $project->fetch($this->fk_project); $olddir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->oldcopy->ref); $newdir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->ref); - if (file_exists($olddir)) - { + if (file_exists($olddir)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $res = dol_move($olddir, $newdir); - if (!$res) - { + if (!$res) { $langs->load("errors"); $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; @@ -451,10 +456,8 @@ class Task extends CommonObject } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -484,8 +487,7 @@ class Task extends CommonObject $this->db->begin(); - if ($this->hasChildren() > 0) - { + if ($this->hasChildren() > 0) { dol_syslog(get_class($this)."::delete Can't delete record as it has some sub tasks", LOG_WARNING); $this->error = 'ErrorRecordHasSubTasks'; $this->db->rollback(); @@ -493,20 +495,17 @@ class Task extends CommonObject } $objectisused = $this->isObjectUsed($this->id); - if (!empty($objectisused)) - { + if (!empty($objectisused)) { dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING); $this->error = 'ErrorRecordHasChildren'; $this->db->rollback(); return 0; } - if (!$error) - { + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); - if ($res < 0) - { + if ($res < 0) { $this->error = 'ErrorFailToDeleteLinkedContact'; //$error++; $this->db->rollback(); @@ -514,49 +513,50 @@ class Task extends CommonObject } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; $sql .= " WHERE fk_task=".$this->id; $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."projet_task_extrafields"; $sql .= " WHERE fk_object=".$this->id; $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."projet_task"; $sql .= " WHERE rowid=".$this->id; $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 (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -564,19 +564,16 @@ class Task extends CommonObject return -1 * $error; } else { //Delete associated link file - if ($conf->projet->dir_output) - { + if ($conf->projet->dir_output) { $projectstatic = new Project($this->db); $projectstatic->fetch($this->fk_project); $dir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($this->id); dol_syslog(get_class($this)."::delete dir=".$dir, LOG_DEBUG); - if (file_exists($dir)) - { + if (file_exists($dir)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $res = @dol_delete_dir_recursive($dir); - if (!$res) - { + if (!$res) { $this->error = 'ErrorFailToDeleteDir'; $this->db->rollback(); return 0; @@ -606,14 +603,17 @@ class Task extends CommonObject dol_syslog(get_class($this)."::hasChildren", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } else { $obj = $this->db->fetch_object($resql); - if ($obj) $ret = $obj->nb; + if ($obj) { + $ret = $obj->nb; + } $this->db->free($resql); } - if (!$error) - { + if (!$error) { return $ret; } else { return -1; @@ -636,14 +636,17 @@ class Task extends CommonObject dol_syslog(get_class($this)."::hasTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } else { $obj = $this->db->fetch_object($resql); - if ($obj) $ret = $obj->nb; + if ($obj) { + $ret = $obj->nb; + } $this->db->free($resql); } - if (!$error) - { + if (!$error) { return $ret; } else { return -1; @@ -667,30 +670,35 @@ class Task extends CommonObject { global $conf, $langs, $user; - 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 = img_picto('', $this->picto).' <u>'.$langs->trans("Task").'</u>'; - if (!empty($this->ref)) + if (!empty($this->ref)) { $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; - if (!empty($this->label)) + } + if (!empty($this->label)) { $label .= '<br><b>'.$langs->trans('LabelTask').':</b> '.$this->label; - if ($this->date_start || $this->date_end) - { + } + if ($this->date_start || $this->date_end) { $label .= "<br>".get_date_range($this->date_start, $this->date_end, '', $langs, 0); } $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option == 'withproject' ? '&withproject=1' : ''); // 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'; + 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 = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowTask"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -707,10 +715,16 @@ class Task extends CommonObject $picto = 'projecttask'; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($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), $picto, ($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)) : ''); + if ($withpicto != 2) { + $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + } return $result; } @@ -766,23 +780,26 @@ class Task extends CommonObject // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT "; - if ($filteronprojuser > 0 || $filterontaskuser > 0) $sql .= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task + if ($filteronprojuser > 0 || $filterontaskuser > 0) { + $sql .= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task + } $sql .= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; $sql .= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; $sql .= " t.description, "; $sql .= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; - if (!empty($extrafields->attributes['projet']['label'])) - { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); + if (!empty($extrafields->attributes['projet']['label'])) { + foreach ($extrafields->attributes['projet']['label'] as $key => $val) { + $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); + } } - if (!empty($extrafields->attributes['projet_task']['label'])) - { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); + if (!empty($extrafields->attributes['projet_task']['label'])) { + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { + $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); + } } - if ($includebilltime) - { + if ($includebilltime) { $sql .= ", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } @@ -790,55 +807,47 @@ class Task extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)"; - if ($mode == 0) - { - if ($filteronprojuser > 0) - { + if ($mode == 0) { + if ($filteronprojuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; - if ($includebilltime) - { + if ($includebilltime) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } - if ($filterontaskuser > 0) - { + if ($filterontaskuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND t.fk_projet = p.rowid"; - } elseif ($mode == 1) - { - if ($filteronprojuser > 0) - { + } elseif ($mode == 1) { + if ($filteronprojuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } - if ($filterontaskuser > 0) - { + if ($filterontaskuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; - if ($includebilltime) - { + if ($includebilltime) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; - if ($includebilltime) - { + if ($includebilltime) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; - } else return 'BadValueForParameterMode'; + } else { + return 'BadValueForParameterMode'; + } - if ($filteronprojuser > 0) - { + if ($filteronprojuser > 0) { $sql .= " AND p.rowid = ec.element_id"; $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; $sql .= " AND ctc.element = 'project'"; @@ -846,8 +855,7 @@ class Task extends CommonObject $sql .= " AND ec.statut = 4"; $sql .= " AND ctc.source = 'internal'"; } - if ($filterontaskuser > 0) - { + if ($filterontaskuser > 0) { $sql .= " AND t.fk_projet = p.rowid"; $sql .= " AND p.rowid = ec2.element_id"; $sql .= " AND ctc2.rowid = ec2.fk_c_type_contact"; @@ -856,11 +864,21 @@ class Task extends CommonObject $sql .= " AND ec2.statut = 4"; $sql .= " AND ctc2.source = 'internal'"; } - if ($socid) $sql .= " AND p.fk_soc = ".$socid; - if ($projectid) $sql .= " AND p.rowid in (".$projectid.")"; - if ($filteronproj) $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); - if ($filteronprojstatus && $filteronprojstatus != '-1') $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; - if ($morewherefilter) $sql .= $morewherefilter; + if ($socid) { + $sql .= " AND p.fk_soc = ".$socid; + } + if ($projectid) { + $sql .= " AND p.rowid in (".$projectid.")"; + } + if ($filteronproj) { + $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); + } + if ($filteronprojstatus && $filteronprojstatus != '-1') { + $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; + } + if ($morewherefilter) { + $sql .= $morewherefilter; + } // Add where from extra fields $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; @@ -869,8 +887,7 @@ class Task extends CommonObject $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - if ($includebilltime) - { + if ($includebilltime) { $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; $sql .= " t.datec, t.dateo, t.datee, t.tms,"; $sql .= " t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; @@ -878,13 +895,15 @@ class Task extends CommonObject $sql .= " t.description, "; $sql .= " s.rowid, s.nom, s.email,"; $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; - if (!empty($extrafields->attributes['projet']['label'])) - { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); + if (!empty($extrafields->attributes['projet']['label'])) { + foreach ($extrafields->attributes['projet']['label'] as $key => $val) { + $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); + } } - if (!empty($extrafields->attributes['projet_task']['label'])) - { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); + if (!empty($extrafields->attributes['projet_task']['label'])) { + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { + $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); + } } } @@ -894,34 +913,27 @@ class Task extends CommonObject //print $sql;exit; dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; // Loop on each record found, so each couple (project id, task id) - while ($i < $num) - { + while ($i < $num) { $error = 0; $obj = $this->db->fetch_object($resql); - if ((!$obj->public) && (is_object($userp))) // If not public project and we ask a filter on project owned by a user - { - if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) - { + if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user + if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { $error++; } } - if (is_object($usert)) // If we ask a filter on a user affected to a task - { - if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) - { + if (is_object($usert)) { // If we ask a filter on a user affected to a task + if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { $error++; } } - if (!$error) - { + if (!$error) { $tasks[$i] = new Task($this->db); $tasks[$i]->id = $obj->taskid; $tasks[$i]->ref = $obj->taskref; @@ -960,21 +972,19 @@ class Task extends CommonObject $tasks[$i]->thirdparty_name = $obj->thirdparty_name; $tasks[$i]->thirdparty_email = $obj->thirdparty_email; - if (!empty($extrafields->attributes['projet']['label'])) - { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) - { - if ($extrafields->attributes['projet']['type'][$key] != 'separate') + if (!empty($extrafields->attributes['projet']['label'])) { + foreach ($extrafields->attributes['projet']['label'] as $key => $val) { + if ($extrafields->attributes['projet']['type'][$key] != 'separate') { $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + } } } - if (!empty($extrafields->attributes['projet_task']['label'])) - { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) - { - if ($extrafields->attributes['projet_task']['type'][$key] != 'separate') + if (!empty($extrafields->attributes['projet_task']['label'])) { + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { + if ($extrafields->attributes['projet_task']['type'][$key] != 'separate') { $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + } } } } @@ -1006,57 +1016,80 @@ class Task extends CommonObject dol_syslog(get_class($this)."::getUserRolesForProjectsOrTasks userp=".is_object($userp)." usert=".is_object($usert)." projectid=".$projectid." taskid=".$taskid); // We want role of user for a projet or role of user for a task. Both are not possible. - if (empty($userp) && empty($usert)) - { + if (empty($userp) && empty($usert)) { $this->error = "CallWithWrongParameters"; return -1; } - if (!empty($userp) && !empty($usert)) - { + if (!empty($userp) && !empty($usert)) { $this->error = "CallWithWrongParameters"; return -1; } /* Liste des taches et role sur les projets ou taches */ $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code, ctc.source"; - if ($userp) $sql .= " FROM ".MAIN_DB_PREFIX."projet as pt"; - if ($usert && $filteronprojstatus > -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; - if ($usert && $filteronprojstatus <= -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + if ($userp) { + $sql .= " FROM ".MAIN_DB_PREFIX."projet as pt"; + } + if ($usert && $filteronprojstatus > -1) { + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; + } + if ($usert && $filteronprojstatus <= -1) { + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + } $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql .= " WHERE pt.rowid = ec.element_id"; - if ($userp && $filteronprojstatus > -1) $sql .= " AND pt.fk_statut = ".$filteronprojstatus; - if ($usert && $filteronprojstatus > -1) $sql .= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; - if ($userp) $sql .= " AND ctc.element = 'project'"; - if ($usert) $sql .= " AND ctc.element = 'project_task'"; + if ($userp && $filteronprojstatus > -1) { + $sql .= " AND pt.fk_statut = ".$filteronprojstatus; + } + if ($usert && $filteronprojstatus > -1) { + $sql .= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; + } + if ($userp) { + $sql .= " AND ctc.element = 'project'"; + } + if ($usert) { + $sql .= " AND ctc.element = 'project_task'"; + } $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; - if ($userp) $sql .= " AND ec.fk_socpeople = ".$userp->id; - if ($usert) $sql .= " AND ec.fk_socpeople = ".$usert->id; + if ($userp) { + $sql .= " AND ec.fk_socpeople = ".$userp->id; + } + if ($usert) { + $sql .= " AND ec.fk_socpeople = ".$usert->id; + } $sql .= " AND ec.statut = 4"; $sql .= " AND ctc.source = 'internal'"; - if ($projectid) - { - if ($userp) $sql .= " AND pt.rowid in (".$projectid.")"; - if ($usert) $sql .= " AND pt.fk_projet in (".$projectid.")"; + if ($projectid) { + if ($userp) { + $sql .= " AND pt.rowid in (".$projectid.")"; + } + if ($usert) { + $sql .= " AND pt.fk_projet in (".$projectid.")"; + } } - if ($taskid) - { - if ($userp) $sql .= " ERROR SHOULD NOT HAPPENS"; - if ($usert) $sql .= " AND pt.rowid = ".$taskid; + if ($taskid) { + if ($userp) { + $sql .= " ERROR SHOULD NOT HAPPENS"; + } + if ($usert) { + $sql .= " AND pt.rowid = ".$taskid; + } } //print $sql; dol_syslog(get_class($this)."::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if (empty($arrayroles[$obj->pid])) $arrayroles[$obj->pid] = $obj->code; - else $arrayroles[$obj->pid] .= ','.$obj->code; + if (empty($arrayroles[$obj->pid])) { + $arrayroles[$obj->pid] = $obj->code; + } else { + $arrayroles[$obj->pid] .= ','.$obj->code; + } $i++; } $this->db->free($resql); @@ -1081,10 +1114,12 @@ class Task extends CommonObject //var_dump($tab); $num = count($tab); $i = 0; - while ($i < $num) - { - if ($source == 'thirdparty') $contactAlreadySelected[$i] = $tab[$i]['socid']; - else $contactAlreadySelected[$i] = $tab[$i]['id']; + while ($i < $num) { + if ($source == 'thirdparty') { + $contactAlreadySelected[$i] = $tab[$i]['socid']; + } else { + $contactAlreadySelected[$i] = $tab[$i]['id']; + } $i++; } return $contactAlreadySelected; @@ -1107,15 +1142,18 @@ class Task extends CommonObject $ret = 0; // Check parameters - if (!is_object($user)) - { + if (!is_object($user)) { dol_print_error('', "Method addTimeSpent was called with wrong parameter user"); return -1; } // Clean parameters - if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); - if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; + if (isset($this->timespent_note)) { + $this->timespent_note = trim($this->timespent_note); + } + if (empty($this->timespent_datehour)) { + $this->timespent_datehour = $this->timespent_date; + } $this->db->begin(); @@ -1138,17 +1176,17 @@ class Task extends CommonObject $sql .= ")"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); $ret = $tasktime_id; $this->timespent_id = $ret; - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_TIMESPENT_CREATE', $user); - if ($result < 0) { $ret = -1; } + if ($result < 0) { + $ret = -1; + } // End call triggers } } else { @@ -1156,17 +1194,17 @@ class Task extends CommonObject $ret = -1; } - if ($ret > 0) - { + if ($ret > 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; - if (isset($this->progress)) $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + if (isset($this->progress)) { + $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $ret = -2; } @@ -1176,15 +1214,13 @@ class Task extends CommonObject $sql .= " WHERE rowid = ".$tasktime_id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $ret = -2; } } - if ($ret > 0) - { + if ($ret > 0) { $this->db->commit(); } else { $this->db->rollback(); @@ -1203,12 +1239,14 @@ class Task extends CommonObject { global $langs; - if (is_object($userobj)) $userid = $userobj->id; - else $userid = $userobj; // old method + if (is_object($userobj)) { + $userid = $userobj->id; + } else { + $userid = $userobj; // old method + } $id = $this->id; - if (empty($id) && empty($userid)) - { + if (empty($id) && empty($userid)) { dol_syslog("getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR); return -1; } @@ -1224,14 +1262,19 @@ class Task extends CommonObject $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " WHERE 1 = 1"; - if ($morewherefilter) $sql .= $morewherefilter; - if ($id > 0) $sql .= " AND t.fk_task = ".$id; - if ($userid > 0) $sql .= " AND t.fk_user = ".$userid; + if ($morewherefilter) { + $sql .= $morewherefilter; + } + if ($id > 0) { + $sql .= " AND t.fk_task = ".$id; + } + if ($userid > 0) { + $sql .= " AND t.fk_user = ".$userid; + } dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead @@ -1264,7 +1307,9 @@ class Task extends CommonObject { global $langs; - if (empty($id)) $id = $this->id; + if (empty($id)) { + $id = $this->id; + } $result = array(); @@ -1273,17 +1318,14 @@ class Task extends CommonObject $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " WHERE t.fk_task = ".$id; - if (is_object($fuser) && $fuser->id > 0) - { + if (is_object($fuser) && $fuser->id > 0) { $sql .= " AND fk_user = ".$fuser->id; } - if ($dates > 0) - { + if ($dates > 0) { $datefieldname = "task_datehour"; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } - if ($datee > 0) - { + if ($datee > 0) { $datefieldname = "task_datehour"; $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } @@ -1291,8 +1333,7 @@ class Task extends CommonObject dol_syslog(get_class($this)."::getSumOfAmount", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $result['amount'] = $obj->amount; @@ -1332,10 +1373,8 @@ class Task extends CommonObject dol_syslog(get_class($this)."::fetchTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->timespent_id = $obj->rowid; @@ -1395,17 +1434,17 @@ class Task extends CommonObject $sql .= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; $sql .= " AND ptt.fk_user = ".$userobj->id; $sql .= " AND pt.entity IN (".getEntity('project').")"; - if ($morewherefilter) $sql .= $morewherefilter; + if ($morewherefilter) { + $sql .= $morewherefilter; + } dol_syslog(get_class($this)."::fetchAllTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $newobj = new stdClass(); @@ -1460,20 +1499,22 @@ class Task extends CommonObject $ret = 0; // Check parameters - if ($this->timespent_date == '') - { + if ($this->timespent_date == '') { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")); return -1; } - if (!($this->timespent_fk_user > 0)) - { + if (!($this->timespent_fk_user > 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("User")); return -1; } // Clean parameters - if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; - if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); + if (empty($this->timespent_datehour)) { + $this->timespent_datehour = $this->timespent_date; + } + if (isset($this->timespent_note)) { + $this->timespent_note = trim($this->timespent_note); + } $this->db->begin(); @@ -1487,27 +1528,27 @@ class Task extends CommonObject $sql .= " WHERE rowid = ".$this->timespent_id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!$notrigger) - { + if ($this->db->query($sql)) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_TIMESPENT_MODIFY', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); $ret = -1; - } else $ret = 1; + } else { + $ret = 1; + } // End call triggers - } else $ret = 1; + } else { + $ret = 1; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -1; } - if ($ret == 1 && ($this->timespent_old_duration != $this->timespent_duration)) - { + if ($ret == 1 && ($this->timespent_old_duration != $this->timespent_duration)) { $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; @@ -1515,15 +1556,16 @@ class Task extends CommonObject $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -2; } } - if ($ret >= 0) $this->db->commit(); + if ($ret >= 0) { + $this->db->commit(); + } return $ret; } @@ -1547,28 +1589,28 @@ class Task extends CommonObject dol_syslog(get_class($this)."::delTimeSpent", 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 (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_TIMESPENT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error) - { + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; $sql .= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0); $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $result = 0; } else { $this->error = $this->db->lasterror(); @@ -1577,10 +1619,8 @@ class Task extends CommonObject } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delTimeSpent ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -1633,8 +1673,7 @@ class Task extends CommonObject $defaultref = ''; $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; - if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) - { + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(0, $clone_task); @@ -1651,8 +1690,7 @@ class Task extends CommonObject $clone_task->rang = $origin_task->rang; //Manage Task Date - if ($clone_change_dt) - { + if ($clone_change_dt) { $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); @@ -1660,20 +1698,17 @@ class Task extends CommonObject $orign_project_dt_start = $projectstatic->date_start; //Calcultate new task start date with difference between origin proj start date and origin task start date - if (!empty($clone_task->date_start)) - { + if (!empty($clone_task->date_start)) { $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; } //Calcultate new task end date with difference between origin proj end date and origin task end date - if (!empty($clone_task->date_end)) - { + if (!empty($clone_task->date_end)) { $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; } } - if (!$clone_prog) - { + if (!$clone_prog) { $clone_task->progress = 0; } @@ -1681,28 +1716,24 @@ class Task extends CommonObject $result = $clone_task->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $clone_task->error; $error++; } // End - if (!$error) - { + if (!$error) { $clone_task_id = $clone_task->id; $clone_task_ref = $clone_task->ref; - //Note Update - if (!$clone_note) - { + //Note Update + if (!$clone_note) { $clone_task->note_private = ''; $clone_task->note_public = ''; } else { $this->db->begin(); $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES | ENT_HTML5), '_public'); - if ($res < 0) - { + if ($res < 0) { $this->error .= $clone_task->error; $error++; $this->db->rollback(); @@ -1712,8 +1743,7 @@ class Task extends CommonObject $this->db->begin(); $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES | ENT_HTML5), '_private'); - if ($res < 0) - { + if ($res < 0) { $this->error .= $clone_task->error; $error++; $this->db->rollback(); @@ -1723,8 +1753,7 @@ class Task extends CommonObject } //Duplicate file - if ($clone_file) - { + if ($clone_file) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; //retrieve project origin ref to know folder to copy @@ -1732,8 +1761,7 @@ class Task extends CommonObject $projectstatic->fetch($ori_project_id); $ori_project_ref = $projectstatic->ref; - if ($ori_project_id != $project_id) - { + if ($ori_project_id != $project_id) { $projectstatic->fetch($project_id); $clone_project_ref = $projectstatic->ref; } else { @@ -1744,20 +1772,16 @@ class Task extends CommonObject $ori_task_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($ori_project_ref)."/".dol_sanitizeFileName($fromid); $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - foreach ($filearray as $key => $file) - { - if (!file_exists($clone_task_dir)) - { - if (dol_mkdir($clone_task_dir) < 0) - { + foreach ($filearray as $key => $file) { + if (!file_exists($clone_task_dir)) { + if (dol_mkdir($clone_task_dir) < 0) { $this->error .= $langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; $error++; } } $rescopy = dol_copy($ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name'], 0, 1); - if (is_numeric($rescopy) && $rescopy < 0) - { + if (is_numeric($rescopy) && $rescopy < 0) { $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name']); $error++; } @@ -1765,27 +1789,22 @@ class Task extends CommonObject } // clone affectation - if ($clone_affectation) - { + if ($clone_affectation) { $origin_task = new Task($this->db); $origin_task->fetch($fromid); - foreach (array('internal', 'external') as $source) - { + foreach (array('internal', 'external') as $source) { $tab = $origin_task->liste_contact(-1, $source); $num = count($tab); $i = 0; - while ($i < $num) - { + while ($i < $num) { $clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']); - if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { - if ($clone_task->error != '') - { + if ($clone_task->error != '') { $this->error .= $clone_task->error; $error++; } @@ -1795,16 +1814,14 @@ class Task extends CommonObject } } - if ($clone_time) - { + if ($clone_time) { //TODO clone time of affectation } } unset($clone_task->context['createfromclone']); - if (!$error) - { + if (!$error) { $this->db->commit(); return $clone_task_id; } else { @@ -1851,38 +1868,53 @@ class Task extends CommonObject $this->statuts_short[3] = 'Completed'; $this->statuts_short[4] = 'Transfered'; - if ($mode == 0) - { + if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } elseif ($mode == 1) - { + } elseif ($mode == 1) { return $langs->trans($this->statuts_short[$status]); - } 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]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); - } elseif ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); - elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); - elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); - } elseif ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); - } elseif ($mode == 5) - { + } 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]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); + } elseif ($status == 2) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); + } elseif ($status == 3) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + } elseif ($status == 4) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + } elseif ($status == 5) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); + } + } elseif ($mode == 3) { + if ($status == 0) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + } elseif ($status == 1) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); + } elseif ($status == 2) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); + } elseif ($status == 3) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + } elseif ($status == 4) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + } elseif ($status == 5) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); + } + } elseif ($mode == 4) { + if ($status == 0) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 1) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 2) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 3) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 4) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + } elseif ($status == 5) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); + } + } elseif ($mode == 5) { /*if ($status==0) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut0'); elseif ($status==1) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut1'); elseif ($status==2) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut3'); @@ -1892,8 +1924,7 @@ class Task extends CommonObject */ //else return $this->progress.' %'; return '&nbsp;'; - } elseif ($mode == 6) - { + } elseif ($mode == 6) { /*if ($status==0) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut0'); elseif ($status==1) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut1'); elseif ($status==2) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut3'); @@ -1970,29 +2001,34 @@ class Task extends CommonObject $sql .= " AND p.fk_statut = 1"; $sql .= " AND t.fk_projet = p.rowid"; $sql .= " AND (t.progress IS NULL OR t.progress < 100)"; // tasks to do - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; + if (!$user->rights->projet->all->lire) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; + } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $task_static = new Task($this->db); $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->task->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("OpenedTasks"); - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; - else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&amp;mainmenu=project'; + if ($user->rights->projet->all->lire) { + $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; + } else { + $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&amp;mainmenu=project'; + } $response->img = img_object('', "task"); // 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)) { $response->nbtodo++; $task_static->projectstatus = $obj->projectstatus; @@ -2033,22 +2069,28 @@ class Task extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + } $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; $sql .= " AND t.fk_projet = p.rowid"; // tasks to do - if ($mine || !$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; + if ($mine || !$user->rights->projet->all->lire) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; + } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id.") OR (s.rowid IS NULL))"; + if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id.") OR (s.rowid IS NULL))"; + } $resql = $this->db->query($sql); - if ($resql) - { + 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->nb["tasks"] = $obj->nb; } $this->db->free($resql); diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 296a36c2dcf..d18950ec482 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -59,8 +59,9 @@ class TaskStats extends Stats $sql = "SELECT"; $sql .= " COUNT(t.rowid), t.priority"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; - if (!$user->rights->societe->client->voir && !$user->soc_id) + if (!$user->rights->societe->client->voir && !$user->soc_id) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; + } $sql .= $this->buildWhere(); //$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all task not draft $sql .= " GROUP BY t.priority"; @@ -76,20 +77,22 @@ class TaskStats extends Stats $other = 0; while ($i < $num) { $row = $this->db->fetch_row($resql); - if ($i < $limit || $num == $limit) - { + if ($i < $limit || $num == $limit) { $result[$i] = array( $row[1], $row[0] ); - } else $other += $row[1]; + } else { + $other += $row[1]; + } $i++; } - if ($num > $limit) + if ($num > $limit) { $result[$i] = array( $langs->transnoentitiesnoconv("Other"), $other ); + } $this->db->free($resql); } else { $this->error = "Error ".$this->db->lasterror(); @@ -115,8 +118,9 @@ class TaskStats extends Stats $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; - if (!$user->rights->societe->client->voir && !$user->soc_id) + if (!$user->rights->societe->client->voir && !$user->soc_id) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; + } $sql .= $this->buildWhere(); $sql .= " GROUP BY year"; $sql .= $this->db->order('year', 'DESC'); @@ -137,18 +141,23 @@ class TaskStats extends Stats $sqlwhere[] = ' t.entity IN ('.getEntity('project').')'; - if (!empty($this->userid)) + if (!empty($this->userid)) { $sqlwhere[] = ' t.fk_user_resp='.$this->userid; + } // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project - if (!empty($this->socid)) + if (!empty($this->socid)) { $sqlwhere[] = ' p.fk_soc='.$this->socid; // Link on thirdparty is on project, not on task - if (!empty($this->year) && empty($this->yearmonth)) + } + if (!empty($this->year) && empty($this->yearmonth)) { $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; - if (!empty($this->yearmonth)) + } + if (!empty($this->yearmonth)) { $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; + } - if (!empty($this->status)) + if (!empty($this->status)) { $sqlwhere[] = " t.priority IN (".$this->priority.")"; + } if (count($sqlwhere) > 0) { $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere); @@ -172,8 +181,9 @@ class TaskStats extends Stats $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; - if (!$user->rights->societe->client->voir && !$user->soc_id) + if (!$user->rights->societe->client->voir && !$user->soc_id) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; + } $sql .= $this->buildWhere(); $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 1200e0bc060..ac00e0adfad 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -50,7 +50,9 @@ $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('p // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projectcard', 'globalcard')); @@ -62,12 +64,13 @@ $object = new Project($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $id = $object->id; } } @@ -122,20 +125,27 @@ print '<table class="border centpercent">'; // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; -if ($object->public) print $langs->trans('SharedProject'); -else print $langs->trans('PrivateProject'); +if ($object->public) { + print $langs->trans('SharedProject'); +} else { + print $langs->trans('PrivateProject'); +} print '</td></tr>'; // Date start - end print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; print dol_print_date($object->date_start, 'day'); $end = dol_print_date($object->date_end, 'day'); -if ($end) print ' - '.$end; +if ($end) { + print ' - '.$end; +} print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; -if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); +if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); +} print '</td></tr>'; // Other attributes diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 3942ee4a5a2..fed592a808c 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } +if ($conf->categorie->enabled) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('projects', 'companies')); @@ -45,7 +47,9 @@ $mine = GETPOST('mode') == 'mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} // Security check $socid = 0; @@ -140,8 +144,7 @@ if ($action == 'addcontact') { } // Add new contact -if ($action == 'addcontact_confirm' && $user->rights->projet->creer) -{ +if ($action == 'addcontact_confirm' && $user->rights->projet->creer) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -154,15 +157,13 @@ if ($action == 'addcontact_confirm' && $user->rights->projet->creer) $result = 0; $result = $object->fetch($id); - if (!$error && $result > 0 && $id > 0) - { - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); + if (!$error && $result > 0 && $id > 0) { + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - if ($result == 0) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } - elseif ($result < 0) { + if ($result == 0) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } elseif ($result < 0) { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); @@ -171,7 +172,7 @@ if ($action == 'addcontact_confirm' && $user->rights->projet->creer) } } - $affecttotask=GETPOST('tasksavailable', 'intcomma'); + $affecttotask=GETPOST('tasksavailable', 'intcomma'); if (!empty($affecttotask)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $task_to_affect = explode(',', $affecttotask); @@ -199,18 +200,15 @@ if ($action == 'addcontact_confirm' && $user->rights->projet->creer) } } - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } // Change contact's status -if ($action == 'swapstatut' && $user->rights->projet->creer) -{ - if ($object->fetch($id)) - { +if ($action == 'swapstatut' && $user->rights->projet->creer) { + if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); @@ -218,13 +216,11 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) } // Delete a contact -if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) -{ +if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) { $object->fetch($id); $result = $object->delete_contact(GETPOST("lineid")); - if ($result >= 0) - { + if ($result >= 0) { header("Location: contact.php?id=".$object->id); exit; } else { @@ -239,7 +235,9 @@ if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->pr */ $title = $langs->trans("ProjectContact").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("ProjectContact"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("ProjectContact"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader('', $title, $help_url); @@ -254,9 +252,10 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if ($id > 0 || !empty($ref)) { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -271,8 +270,11 @@ if ($id > 0 || !empty($ref)) // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } // Print form confirm print $formconfirm; @@ -285,15 +287,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -312,22 +312,19 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -337,26 +334,34 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) { // Opportunity status print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td></tr>'; // Opportunity percent print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($object->opp_percent, '', $langs, 1, 0).' %'; + } print '</td></tr>'; // Opportunity Amount print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 0, 0, 0, $conf->currency); + if (strcmp($object->opp_amount, '')) { + print price($object->opp_amount, '', $langs, 0, 0, 0, $conf->currency); + } print '</td></tr>'; } @@ -367,12 +372,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 0, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, '', $langs, 0, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -414,10 +423,11 @@ if ($id > 0 || !empty($ref)) // 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) - { + foreach ($dirtpls as $reldir) { $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + if ($res) { + break; + } } } diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 5557740704d..795e10f2739 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -48,7 +48,9 @@ $result = restrictedArea($user, 'projet', $id, 'projet&project'); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} if ($id > 0 || !empty($ref)) { $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); @@ -59,16 +61,26 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!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 = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} @@ -84,15 +96,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; */ $title = $langs->trans("Project").' - '.$langs->trans("Document").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Document"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Document"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader('', $title, $help_url); $form = new Form($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); // To verify role of users @@ -107,8 +120,7 @@ if ($object->id > 0) // Files list constructor $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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } @@ -121,15 +133,13 @@ if ($object->id > 0) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3df802018ef..fa9dc351a60 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -34,41 +34,105 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -if (!empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; -if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; -if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; -if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; -if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->mrp->enabled)) require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +if (!empty($conf->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +} +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +} +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +} +if (!empty($conf->commande->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +} +if (!empty($conf->supplier_proposal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +} +if (!empty($conf->fournisseur->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +} +if (!empty($conf->fournisseur->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +} +if (!empty($conf->contrat->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} +if (!empty($conf->ficheinter->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +} +if (!empty($conf->expedition->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +} +if (!empty($conf->deplacement->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +} +if (!empty($conf->expensereport->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +} +if (!empty($conf->agenda->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +} +if (!empty($conf->don->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +} +if (!empty($conf->loan->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +} +if (!empty($conf->loan->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; +} +if (!empty($conf->stock->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +} +if (!empty($conf->tax->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +} +if (!empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +} +if (!empty($conf->salaries->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +} +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} +if (!empty($conf->mrp->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta')); -if (!empty($conf->facture->enabled)) $langs->load("bills"); -if (!empty($conf->commande->enabled)) $langs->load("orders"); -if (!empty($conf->propal->enabled)) $langs->load("propal"); -if (!empty($conf->ficheinter->enabled)) $langs->load("interventions"); -if (!empty($conf->deplacement->enabled)) $langs->load("trips"); -if (!empty($conf->expensereport->enabled)) $langs->load("trips"); -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->mrp->enabled)) $langs->load("mrp"); +if (!empty($conf->facture->enabled)) { + $langs->load("bills"); +} +if (!empty($conf->commande->enabled)) { + $langs->load("orders"); +} +if (!empty($conf->propal->enabled)) { + $langs->load("propal"); +} +if (!empty($conf->ficheinter->enabled)) { + $langs->load("interventions"); +} +if (!empty($conf->deplacement->enabled)) { + $langs->load("trips"); +} +if (!empty($conf->expensereport->enabled)) { + $langs->load("trips"); +} +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->mrp->enabled)) { + $langs->load("mrp"); +} $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -77,8 +141,12 @@ $datesrfc = GETPOST('datesrfc'); $dateerfc = GETPOST('dateerfc'); $dates = dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear')); $datee = dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear')); -if (empty($dates) && !empty($datesrfc)) $dates = dol_stringtotime($datesrfc); -if (empty($datee) && !empty($dateerfc)) $datee = dol_stringtotime($dateerfc); +if (empty($dates) && !empty($datesrfc)) { + $dates = dol_stringtotime($datesrfc); +} +if (empty($datee) && !empty($dateerfc)) { + $datee = dol_stringtotime($dateerfc); +} if (!GETPOSTISSET('datesrfc') && !GETPOSTISSET('datesday') && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) { $new = dol_now(); $tmp = dol_getdate($new); @@ -86,8 +154,7 @@ if (!GETPOSTISSET('datesrfc') && !GETPOSTISSET('datesday') && !empty($conf->glob //$dates=dol_time_plus_duree($datee, -1, 'y'); $dates = dol_get_first_day($tmp['year'], 1); } -if ($id == '' && $ref == '') -{ +if ($id == '' && $ref == '') { setEventMessage($langs->trans('ErrorBadParameters'), 'errors'); header('Location: list.php'); exit(); @@ -99,7 +166,9 @@ $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} // Security check $socid = $object->socid; @@ -114,7 +183,9 @@ $hookmanager->initHooks(array('projectOverview')); */ $title = $langs->trans("ProjectReferers").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("ProjectReferers"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("ProjectReferers"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $langs->trans("Referers"), $help_url); @@ -139,15 +210,13 @@ $morehtmlref = '<div class="refidno">'; // Title $morehtmlref .= $object->title; // Thirdparty -if ($object->thirdparty->id > 0) -{ +if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. -if (!$user->rights->projet->all->lire) -{ +if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " te.rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -166,22 +235,19 @@ print '<tr><td class="tdtop">'; print $langs->trans("Usage"); print '</td>'; print '<td>'; -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } -if (empty($conf->global->PROJECT_HIDE_TASKS)) -{ +if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } -if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) -{ +if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -191,26 +257,34 @@ print '</td></tr>'; // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; -if ($object->public) print $langs->trans('SharedProject'); -else print $langs->trans('PrivateProject'); +if ($object->public) { + print $langs->trans('SharedProject'); +} else { + print $langs->trans('PrivateProject'); +} print '</td></tr>'; -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td></tr>'; // Opportunity percent print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, '', $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($object->opp_percent, '', $langs, 1, 0).' %'; + } print '</td></tr>'; // Opportunity Amount print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->opp_amount, '')) { + print price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; } @@ -221,12 +295,16 @@ print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); -if ($object->hasDelay()) print img_warning("Late"); +if ($object->hasDelay()) { + print img_warning("Late"); +} print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; -if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); +if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); +} print '</td></tr>'; // Other attributes @@ -517,11 +595,11 @@ $listofreferent = array( 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid, - 'lang'=>'agenda', - 'buttonnew'=>'AddEvent', - 'testnew'=>$user->rights->agenda->myactions->create, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read), + 'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'agenda', + 'buttonnew'=>'AddEvent', + 'testnew'=>$user->rights->agenda->myactions->create, + 'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read), */ ); @@ -558,24 +636,20 @@ if (!empty($hookmanager->resArray)) { $listofreferent = array_merge($listofreferent, $hookmanager->resArray); } -if ($action == "addelement") -{ +if ($action == "addelement") { $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); $result = $object->update_element($tablename, $elementselectid); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == "unlink") -{ +} elseif ($action == "unlink") { $tablename = GETPOST("tablename", "aZ09"); $projectField = GETPOSTISSET('projectfield') ? GETPOST('projectfield', 'aZ09') : 'fk_projet'; $elementselectid = GETPOST("elementselect", "int"); $result = $object->remove_element($tablename, $elementselectid, $projectField); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -586,8 +660,7 @@ $elementuser = new User($db); $showdatefilter = 0; // Show the filter on date on top of element list -if (!$showdatefilter) -{ +if (!$showdatefilter) { print '<div class="center centpercent">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -614,7 +687,9 @@ if (!$showdatefilter) $langs->loadLangs(array("suppliers", "bills", "orders", "proposals", "margins")); -if (!empty($conf->stock->enabled)) $langs->load('stocks'); +if (!empty($conf->stock->enabled)) { + $langs->load('stocks'); +} print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); @@ -623,13 +698,11 @@ print '<tr class="liste_titre">'; print '<td class="left" width="200">'; $tooltiponprofit = $langs->trans("ProfitIsCalculatedWith")."<br>\n"; $tooltiponprofitplus = $tooltiponprofitminus = ''; -foreach ($listofreferent as $key => $value) -{ +foreach ($listofreferent as $key => $value) { $name = $langs->trans($value['name']); $qualified = $value['test']; $margin = $value['margin']; - if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') - { + if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') if ($margin == 'add') { $tooltiponprofitplus .= ' &gt; '.$name." (+)<br>\n"; } @@ -651,8 +724,7 @@ $total_revenue_ht = 0; $balance_ht = 0; $balance_ttc = 0; -foreach ($listofreferent as $key => $value) -{ +foreach ($listofreferent as $key => $value) { $parameters = array( 'total_revenue_ht' =>& $total_revenue_ht, 'balance_ht' =>& $balance_ht, @@ -694,25 +766,38 @@ foreach ($listofreferent as $key => $value) $idofelementuser = $tmp[1]; $element->fetch($idofelement); - if ($idofelementuser) $elementuser->fetch($idofelementuser); + if ($idofelementuser) { + $elementuser->fetch($idofelementuser); + } // Define if record must be used for total or not $qualifiedfortotal = true; if ($key == 'invoice') { - if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included + if (!empty($element->close_code) && $element->close_code == 'replaced') { + $qualifiedfortotal = false; // Replacement invoice, do not include into total + } + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) { + $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included + } } if ($key == 'propal') { - if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedfortotal = false; // Only signed proposal must not be included in total + if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) { + $qualifiedfortotal = false; // Only signed proposal must not be included in total + } } - if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); + if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) { + $element->fetch_thirdparty(); + } // Define $total_ht_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; - elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); - elseif ($tablename == 'projet_task') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + $total_ht_by_line = $element->amount; + } elseif ($tablename == 'fichinter') { + $total_ht_by_line = $element->getAmount(); + } elseif ($tablename == 'stock_mouvement') { + $total_ht_by_line = $element->price * abs($element->qty); + } elseif ($tablename == 'projet_task') { if ($idofelementuser) { $tmp = $element->getSumOfAmount($elementuser, $dates, $datee); $total_ht_by_line = price2num($tmp['amount'], 'MT'); @@ -743,18 +828,25 @@ foreach ($listofreferent as $key => $value) } } } - } else $total_ht_by_line = $element->total_ht; + } else { + $total_ht_by_line = $element->total_ht; + } // Define $total_ttc_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; - elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); - elseif ($tablename == 'projet_task') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + $total_ttc_by_line = $element->amount; + } elseif ($tablename == 'fichinter') { + $total_ttc_by_line = $element->getAmount(); + } elseif ($tablename == 'stock_mouvement') { + $total_ttc_by_line = $element->price * abs($element->qty); + } elseif ($tablename == 'projet_task') { $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } elseif ($key == 'loan') { $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr - } else $total_ttc_by_line = $element->total_ttc; + } else { + $total_ttc_by_line = $element->total_ttc; + } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases if ($tablename == 'payment_various') { @@ -773,7 +865,9 @@ foreach ($listofreferent as $key => $value) // Each element with at least one line is output $qualifiedforfinalprofit = true; - if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit = false; + if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) { + $qualifiedforfinalprofit = false; + } //var_dump($key.' '.$qualifiedforfinalprofit); // Calculate margin @@ -798,18 +892,24 @@ foreach ($listofreferent as $key => $value) print '<td class="right">'.$i.'</td>'; // Amount HT print '<td class="right">'; - if ($key == 'intervention' && !$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>'; - else { + if ($key == 'intervention' && !$qualifiedforfinalprofit) { + print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>'; + } else { print price($total_ht); - if ($key == 'propal') print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>'; + if ($key == 'propal') { + print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>'; + } } print '</td>'; // Amount TTC print '<td class="right">'; - if ($key == 'intervention' && !$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>'; - else { + if ($key == 'intervention' && !$qualifiedforfinalprofit) { + print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>'; + } else { print price($total_ttc); - if ($key == 'propal') print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>'; + if ($key == 'propal') { + print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>'; + } } print '</td>'; print '</tr>'; @@ -841,8 +941,7 @@ print '<br>'; // Detail -foreach ($listofreferent as $key => $value) -{ +foreach ($listofreferent as $key => $value) { $parameters = array( 'key' => $key, 'value' =>& $value, @@ -869,13 +968,17 @@ foreach ($listofreferent as $key => $value) $project_field = $value['project_field']; $exclude_select_element = array('payment_various'); - if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element']; + if (!empty($value['exclude_select_element'])) { + $exclude_select_element[] = $value['exclude_select_element']; + } if ($qualified) { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; - if ($langtoload) $langs->load($langtoload); + if ($langtoload) { + $langs->load($langtoload); + } $element = new $classname($db); @@ -883,20 +986,18 @@ foreach ($listofreferent as $key => $value) $idtofilterthirdparty = 0; $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur'); - if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) - { + if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) { $idtofilterthirdparty = $object->thirdparty->id; - if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty .= ','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; + if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) { + $idtofilterthirdparty .= ','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; + } } - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) - { + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) { $selectList = $formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300 minwidth75imp', -2, !empty($project_field) ? $project_field : 'fk_projet'); - if ($selectList < 0) - { + if ($selectList < 0) { setEventMessages($formproject->error, $formproject->errors, 'errors'); - } elseif ($selectList) - { + } elseif ($selectList) { // Define form with the combo list of elements to link $addform .= '<div class="inline-block valignmiddle">'; $addform .= '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; @@ -913,11 +1014,11 @@ foreach ($listofreferent as $key => $value) $addform .= '</div>'; } } - if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) - { + if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) { $addform .= '<div class="inline-block valignmiddle">'; - if ($testnew) $addform .= '<a class="buttonxxx" href="'.$urlnew.'"><span class="valignmiddle text-plus-circle hideonsmartphone">'.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; - elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { + if ($testnew) { + $addform .= '<a class="buttonxxx" href="'.$urlnew.'"><span class="valignmiddle text-plus-circle hideonsmartphone">'.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; + } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { $addform .= '<a class="buttonxxx buttonRefused" disabled="disabled" href="#"><span class="valignmiddle text-plus-circle hideonsmartphone">'.($buttonnew ? $langs->trans($buttonnew) : $langs->trans("Create")).'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; } $addform .= '<div>'; @@ -936,19 +1037,27 @@ foreach ($listofreferent as $key => $value) print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"' : '').'>'.$langs->trans("Ref").'</td>'; // Date print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"' : '').' class="center">'; - if (in_array($tablename, array('projet_task'))) print $langs->trans("TimeSpent"); - if (!in_array($tablename, array('projet_task'))) print $langs->trans("Date"); + if (in_array($tablename, array('projet_task'))) { + print $langs->trans("TimeSpent"); + } + if (!in_array($tablename, array('projet_task'))) { + print $langs->trans("Date"); + } print '</td>'; // Thirdparty or user print '<td>'; - if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user - elseif (in_array($tablename, array('payment_various'))) print ''; // if $key == 'payment_various', we don't have any thirdparty - elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) print $langs->trans("User"); - else print $langs->trans("ThirdParty"); + if (in_array($tablename, array('projet_task')) && $key == 'project_task') { + print ''; // if $key == 'project_task', we don't want details per user + } elseif (in_array($tablename, array('payment_various'))) { + print ''; // if $key == 'payment_various', we don't have any thirdparty + } elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) { + print $langs->trans("User"); + } else { + print $langs->trans("ThirdParty"); + } print '</td>'; // Duration of intervention - if ($tablename == 'fichinter') - { + if ($tablename == 'fichinter') { print '<td>'; print $langs->trans("TotalDuration"); $total_duration = 0; @@ -957,22 +1066,32 @@ foreach ($listofreferent as $key => $value) // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("Amount").'</td>'; - if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("LoanCapital").'</td>'; - elseif (empty($value['disableamount'])) print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>'; - else print '<td width="120"></td>'; + if ($key == 'loan') { + print '<td class="right" width="120">'.$langs->trans("LoanCapital").'</td>'; + } elseif (empty($value['disableamount'])) { + print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>'; + } else { + print '<td width="120"></td>'; + } // Amount TTC //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; - if ($key == 'loan') print '<td class="right" width="120">'.$langs->trans("RemainderToPay").'</td>'; - elseif (empty($value['disableamount'])) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; - else print '<td width="120"></td>'; + if ($key == 'loan') { + print '<td class="right" width="120">'.$langs->trans("RemainderToPay").'</td>'; + } elseif (empty($value['disableamount'])) { + print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>'; + } else { + print '<td width="120"></td>'; + } // Status - if (in_array($tablename, array('projet_task'))) print '<td class="right" width="200">'.$langs->trans("ProgressDeclared").'</td>'; - else print '<td class="right" width="200">'.$langs->trans("Status").'</td>'; + if (in_array($tablename, array('projet_task'))) { + print '<td class="right" width="200">'.$langs->trans("ProgressDeclared").'</td>'; + } else { + print '<td class="right" width="200">'.$langs->trans("Status").'</td>'; + } print '</tr>'; $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); - if (is_array($elementarray) && count($elementarray) > 0) - { + if (is_array($elementarray) && count($elementarray) > 0) { $total_ht = 0; $total_ttc = 0; @@ -982,26 +1101,27 @@ foreach ($listofreferent as $key => $value) $saved_third_id = 0; $breakline = ''; - if (canApplySubtotalOn($tablename)) - { + if (canApplySubtotalOn($tablename)) { // Sort $elementarray = sortElementsByClientName($elementarray); } $num = count($elementarray); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $tmp = explode('_', $elementarray[$i]); $idofelement = $tmp[0]; $idofelementuser = $tmp[1]; $element->fetch($idofelement); - if ($idofelementuser) $elementuser->fetch($idofelementuser); + if ($idofelementuser) { + $elementuser->fetch($idofelementuser); + } // Special cases - if ($tablename != 'expensereport_det') - { - if (method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); + if ($tablename != 'expensereport_det') { + if (method_exists($element, 'fetch_thirdparty')) { + $element->fetch_thirdparty(); + } } else { $expensereport = new ExpenseReport($db); $expensereport->fetch($element->fk_expensereport); @@ -1009,8 +1129,7 @@ foreach ($listofreferent as $key => $value) //print 'xxx'.$tablename.'yyy'.$classname; - if ($breakline && $saved_third_id != $element->thirdparty->id) - { + if ($breakline && $saved_third_id != $element->thirdparty->id) { print $breakline; $saved_third_id = $element->thirdparty->id; @@ -1022,19 +1141,18 @@ foreach ($listofreferent as $key => $value) $saved_third_id = $element->thirdparty->id; $qualifiedfortotal = true; - if ($key == 'invoice') - { - if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total + if ($key == 'invoice') { + if (!empty($element->close_code) && $element->close_code == 'replaced') { + $qualifiedfortotal = false; // Replacement invoice, do not include into total + } } print '<tr class="oddeven">'; // Remove link print '<td style="width: 24px">'; - if ($tablename != 'projet_task' && $tablename != 'stock_mouvement') - { - if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true - { + if ($tablename != 'projet_task' && $tablename != 'stock_mouvement') { + if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) { // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=unlink&tablename='.$tablename.'&elementselect='.$element->id.($project_field ? '&projectfield='.$project_field : '').'" class="reposition">'; print img_picto($langs->trans('Unlink'), 'unlink'); print '</a>'; @@ -1044,19 +1162,19 @@ foreach ($listofreferent as $key => $value) // Ref print '<td class="left nowraponall">'; - if ($tablename == 'expensereport_det') - { + if ($tablename == 'expensereport_det') { print $expensereport->getNomUrl(1); } else { // Show ref with link - if ($element instanceof Task) - { + if ($element instanceof Task) { print $element->getNomUrl(1, 'withproject', 'time'); print ' - '.dol_trunc($element->label, 48); } elseif ($key == 'loan') { print $element->getNomUrl(1); print ' - '.dol_trunc($element->label, 48); - } else print $element->getNomUrl(1); + } else { + print $element->getNomUrl(1); + } $element_doc = $element->element; $filename = dol_sanitizeFileName($element->ref); @@ -1074,32 +1192,48 @@ foreach ($listofreferent as $key => $value) print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>'; // Show supplier ref - if (!empty($element->ref_supplier)) print ' - '.$element->ref_supplier; + if (!empty($element->ref_supplier)) { + print ' - '.$element->ref_supplier; + } // Show customer ref - if (!empty($element->ref_customer)) print ' - '.$element->ref_customer; + if (!empty($element->ref_customer)) { + print ' - '.$element->ref_customer; + } } print "</td>\n"; // Date or TimeSpent $date = ''; $total_time_by_line = null; - if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines - elseif ($tablename == 'stock_mouvement') $date = $element->datem; - elseif ($tablename == 'payment_salary') $date = $element->datev; - elseif ($tablename == 'payment_various') $date = $element->datev; - elseif ($tablename == 'chargesociales') $date = $element->date_ech; - elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) - { - if ($tablename == 'don') $date = $element->datedon; - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') - { + if ($tablename == 'expensereport_det') { + $date = $element->date; // No draft status on lines + } elseif ($tablename == 'stock_mouvement') { + $date = $element->datem; + } elseif ($tablename == 'payment_salary') { + $date = $element->datev; + } elseif ($tablename == 'payment_various') { + $date = $element->datev; + } elseif ($tablename == 'chargesociales') { + $date = $element->date_ech; + } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) { + if ($tablename == 'don') { + $date = $element->datedon; + } + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') { $date = ($element->date_commande ? $element->date_commande : $element->date_valid); - } elseif ($tablename == 'supplier_proposal') $date = $element->date_validation; // There is no other date for this - elseif ($tablename == 'fichinter') $date = $element->datev; // There is no other date for this - elseif ($tablename == 'projet_task') $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed - else { + } elseif ($tablename == 'supplier_proposal') { + $date = $element->date_validation; // There is no other date for this + } elseif ($tablename == 'fichinter') { + $date = $element->datev; // There is no other date for this + } elseif ($tablename == 'projet_task') { + $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed + } else { $date = $element->date; // invoice, ... - if (empty($date)) $date = $element->date_contrat; - if (empty($date)) $date = $element->datev; + if (empty($date)) { + $date = $element->date_contrat; + } + if (empty($date)) { + $date = $element->datev; + } if (empty($date) && !empty($datefieldname)) { $date = $element->$datefieldname; } @@ -1109,18 +1243,20 @@ foreach ($listofreferent as $key => $value) } print '<td class="center">'; - if ($tablename == 'actioncomm') - { + if ($tablename == 'actioncomm') { print dol_print_date($element->datep, 'dayhour'); - if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef, 'dayhour'); - } elseif (in_array($tablename, array('projet_task'))) - { + if ($element->datef && $element->datef > $element->datep) { + print " - ".dol_print_date($element->datef, 'dayhour'); + } + } elseif (in_array($tablename, array('projet_task'))) { $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$idofelement.'&withproject=1">'; print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin'); print '</a>'; $total_time_by_line = $tmpprojtime['nbseconds']; - } else print dol_print_date($date, 'day'); + } else { + print dol_print_date($date, 'day'); + } print '</td>'; // Third party or user @@ -1131,28 +1267,23 @@ foreach ($listofreferent as $key => $value) $tmpuser = new User($db); $tmpuser->fetch($expensereport->fk_user_author); print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'payment_salary') - { + } elseif ($tablename == 'payment_salary') { $tmpuser = new User($db); $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'don' || $tablename == 'stock_mouvement') - { - if ($element->fk_user_author > 0) - { + } elseif ($tablename == 'don' || $tablename == 'stock_mouvement') { + if ($element->fk_user_author > 0) { $tmpuser2 = new User($db); $tmpuser2->fetch($element->fk_user_author); print $tmpuser2->getNomUrl(1, '', 48); } - } elseif ($tablename == 'projet_task' && $key == 'project_task_time') // if $key == 'project_task', we don't want details per user - { + } elseif ($tablename == 'projet_task' && $key == 'project_task_time') { // if $key == 'project_task', we don't want details per user print $elementuser->getNomUrl(1); } print '</td>'; // Add duration and store it in counter for fichinter - if ($tablename == 'fichinter') - { + if ($tablename == 'fichinter') { print '<td>'; print convertSecondToTime($element->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); $total_duration += $element->duration; @@ -1161,113 +1292,123 @@ foreach ($listofreferent as $key => $value) // Amount without tax $warning = ''; - if (empty($value['disableamount'])) - { + if (empty($value['disableamount'])) { $total_ht_by_line = null; $othermessage = ''; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; - elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); - elseif (in_array($tablename, array('projet_task'))) - { - if (!empty($conf->salaries->enabled)) - { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + $total_ht_by_line = $element->amount; + } elseif ($tablename == 'fichinter') { + $total_ht_by_line = $element->getAmount(); + } elseif ($tablename == 'stock_mouvement') { + $total_ht_by_line = $element->price * abs($element->qty); + } elseif (in_array($tablename, array('projet_task'))) { + if (!empty($conf->salaries->enabled)) { // TODO Permission to read daily rate to show value $total_ht_by_line = price2num($tmpprojtime['amount'], 'MT'); - if ($tmpprojtime['nblinesnull'] > 0) - { + if ($tmpprojtime['nblinesnull'] > 0) { $langs->load("errors"); $warning = $langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); } } else { $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } - } elseif ($key == 'loan') $total_ht_by_line = $element->capital; - else { + } elseif ($key == 'loan') { + $total_ht_by_line = $element->capital; + } else { $total_ht_by_line = $element->total_ht; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases - if ($tablename == 'payment_various') - { - if ($element->sens == 0) - { + if ($tablename == 'payment_various') { + if ($element->sens == 0) { $total_ht_by_line = -$total_ht_by_line; } } print '<td class="right">'; - if ($othermessage) print $othermessage; - if (isset($total_ht_by_line)) - { - if (!$qualifiedfortotal) print '<strike>'; - print price($total_ht_by_line); - if (!$qualifiedfortotal) print '</strike>'; + if ($othermessage) { + print $othermessage; + } + if (isset($total_ht_by_line)) { + if (!$qualifiedfortotal) { + print '<strike>'; + } + print price($total_ht_by_line); + if (!$qualifiedfortotal) { + print '</strike>'; + } + } + if ($warning) { + print ' '.img_warning($warning); } - if ($warning) print ' '.img_warning($warning); print '</td>'; - } else print '<td></td>'; + } else { + print '<td></td>'; + } // Amount inc tax - if (empty($value['disableamount'])) - { + if (empty($value['disableamount'])) { $total_ttc_by_line = null; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; - elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); - elseif ($tablename == 'projet_task') - { - if (!empty($conf->salaries->enabled)) - { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + $total_ttc_by_line = $element->amount; + } elseif ($tablename == 'fichinter') { + $total_ttc_by_line = $element->getAmount(); + } elseif ($tablename == 'stock_mouvement') { + $total_ttc_by_line = $element->price * abs($element->qty); + } elseif ($tablename == 'projet_task') { + if (!empty($conf->salaries->enabled)) { // TODO Permission to read daily rate $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } else { $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } - } elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); - else { + } elseif ($key == 'loan') { + $total_ttc_by_line = $element->capital - $element->getSumPayment(); + } else { $total_ttc_by_line = $element->total_ttc; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases - if ($tablename == 'payment_various') - { - if ($element->sens == 0) - { + if ($tablename == 'payment_various') { + if ($element->sens == 0) { $total_ttc_by_line = -$total_ttc_by_line; } } print '<td class="right">'; - if ($othermessage) print $othermessage; - if (isset($total_ttc_by_line)) - { - if (!$qualifiedfortotal) print '<strike>'; - print price($total_ttc_by_line); - if (!$qualifiedfortotal) print '</strike>'; + if ($othermessage) { + print $othermessage; + } + if (isset($total_ttc_by_line)) { + if (!$qualifiedfortotal) { + print '<strike>'; + } + print price($total_ttc_by_line); + if (!$qualifiedfortotal) { + print '</strike>'; + } + } + if ($warning) { + print ' '.img_warning($warning); } - if ($warning) print ' '.img_warning($warning); print '</td>'; - } else print '<td></td>'; + } else { + print '<td></td>'; + } // Status print '<td class="right">'; - if ($tablename == 'expensereport_det') - { + if ($tablename == 'expensereport_det') { print $expensereport->getLibStatut(5); - } elseif ($element instanceof CommonInvoice) - { + } elseif ($element instanceof CommonInvoice) { //This applies for Facture and FactureFournisseur print $element->getLibStatut(5, $element->getSommePaiement()); - } elseif ($element instanceof Task) - { - if ($element->progress != '') - { + } elseif ($element instanceof Task) { + if ($element->progress != '') { print $element->progress.' %'; } - } elseif ($tablename == 'stock_mouvement') - { + } elseif ($tablename == 'stock_mouvement') { print $element->getLibStatut(3); } else { print $element->getLibStatut(5); @@ -1276,8 +1417,7 @@ foreach ($listofreferent as $key => $value) print '</tr>'; - if ($qualifiedfortotal) - { + if ($qualifiedfortotal) { $total_ht = $total_ht + $total_ht_by_line; $total_ttc = $total_ttc + $total_ttc_by_line; @@ -1287,8 +1427,7 @@ foreach ($listofreferent as $key => $value) $total_time = $total_time + $total_time_by_line; } - if (canApplySubtotalOn($tablename)) - { + if (canApplySubtotalOn($tablename)) { $breakline = '<tr class="liste_total liste_sub_total">'; $breakline .= '<td colspan="2">'; $breakline .= '</td>'; @@ -1296,7 +1435,9 @@ foreach ($listofreferent as $key => $value) $breakline .= '</td>'; $breakline .= '<td class="right">'; $breakline .= $langs->trans('SubTotal').' : '; - if (is_object($element->thirdparty)) $breakline .= $element->thirdparty->getNomUrl(0, '', 48); + if (is_object($element->thirdparty)) { + $breakline .= $element->thirdparty->getNomUrl(0, '', 48); + } $breakline .= '</td>'; $breakline .= '<td class="right">'.price($total_ht_by_third).'</td>'; $breakline .= '<td class="right">'.price($total_ttc_by_third).'</td>'; @@ -1307,14 +1448,17 @@ foreach ($listofreferent as $key => $value) //var_dump($element->thirdparty->name.' - '.$saved_third_id.' - '.$element->thirdparty->id); } - if ($breakline) print $breakline; + if ($breakline) { + print $breakline; + } // Total $colspan = 4; - if (in_array($tablename, array('projet_task'))) $colspan = 2; + if (in_array($tablename, array('projet_task'))) { + $colspan = 2; + } print '<tr class="liste_total"><td colspan="'.$colspan.'">'.$langs->trans("Number").': '.$i.'</td>'; - if (in_array($tablename, array('projet_task'))) - { + if (in_array($tablename, array('projet_task'))) { print '<td class="center">'; print convertSecondToTime($total_time, 'allhourmin'); print '</td>'; @@ -1324,28 +1468,33 @@ foreach ($listofreferent as $key => $value) //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("Total").' : '.price($total_ht).'</td>'; // If fichinter add the total_duration - if ($tablename == 'fichinter') print '<td class="left">'.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; + if ($tablename == 'fichinter') { + print '<td class="left">'.convertSecondToTime($total_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; + } print '<td class="right">'; - if (empty($value['disableamount'])) - { - if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); - elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if (empty($value['disableamount'])) { + if ($key == 'loan') { + print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); + } elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) { + print ''.$langs->trans("TotalHT").' : '.price($total_ht); + } } print '</td>'; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="100"></td>'; print '<td class="right">'; - if (empty($value['disableamount'])) - { - if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); - elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if (empty($value['disableamount'])) { + if ($key == 'loan') { + print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); + } elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) { + print $langs->trans("TotalTTC").' : '.price($total_ttc); + } } print '</td>'; print '<td>&nbsp;</td>'; print '</tr>'; } else { - if (!is_array($elementarray)) // error - { + if (!is_array($elementarray)) { // error print $elementarray; } } @@ -1356,8 +1505,7 @@ foreach ($listofreferent as $key => $value) } // Enhance with select2 -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('.elementselect'); @@ -1380,7 +1528,9 @@ function canApplySubtotalOn($tablename) { global $conf; - if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) return false; + if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) { + return false; + } return in_array($tablename, array('facture_fourn', 'commande_fournisseur')); } @@ -1397,10 +1547,8 @@ function sortElementsByClientName($elementarray) $element = new $classname($db); $clientname = array(); - foreach ($elementarray as $key => $id) // id = id of object - { - if (empty($clientname[$id])) - { + foreach ($elementarray as $key => $id) { // id = id of object + if (empty($clientname[$id])) { $element->fetch($id); $element->fetch_thirdparty(); @@ -1412,8 +1560,7 @@ function sortElementsByClientName($elementarray) asort($clientname); // sort on name $elementarray = array(); - foreach ($clientname as $id => $name) - { + foreach ($clientname as $id => $name) { $elementarray[] = $id; } diff --git a/htdocs/projet/event.php b/htdocs/projet/event.php index 8cbd1895b89..b033cb95742 100644 --- a/htdocs/projet/event.php +++ b/htdocs/projet/event.php @@ -74,8 +74,11 @@ if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) { $action = 'edit'; } else { $db->commit(); - if (GETPOST('socid', 'int') > 0) $object->fetch_thirdparty(GETPOST('socid', 'int')); - else unset($object->thirdparty); + if (GETPOST('socid', 'int') > 0) { + $object->fetch_thirdparty(GETPOST('socid', 'int')); + } else { + unset($object->thirdparty); + } $action=''; } } @@ -87,7 +90,9 @@ if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) { */ $title = $langs->trans("Project").' - '.$langs->trans("ConferenceOrBoothTab").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); +} //TODO Make wiki docs $help_url = ''; llxHeader("", $title, $help_url); @@ -97,8 +102,7 @@ $userstatic = new User($db); $now = dol_now(); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $head = project_prepare_head($object); print dol_get_fiche_head($head, 'eventorganisation', $langs->trans('ConferenceOrBoothTab'), -1); @@ -110,15 +114,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -137,30 +139,26 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '<br>'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -169,21 +167,27 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td></tr>'; // Opportunity percent print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, 0, $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($object->opp_percent, 0, $langs, 1, 0).' %'; + } print '</td></tr>'; // Opportunity Amount @@ -192,12 +196,16 @@ if ($id > 0 || !empty($ref)) { print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); }*/ - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + if (strcmp($object->opp_amount, '')) { + print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + } print '</td></tr>'; // Opportunity Weighted Amount print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>'; - if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) { + print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + } print '</td></tr>'; } @@ -208,12 +216,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -281,12 +293,16 @@ if ($id > 0 || !empty($ref)) //Price of registration print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfRegistration") . '</td><td>'; - if (strcmp($object->price_registration, '')) print price($object->price_registration, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->price_registration, '')) { + print price($object->price_registration, 0, $langs, 1, 0, 0, $conf->currency); + } print "</td></tr>"; //Price of registration print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfBooth") . '</td><td>'; - if (strcmp($object->price_booth, '')) print price($object->price_booth, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->price_booth, '')) { + print price($object->price_booth, 0, $langs, 1, 0, 0, $conf->currency); + } print "</td></tr>"; } @@ -309,8 +325,7 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_end(); -if ($action == 'edit' && $permissiontoadd > 0) -{ +if ($action == 'edit' && $permissiontoadd > 0) { print '<div class="center">'; print '<input name="update" class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp; &nbsp; &nbsp;'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; @@ -321,19 +336,16 @@ if ($action == 'edit' && $permissiontoadd > 0) /* - * Actions Buttons - */ + * Actions Buttons + */ print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook -if (empty($reshook)) -{ +if (empty($reshook)) { // Modify - if ($object->statut != Project::STATUS_CLOSED && $action=='') - { - if ($permissiontoadd > 0) - { + if ($object->statut != Project::STATUS_CLOSED && $action=='') { + if ($permissiontoadd > 0) { print '<a class="butAction" href="event.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>'; diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index bacd7607f82..d83c10ec6bd 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -116,12 +116,10 @@ if (g.getDivId() != null) $level = 0; $tnums = count($tasks); $old_project_id = 0; - for ($tcursor = 0; $tcursor < $tnums; $tcursor++) - { + for ($tcursor = 0; $tcursor < $tnums; $tcursor++) { $t = $tasks[$tcursor]; - if (empty($old_project_id) || $old_project_id != $t['task_project_id']) - { + if (empty($old_project_id) || $old_project_id != $t['task_project_id']) { // Break on project, create a fictive task for project id $t['task_project_id'] $projecttmp = new Project($db); $projecttmp->fetch($t['task_project_id']); @@ -140,8 +138,7 @@ if (g.getDivId() != null) $old_project_id = $t['task_project_id']; } - if ($t["task_parent"] <= 0) - { + if ($t["task_parent"] <= 0) { constructGanttLine($tasks, $t, $task_dependencies, $level, $t['task_project_id']); findChildGanttLine($tasks, $t["task_id"], $task_dependencies, $level + 1); } @@ -180,7 +177,9 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje $start_date = $task["task_start_date"]; $end_date = $task["task_end_date"]; - if (!$end_date) $end_date = $start_date; + if (!$end_date) { + $end_date = $start_date; + } $start_date = dol_print_date($start_date, $dateformatinput2); $end_date = dol_print_date($end_date, $dateformatinput2); // Resources @@ -198,8 +197,7 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje } // $depend .= "\""; // Define parent - if ($project_id && $level < 0) - { + if ($project_id && $level < 0) { $parent = '-'.$project_id; } else { $parent = $task["task_parent_alternate_id"]; @@ -208,8 +206,7 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje // Define percent $percent = $task['task_percent_complete'] ? $task['task_percent_complete'] : 0; // Link (more information) - if ($task["task_id"] < 0) - { + if ($task["task_id"] < 0) { //$link=DOL_URL_ROOT.'/projet/tasks.php?withproject=1&id='.abs($task["task_id"]); $link = ''; } else { @@ -221,8 +218,8 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje $name = $task['task_name']; /*for($i=0; $i < $level; $i++) { - $name=' - '.$name; - }*/ + $name=' - '.$name; + }*/ // Add line to gantt /* g.AddTaskItem(new JSGantt.TaskItem(1, 'Define Chart API','', '', 'ggroupblack','', 0, 'Brian', 0, 1,0,1,'','','Some Notes text',g)); @@ -247,7 +244,7 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje <dt>pCaption</dt><dd>(optional) caption that will be added after task bar if CaptionType set to "Caption"</dd> <dt>pNotes</dt><dd>(optional) Detailed task information that will be displayed in tool tip for this task</dd> <dt>pGantt</dt><dd>(required) javascript JSGantt.GanttChart object from which to take settings. Defaults to &quot;g&quot; for backwards compatibility</dd> - */ + */ //$note=""; @@ -289,18 +286,16 @@ function findChildGanttLine($tarr, $parent, $task_dependencies, $level) $n = count($tarr); $old_parent_id = 0; - for ($x = 0; $x < $n; $x++) - { - if ($tarr[$x]["task_parent"] == $parent && $tarr[$x]["task_parent"] != $tarr[$x]["task_id"]) - { + for ($x = 0; $x < $n; $x++) { + if ($tarr[$x]["task_parent"] == $parent && $tarr[$x]["task_parent"] != $tarr[$x]["task_id"]) { // Create a grouping parent task for the new level /*if (empty($old_parent_id) || $old_parent_id != $tarr[$x]['task_project_id']) { $tmpt = array( - 'task_id'=> -98, 'task_name'=>'Level '.$level, 'task_resources'=>'', 'task_start_date'=>'', 'task_end_date'=>'', - 'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>$tarr[$x]["task_parent"], 'task_notes'=>''); - constructGanttLine($tasks, $tmpt, array(), 0, $tarr[$x]['task_project_id']); - $old_parent_id = $tarr[$x]['task_project_id']; + 'task_id'=> -98, 'task_name'=>'Level '.$level, 'task_resources'=>'', 'task_start_date'=>'', 'task_end_date'=>'', + 'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>$tarr[$x]["task_parent"], 'task_notes'=>''); + constructGanttLine($tasks, $tmpt, array(), 0, $tarr[$x]['task_project_id']); + $old_parent_id = $tarr[$x]['task_project_id']; }*/ constructGanttLine($tarr, $tarr[$x], $task_dependencies, $level, null); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 8b2f41554d3..b4dbc21e894 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -43,7 +43,9 @@ $mine = ($mode == 'mine' ? 1 : 0); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} // Security check $socid = 0; @@ -74,8 +76,7 @@ $task = new Task($db); $arrayofcss = array('/includes/jsgantt/jsgantt.css'); -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { $arrayofjs = array( '/includes/jsgantt/jsgantt.js', '/projet/jsgantt_language.js.php?lang='.$langs->defaultlang @@ -84,12 +85,13 @@ if (!empty($conf->use_javascript_ajax)) //$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); $title = $langs->trans("Gantt"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss); -if (($id > 0 && is_numeric($id)) || !empty($ref)) -{ +if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -113,15 +115,13 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -140,22 +140,19 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -165,8 +162,11 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -176,12 +176,16 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -252,8 +256,7 @@ $tasksarray = $task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $soc //var_dump($tasksrole); -if (count($tasksarray) > 0) -{ +if (count($tasksarray) > 0) { // Show Gant diagram from $taskarray using JSGantt $dateformat = $langs->trans("FormatDateShortJQuery"); // Used by include ganttchart.inc.php later @@ -262,8 +265,7 @@ if (count($tasksarray) > 0) $tasks = array(); $task_dependencies = array(); $taskcursor = 0; - foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, date" - { + foreach ($tasksarray as $key => $val) { // Task array are sorted by "project, position, date" $task->fetch($val->id, ''); $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id @@ -299,34 +301,34 @@ if (count($tasksarray) > 0) $idofusers = $task->getListContactId('internal'); $idofcontacts = $task->getListContactId('external'); - $s = ''; - if (count($idofusers) > 0) - { + $s = ''; + if (count($idofusers) > 0) { $s .= $langs->trans("Internals").': '; $i = 0; - foreach ($idofusers as $valid) - { + foreach ($idofusers as $valid) { $userstatic->fetch($valid); - if ($i) $s .= ', '; + if ($i) { + $s .= ', '; + } $s .= $userstatic->login; $i++; } } //if (count($idofusers)>0 && (count($idofcontacts)>0)) $s.=' - '; - if (count($idofcontacts) > 0) - { - if ($s) $s .= ' - '; + if (count($idofcontacts) > 0) { + if ($s) { + $s .= ' - '; + } $s .= $langs->trans("Externals").': '; $i = 0; $contactidfound = array(); - foreach ($idofcontacts as $valid) - { - if (empty($contactidfound[$valid])) - { + foreach ($idofcontacts as $valid) { + if (empty($contactidfound[$valid])) { $res = $contactstatic->fetch($valid); - if ($res > 0) - { - if ($i) $s .= ', '; + if ($res > 0) { + if ($i) { + $s .= ', '; + } $s .= $contactstatic->getFullName($langs); $contactidfound[$valid] = 1; $i++; @@ -338,30 +340,30 @@ if (count($tasksarray) > 0) /* For JSGanttImproved */ //if ($s) $tasks[$taskcursor]['task_resources']=implode(',',$idofusers); $tasks[$taskcursor]['task_resources'] = $s; - if ($s) $tasks[$taskcursor]['task_resources'] = '<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>'; + if ($s) { + $tasks[$taskcursor]['task_resources'] = '<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>'; + } //print "xxx".$val->id.$tasks[$taskcursor]['task_resources']; $tasks[$taskcursor]['note'] = $task->note_public; $taskcursor++; } // Search parent to set task_parent_alternate_id (requird by ganttchart) - foreach ($tasks as $tmpkey => $tmptask) - { - foreach ($tasks as $tmptask2) - { - if ($tmptask2['task_id'] == $tmptask['task_parent']) - { + foreach ($tasks as $tmpkey => $tmptask) { + foreach ($tasks as $tmptask2) { + if ($tmptask2['task_id'] == $tmptask['task_parent']) { $tasks[$tmpkey]['task_parent_alternate_id'] = $tmptask2['task_alternate_id']; break; } } - if (empty($tasks[$tmpkey]['task_parent_alternate_id'])) $tasks[$tmpkey]['task_parent_alternate_id'] = $tasks[$tmpkey]['task_parent']; + if (empty($tasks[$tmpkey]['task_parent_alternate_id'])) { + $tasks[$tmpkey]['task_parent_alternate_id'] = $tasks[$tmpkey]['task_parent']; + } } print "\n"; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { //var_dump($_SESSION); // How the date for data are formated (format used bu jsgantt) @@ -369,7 +371,7 @@ if (count($tasksarray) > 0) // How the date for data are formated (format used by dol_print_date) $dateformatinput2 = 'standard'; //var_dump($dateformatinput); - //var_dump($dateformatinput2); + //var_dump($dateformatinput2); $moreforfilter = '<div class="liste_titre liste_titre_bydiv centpercent">'; diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 66b04527772..7795981c4c3 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -17,19 +17,21 @@ // variable $listofopplabel and $listofoppstatus should be defined -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON p.fk_opp_status = cls.rowid"; // If lead status has been removed, we must show it in stats as unknown $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.fk_statut = 1"; // Opend projects only - if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; - if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($mine || empty($user->rights->projet->all->lire)) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; + } + if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + } $sql .= " GROUP BY p.fk_opp_status, cls.code"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -41,15 +43,15 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $valsamount = array(); $dataseries = array(); // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $valsnb[$obj->opp_status] = $obj->nb; $valsamount[$obj->opp_status] = $obj->opp_amount; $totalnb += $obj->nb; - if ($obj->opp_status) $totaloppnb += $obj->nb; + if ($obj->opp_status) { + $totaloppnb += $obj->nb; + } if (!in_array($obj->code, array('WON', 'LOST'))) { $totalamount += $obj->opp_amount; $ponderated_opp_amount += $obj->ponderated_opp_amount; @@ -63,40 +65,43 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $ponderated_opp_amount = $ponderated_opp_amount / 100; print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder nohover centpercent">'; - print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'</th></tr>'."\n"; + print '<table class="noborder nohover centpercent">'; + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'</th></tr>'."\n"; - $listofstatus = array_keys($listofoppstatus); + $listofstatus = array_keys($listofoppstatus); // Complete with values found into database and not into the dictionary - foreach ($valsamount as $key => $val) { - if (!in_array($key, $listofstatus) && $key) { - $listofstatus[] = $key; - } - } + foreach ($valsamount as $key => $val) { + if (!in_array($key, $listofstatus) && $key) { + $listofstatus[] = $key; + } + } - foreach ($listofstatus as $status) - { - $labelStatus = ''; + foreach ($listofstatus as $status) { + $labelStatus = ''; $code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code'); - if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus".$code); - if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; - if (empty($labelStatus)) $labelStatus = $langs->transnoentitiesnoconv('OldValue', $status); // When id is id of an entry no more in dictionary for example. + if ($code) { + $labelStatus = $langs->transnoentitiesnoconv("OppStatus".$code); + } + if (empty($labelStatus)) { + $labelStatus = $listofopplabel[$status]; + } + if (empty($labelStatus)) { + $labelStatus = $langs->transnoentitiesnoconv('OldValue', $status); // When id is id of an entry no more in dictionary for example. + } //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%'; $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); - if (!$conf->use_javascript_ajax) - { + if (!$conf->use_javascript_ajax) { print '<tr class="oddeven">'; print '<td>'.$labelStatus.'</td>'; print '<td class="right"><a href="list.php?statut='.$status.'">'.price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency).'</a></td>'; print "</tr>\n"; } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '<tr><td class="center nopaddingleftimp nopaddingrightimp" colspan="2">'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index f2b1820c019..25844a573dd 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -42,13 +42,19 @@ $langs->loadLangs(array('projects', 'companies')); $action = GETPOST('action', 'aZ09'); $search_project_user = GETPOST('search_project_user', 'int'); $mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0; -if ($mine == 0 && $search_project_user === '') $search_project_user = $user->conf->MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX; -if ($search_project_user == $user->id) $mine = 1; +if ($mine == 0 && $search_project_user === '') { + $search_project_user = $user->conf->MAIN_SEARCH_PROJECT_USER_PROJECTSINDEX; +} +if ($search_project_user == $user->id) { + $mine = 1; +} // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -62,7 +68,9 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { if ($action == 'refresh_search_project_user') { $search_project_user = GETPOST('search_project_user', 'int'); @@ -95,8 +103,11 @@ $title = $langs->trans("ProjectsArea"); // Title for combo list see all projects $titleall = $langs->trans("AllAllowedProjects"); -if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects"); -else $titleall = $langs->trans("AllAllowedProjects").'<br><br>'; +if (!empty($user->rights->projet->all->lire) && !$socid) { + $titleall = $langs->trans("AllProjects"); +} else { + $titleall = $langs->trans("AllAllowedProjects").'<br><br>'; +} $morehtml = ''; $morehtml .= '<form name="projectform" method="POST">'; @@ -109,10 +120,14 @@ $morehtml .= '</SELECT>'; $morehtml .= '<input type="submit" class="button smallpaddingimp" name="refresh" value="'.$langs->trans("Refresh").'">'; $morehtml .= '</form>'; -if ($mine) $tooltiphelp = $langs->trans("MyProjectsDesc"); -else { - if (!empty($user->rights->projet->all->lire) && !$socid) $tooltiphelp = $langs->trans("ProjectsDesc"); - else $tooltiphelp = $langs->trans("ProjectsPublicDesc"); +if ($mine) { + $tooltiphelp = $langs->trans("MyProjectsDesc"); +} else { + if (!empty($user->rights->projet->all->lire) && !$socid) { + $tooltiphelp = $langs->trans("ProjectsDesc"); + } else { + $tooltiphelp = $langs->trans("ProjectsPublicDesc"); + } } print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'project', 0, $morehtml); @@ -125,13 +140,11 @@ $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; $sql .= " WHERE active=1"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $listofoppstatus[$objp->rowid] = $objp->percent; $listofopplabel[$objp->rowid] = $objp->label; @@ -161,34 +174,36 @@ if ($resql) } $i++; } -} else dol_print_error($db); +} else { + dol_print_error($db); +} //var_dump($listofoppcode); print '<div class="fichecenter"><div class="fichethirdleft">'; -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 // Search project - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) - { + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $listofsearchfields['search_project'] = array('text'=>'Project'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + } print '<tr>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + if ($i == 0) { + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + } print '</tr>'; $i++; } @@ -222,14 +237,17 @@ $sql .= ", s.canvas, s.status as thirdpartystatus"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; -if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 -if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($mine || empty($user->rights->projet->all->lire)) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 +} +if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +} $sql .= " ORDER BY p.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; @@ -238,11 +256,9 @@ if ($resql) $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '<tr class="oddeven">'; @@ -290,8 +306,7 @@ if ($resql) print '</td>'; print '<td class="nowrap">'; - if ($companystatic->id > 0) - { + if ($companystatic->id > 0) { print $companystatic->getNomUrl(1, 'company', 16); } print '</td>'; @@ -304,7 +319,9 @@ if ($resql) print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; } print "</table></div>"; -} else dol_print_error($db); +} else { + dol_print_error($db); +} $companystatic = new Societe($db); // We need a clean new object for next loop because current one has some properties set. @@ -320,15 +337,18 @@ $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.fk_statut = 1"; -if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 -if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($mine || empty($user->rights->projet->all->lire)) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 +} +if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +} $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, s.canvas, s.status"; $sql .= $db->order($sortfield, $sortorder); //$sql .= $db->plimit($max + 1, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; $othernb = 0; @@ -345,8 +365,7 @@ if ($resql) print "</tr>\n"; } - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($i >= $max) { @@ -357,8 +376,7 @@ if ($resql) print '<tr class="oddeven">'; print '<td class="nowraponall tdoverflowmax100">'; - if ($obj->socid > 0) - { + if ($obj->socid > 0) { $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->name_alias = $obj->name_alias; @@ -380,8 +398,11 @@ if ($resql) } print '</td>'; print '<td class="right">'; - if ($obj->socid) print '<a href="'.DOL_URL_ROOT.'/projet/list.php?socid='.$obj->socid.'&search_status=1">'.$obj->nb.'</a>'; - else print '<a href="'.DOL_URL_ROOT.'/projet/list.php?search_societe='.urlencode('^$').'&search_status=1">'.$obj->nb.'</a>'; + if ($obj->socid) { + print '<a href="'.DOL_URL_ROOT.'/projet/list.php?socid='.$obj->socid.'&search_status=1">'.$obj->nb.'</a>'; + } else { + print '<a href="'.DOL_URL_ROOT.'/projet/list.php?search_societe='.urlencode('^$').'&search_status=1">'.$obj->nb.'</a>'; + } print '</td>'; print "</tr>\n"; @@ -408,8 +429,7 @@ if ($resql) dol_print_error($db); } -if (empty($conf->global->PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA)) -{ +if (empty($conf->global->PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA)) { // This list can be very long, so we allow to hide it to prefer to use the list page. // Add constant PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA to hide this list diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index e87aa25dadb..d99da02caa6 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -42,16 +42,21 @@ $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (!$sortfield) $sortfield = "a.datep,a.id"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "a.datep,a.id"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + 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)); } @@ -63,7 +68,9 @@ $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. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} @@ -73,11 +80,12 @@ if (!$user->rights->projet->lire) accessforbidden(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -91,16 +99,19 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $object = new Project($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $object->info($object->id); } $title = $langs->trans("Project").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url); @@ -117,15 +128,13 @@ $morehtmlref = '<div class="refidno">'; // Title $morehtmlref .= $object->title; // Thirdparty -if ($object->thirdparty->id > 0) -{ +if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. -if (!$user->rights->projet->all->lire) -{ +if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -149,29 +158,30 @@ print dol_get_fiche_end(); $out = ''; $permok = $user->rights->agenda->myactions->create; -if ($permok) -{ +if ($permok) { $out .= '&projectid='.$object->id; } //print '<div class="tabsAction">'; $morehtmlcenter = ''; -if (!empty($conf->agenda->enabled)) -{ +if (!empty($conf->agenda->enabled)) { $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); - $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); + $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } //print '</div>'; -if (!empty($object->id)) -{ +if (!empty($object->id)) { print '<br>'; $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; + } print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index 41fcd1934ae..35ab1132ae7 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -20,13 +20,27 @@ * \brief Fichier de javascript de traduction pour JSGantt */ -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'); +} require_once __DIR__.'/../main.inc.php'; @@ -40,20 +54,22 @@ $langs->load("projects"); var vLangs={'<?php print $langs->getDefaultLang(1); ?>': { 'format':'<?php print $langs->transnoentities('Period'); ?>','hour':'"<?php print $langs->transnoentities('Hour'); ?>','day':'<?php print $langs->transnoentities('Day'); ?>', - 'week':'<?php print $langs->transnoentities('Week'); ?>','month':'<?php print $langs->transnoentities('Month'); ?>','quarter':'<?php print $langs->transnoentities('Quadri'); ?>', - 'hours':'<?php print $langs->transnoentities('Hours'); ?>','days':'<?php print $langs->transnoentities('Days'); ?>','weeks':'<?php print $langs->transnoentities('Weeks'); ?>', - 'months':'<?php print $langs->transnoentities('Months'); ?>','quarters':'<?php print $langs->transnoentities('Quadri'); ?>','hr':'Hr','dy':'<?php print $langs->transnoentities('Day'); ?>','wk':'<?php print $langs->transnoentities('Week'); ?>','mth':'<?php print $langs->transnoentities('Month'); ?>','qtr':'<?php print $langs->transnoentities('Quadri'); ?>','hrs':'<?php print $langs->transnoentities('Hours'); ?>', - 'dys':'<?php print $langs->transnoentities('Days'); ?>','wks':'<?php print $langs->transnoentities('Weeks'); ?>','mths':'<?php print $langs->transnoentities('Months'); ?>','qtrs':'<?php print $langs->transnoentities('Quadri'); ?>','resource':'<?php print dol_escape_js($langs->transnoentities('Resource')); ?>','duration':'<?php print dol_escape_js($langs->transnoentities('Duration')); ?>','comp':'%', - 'completion':'<?php print $langs->transnoentities('Total'); ?>','startdate':'<?php print $langs->transnoentities('DateStart'); ?>','enddate':'<?php print $langs->transnoentities('DateEnd'); ?>','moreinfo':'<?php print dol_escape_js($langs->transnoentities('ShowTask')); ?>', - 'notes':'<?php print $langs->transnoentities('NotePublic'); ?>', - 'january':'<?php print $langs->transnoentities('January'); ?>','february':'<?php print $langs->transnoentities('February'); ?>','march':'<?php print $langs->transnoentities('March'); ?>','april':'<?php print $langs->transnoentities('April'); ?>','maylong':'<?php print $langs->transnoentities('May'); ?>','june':'<?php print $langs->transnoentities('June'); ?>','july':'<?php print $langs->transnoentities('July'); ?>', - 'august':'<?php print $langs->transnoentities('August'); ?>','september':'<?php print $langs->transnoentities('September'); ?>','october':'<?php print $langs->transnoentities('October'); ?>','november':'<?php print $langs->transnoentities('November'); ?>','december':'<?php print $langs->transnoentities('December'); ?>', - 'jan':'<?php print $langs->transnoentities('MonthShort01'); ?>','feb':'<?php print $langs->transnoentities('MonthShort02'); ?>','mar':'<?php print $langs->transnoentities('MonthShort03'); ?>','apr':'<?php print $langs->transnoentities('MonthShort04'); ?>','may':'<?php print $langs->transnoentities('MonthShort05'); ?>','jun':'<?php print $langs->transnoentities('MonthShort06'); ?>','jul':'<?php print $langs->transnoentities('MonthShort07'); ?>', - 'aug':'<?php print $langs->transnoentities('MonthShort08'); ?>','sep':'<?php print $langs->transnoentities('MonthShort09'); ?>','oct':'<?php print $langs->transnoentities('MonthShort10'); ?>','nov':'<?php print $langs->transnoentities('MonthShort11'); ?>','dec':'<?php print $langs->transnoentities('MonthShort12'); ?>', - 'sunday':'<?php print $langs->transnoentities('Sunday'); ?>','monday':'<?php print $langs->transnoentities('Monday'); ?>','tuesday':'<?php print $langs->transnoentities('Tuesday'); ?>','wednesday':'<?php print $langs->transnoentities('Wednesday'); ?>','thursday':'<?php print $langs->transnoentities('Thursday'); ?>','friday':'<?php print $langs->transnoentities('Friday'); ?>','saturday':'<?php print $langs->transnoentities('Saturday'); ?>', - 'sun':'<?php print $langs->transnoentities('SundayMin'); ?>','mon':'<?php print $langs->transnoentities('MondayMin'); ?>','tue':'<?php print $langs->transnoentities('TuesdayMin'); ?>','wed':'<?php print $langs->transnoentities('WednesdayMin'); ?>','thu':'<?php print $langs->transnoentities('ThursdayMin'); ?>','fri':'<?php print $langs->transnoentities('FridayMin'); ?>','sat':'<?php print $langs->transnoentities('SaturdayMin'); ?>' - } + 'week':'<?php print $langs->transnoentities('Week'); ?>','month':'<?php print $langs->transnoentities('Month'); ?>','quarter':'<?php print $langs->transnoentities('Quadri'); ?>', + 'hours':'<?php print $langs->transnoentities('Hours'); ?>','days':'<?php print $langs->transnoentities('Days'); ?>','weeks':'<?php print $langs->transnoentities('Weeks'); ?>', + 'months':'<?php print $langs->transnoentities('Months'); ?>','quarters':'<?php print $langs->transnoentities('Quadri'); ?>','hr':'Hr','dy':'<?php print $langs->transnoentities('Day'); ?>','wk':'<?php print $langs->transnoentities('Week'); ?>','mth':'<?php print $langs->transnoentities('Month'); ?>','qtr':'<?php print $langs->transnoentities('Quadri'); ?>','hrs':'<?php print $langs->transnoentities('Hours'); ?>', + 'dys':'<?php print $langs->transnoentities('Days'); ?>','wks':'<?php print $langs->transnoentities('Weeks'); ?>','mths':'<?php print $langs->transnoentities('Months'); ?>','qtrs':'<?php print $langs->transnoentities('Quadri'); ?>','resource':'<?php print dol_escape_js($langs->transnoentities('Resource')); ?>','duration':'<?php print dol_escape_js($langs->transnoentities('Duration')); ?>','comp':'%', + 'completion':'<?php print $langs->transnoentities('Total'); ?>','startdate':'<?php print $langs->transnoentities('DateStart'); ?>','enddate':'<?php print $langs->transnoentities('DateEnd'); ?>','moreinfo':'<?php print dol_escape_js($langs->transnoentities('ShowTask')); ?>', + 'notes':'<?php print $langs->transnoentities('NotePublic'); ?>', + 'january':'<?php print $langs->transnoentities('January'); ?>','february':'<?php print $langs->transnoentities('February'); ?>','march':'<?php print $langs->transnoentities('March'); ?>','april':'<?php print $langs->transnoentities('April'); ?>','maylong':'<?php print $langs->transnoentities('May'); ?>','june':'<?php print $langs->transnoentities('June'); ?>','july':'<?php print $langs->transnoentities('July'); ?>', + 'august':'<?php print $langs->transnoentities('August'); ?>','september':'<?php print $langs->transnoentities('September'); ?>','october':'<?php print $langs->transnoentities('October'); ?>','november':'<?php print $langs->transnoentities('November'); ?>','december':'<?php print $langs->transnoentities('December'); ?>', + 'jan':'<?php print $langs->transnoentities('MonthShort01'); ?>','feb':'<?php print $langs->transnoentities('MonthShort02'); ?>','mar':'<?php print $langs->transnoentities('MonthShort03'); ?>','apr':'<?php print $langs->transnoentities('MonthShort04'); ?>','may':'<?php print $langs->transnoentities('MonthShort05'); ?>','jun':'<?php print $langs->transnoentities('MonthShort06'); ?>','jul':'<?php print $langs->transnoentities('MonthShort07'); ?>', + 'aug':'<?php print $langs->transnoentities('MonthShort08'); ?>','sep':'<?php print $langs->transnoentities('MonthShort09'); ?>','oct':'<?php print $langs->transnoentities('MonthShort10'); ?>','nov':'<?php print $langs->transnoentities('MonthShort11'); ?>','dec':'<?php print $langs->transnoentities('MonthShort12'); ?>', + 'sunday':'<?php print $langs->transnoentities('Sunday'); ?>','monday':'<?php print $langs->transnoentities('Monday'); ?>','tuesday':'<?php print $langs->transnoentities('Tuesday'); ?>','wednesday':'<?php print $langs->transnoentities('Wednesday'); ?>','thursday':'<?php print $langs->transnoentities('Thursday'); ?>','friday':'<?php print $langs->transnoentities('Friday'); ?>','saturday':'<?php print $langs->transnoentities('Saturday'); ?>', + 'sun':'<?php print $langs->transnoentities('SundayMin'); ?>','mon':'<?php print $langs->transnoentities('MondayMin'); ?>','tue':'<?php print $langs->transnoentities('TuesdayMin'); ?>','wed':'<?php print $langs->transnoentities('WednesdayMin'); ?>','thu':'<?php print $langs->transnoentities('ThursdayMin'); ?>','fri':'<?php print $langs->transnoentities('FridayMin'); ?>','sat':'<?php print $langs->transnoentities('SaturdayMin'); ?>' + } }; var vLang='<?php print $langs->getDefaultLang(1); ?>'; <?php -if (is_object($db)) $db->close(); +if (is_object($db)) { + $db->close(); +} diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 820834b2b8e..933abd53692 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -35,8 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -59,13 +58,14 @@ $title = $langs->trans("Projects"); // Security check $socid = (is_numeric($_GET["socid"]) ? $_GET["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. -if ($socid > 0) -{ +if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); $title .= ' (<a href="list.php">'.$soc->name.'</a>)'; } -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id; @@ -73,9 +73,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "aZ09comma"); $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters -if (!$sortfield) $sortfield = "p.ref"; -if (!$sortorder) $sortorder = "ASC"; +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +if (!$sortfield) { + $sortfield = "p.ref"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -103,7 +109,9 @@ $search_price_booth = GETPOST("search_price_booth", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; -if ($mine) { $search_project_user = $user->id; $mine = 0; } +if ($mine) { + $search_project_user = $user->id; $mine = 0; +} $search_sday = GETPOST('search_sday', 'int'); $search_smonth = GETPOST('search_smonth', 'int'); @@ -112,10 +120,11 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); -if ($search_status == '') $search_status = -1; // -1 or 1 +if ($search_status == '') { + $search_status = -1; // -1 or 1 +} -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array"); } @@ -179,21 +188,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_all = ''; $search_ref = ""; $search_label = ""; @@ -236,17 +249,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (!$error && $massaction == 'close' && $user->rights->projet->creer) - { + if (!$error && $massaction == 'close' && $user->rights->projet->creer) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $userWrite = $object->restrictedProjectArea($user, 'write'); if ($userWrite > 0 && $objecttmp->statut == 1) { $result = $objecttmp->setClose($user); @@ -254,7 +264,9 @@ if (empty($reshook)) setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } elseif ($userWrite <= 0) { setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); } else { @@ -267,10 +279,12 @@ if (empty($reshook)) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -294,7 +308,9 @@ $title = $langs->trans("Projects"); // Get list of project id allowed to user (in a string list separated by comma) $projectsListId = ''; -if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); +if (!$user->rights->projet->all->lire) { + $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); +} // Get id of types of contacts for projects (This list never contains a lot of elements) $listofprojectcontacttype = array(); @@ -302,14 +318,16 @@ $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc" $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); -if ($resql) -{ - while ($obj = $db->fetch_object($resql)) - { +if ($resql) { + while ($obj = $db->fetch_object($resql)) { $listofprojectcontacttype[$obj->rowid] = $obj->code; } -} else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found +} else { + dol_print_error($db); +} +if (count($listofprojectcontacttype) == 0) { + $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found +} $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat"; @@ -320,7 +338,9 @@ $sql .= ", s.rowid as socid, s.nom as name, s.email"; $sql .= ", cls.code as opp_status_code"; // 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 : ''); + 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(); @@ -328,67 +348,121 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p"; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid"); } -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 (p.rowid = ef.fk_object)"; +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 (p.rowid = ef.fk_object)"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; // We'll need this table joined to the select in order to filter by sale // No check is done on company permission because readability is managed by public status of project and assignement. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; -if ($search_sale > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; -if ($search_project_user > 0) -{ +if ($search_sale > 0) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; +} +if ($search_project_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; } $sql .= " WHERE p.entity IN (".getEntity('project').')'; -if (!empty($conf->categorie->enabled)) -{ +if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array); } -if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users +if (!$user->rights->projet->all->lire) { + $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users +} // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid > 0) $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); -if ($search_label) $sql .= natural_search('p.title', $search_label); -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); -if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1); +if ($socid > 0) { + $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) +} +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} +if ($search_label) { + $sql .= natural_search('p.title', $search_label); +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); +} +if ($search_opp_amount) { + $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); +} +if ($search_opp_percent) { + $sql .= natural_search('p.opp_percent', $search_opp_percent, 1); +} $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear); -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_status >= 0) -{ - if ($search_status == 99) $sql .= " AND p.fk_statut <> 2"; - else $sql .= " AND p.fk_statut = ".$db->escape($search_status); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_opp_status) -{ - if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); - if ($search_opp_status == 'all') $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)"; - if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; - if ($search_opp_status == 'notopenedopp') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; - if ($search_opp_status == 'none') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; +if ($search_status >= 0) { + if ($search_status == 99) { + $sql .= " AND p.fk_statut <> 2"; + } else { + $sql .= " AND p.fk_statut = ".$db->escape($search_status); + } +} +if ($search_opp_status) { + if (is_numeric($search_opp_status) && $search_opp_status > 0) { + $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); + } + if ($search_opp_status == 'all') { + $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)"; + } + if ($search_opp_status == 'openedopp') { + $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; + } + if ($search_opp_status == 'notopenedopp') { + $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; + } + if ($search_opp_status == 'none') { + $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; + } +} +if ($search_public != '') { + $sql .= " AND p.public = ".$db->escape($search_public); } -if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$search_sale; +if ($search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; +} // No check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; -if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; -if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); -if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1); -if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2); -if ($search_usage_task != '' && $search_usage_task >= 0) $sql .= natural_search('p.usage_task', $search_usage_task, 2); -if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2); -if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2); -if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2); -if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2); -if ($search_price_registration != '') $sql .= natural_search('p.price_registration', $search_price_registration, 1); -if ($search_price_booth != '') $sql .= natural_search('p.price_booth', $search_price_booth, 1); +if ($search_project_user > 0) { + $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +} +if ($search_opp_amount != '') { + $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); +} +if ($search_budget_amount != '') { + $sql .= natural_search('p.budget_amount', $search_budget_amount, 1); +} +if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) { + $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2); +} +if ($search_usage_task != '' && $search_usage_task >= 0) { + $sql .= natural_search('p.usage_task', $search_usage_task, 2); +} +if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) { + $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2); +} +if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) { + $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2); +} +if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) { + $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2); +} +if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) { + $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2); +} +if ($search_price_registration != '') { + $sql .= natural_search('p.price_registration', $search_price_registration, 1); +} +if ($search_price_booth != '') { + $sql .= natural_search('p.price_booth', $search_price_booth, 1); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -411,7 +485,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if (!$resql) { @@ -423,8 +499,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id); exit; @@ -441,36 +516,96 @@ llxHeader('', $title, $help_url); $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); -if ($search_all != '') $param .= '&search_all='.urlencode($search_all); -if ($search_sday) $param .= '&search_sday='.urlencode($search_sday); -if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); -if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); -if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); -if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); -if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); -if ($socid) $param .= '&socid='.urlencode($socid); -if ($search_categ) $param .= '&search_categ='.urlencode($search_categ); -if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); -if ($search_label != '') $param .= '&search_label='.urlencode($search_label); -if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); -if ($search_status >= 0) $param .= '&search_status='.urlencode($search_status); -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); -if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent); -if ($search_public != '') $param .= '&search_public='.urlencode($search_public); -if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); -if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); -if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount); -if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount); -if ($search_usage_task != '') $param .= '&search_usage_task='.urlencode($search_usage_task); -if ($search_usage_bill_time != '') $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time); -if ($search_usage_event_organization != '') $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization); -if ($search_accept_conference_suggestions != '') $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions); -if ($search_accept_booth_suggestions != '') $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions); -if ($search_price_registration != '') $param .= '&search_price_registration='.urlencode($search_price_registration); -if ($search_price_booth != '') $param .= '&search_price_booth='.urlencode($search_price_booth); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($search_all != '') { + $param .= '&search_all='.urlencode($search_all); +} +if ($search_sday) { + $param .= '&search_sday='.urlencode($search_sday); +} +if ($search_smonth) { + $param .= '&search_smonth='.urlencode($search_smonth); +} +if ($search_syear) { + $param .= '&search_syear='.urlencode($search_syear); +} +if ($search_eday) { + $param .= '&search_eday='.urlencode($search_eday); +} +if ($search_emonth) { + $param .= '&search_emonth='.urlencode($search_emonth); +} +if ($search_eyear) { + $param .= '&search_eyear='.urlencode($search_eyear); +} +if ($socid) { + $param .= '&socid='.urlencode($socid); +} +if ($search_categ) { + $param .= '&search_categ='.urlencode($search_categ); +} +if ($search_ref != '') { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_label != '') { + $param .= '&search_label='.urlencode($search_label); +} +if ($search_societe != '') { + $param .= '&search_societe='.urlencode($search_societe); +} +if ($search_status >= 0) { + $param .= '&search_status='.urlencode($search_status); +} +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) { + $param .= '&search_opp_status='.urlencode($search_opp_status); +} +if ($search_opp_percent != '') { + $param .= '&search_opp_percent='.urlencode($search_opp_percent); +} +if ($search_public != '') { + $param .= '&search_public='.urlencode($search_public); +} +if ($search_project_user != '') { + $param .= '&search_project_user='.urlencode($search_project_user); +} +if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); +} +if ($search_opp_amount != '') { + $param .= '&search_opp_amount='.urlencode($search_opp_amount); +} +if ($search_budget_amount != '') { + $param .= '&search_budget_amount='.urlencode($search_budget_amount); +} +if ($search_usage_task != '') { + $param .= '&search_usage_task='.urlencode($search_usage_task); +} +if ($search_usage_bill_time != '') { + $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time); +} +if ($search_usage_event_organization != '') { + $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization); +} +if ($search_accept_conference_suggestions != '') { + $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions); +} +if ($search_accept_booth_suggestions != '') { + $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions); +} +if ($search_price_registration != '') { + $param .= '&search_price_registration='.urlencode($search_price_registration); +} +if ($search_price_booth != '') { + $param .= '&search_price_booth='.urlencode($search_price_booth); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -481,19 +616,31 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); -if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if ($user->rights->projet->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); -if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); +if ($user->rights->projet->creer) { + $arrayofmassactions['close'] = $langs->trans("Close"); +} +if ($user->rights->projet->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if ($user->rights->projet->creer) { + $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); +} +if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/projet/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="action" value="list">'; @@ -503,10 +650,14 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; // Show description of content $texthelp = ''; -if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc"); -else { - if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); - else $texthelp .= $langs->trans("ProjectsPublicDesc"); +if ($search_project_user == $user->id) { + $texthelp .= $langs->trans("MyProjectsDesc"); +} else { + if ($user->rights->projet->all->lire && !$socid) { + $texthelp .= $langs->trans("ProjectsDesc"); + } else { + $texthelp .= $langs->trans("ProjectsPublicDesc"); + } } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -518,17 +669,17 @@ $objecttmp = new Project($db); $trackid = 'proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; // Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); } @@ -538,13 +689,14 @@ $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; //$includeonly = 'hierarchyme'; $includeonly = ''; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; // If the user can view thirdparties other than his' -if ($user->rights->societe->client->voir || $socid) -{ +if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; @@ -552,8 +704,7 @@ if ($user->rights->societe->client->voir || $socid) $moreforfilter .= '</div>'; } -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -573,22 +724,19 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit // -------------------------------------------------------------------- print '<tr class="liste_titre_filter">'; // Project ref -if (!empty($arrayfields['p.ref']['checked'])) -{ +if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">'; print '</td>'; } // Project label -if (!empty($arrayfields['p.title']['checked'])) -{ +if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">'; print '</td>'; } // Third party -if (!empty($arrayfields['s.nom']['checked'])) -{ +if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; if ($socid > 0) { $tmpthirdparty = new Societe($db); @@ -599,110 +747,97 @@ if (!empty($arrayfields['s.nom']['checked'])) print '</td>'; } // Sale representative -if (!empty($arrayfields['commercial']['checked'])) -{ +if (!empty($arrayfields['commercial']['checked'])) { print '<td class="liste_titre">&nbsp;</td>'; } // Start date -if (!empty($arrayfields['p.dateo']['checked'])) -{ +if (!empty($arrayfields['p.dateo']['checked'])) { print '<td class="liste_titre center nowraponall">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">'; + } print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">'; $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '</td>'; } // End date -if (!empty($arrayfields['p.datee']['checked'])) -{ +if (!empty($arrayfields['p.datee']['checked'])) { print '<td class="liste_titre center nowraponall">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">'; + } print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">'; $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '</td>'; } -if (!empty($arrayfields['p.public']['checked'])) -{ +if (!empty($arrayfields['p.public']['checked'])) { print '<td class="liste_titre">'; $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject")); print $form->selectarray('search_public', $array, $search_public); print '</td>'; } // Opp status -if (!empty($arrayfields['p.fk_opp_status']['checked'])) -{ +if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print '<td class="liste_titre nowrap center">'; print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); print '</td>'; } -if (!empty($arrayfields['p.opp_amount']['checked'])) -{ +if (!empty($arrayfields['p.opp_amount']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">'; print '</td>'; } -if (!empty($arrayfields['p.opp_percent']['checked'])) -{ +if (!empty($arrayfields['p.opp_percent']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">'; print '</td>'; } -if (!empty($arrayfields['opp_weighted_amount']['checked'])) -{ +if (!empty($arrayfields['opp_weighted_amount']['checked'])) { print '<td class="liste_titre nowrap right">'; print '</td>'; } -if (!empty($arrayfields['p.budget_amount']['checked'])) -{ +if (!empty($arrayfields['p.budget_amount']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">'; print '</td>'; } -if (!empty($arrayfields['p.usage_opportunity']['checked'])) -{ +if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1); print ''; print '</td>'; } -if (!empty($arrayfields['p.usage_task']['checked'])) -{ +if (!empty($arrayfields['p.usage_task']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1); print '</td>'; } -if (!empty($arrayfields['p.usage_bill_time']['checked'])) -{ +if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1); print '</td>'; } -if (!empty($arrayfields['p.usage_organize_event']['checked'])) -{ +if (!empty($arrayfields['p.usage_organize_event']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1); print '</td>'; } -if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) -{ +if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1); print '</td>'; } -if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) -{ +if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1); print '</td>'; } -if (!empty($arrayfields['p.price_registration']['checked'])) -{ +if (!empty($arrayfields['p.price_registration']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">'; print '</td>'; } -if (!empty($arrayfields['p.price_booth']['checked'])) -{ +if (!empty($arrayfields['p.price_booth']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">'; print '</td>'; @@ -714,23 +849,22 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['p.datec']['checked'])) -{ +if (!empty($arrayfields['p.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } -if (!empty($arrayfields['p.tms']['checked'])) -{ +if (!empty($arrayfields['p.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; } -if (!empty($arrayfields['p.fk_statut']['checked'])) -{ +if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="liste_titre nowrap right">'; $arrayofstatus = array(); - foreach ($object->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + foreach ($object->statuts_short as $key => $val) { + $arrayofstatus[$key] = $langs->trans($val); + } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth150 selectarrowonleft'); print ajax_combobox('search_status'); @@ -745,35 +879,81 @@ print '</td>'; print '</tr>'."\n"; print '<tr class="liste_titre">'; -if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp '); -if (!empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['opp_weighted_amount']['checked'])) print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.usage_organize_event']['checked'])) print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.price_registration']['checked'])) print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right '); -if (!empty($arrayfields['p.price_booth']['checked'])) print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.title']['checked'])) { + print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['commercial']['checked'])) { + print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp '); +} +if (!empty($arrayfields['p.dateo']['checked'])) { + print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.datee']['checked'])) { + print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.public']['checked'])) { + print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.fk_opp_status']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.opp_amount']['checked'])) { + print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.opp_percent']['checked'])) { + print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['opp_weighted_amount']['checked'])) { + print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.budget_amount']['checked'])) { + print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.usage_opportunity']['checked'])) { + print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.usage_task']['checked'])) { + print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.usage_bill_time']['checked'])) { + print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.usage_organize_event']['checked'])) { + print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) { + print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) { + print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.price_registration']['checked'])) { + print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['p.price_booth']['checked'])) { + print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.datec']['checked'])) { + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['p.tms']['checked'])) { + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['p.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; @@ -782,8 +962,7 @@ $totalarray = array( 'nbfield' => 0, 'val' => array(), ); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $object->id = $obj->id; @@ -798,8 +977,7 @@ while ($i < min($num, $limit)) $object->title = $obj->title; $userAccess = $object->restrictedProjectArea($user); // why this ? - if ($userAccess >= 0) - { + if ($userAccess >= 0) { $socstatic->id = $obj->socid; $socstatic->name = $obj->name; $socstatic->email = $obj->email; @@ -807,25 +985,28 @@ while ($i < min($num, $limit)) print '<tr class="oddeven">'; // Project url - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowraponall">'; print $object->getNomUrl(1); - if ($object->hasDelay()) print img_warning($langs->trans('Late')); + if ($object->hasDelay()) { + print img_warning($langs->trans('Late')); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Title - if (!empty($arrayfields['p.title']['checked'])) - { + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="tdoverflowmax200">'; print dol_trunc($obj->title, 80); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Company - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax100">'; if ($obj->socid) { print $socstatic->getNomUrl(1); @@ -833,7 +1014,9 @@ while ($i < min($num, $limit)) print '&nbsp;'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Sales Representatives if (!empty($arrayfields['commercial']['checked'])) { @@ -873,180 +1056,207 @@ while ($i < min($num, $limit)) print '&nbsp;'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date start - if (!empty($arrayfields['p.dateo']['checked'])) - { + if (!empty($arrayfields['p.dateo']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_start), 'day'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date end - if (!empty($arrayfields['p.datee']['checked'])) - { + if (!empty($arrayfields['p.datee']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_end), 'day'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Visibility - if (!empty($arrayfields['p.public']['checked'])) - { + if (!empty($arrayfields['p.public']['checked'])) { print '<td class="left">'; - if ($obj->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($obj->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Opp Status - if (!empty($arrayfields['p.fk_opp_status']['checked'])) - { + if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print '<td class="center">'; - if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); + if ($obj->opp_status_code) { + print $langs->trans("OppStatus".$obj->opp_status_code); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Opp Amount - if (!empty($arrayfields['p.opp_amount']['checked'])) - { + if (!empty($arrayfields['p.opp_amount']['checked'])) { print '<td class="right">'; //if ($obj->opp_status_code) - if (strcmp($obj->opp_amount, '')) - { + if (strcmp($obj->opp_amount, '')) { print price($obj->opp_amount, 1, $langs, 1, -1, -1, ''); $totalarray['val']['p.opp_amount'] += $obj->opp_amount; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount'; + } } // Opp percent - if (!empty($arrayfields['p.opp_percent']['checked'])) - { + if (!empty($arrayfields['p.opp_percent']['checked'])) { print '<td class="right">'; - if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%'; + if ($obj->opp_percent) { + print price($obj->opp_percent, 1, $langs, 1, 0).'%'; + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Opp weighted amount - if (!empty($arrayfields['opp_weighted_amount']['checked'])) - { - if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0; + if (!empty($arrayfields['opp_weighted_amount']['checked'])) { + if (!isset($totalarray['val']['opp_weighted_amount'])) { + $totalarray['val']['opp_weighted_amount'] = 0; + } print '<td align="right">'; if ($obj->opp_weighted_amount) { print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; + } } // Budget - if (!empty($arrayfields['p.budget_amount']['checked'])) - { + if (!empty($arrayfields['p.budget_amount']['checked'])) { print '<td class="right">'; - if ($obj->budget_amount != '') - { + if ($obj->budget_amount != '') { print price($obj->budget_amount, 1, $langs, 1, -1, -1); $totalarray['val']['p.budget_amount'] += $obj->budget_amount; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; + } } // Usage opportunity - if (!empty($arrayfields['p.usage_opportunity']['checked'])) - { + if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print '<td class="right">'; - if ($obj->usage_opportunity) - { + if ($obj->usage_opportunity) { print yn($obj->usage_opportunity); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Usage task - if (!empty($arrayfields['p.usage_task']['checked'])) - { + if (!empty($arrayfields['p.usage_task']['checked'])) { print '<td class="right">'; - if ($obj->usage_task) - { + if ($obj->usage_task) { print yn($obj->usage_task); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Bill time - if (!empty($arrayfields['p.usage_bill_time']['checked'])) - { + if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print '<td class="right">'; - if ($obj->usage_bill_time) - { + if ($obj->usage_bill_time) { print yn($obj->usage_bill_time); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Event Organization - if (!empty($arrayfields['p.usage_organize_event']['checked'])) - { + if (!empty($arrayfields['p.usage_organize_event']['checked'])) { print '<td class="right">'; - if ($obj->usage_event_organization) - { + if ($obj->usage_event_organization) { print yn($obj->usage_event_organization); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Allow unknown people to suggest conferences - if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) - { + if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) { print '<td class="right">'; - if ($obj->accept_conference_suggestions) - { + if ($obj->accept_conference_suggestions) { print yn($obj->accept_conference_suggestions); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Allow unknown people to suggest booth - if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) - { + if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) { print '<td class="right">'; - if ($obj->accept_booth_suggestions) - { + if ($obj->accept_booth_suggestions) { print yn($obj->accept_booth_suggestions); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Price of registration - if (!empty($arrayfields['p.price_registration']['checked'])) - { + if (!empty($arrayfields['p.price_registration']['checked'])) { print '<td class="right">'; - if ($obj->price_registration != '') - { + if ($obj->price_registration != '') { print price($obj->price_registration, 1, $langs, 1, -1, -1); $totalarray['val']['p.price_registration'] += $obj->price_registration; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; + } } // PriceOfBooth - if (!empty($arrayfields['p.price_booth']['checked'])) - { + if (!empty($arrayfields['p.price_booth']['checked'])) { print '<td class="right">'; - if ($obj->price_booth != '') - { + if ($obj->price_booth != '') { print price($obj->price_booth, 1, $langs, 1, -1, -1); $totalarray['val']['p.price_booth'] += $obj->price_booth; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -1055,37 +1265,43 @@ while ($i < min($num, $limit)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['p.datec']['checked'])) - { + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['p.tms']['checked'])) - { + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) - { + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="right">'.$object->getLibStatut(5).'</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->id, $arrayofselected)) $selected = 1; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 65172311441..a1ef737ddc7 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -39,7 +39,9 @@ $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} // Security check $socid = 0; @@ -61,7 +63,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, */ $title = $langs->trans("Project").' - '.$langs->trans("Note").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url); @@ -70,8 +74,7 @@ $userstatic = new User($db); $now = dol_now(); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -90,15 +93,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index add142f1f57..f25e78bceda 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php'; // Security check -if (!$user->rights->projet->lire) +if (!$user->rights->projet->lire) { accessforbidden(); +} $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); @@ -38,8 +39,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -73,9 +73,15 @@ dol_mkdir($dir); $stats_project = new ProjectStats($db); -if (!empty($userid) && $userid != -1) $stats_project->userid = $userid; -if (!empty($socid) && $socid != -1) $stats_project->socid = $socid; -if (!empty($year)) $stats_project->year = $year; +if (!empty($userid) && $userid != -1) { + $stats_project->userid = $userid; +} +if (!empty($socid) && $socid != -1) { + $stats_project->socid = $socid; +} +if (!empty($year)) { + $stats_project->year = $year; +} /* if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) @@ -149,12 +155,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&amp;file=proje $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -172,8 +176,7 @@ if (!$mesg) } -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Build graphic amount of object $data = $stats_project->getAmountByMonthWithPrevYear($endyear, $startyear); //var_dump($data); @@ -184,11 +187,9 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (!$mesg) - { + if (!$mesg) { $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -210,8 +211,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) } } -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Build graphic with transformation rate $data = $stats_project->getWeightedAmountByMonthWithPrevYear($endyear, $startyear, 0, 0); //var_dump($data); @@ -222,12 +222,10 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); - if (!$mesg) - { + if (!$mesg) { $px3->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -251,12 +249,16 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $stats_project->year = 0; $data_all_year = $stats_project->getAllByYear(); -if (!empty($year)) $stats_project->year = $year; +if (!empty($year)) { + $stats_project->year = $year; +} $arrayyears = array(); foreach ($data_all_year as $val) { $arrayyears[$val['year']] = $val['year']; } -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; +if (!count($arrayyears)) { + $arrayyears[$nowyear] = $nowyear; +} $h = 0; @@ -288,8 +290,12 @@ print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist); print '</td></tr>';*/ // Year print '<tr><td>'.$langs->trans("Year").'</td><td>'; -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 '</td></tr>'; @@ -303,8 +309,7 @@ print '<table class="noborder centpercent">'; print '<tr class="liste_titre" height="24">'; print '<td class="center">'.$langs->trans("Year").'</td>'; print '<td class="right">'.$langs->trans("NbOfProjects").'</td>'; -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>'; print '<td class="right">'.$langs->trans("OpportunityAmountAverageShort").'</td>'; print '<td class="right">'.$langs->trans("OpportunityAmountWeigthedShort").'</td>'; @@ -312,17 +317,14 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '</tr>'; $oldyear = 0; -foreach ($data_all_year as $val) -{ +foreach ($data_all_year as $val) { $year = $val['year']; - while ($year && $oldyear > $year + 1) - { // If we have empty year + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; print '<tr class="oddeven" height="24">'; print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$oldyear.'</a></td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td class="right">0</td>'; print '<td class="right">0</td>'; print '<td class="right">0</td>'; @@ -334,8 +336,7 @@ foreach ($data_all_year as $val) print '<tr class="oddeven" height="24">'; print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; print '<td class="right">'.$val['nb'].'</td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td class="right">'.($val['total'] ?price(price2num($val['total'], 'MT'), 1) : '0').'</td>'; print '<td class="right">'.($val['avg'] ?price(price2num($val['avg'], 'MT'), 1) : '0').'</td>'; print '<td class="right">'.($val['weighted'] ?price(price2num($val['weighted'], 'MT'), 1) : '0').'</td>'; @@ -350,11 +351,12 @@ print '</div>'; print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; $stringtoshow .= '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { $stringtoshow .= $px1->show(); $stringtoshow .= "<br>\n"; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { //$stringtoshow .= $px->show(); //$stringtoshow .= "<br>\n"; $stringtoshow .= $px2->show(); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index c9994dcf108..fe333a2d01e 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } +if ($conf->categorie->enabled) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('projects', 'users', 'companies')); @@ -51,7 +53,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -83,10 +87,11 @@ $taskstatic = new Task($db); $extrafields = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); +} -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); } @@ -95,8 +100,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_el // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) { reset($object->fields); $sortfield="t.".key($object->fields); } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + reset($object->fields); $sortfield="t.".key($object->fields); +} // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null. +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check @@ -148,16 +157,16 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_user_id = ""; $search_taskref = ''; $search_tasklabel = ''; @@ -195,10 +204,14 @@ if (!empty($search_tasklabel)) { } $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1); -if ($moresql) $morewherefilterarray[] = $moresql; +if ($moresql) { + $morewherefilterarray[] = $moresql; +} $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $search_dtendyear, 1); -if ($moresql) $morewherefilterarray[] = $moresql; +if ($moresql) { + $morewherefilterarray[] = $moresql; +} if (!empty($search_planedworkload)) { $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1); @@ -223,8 +236,7 @@ if (count($morewherefilterarray) > 0) { $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray); } -if ($action == 'createtask' && $user->rights->projet->creer) -{ +if ($action == 'createtask' && $user->rights->projet->creer) { $error = 0; // If we use user timezone, we must change also view/list to use user timezone everywhere @@ -233,33 +245,32 @@ if ($action == 'createtask' && $user->rights->projet->creer) $date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int')); $date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int')); - if (!$cancel) - { - if (empty($taskref)) - { + if (!$cancel) { + if (empty($taskref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); $action = 'create'; $error++; } - if (empty($label)) - { + if (empty($label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; $error++; - } elseif (empty($_POST['task_parent'])) - { + } elseif (empty($_POST['task_parent'])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); $action = 'create'; $error++; } - if (!$error) - { + if (!$error) { $tmparray = explode('_', GETPOST('task_parent')); $projectid = $tmparray[0]; - if (empty($projectid)) $projectid = $id; // If projectid is '' + if (empty($projectid)) { + $projectid = $id; // If projectid is '' + } $task_parent = $tmparray[1]; - if (empty($task_parent)) $task_parent = 0; // If task_parent is '' + if (empty($task_parent)) { + $task_parent = 0; // If task_parent is '' + } $task = new Task($db); @@ -279,12 +290,10 @@ if ($action == 'createtask' && $user->rights->projet->creer) $taskid = $task->create($user); - if ($taskid > 0) - { + if ($taskid > 0) { $result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal'); } else { - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); $duplicate_code_error = true; @@ -296,26 +305,21 @@ if ($action == 'createtask' && $user->rights->projet->creer) } } - if (!$error) - { - if (!empty($backtopage)) - { + if (!$error) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; - } elseif (empty($projectid)) - { + } elseif (empty($projectid)) { header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } $id = $projectid; } } else { - if (!empty($backtopage)) - { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; - } elseif (empty($id)) - { + } elseif (empty($id)) { // We go back on task list header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; @@ -337,14 +341,15 @@ $taskstatic = new Task($db); $userstatic = new User($db); $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); $res = $object->fetch_optionals(); @@ -362,22 +367,54 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($search_user_id) $param .= '&search_user_id='.urlencode($search_user_id); - if ($search_taskref) $param .= '&search_taskref='.urlencode($search_taskref); - if ($search_tasklabel) $param .= '&search_tasklabel='.urlencode($search_tasklabel); - if ($search_taskdescription) $param .= '&search_taskdescription='.urlencode($search_taskdescription); - if ($search_dtstartday) $param .= '&search_dtstartday='.urlencode($search_dtstartday); - if ($search_dtstartmonth) $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth); - if ($search_dtstartyear) $param .= '&search_dtstartyear='.urlencode($search_dtstartyear); - if ($search_dtendday) $param .= '&search_dtendday='.urlencode($search_dtendday); - if ($search_dtendmonth) $param .= '&search_dtendmonth='.urlencode($search_dtendmonth); - if ($search_dtendyear) $param .= '&search_dtendyear='.urlencode($search_dtendyear); - if ($search_planedworkload) $param .= '&search_planedworkload='.urlencode($search_planedworkload); - if ($search_timespend) $param .= '&search_timespend='.urlencode($search_timespend); - if ($search_progresscalc) $param .= '&search_progresscalc='.urlencode($search_progresscalc); - if ($search_progressdeclare) $param .= '&search_progressdeclare='.urlencode($search_progressdeclare); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($search_user_id) { + $param .= '&search_user_id='.urlencode($search_user_id); + } + if ($search_taskref) { + $param .= '&search_taskref='.urlencode($search_taskref); + } + if ($search_tasklabel) { + $param .= '&search_tasklabel='.urlencode($search_tasklabel); + } + if ($search_taskdescription) { + $param .= '&search_taskdescription='.urlencode($search_taskdescription); + } + if ($search_dtstartday) { + $param .= '&search_dtstartday='.urlencode($search_dtstartday); + } + if ($search_dtstartmonth) { + $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth); + } + if ($search_dtstartyear) { + $param .= '&search_dtstartyear='.urlencode($search_dtstartyear); + } + if ($search_dtendday) { + $param .= '&search_dtendday='.urlencode($search_dtendday); + } + if ($search_dtendmonth) { + $param .= '&search_dtendmonth='.urlencode($search_dtendmonth); + } + if ($search_dtendyear) { + $param .= '&search_dtendyear='.urlencode($search_dtendyear); + } + if ($search_planedworkload) { + $param .= '&search_planedworkload='.urlencode($search_planedworkload); + } + if ($search_timespend) { + $param .= '&search_timespend='.urlencode($search_timespend); + } + if ($search_progresscalc) { + $param .= '&search_progresscalc='.urlencode($search_progresscalc); + } + if ($search_progressdeclare) { + $param .= '&search_progressdeclare='.urlencode($search_progressdeclare); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -389,15 +426,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $object->title; // Thirdparty - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -415,22 +450,19 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -440,8 +472,11 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -451,12 +486,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -497,9 +536,10 @@ if ($id > 0 || !empty($ref)) } -if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) -{ - if ($id > 0 || !empty($ref)) print '<br>'; +if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) { + if ($id > 0 || !empty($ref)) { + print '<br>'; + } print load_fiche_titre($langs->trans("NewTask"), '', 'projecttask'); @@ -521,7 +561,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if (!empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; + if (!empty($object->id)) { + print '<input type="hidden" name="id" value="'.$object->id.'">'; + } print dol_get_fiche_head(''); @@ -529,19 +571,19 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $defaultref = ''; $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; - if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) - { + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue($object->thirdparty, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + if (is_numeric($defaultref) && $defaultref <= 0) { + $defaultref = ''; + } // Ref print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; - if (empty($duplicate_code_error)) - { + if (empty($duplicate_code_error)) { print (GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref); } else { print $defaultref; @@ -561,8 +603,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); - if (is_array($contactsofproject) && count($contactsofproject)) - { + if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); } else { print $langs->trans("NoUserAssignedToTheProject"); @@ -600,8 +641,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) - { + if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) { print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } @@ -639,7 +679,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; @@ -662,28 +704,27 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // We load also tasks limited to a particular user $tmpuser = new User($db); - if ($search_user_id > 0) $tmpuser->fetch($search_user_id); + if ($search_user_id > 0) { + $tmpuser->fetch($search_user_id); + } $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } // Filter on categories $moreforfilter = ''; - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans("TasksAssignedTo").': '; $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); $moreforfilter .= '</div>'; } - if ($moreforfilter) - { + if ($moreforfilter) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -756,8 +797,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // progress resume not searchable print '<td class="liste_titre right"></td>'; - if ($object->usage_bill_time) - { + if ($object->usage_bill_time) { if (!empty($arrayfields['t.tobill']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; @@ -769,7 +809,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } } - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print '<td class="liste_titre"></td>'; + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { + print '<td class="liste_titre"></td>'; + } $extrafieldsobjectkey = $taskstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -783,22 +825,47 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '<tr class="liste_titre nodrag nodrop">'; // print '<td>'.$langs->trans("Project").'</td>'; - if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, ''); - if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); - if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); - if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); - if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1); - if ($object->usage_bill_time) - { - if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.ref']['checked'])) { + print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, ''); + } + if (!empty($arrayfields['t.label']['checked'])) { + print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); + } + if (!empty($arrayfields['t.description']['checked'])) { + print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); + } + if (!empty($arrayfields['t.dateo']['checked'])) { + print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['t.datee']['checked'])) { + print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['t.planned_workload']['checked'])) { + print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); + } + if (!empty($arrayfields['t.duration_effective']['checked'])) { + print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); + } + if (!empty($arrayfields['t.progress_calculated']['checked'])) { + print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); + } + if (!empty($arrayfields['t.progress']['checked'])) { + print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1); + } + if (!empty($arrayfields['t.progress_summary']['checked'])) { + print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1); + } + if ($object->usage_bill_time) { + if (!empty($arrayfields['t.tobill']['checked'])) { + print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['t.billed']['checked'])) { + print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + } + } + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { + print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder); } - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder); // Extra fields $disablesortlink = 1; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -809,14 +876,15 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) $j = 0; $level = 0; $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); } else { $colspan = 10; - if ($object->usage_bill_time) $colspan += 2; + if ($object->usage_bill_time) { + $colspan += 2; + } print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>'; } @@ -828,18 +896,14 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>'; - if (!empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) - { - if ($search_user_id == $user->id) - { - if ($nboftaskshown < count($tasksrole)) - { + if (!empty($user->rights->projet->all->lire)) { // We make test to clean only if user has permission to see all (test may report false positive otherwise) + if ($search_user_id == $user->id) { + if ($nboftaskshown < count($tasksrole)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); } } else { - if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) - { + if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); } diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 51bf3b6dfa8..9829e079da6 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -50,7 +50,9 @@ $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('p // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcommentcard', 'globalcard')); @@ -66,13 +68,10 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php'; // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch('', $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch('', $project_ref) > 0) { $objectsarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($objectsarray) > 0) - { + if (count($objectsarray) > 0) { $id = $objectsarray[0]->id; } else { header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode)); @@ -91,10 +90,8 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $result = $object->fetch_optionals(); $result = $object->fetchComments(); @@ -103,15 +100,18 @@ if ($id > 0 || !empty($ref)) } $result = $projectstatic->fetch($object->fk_project); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } $object->project = clone $projectstatic; $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if (!empty($withproject)) - { + if (!empty($withproject)) { // Tabs for project $tab = 'tasks'; $head = project_prepare_head($projectstatic); @@ -127,15 +127,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -153,22 +151,19 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -178,31 +173,39 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Usage - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>'; $code = dol_getIdFromCode($db, $projectstatic->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '</td></tr>'; // Opportunity percent print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>'; - if (strcmp($object->opp_percent, '')) print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %'; + } print '</td></tr>'; // Opportunity Amount print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>'; /*if ($object->opp_status) - { - print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); - }*/ - if (strcmp($projectstatic->opp_amount, '')) print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($projectstatic->opp_amount, '')) { + print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + } print '</td></tr>'; } @@ -213,12 +216,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -269,22 +276,21 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $projectstatic->getNomUrl(1); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 1b12bf166f2..854e57bbd1f 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -44,7 +44,9 @@ $project_ref = GETPOST('project_ref', 'alpha'); $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. //$result = restrictedArea($user, 'projet', $id, 'projet_task'); -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $object = new Task($db); $projectstatic = new Project($db); @@ -55,8 +57,7 @@ $projectstatic = new Project($db); */ // Add new contact -if ($action == 'addcontact' && $user->rights->projet->creer) -{ +if ($action == 'addcontact' && $user->rights->projet->creer) { $source = 'internal'; if (GETPOST("addsourceexternal")) { $source ='external'; @@ -64,8 +65,7 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $result = $object->fetch($id, $ref); - if ($result > 0 && $id > 0) - { + if ($result > 0 && $id > 0) { if ($source == 'internal') { $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" $typeid = GETPOST('type'); @@ -73,16 +73,13 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" $typeid = GETPOST('typecontact'); } - if ($idfortaskuser == -2) - { + if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db, $projectstatic->error, $projectstatic->errors); } else { $contactsofproject = $projectstatic->getListContactId('internal'); - foreach ($contactsofproject as $key => $val) - { + foreach ($contactsofproject as $key => $val) { $result = $object->add_contact($val, $typeid, $source); } } @@ -105,8 +102,7 @@ if ($action == 'addcontact' && $user->rights->projet->creer) } // bascule du statut d'un contact -if ($action == 'swapstatut' && $user->rights->projet->creer) -{ +if ($action == 'swapstatut' && $user->rights->projet->creer) { if ($object->fetch($id, $ref)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -115,13 +111,11 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) } // Efface un contact -if ($action == 'deleteline' && $user->rights->projet->creer) -{ +if ($action == 'deleteline' && $user->rights->projet->creer) { $object->fetch($id, $ref); $result = $object->delete_contact($_GET["lineid"]); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id.($withproject ? '&withproject=1' : '')); exit; } else { @@ -130,13 +124,10 @@ if ($action == 'deleteline' && $user->rights->projet->creer) } // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch(0, $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch(0, $project_ref) > 0) { $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $id = $tasksarray[0]->id; } else { header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode)); @@ -163,23 +154,26 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $id = $object->id; // So when doing a search from ref, id is also set correctly. $result = $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $object->project = clone $projectstatic; $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if ($withproject) - { + if ($withproject) { // Tabs for project $tab = 'tasks'; $head = project_prepare_head($projectstatic); @@ -195,15 +189,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -221,22 +213,19 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -246,8 +235,11 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -257,12 +249,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -315,17 +311,17 @@ if ($id > 0 || !empty($ref)) $param = (GETPOST('withproject') ? '&withproject=1' : ''); $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : ''; - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $result = $projectstatic->fetch($object->fk_project); $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; @@ -354,8 +350,8 @@ if ($id > 0 || !empty($ref)) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; } */ @@ -366,12 +362,13 @@ if ($id > 0 || !empty($ref)) print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="addcontact">'; print '<input type="hidden" name="id" value="'.$id.'">'; - if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; + if ($withproject) { + print '<input type="hidden" name="withproject" value="'.$withproject.'">'; + } print '<table class="noborder centpercent">'; - if ($action != 'editline' && $user->rights->projet->creer) - { + if ($action != 'editline' && $user->rights->projet->creer) { print '<tr class="liste_titre">'; print '<td>'.$langs->trans("NatureOfContact").'</td>'; print '<td>'.$langs->trans("ThirdParty").'</td>'; @@ -393,8 +390,11 @@ if ($id > 0 || !empty($ref)) print '<td>'; // On recupere les id des users deja selectionnes - if ($object->project->public) $contactsofproject = ''; // Everybody - else $contactsofproject = $projectstatic->getListContactId('internal'); + if ($object->project->public) { + $contactsofproject = ''; // Everybody + } else { + $contactsofproject = $projectstatic->getListContactId('internal'); + } print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); print '</td>'; print '<td>'; @@ -404,8 +404,7 @@ if ($id > 0 || !empty($ref)) print '</tr>'; // Line to add an external contact. Only if project linked to a third party. - if ($projectstatic->socid) - { + if ($projectstatic->socid) { print '<tr class="oddeven">'; print '<td class="nowrap">'; @@ -427,7 +426,9 @@ if ($id > 0 || !empty($ref)) $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'rowid'); print '</td>'; print '<td class="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans("Add").'"'; - if (!$nbofcontacts) print ' disabled'; + if (!$nbofcontacts) { + print ' disabled'; + } print '></td>'; print '</tr>'; } @@ -445,44 +446,42 @@ if ($id > 0 || !empty($ref)) $companystatic = new Societe($db); - foreach (array('internal', 'external') as $source) - { + foreach (array('internal', 'external') as $source) { $tab = $object->liste_contact(-1, $source); $num = count($tab); $i = 0; - while ($i < $num) - { + while ($i < $num) { print '<tr class="oddeven" valign="top">'; // Source print '<td class="left">'; - if ($tab[$i]['source'] == 'internal') print $langs->trans("User"); - if ($tab[$i]['source'] == 'external') print $langs->trans("ThirdPartyContact"); + if ($tab[$i]['source'] == 'internal') { + print $langs->trans("User"); + } + if ($tab[$i]['source'] == 'external') { + print $langs->trans("ThirdPartyContact"); + } print '</td>'; // Societe print '<td class="left">'; - if ($tab[$i]['socid'] > 0) - { + if ($tab[$i]['socid'] > 0) { $companystatic->fetch($tab[$i]['socid']); print $companystatic->getNomUrl(1); } - if ($tab[$i]['socid'] < 0) - { + if ($tab[$i]['socid'] < 0) { print $conf->global->MAIN_INFO_SOCIETE_NOM; } - if (!$tab[$i]['socid']) - { + if (!$tab[$i]['socid']) { print '&nbsp;'; } print '</td>'; // Contact print '<td>'; - if ($tab[$i]['source'] == 'internal') - { + if ($tab[$i]['source'] == 'internal') { $userstatic->id = $tab[$i]['id']; $userstatic->lastname = $tab[$i]['lastname']; $userstatic->firstname = $tab[$i]['firstname']; @@ -493,8 +492,7 @@ if ($id > 0 || !empty($ref)) print $userstatic->getNomUrl(-1); } - if ($tab[$i]['source'] == 'external') - { + if ($tab[$i]['source'] == 'external') { $contactstatic->id = $tab[$i]['id']; $contactstatic->lastname = $tab[$i]['lastname']; $contactstatic->firstname = $tab[$i]['firstname']; @@ -510,15 +508,18 @@ if ($id > 0 || !empty($ref)) // Statut print '<td class="center">'; // Activation desativation du contact - if ($object->statut >= 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].($withproject ? '&withproject=1' : '').'">'; + if ($object->statut >= 0) { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].($withproject ? '&withproject=1' : '').'">'; + } print $contactstatic->LibStatut($tab[$i]['status'], 3); - if ($object->statut >= 0) print '</a>'; + if ($object->statut >= 0) { + print '</a>'; + } print '</td>'; // Icon update et delete print '<td class="center nowrap">'; - if ($user->rights->projet->creer) - { + if ($user->rights->projet->creer) { print '&nbsp;'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteline&token='.newToken().'&lineid='.$tab[$i]['rowid'].($withproject ? '&withproject=1' : '').'">'; print img_picto($langs->trans('Unlink'), 'unlink'); @@ -539,8 +540,7 @@ if ($id > 0 || !empty($ref)) } } -if (is_object($hookmanager)) -{ +if (is_object($hookmanager)) { $hookmanager->initHooks(array('contacttpl')); $parameters = array(); $reshook = $hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index ef4ad0292f3..9e2ea202601 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -48,19 +48,27 @@ $project_ref = GETPOST('project_ref', 'alpha'); $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. //$result=restrictedArea($user,'projet',$id,''); -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} // Get parameters $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Task($db); $projectstatic = new Project($db); @@ -70,13 +78,10 @@ $projectstatic = new Project($db); */ // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch(0, $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch(0, $project_ref) > 0) { $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $id = $tasksarray[0]->id; $object->fetch($id); } else { @@ -86,13 +91,15 @@ if (!empty($project_ref) && !empty($withproject)) } } -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } if (!empty($projectstatic->socid)) { $projectstatic->fetch_thirdparty(); @@ -117,14 +124,12 @@ $form = new Form($db); llxHeader('', $langs->trans('Task')); -if ($object->id > 0) -{ +if ($object->id > 0) { $projectstatic->fetch_thirdparty(); $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if (!empty($withproject)) - { + if (!empty($withproject)) { // Tabs for project $tab = 'tasks'; $head = project_prepare_head($projectstatic); @@ -141,15 +146,13 @@ if ($object->id > 0) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -167,22 +170,19 @@ if ($object->id > 0) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -192,8 +192,11 @@ if ($object->id > 0) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -203,12 +206,16 @@ if ($object->id > 0) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -255,25 +262,24 @@ if ($object->id > 0) // Files list constructor $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) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } $param = (GETPOST('withproject') ? '&withproject=1' : ''); $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : ''; - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $projectstatic->getNomUrl(1); @@ -307,7 +313,9 @@ if ($object->id > 0) print '<br>'; $param = ''; - if ($withproject) $param .= '&withproject=1'; + if ($withproject) { + $param .= '&withproject=1'; + } $modulepart = 'project_task'; $permission = $user->rights->projet->creer; $permtoedit = $user->rights->projet->creer; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index b318b44f053..57f9ec2b24f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -47,10 +47,12 @@ $search_categ = GETPOST("search_categ", 'alpha'); $search_project = GETPOST('search_project'); $search_projectstatus = GETPOST('search_projectstatus'); -if (!isset($search_projectstatus) || $search_projectstatus === '') -{ - if ($search_all != '') $search_projectstatus = -1; - else $search_projectstatus = 1; +if (!isset($search_projectstatus) || $search_projectstatus === '') { + if ($search_all != '') { + $search_projectstatus = -1; + } else { + $search_projectstatus = 1; + } } $search_project_ref = GETPOST('search_project_ref'); @@ -65,7 +67,9 @@ $search_task_progress = GETPOST('search_task_progress'); $search_societe = GETPOST('search_societe'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; -if ($mine) { $search_task_user = $user->id; $mine = 0; } +if ($mine) { + $search_task_user = $user->id; $mine = 0; +} $search_sday = GETPOST('search_sday', 'int'); $search_smonth = GETPOST('search_smonth', 'int'); @@ -89,7 +93,9 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; @@ -97,12 +103,18 @@ $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 'p.ref'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'p.ref'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -111,7 +123,9 @@ $fieldstosearchall = array( 't.description'=>"Description", 't.note_public'=>"NotePublic", ); -if (empty($user->socid)) $fieldstosearchall['t.note_private'] = "NotePrivate"; +if (empty($user->socid)) { + $fieldstosearchall['t.note_private'] = "NotePrivate"; +} $arrayfields = array( 't.fk_task_parent'=>array('label'=>$langs->trans("RefTaskParent"), 'checked'=>0, 'position'=>70), @@ -146,21 +160,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} $parameters = array('socid'=>$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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_all = ""; $search_categ = ""; $search_project = ""; @@ -193,7 +211,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus = 1; +if (empty($search_projectstatus) && $search_projectstatus == '') { + $search_projectstatus = 1; +} @@ -209,8 +229,12 @@ $socstatic = new Societe($db); $projectstatic = new Project($db); $puser = new User($db); $tuser = new User($db); -if ($search_project_user > 0) $puser->fetch($search_project_user); -if ($search_task_user > 0) $tuser->fetch($search_task_user); +if ($search_project_user > 0) { + $puser->fetch($search_project_user); +} +if ($search_task_user > 0) { + $tuser->fetch($search_task_user); +} $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; @@ -220,14 +244,15 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $title = $langs->trans("Activities"); //if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); -if ($id) -{ +if ($id) { $projectstatic->fetch($id); $projectstatic->fetch_thirdparty(); } // Get list of project id allowed to user (in a string list separated by coma) -if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); +if (!$user->rights->projet->all->lire) { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); +} //var_dump($projectsListId); // Get id of types of contacts for projects (This list never contains a lot of elements) @@ -236,28 +261,32 @@ $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc" $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); -if ($resql) -{ - while ($obj = $db->fetch_object($resql)) - { +if ($resql) { + while ($obj = $db->fetch_object($resql)) { $listofprojectcontacttype[$obj->rowid] = $obj->code; } -} else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found +} else { + dol_print_error($db); +} +if (count($listofprojectcontacttype) == 0) { + $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found +} // Get id of types of contacts for tasks (This list never contains a lot of elements) $listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'"; $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); -if ($resql) -{ - while ($obj = $db->fetch_object($resql)) - { +if ($resql) { + while ($obj = $db->fetch_object($resql)) { $listoftaskcontacttype[$obj->rowid] = $obj->code; } -} else dol_print_error($db); -if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found +} else { + dol_print_error($db); +} +if (count($listoftaskcontacttype) == 0) { + $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found +} $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,"; @@ -266,15 +295,18 @@ $sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, $sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut, "; $sql .= " t.description, t.fk_task_parent"; // We'll need these fields in order to filter by categ -if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; +if ($search_categ) { + $sql .= ", cs.fk_categorie, cs.fk_project"; +} // Add sum fields -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) -{ +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { $sql .= " , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // 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 : ''); + 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(); @@ -283,69 +315,113 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; // We'll need this table joined to the select in order to filter by categ -if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +} $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) -{ +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } -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 (t.rowid = ef.fk_object)"; -if ($search_project_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; -if ($search_task_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; +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 (t.rowid = ef.fk_object)"; +} +if ($search_project_user > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; +} +if ($search_task_user > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; +} $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity IN (".getEntity('project').')'; -if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users -if (is_object($projectstatic) && $projectstatic->id > 0) $sql .= " AND p.rowid = ".$projectstatic->id; +if (!$user->rights->projet->all->lire) { + $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users +} +if (is_object($projectstatic) && $projectstatic->id > 0) { + $sql .= " AND p.rowid = ".$projectstatic->id; +} // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; -if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); -if ($search_project_title) $sql .= natural_search('p.title', $search_project_title); -if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); -if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); -if ($search_task_description) $sql .= natural_search('t.description', $search_task_description); -if ($search_task_ref_parent) $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; -if ($search_task_progress) $sql .= natural_search('t.progress', $search_task_progress, 1); -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($socid) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +} +if ($search_categ > 0) { + $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +} +if ($search_categ == -2) { + $sql .= " AND cs.fk_categorie IS NULL"; +} +if ($search_project_ref) { + $sql .= natural_search('p.ref', $search_project_ref); +} +if ($search_project_title) { + $sql .= natural_search('p.title', $search_project_title); +} +if ($search_task_ref) { + $sql .= natural_search('t.ref', $search_task_ref); +} +if ($search_task_label) { + $sql .= natural_search('t.label', $search_task_label); +} +if ($search_task_description) { + $sql .= natural_search('t.description', $search_task_description); +} +if ($search_task_ref_parent) { + $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; +} +if ($search_task_progress) { + $sql .= natural_search('t.progress', $search_task_progress, 1); +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); +} $sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_projectstatus >= 0) -{ - if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; - else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} +if ($search_projectstatus >= 0) { + if ($search_projectstatus == 99) { + $sql .= " AND p.fk_statut <> 2"; + } else { + $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); + } +} +if ($search_public != '') { + $sql .= " AND p.public = ".$db->escape($search_public); +} +if ($search_project_user > 0) { + $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +} +if ($search_task_user > 0) { + $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; } -if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); -if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; -if ($search_task_user > 0) $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; // 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; -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) -{ +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; $sql .= " s.nom, s.rowid,"; $sql .= " t.datec, t.dateo, t.datee, t.tms,"; $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; - if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; + if ($search_categ) { + $sql .= ", cs.fk_categorie, cs.fk_project"; + } // 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 : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + } } } $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -356,8 +432,7 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); -if (!$resql) -{ +if (!$resql) { dol_print_error($db); exit; } @@ -366,8 +441,7 @@ $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->id; header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withproject=1'); @@ -378,30 +452,78 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; llxHeader("", $title, $help_url); $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_sday) $param .= '&search_sday='.urlencode($search_sday); -if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); -if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); -if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); -if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); -if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); -if ($socid) $param .= '&socid='.urlencode($socid); -if ($search_all != '') $param .= '&search_all='.urlencode($search_all); -if ($search_project_ref != '') $param .= '&search_project_ref='.urlencode($search_project_ref); -if ($search_project_title != '') $param .= '&search_project_title='.urlencode($search_project_title); -if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_ref); -if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_label); -if ($search_task_description != '') $param .= '&search_task_description='.urlencode($search_description); -if ($search_task_ref_parent != '') $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); -if ($search_task_progress != '') $param .= '&search_task_progress='.urlencode($search_task_progress); -if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); -if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($search_projectstatus); -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); -if ($search_public != '') $param .= '&search_public='.urlencode($search_public); -if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); -if ($search_task_user > 0) $param .= '&search_task_user='.urlencode($search_task_user); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($search_sday) { + $param .= '&search_sday='.urlencode($search_sday); +} +if ($search_smonth) { + $param .= '&search_smonth='.urlencode($search_smonth); +} +if ($search_syear) { + $param .= '&search_syear='.urlencode($search_syear); +} +if ($search_eday) { + $param .= '&search_eday='.urlencode($search_eday); +} +if ($search_emonth) { + $param .= '&search_emonth='.urlencode($search_emonth); +} +if ($search_eyear) { + $param .= '&search_eyear='.urlencode($search_eyear); +} +if ($socid) { + $param .= '&socid='.urlencode($socid); +} +if ($search_all != '') { + $param .= '&search_all='.urlencode($search_all); +} +if ($search_project_ref != '') { + $param .= '&search_project_ref='.urlencode($search_project_ref); +} +if ($search_project_title != '') { + $param .= '&search_project_title='.urlencode($search_project_title); +} +if ($search_task_ref != '') { + $param .= '&search_task_ref='.urlencode($search_ref); +} +if ($search_task_label != '') { + $param .= '&search_task_label='.urlencode($search_label); +} +if ($search_task_description != '') { + $param .= '&search_task_description='.urlencode($search_description); +} +if ($search_task_ref_parent != '') { + $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); +} +if ($search_task_progress != '') { + $param .= '&search_task_progress='.urlencode($search_task_progress); +} +if ($search_societe != '') { + $param .= '&search_societe='.urlencode($search_societe); +} +if ($search_projectstatus != '') { + $param .= '&search_projectstatus='.urlencode($search_projectstatus); +} +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) { + $param .= '&search_opp_status='.urlencode($search_opp_status); +} +if ($search_public != '') { + $param .= '&search_public='.urlencode($search_public); +} +if ($search_project_user != '') { + $param .= '&search_project_user='.urlencode($search_project_user); +} +if ($search_task_user > 0) { + $param .= '&search_task_user='.urlencode($search_task_user); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -411,14 +533,20 @@ $arrayofmassactions = array( // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->societe->supprimer) { + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +} +if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $user->rights->projet->creer); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; @@ -429,10 +557,14 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; // Show description of content $texthelp = ''; -if ($search_task_user == $user->id) $texthelp .= $langs->trans("MyTasksDesc"); -else { - if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("TasksOnProjectsDesc"); - else $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); +if ($search_task_user == $user->id) { + $texthelp .= $langs->trans("MyTasksDesc"); +} else { + if ($user->rights->projet->all->lire && !$socid) { + $texthelp .= $langs->trans("TasksOnProjectsDesc"); + } else { + $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); + } } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'projecttask', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -443,17 +575,17 @@ $objecttmp = new Task($db); $trackid = 'tas'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $morehtmlfilter = ''; // Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) -{ +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ProjectCategories').': '; @@ -465,7 +597,9 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; $includeonly = ''; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; @@ -473,12 +607,13 @@ $moreforfilter .= '</div>'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; $includeonly = ''; -if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +if (empty($user->rights->user->user->lire)) { + $includeonly = array($user->id); +} $moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '</div>'; -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; $parameters = array(); @@ -487,109 +622,116 @@ if (!empty($moreforfilter)) print '</div>'; } -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} print '<div class="div-table-responsive">'; print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<tr class="liste_titre_filter">'; -if (!empty($arrayfields['t.fk_task_parent']['checked'])) -{ +if (!empty($arrayfields['t.fk_task_parent']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_ref_parent" value="'.dol_escape_htmltag($search_task_ref_parent).'" size="4">'; print '</td>'; } -if (!empty($arrayfields['t.ref']['checked'])) -{ +if (!empty($arrayfields['t.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">'; print '</td>'; } -if (!empty($arrayfields['t.label']['checked'])) -{ +if (!empty($arrayfields['t.label']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">'; print '</td>'; } // Task Description -if (!empty($arrayfields['t.description']['checked'])) -{ +if (!empty($arrayfields['t.description']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_description" value="'.dol_escape_htmltag($search_task_description).'" size="8">'; print '</td>'; } // Start date -if (!empty($arrayfields['t.dateo']['checked'])) -{ +if (!empty($arrayfields['t.dateo']['checked'])) { print '<td class="liste_titre center minwidth150">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">'; + } print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">'; $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); print '</td>'; } // End date -if (!empty($arrayfields['t.datee']['checked'])) -{ +if (!empty($arrayfields['t.datee']['checked'])) { print '<td class="liste_titre center minwidth150">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">'; + } print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">'; $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); print '</td>'; } -if (!empty($arrayfields['p.ref']['checked'])) -{ +if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'" size="4">'; print '</td>'; } -if (!empty($arrayfields['p.title']['checked'])) -{ +if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_project_title" value="'.$search_project_title.'" size="6">'; print '</td>'; } -if (!empty($arrayfields['s.nom']['checked'])) -{ +if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_societe" value="'.dol_escape_htmltag($search_societe).'" size="4">'; print '</td>'; } -if (!empty($arrayfields['p.fk_statut']['checked'])) -{ +if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="liste_titre center">'; $arrayofstatus = array(); - foreach ($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + foreach ($projectstatic->statuts_short as $key => $val) { + $arrayofstatus[$key] = $langs->trans($val); + } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print '</td>'; } -if (!empty($arrayfields['t.planned_workload']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.duration_effective']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.progress_calculated']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.progress']['checked'])) -{ +if (!empty($arrayfields['t.planned_workload']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['t.duration_effective']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['t.progress_calculated']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['t.progress']['checked'])) { print '<td class="liste_titre center">'; print '<input type="text" class="flat" name="search_task_progress" value="'.$search_task_progress.'" size="4">'; print '</td>'; } -if (!empty($arrayfields['t.progress_summary']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.tobill']['checked'])) print '<td class="liste_titre"></td>'; -if (!empty($arrayfields['t.billed']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.progress_summary']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['t.tobill']['checked'])) { + print '<td class="liste_titre"></td>'; +} +if (!empty($arrayfields['t.billed']['checked'])) { + print '<td class="liste_titre"></td>'; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['t.datec']['checked'])) -{ +if (!empty($arrayfields['t.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } -if (!empty($arrayfields['t.tms']['checked'])) -{ +if (!empty($arrayfields['t.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; @@ -602,44 +744,85 @@ print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (!empty($arrayfields['t.fk_task_parent']['checked'])) print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); -if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.fk_task_parent']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['t.ref']['checked'])) { + print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['t.label']['checked'])) { + print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['t.description']['checked'])) { + print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['t.dateo']['checked'])) { + print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.datee']['checked'])) { + print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.title']['checked'])) { + print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.planned_workload']['checked'])) { + print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.duration_effective']['checked'])) { + print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.progress_calculated']['checked'])) { + print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +} +if (!empty($arrayfields['t.progress']['checked'])) { + print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.progress_summary']['checked'])) { + print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.tobill']['checked'])) { + print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['t.billed']['checked'])) { + print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.datec']['checked'])) { + print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['t.tms']['checked'])) { + print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; $plannedworkloadoutputformat = 'allhourmin'; $timespentoutputformat = 'allhourmin'; -if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; -if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; +if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) { + $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; +} +if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) { + $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; +} $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $object->id = $obj->id; @@ -663,8 +846,7 @@ while ($i < min($num, $limit)) $projectstatic->datee = $db->jdate($obj->projectdatee); $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? - if ($userAccess >= 0) - { + if ($userAccess >= 0) { print '<tr data-rowid="'.$object->id.'" class="oddeven">'; // Ref Parent @@ -677,77 +859,89 @@ while ($i < min($num, $limit)) setEventMessage($object_parent->error, 'errors'); } else { print $object_parent->getNomUrl(1, 'withproject'); - if ($object_parent->hasDelay()) + if ($object_parent->hasDelay()) { print img_warning("Late"); + } } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref - if (!empty($arrayfields['t.ref']['checked'])) - { + if (!empty($arrayfields['t.ref']['checked'])) { print '<td class="nowraponall">'; print $object->getNomUrl(1, 'withproject'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Label - if (!empty($arrayfields['t.label']['checked'])) - { + if (!empty($arrayfields['t.label']['checked'])) { print '<td>'; print $object->label; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Description - if (!empty($arrayfields['t.description']['checked'])) - { + if (!empty($arrayfields['t.description']['checked'])) { print '<td>'; print $object->description; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date start - if (!empty($arrayfields['t.dateo']['checked'])) - { + if (!empty($arrayfields['t.dateo']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_start), 'day'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date end - if (!empty($arrayfields['t.datee']['checked'])) - { + if (!empty($arrayfields['t.datee']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_end), 'day'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project ref - if (!empty($arrayfields['p.ref']['checked'])) - { + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowraponall tdoverflowmax150">'; print $projectstatic->getNomUrl(1, 'task'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project title - if (!empty($arrayfields['p.title']['checked'])) - { + if (!empty($arrayfields['p.title']['checked'])) { print '<td>'; print dol_trunc($obj->projecttitle, 80); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Third party - if (!empty($arrayfields['s.nom']['checked'])) - { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td>'; - if ($obj->socid) - { + if ($obj->socid) { $socstatic->id = $obj->socid; $socstatic->name = $obj->name; print $socstatic->getNomUrl(1); @@ -755,100 +949,131 @@ while ($i < min($num, $limit)) print '&nbsp;'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Project status - if (!empty($arrayfields['p.fk_statut']['checked'])) - { + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="center">'; print $projectstatic->getLibStatut(1); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Planned workload - if (!empty($arrayfields['t.planned_workload']['checked'])) - { + if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<td class="center">'; $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks - if ($obj->planned_workload != '') - { + if ($obj->planned_workload != '') { print $fullhour; // TODO Add delay taking account of working hours per day and working day per week //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')'; } //else print '--:--'; print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.planned_workload'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.planned_workload'; + } $totalarray['val']['t.planned_workload'] += $obj->planned_workload; - if (!$i) $totalarray['totalplannedworkloadfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['totalplannedworkloadfield'] = $totalarray['nbfield']; + } $totalarray['totalplannedworkload'] += $obj->planned_workload; } // Time spent - if (!empty($arrayfields['t.duration_effective']['checked'])) - { + if (!empty($arrayfields['t.duration_effective']['checked'])) { $showlineingray = 0; $showproject = 1; print '<td class="center">'; - if ($showlineingray) print '<i>'; - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.($showproject ? '' : '&withproject=1').'">'; - if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective, $timespentoutputformat); - else print '--:--'; - if ($showlineingray) print '</i>'; - else print '</a>'; + if ($showlineingray) { + print '<i>'; + } else { + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.($showproject ? '' : '&withproject=1').'">'; + } + if ($obj->duration_effective) { + print convertSecondToTime($obj->duration_effective, $timespentoutputformat); + } else { + print '--:--'; + } + if ($showlineingray) { + print '</i>'; + } else { + print '</a>'; + } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.duration_effective'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.duration_effective'; + } $totalarray['val']['t.duration_effective'] += $obj->duration_effective; - if (!$i) $totalarray['totaldurationeffectivefield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['totaldurationeffectivefield'] = $totalarray['nbfield']; + } $totalarray['totaldurationeffective'] += $obj->duration_effective; } // Calculated progress - if (!empty($arrayfields['t.progress_calculated']['checked'])) - { + if (!empty($arrayfields['t.progress_calculated']['checked'])) { print '<td class="center">'; - if ($obj->planned_workload || $obj->duration_effective) - { - if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload, 2).' %'; - else print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); + if ($obj->planned_workload || $obj->duration_effective) { + if ($obj->planned_workload) { + print round(100 * $obj->duration_effective / $obj->planned_workload, 2).' %'; + } else { + print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); + } } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; + } } // Declared progress - if (!empty($arrayfields['t.progress']['checked'])) - { + if (!empty($arrayfields['t.progress']['checked'])) { print '<td class="center">'; - if ($obj->progress != '') - { + if ($obj->progress != '') { print getTaskProgressBadge($object); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.progress'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.progress'; + } $totalarray['val']['t.progress'] += ($obj->planned_workload * $obj->progress / 100); - if (!$i) $totalarray['totalprogress_declaredfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['totalprogress_declaredfield'] = $totalarray['nbfield']; + } $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100; } // Progress summary - if (!empty($arrayfields['t.progress_summary']['checked'])) - { + if (!empty($arrayfields['t.progress_summary']['checked'])) { print '<td class="center">'; if ($obj->progress != '' && $obj->duration_effective) { print getTaskProgressView($object, false, false); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['totalprogress_summary'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['totalprogress_summary'] = $totalarray['nbfield']; + } } // Time not billed - if (!empty($arrayfields['t.tobill']['checked'])) - { + if (!empty($arrayfields['t.tobill']['checked'])) { print '<td class="center">'; - if ($obj->usage_bill_time) - { + if ($obj->usage_bill_time) { print convertSecondToTime($obj->tobill, 'allhourmin'); $totalarray['val']['t.tobill'] += $obj->tobill; $totalarray['totaltobill'] += $obj->tobill; @@ -856,16 +1081,20 @@ while ($i < min($num, $limit)) print '<span class="opacitymedium">'.$langs->trans("NA").'</span>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.tobill'; - if (!$i) $totalarray['totaltobillfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.tobill'; + } + if (!$i) { + $totalarray['totaltobillfield'] = $totalarray['nbfield']; + } } // Time billed - if (!empty($arrayfields['t.billed']['checked'])) - { + if (!empty($arrayfields['t.billed']['checked'])) { print '<td class="center">'; - if ($obj->usage_bill_time) - { + if ($obj->usage_bill_time) { print convertSecondToTime($obj->billed, 'allhourmin'); $totalarray['val']['t.billed'] += $obj->billed; $totalarray['totalbilled'] += $obj->billed; @@ -873,9 +1102,15 @@ while ($i < min($num, $limit)) print '<span class="opacitymedium">'.$langs->trans("NA").'</span>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.billed'; - if (!$i) $totalarray['totalbilledfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.billed'; + } + if (!$i) { + $totalarray['totalbilledfield'] = $totalarray['nbfield']; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -884,37 +1119,42 @@ while ($i < min($num, $limit)) $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['t.datec']['checked'])) - { + if (!empty($arrayfields['t.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Date modification - if (!empty($arrayfields['t.tms']['checked'])) - { + if (!empty($arrayfields['t.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Status /*if (! empty($arrayfields['p.fk_statut']['checked'])) { - $projectstatic->statut = $obj->fk_statut; - print '<td class="right">'.$projectstatic->getLibStatut(5).'</td>'; + $projectstatic->statut = $obj->fk_statut; + print '<td class="right">'.$projectstatic->getLibStatut(5).'</td>'; }*/ // Action column print '<td class="nowrap center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->id, $arrayofselected)) $selected = 1; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; } @@ -923,24 +1163,32 @@ while ($i < min($num, $limit)) } // Show total line if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']) || isset($totalarray['totalprogress_calculatedfield']) - || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) -{ + || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) { print '<tr class="liste_total">'; $i = 0; - while ($i < $totalarray['nbfield']) - { + while ($i < $totalarray['nbfield']) { $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; - } elseif ($totalarray['totalplannedworkloadfield'] == $i) print '<td class="center">'.convertSecondToTime($totalarray['totalplannedworkload'], $plannedworkloadoutputformat).'</td>'; - elseif ($totalarray['totaldurationeffectivefield'] == $i) print '<td class="center">'.convertSecondToTime($totalarray['totaldurationeffective'], $timespentoutputformat).'</td>'; - elseif ($totalarray['totalprogress_calculatedfield'] == $i) print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>'; - elseif ($totalarray['totalprogress_declaredfield'] == $i) print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>'; - elseif ($totalarray['totaltobillfield'] == $i) print '<td class="center">'.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).'</td>'; - elseif ($totalarray['totalbilledfield'] == $i) print '<td class="center">'.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).'</td>'; - else print '<td></td>'; + if ($i == 1) { + if ($num < $limit && empty($offset)) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } + } elseif ($totalarray['totalplannedworkloadfield'] == $i) { + print '<td class="center">'.convertSecondToTime($totalarray['totalplannedworkload'], $plannedworkloadoutputformat).'</td>'; + } elseif ($totalarray['totaldurationeffectivefield'] == $i) { + print '<td class="center">'.convertSecondToTime($totalarray['totaldurationeffective'], $timespentoutputformat).'</td>'; + } elseif ($totalarray['totalprogress_calculatedfield'] == $i) { + print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>'; + } elseif ($totalarray['totalprogress_declaredfield'] == $i) { + print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>'; + } elseif ($totalarray['totaltobillfield'] == $i) { + print '<td class="center">'.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).'</td>'; + } elseif ($totalarray['totalbilledfield'] == $i) { + print '<td class="center">'.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).'</td>'; + } else { + print '<td></td>'; + } } print '</tr>'; } diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index af5709c7322..e23b5e3d70b 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -41,20 +41,26 @@ $project_ref = GETPOST('project_ref', 'alpha'); // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification $object = new Task($db); $projectstatic = new Project($db); -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $object->project = clone $projectstatic; } else { @@ -64,13 +70,10 @@ if ($id > 0 || !empty($ref)) // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch(0, $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch(0, $project_ref) > 0) { $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $id = $tasksarray[0]->id; $object->fetch($id); } else { @@ -100,12 +103,10 @@ $userstatic = new User($db); $now = dol_now(); -if ($object->id > 0) -{ +if ($object->id > 0) { $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if (!empty($withproject)) - { + if (!empty($withproject)) { // Tabs for project $tab = 'tasks'; $head = project_prepare_head($projectstatic); @@ -120,15 +121,13 @@ if ($object->id > 0) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -146,22 +145,19 @@ if ($object->id > 0) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -171,8 +167,11 @@ if ($object->id > 0) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -182,12 +181,16 @@ if ($object->id > 0) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -235,17 +238,17 @@ if ($object->id > 0) $param = (GETPOST('withproject') ? '&withproject=1' : ''); $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : ''; - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $projectstatic->getNomUrl(1); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 571560518ab..81c05fde59d 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/taskstats.class.php'; // Security check -if (!$user->rights->projet->lire) +if (!$user->rights->projet->lire) { accessforbidden(); +} $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); @@ -38,8 +39,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -73,9 +73,15 @@ dol_mkdir($dir); $stats_tasks = new TaskStats($db); -if (!empty($userid) && $userid != -1) $stats_tasks->userid = $userid; -if (!empty($socid) && $socid != -1) $stats_tasks->socid = $socid; -if (!empty($year)) $stats_tasks->year = $year; +if (!empty($userid) && $userid != -1) { + $stats_tasks->userid = $userid; +} +if (!empty($socid) && $socid != -1) { + $stats_tasks->socid = $socid; +} +if (!empty($year)) { + $stats_tasks->year = $year; +} @@ -89,12 +95,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=taskstats&amp;file=tasknbpr $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (!$mesg) -{ +if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); - while ($i <= $endyear) - { + while ($i <= $endyear) { $legend[] = $i; $i++; } @@ -116,12 +120,16 @@ if (!$mesg) $stats_tasks->year = 0; $data_all_year = $stats_tasks->getAllByYear(); -if (!empty($year)) $stats_tasks->year = $year; +if (!empty($year)) { + $stats_tasks->year = $year; +} $arrayyears = array(); foreach ($data_all_year as $val) { $arrayyears[$val['year']] = $val['year']; } -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; +if (!count($arrayyears)) { + $arrayyears[$nowyear] = $nowyear; +} $h = 0; @@ -154,8 +162,12 @@ print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist); print '</td></tr>';*/ // Year print '<tr><td>'.$langs->trans("Year").'</td><td>'; -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 '</td></tr>'; @@ -173,11 +185,9 @@ print '<td class="right">'.$langs->trans("NbOfTasks").'</td>'; print '</tr>'; $oldyear = 0; -foreach ($data_all_year as $val) -{ +foreach ($data_all_year as $val) { $year = $val['year']; - while ($year && $oldyear > $year + 1) - { // If we have empty year + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; print '<tr class="oddeven" height="24">'; @@ -199,7 +209,9 @@ print '</div>'; print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; $stringtoshow .= '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; -if ($mesg) { print $mesg; } else { +if ($mesg) { + print $mesg; +} else { $stringtoshow .= $px1->show(); $stringtoshow .= "<br>\n"; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index cd10b43f0c0..7895838e18e 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -49,7 +49,9 @@ $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('p // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard', 'globalcard')); @@ -63,34 +65,34 @@ $extrafields->fetch_name_optionals_label($object->table_element); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} /* * Actions */ -if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) -{ +if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) { $error = 0; - if (empty($taskref)) - { + if (empty($taskref)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (empty($_POST["label"])) - { + if (empty($_POST["label"])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!$error) - { + if (!$error) { $object->fetch($id, $ref); $object->oldcopy = clone $object; $tmparray = explode('_', $_POST['task_parent']); $task_parent = $tmparray[1]; - if (empty($task_parent)) $task_parent = 0; // If task_parent is '' + if (empty($task_parent)) { + $task_parent = 0; // If task_parent is '' + } $object->ref = $taskref ? $taskref : GETPOST("ref", 'alpha', 2); $object->label = GETPOST("label", "alphanohtml"); @@ -103,13 +105,13 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -118,15 +120,12 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) } } -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) -{ - if ($object->fetch($id, $ref) >= 0) - { +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) { + if ($object->fetch($id, $ref) >= 0) { $result = $projectstatic->fetch($object->fk_project); $projectstatic->fetch_thirdparty(); - if ($object->delete($user) > 0) - { + if ($object->delete($user) > 0) { header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); exit; } else { @@ -137,13 +136,10 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->s } // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch('', $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch('', $project_ref) > 0) { $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $id = $tasksarray[0]->id; } else { header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode)); @@ -152,41 +148,41 @@ if (!empty($project_ref) && !empty($withproject)) } // Build doc -if ($action == 'builddoc' && $user->rights->projet->creer) -{ +if ($action == 'builddoc' && $user->rights->projet->creer) { $object->fetch($id, $ref); // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); + if (GETPOST('model')) { + $object->setDocModel($user, GETPOST('model', 'alpha')); + } $outputlangs = $langs; - if (GETPOST('lang_id', 'aZ09')) - { + if (GETPOST('lang_id', 'aZ09')) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } $result = $object->generateDocument($object->model_pdf, $outputlangs); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } // Delete file in doc form -if ($action == 'remove_file' && $user->rights->projet->creer) -{ +if ($action == 'remove_file' && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($object->fetch($id, $ref) >= 0) - { + if ($object->fetch($id, $ref) >= 0) { $langs->load("other"); $upload_dir = $conf->projet->dir_output; $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('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'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } } } @@ -201,23 +197,26 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -if ($id > 0 || !empty($ref)) -{ - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $res = $object->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $result = $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $object->project = clone $projectstatic; //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if (!empty($withproject)) - { + if (!empty($withproject)) { // Tabs for project $tab = 'tasks'; $head = project_prepare_head($projectstatic); @@ -233,15 +232,13 @@ if ($id > 0 || !empty($ref)) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -259,22 +256,19 @@ if ($id > 0 || !empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -284,8 +278,11 @@ if ($id > 0 || !empty($ref)) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -295,12 +292,16 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -372,8 +373,7 @@ if ($id > 0 || !empty($ref)) $head = task_prepare_head($object); - if ($action == 'edit' && $user->rights->projet->creer) - { + if ($action == 'edit' && $user->rights->projet->creer) { print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">'; @@ -393,16 +393,18 @@ if ($id > 0 || !empty($ref)) print '<td><input class="minwidth500" name="label" value="'.$object->label.'"></td></tr>'; // Project - if (empty($withproject)) - { + if (empty($withproject)) { print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; print $projectstatic->getNomUrl(1); print '</td></tr>'; // Third party print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'; - if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); - else print '&nbsp;'; + if ($projectstatic->societe->id) { + print $projectstatic->societe->getNomUrl(1); + } else { + print '&nbsp;'; + } print '</td></tr>'; } @@ -441,8 +443,7 @@ if ($id > 0 || !empty($ref)) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -465,22 +466,21 @@ if ($id > 0 || !empty($ref)) print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $projectstatic->getNomUrl(1); @@ -504,8 +504,7 @@ if ($id > 0 || !empty($ref)) // Task parent print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>'; - if ($object->fk_task_parent > 0) - { + if ($object->fk_task_parent > 0) { $tasktmp = new Task($db); $tasktmp->fetch($object->fk_task_parent); print $tasktmp->getNomUrl(1); @@ -519,13 +518,14 @@ if ($id > 0 || !empty($ref)) $end = dol_print_date($object->date_end, 'dayhour'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Planned workload print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'; - if ($object->planned_workload != '') - { + if ($object->planned_workload != '') { print convertSecondToTime($object->planned_workload, 'allhourmin'); } print '</td></tr>'; @@ -545,20 +545,23 @@ if ($id > 0 || !empty($ref)) // Progress declared print '<tr><td class="titlefield">'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; - if ($object->progress != '') - { + if ($object->progress != '') { print $object->progress.' %'; } print '</td></tr>'; // Progress calculated print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">'; - if ($object->planned_workload != '') - { + if ($object->planned_workload != '') { $tmparray = $object->getSummaryOfTimeSpent(); - if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; - else print '0 %'; - } else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; + if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) { + print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; + } else { + print '0 %'; + } + } else { + print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; + } print '</td></tr>'; // Other attributes @@ -578,32 +581,27 @@ if ($id > 0 || !empty($ref)) } - if ($action != 'edit') - { + if ($action != 'edit') { /* * Actions - */ + */ print '<div class="tabsAction">'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { // Modify - if ($user->rights->projet->creer) - { + if ($user->rights->projet->creer) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;withproject='.$withproject.'">'.$langs->trans('Modify').'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>'; } // Delete - if ($user->rights->projet->supprimer) - { - if (!$object->hasChildren() && !$object->hasTimeSpent()) - { + if ($user->rights->projet->supprimer) { + if (!$object->hasChildren() && !$object->hasTimeSpent()) { print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>'; } else { print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 5cca624d11f..d95fba9d48f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -71,18 +71,26 @@ $search_valuebilled = GETPOST('search_valuebilled', 'int'); // Security check $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. -if (!$user->rights->projet->lire) accessforbidden(); +if (!$user->rights->projet->lire) { + accessforbidden(); +} $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 (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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 (!$sortfield) $sortfield = 't.task_date,t.task_datehour,t.rowid'; -if (!$sortorder) $sortorder = 'DESC,DESC,DESC'; +if (!$sortfield) { + $sortfield = 't.task_date,t.task_datehour,t.rowid'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC,DESC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context //$object = new TaskTime($db); @@ -99,18 +107,23 @@ $extrafields->fetch_name_optionals_label($object->table_element); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_generateinvoice') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_generateinvoice') { + $massaction = ''; +} $parameters = array('socid'=>$socid, 'projectid'=>$projectid); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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_day = ''; $search_month = ''; $search_year = ''; @@ -131,32 +144,26 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $action = ''; } -if ($action == 'addtimespent' && $user->rights->projet->lire) -{ +if ($action == 'addtimespent' && $user->rights->projet->lire) { $error = 0; $timespent_durationhour = GETPOST('timespent_durationhour', 'int'); $timespent_durationmin = GETPOST('timespent_durationmin', 'int'); - if (empty($timespent_durationhour) && empty($timespent_durationmin)) - { + if (empty($timespent_durationhour) && empty($timespent_durationmin)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors'); $error++; } - if (empty($_POST["userid"])) - { + if (empty($_POST["userid"])) { $langs->load("errors"); setEventMessages($langs->trans('ErrorUserNotAssignedToTask'), null, 'errors'); $error++; } - if (!$error) - { - if ($id || $ref) - { + if (!$error) { + if ($id || $ref) { $object->fetch($id, $ref); } else { - if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) - { + if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors'); $action = 'createtime'; $error++; @@ -165,22 +172,21 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } } - if (!$error) - { + if (!$error) { $object->fetch_projet(); - if (empty($object->project->statut)) - { + if (empty($object->project->statut)) { setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); $action = 'createtime'; $error++; } else { $object->timespent_note = $_POST["timespent_note"]; - if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value + if (GETPOST('progress', 'int') > 0) { + $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value + } $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds $object->timespent_duration += ($_POST["timespent_durationmin"] ? $_POST["timespent_durationmin"] : 0) * 60; // We store duration in seconds - if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered - { + if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); $object->timespent_withhour = 1; } else { @@ -188,8 +194,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } $object->timespent_fk_user = $_POST["userid"]; $result = $object->addTimeSpent($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans($object->error), null, 'errors'); @@ -198,25 +203,24 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } } } else { - if (empty($id)) $action = 'createtime'; - else $action = 'createtime'; + if (empty($id)) { + $action = 'createtime'; + } else { + $action = 'createtime'; + } } } -if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $user->rights->projet->lire) -{ +if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $user->rights->projet->lire) { $error = 0; - if (!GETPOST("new_durationhour") && !GETPOST("new_durationmin")) - { + if (!GETPOST("new_durationhour") && !GETPOST("new_durationmin")) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors'); $error++; } - if (!$error) - { - if (GETPOST('taskid', 'int') != $id) // GETPOST('taskid') is id of new task - { + if (!$error) { + if (GETPOST('taskid', 'int') != $id) { // GETPOST('taskid') is id of new task $id = GETPOST('taskid', 'int'); $object->fetchTimeSpent(GETPOST('lineid', 'int')); @@ -228,8 +232,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_old_duration = $_POST["old_duration"]; $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered - { + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); $object->timespent_withhour = 1; } else { @@ -237,8 +240,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } $object->timespent_fk_user = $_POST["userid_line"]; $result = $object->addTimeSpent($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans($object->error), null, 'errors'); @@ -253,8 +255,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_old_duration = $_POST["old_duration"]; $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered - { + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); $object->timespent_withhour = 1; } else { @@ -263,8 +264,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_fk_user = $_POST["userid_line"]; $result = $object->updateTimeSpent($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans($object->error), null, 'errors'); @@ -276,14 +276,12 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } } -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) -{ +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) { $object->fetchTimeSpent(GETPOST('lineid', 'int')); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) $result = $object->delTimeSpent($user); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($object->error), null, 'errors'); $error++; @@ -294,13 +292,10 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->l } // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) -{ - if ($projectstatic->fetch(0, $project_ref) > 0) - { +if (!empty($project_ref) && !empty($withproject)) { + if ($projectstatic->fetch(0, $project_ref) > 0) { $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) - { + if (count($tasksarray) > 0) { $id = $tasksarray[0]->id; } else { header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode)); @@ -311,27 +306,27 @@ if (!empty($project_ref) && !empty($withproject)) // To show all time lines for project $projectidforalltimes = 0; -if (GETPOST('projectid', 'int') > 0) -{ +if (GETPOST('projectid', 'int') > 0) { $projectidforalltimes = GETPOST('projectid', 'int'); $result = $projectstatic->fetch($projectidforalltimes); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $res = $projectstatic->fetch_optionals(); -} elseif (GETPOST('project_ref', 'alpha')) -{ +} elseif (GETPOST('project_ref', 'alpha')) { $projectstatic->fetch(0, GETPOST('project_ref', 'alpha')); $projectidforalltimes = $projectstatic->id; $withproject = 1; -} elseif ($id > 0) -{ +} elseif ($id > 0) { $object->fetch($id); $result = $projectstatic->fetch($object->fk_project); } -if ($action == 'confirm_generateinvoice') -{ - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); +if ($action == 'confirm_generateinvoice') { + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } if (!($projectstatic->thirdparty->id > 0)) { setEventMessages($langs->trans("ThirdPartyRequiredToGenerateInvoice"), null, 'errors'); @@ -351,21 +346,26 @@ if ($action == 'confirm_generateinvoice') $invoiceToUse = GETPOST('invoiceid', 'int'); $prodDurationHours = 1.0; - if ($idprod > 0) - { + if ($idprod > 0) { $tmpproduct->fetch($idprod); - if ($tmpproduct->duration_unit == 'i') + if ($tmpproduct->duration_unit == 'i') { $prodDurationHours = 1. / 60; - if ($tmpproduct->duration_unit == 'h') + } + if ($tmpproduct->duration_unit == 'h') { $prodDurationHours = 1.; - if ($tmpproduct->duration_unit == 'd') + } + if ($tmpproduct->duration_unit == 'd') { $prodDurationHours = 24.; - if ($tmpproduct->duration_unit == 'w') + } + if ($tmpproduct->duration_unit == 'w') { $prodDurationHours = 24. * 7; - if ($tmpproduct->duration_unit == 'm') + } + if ($tmpproduct->duration_unit == 'm') { $prodDurationHours = 24. * 30; - if ($tmpproduct->duration_unit == 'y') + } + if ($tmpproduct->duration_unit == 'y') { $prodDurationHours = 24. * 365; + } $prodDurationHours *= $tmpproduct->duration_value; $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); @@ -389,27 +389,23 @@ if ($action == 'confirm_generateinvoice') $tmpinvoice->fetch($invoiceToUse); } else { $result = $tmpinvoice->create($user); - if ($result <= 0) - { + if ($result <= 0) { $error++; setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); } } - if (!$error) - { + if (!$error) { if ($generateinvoicemode == 'onelineperuser') { $arrayoftasks = array(); - foreach ($toselect as $key => $value) - { + foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); } - foreach ($arrayoftasks as $userid => $value) - { + foreach ($arrayoftasks as $userid => $value) { $fuser->fetch($userid); //$pu_ht = $value['timespent'] * $fuser->thm; $username = $fuser->getFullName($langs); @@ -419,8 +415,7 @@ if ($action == 'confirm_generateinvoice') $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known - if (empty($pu_ht)) - { + if (empty($pu_ht)) { $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); } @@ -431,8 +426,7 @@ if ($action == 'confirm_generateinvoice') $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; $result = $db->query($sql); - if (!$result) - { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; @@ -440,8 +434,7 @@ if ($action == 'confirm_generateinvoice') } } elseif ($generateinvoicemode == 'onelineperperiod') { $arrayoftasks = array(); - foreach ($toselect as $key => $value) - { + foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; @@ -450,8 +443,7 @@ if ($action == 'confirm_generateinvoice') $arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user; } - foreach ($arrayoftasks as $timespent_id => $value) - { + foreach ($arrayoftasks as $timespent_id => $value) { $userid = $value['user']; $fuser->fetch($userid); //$pu_ht = $value['timespent'] * $fuser->thm; @@ -462,8 +454,7 @@ if ($action == 'confirm_generateinvoice') $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known - if (empty($pu_ht)) - { + if (empty($pu_ht)) { $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); } @@ -474,8 +465,7 @@ if ($action == 'confirm_generateinvoice') $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; $result = $db->query($sql); - if (!$result) - { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; @@ -483,8 +473,7 @@ if ($action == 'confirm_generateinvoice') } } elseif ($generateinvoicemode == 'onelinepertask') { $arrayoftasks = array(); - foreach ($toselect as $key => $value) - { + foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); // $object->id is the task id @@ -492,8 +481,7 @@ if ($action == 'confirm_generateinvoice') $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; } - foreach ($arrayoftasks as $task_id => $value) - { + foreach ($arrayoftasks as $task_id => $value) { $ftask = new Task($db); $ftask->fetch($task_id); // Define qty per hour @@ -501,8 +489,7 @@ if ($action == 'confirm_generateinvoice') $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known - if (empty($pu_ht)) - { + if (empty($pu_ht)) { $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); } @@ -514,8 +501,7 @@ if ($action == 'confirm_generateinvoice') $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql .= ' WHERE rowid in ('.join(',', $toselect).')'; $result = $db->query($sql); - if (!$result) - { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; @@ -524,8 +510,7 @@ if ($action == 'confirm_generateinvoice') } } - if (!$error) - { + if (!$error) { $urltoinvoice = $tmpinvoice->getNomUrl(0); setEventMessages($langs->trans("InvoiceGeneratedFromTimeSpent", $urltoinvoice), null, 'mesgs'); //var_dump($tmpinvoice); @@ -551,22 +536,27 @@ $formother = new FormOther($db); $formproject = new FormProjets($db); $userstatic = new User($db); -if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) -{ +if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { /* * Fiche projet en mode visu */ - if ($projectidforalltimes > 0) - { + if ($projectidforalltimes > 0) { $result = $projectstatic->fetch($projectidforalltimes); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $res = $projectstatic->fetch_optionals(); - } elseif ($object->fetch($id, $ref) >= 0) - { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + } elseif ($object->fetch($id, $ref) >= 0) { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } $result = $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } $res = $projectstatic->fetch_optionals(); $object->project = clone $projectstatic; @@ -575,13 +565,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $userRead = $projectstatic->restrictedProjectArea($user, 'read'); $linktocreatetime = ''; - if ($projectstatic->id > 0) - { - if ($withproject) - { + if ($projectstatic->id > 0) { + if ($withproject) { // Tabs for project - if (empty($id) || $tab == 'timespent') $tab = 'timespent'; - else $tab = 'tasks'; + if (empty($id) || $tab == 'timespent') { + $tab = 'timespent'; + } else { + $tab = 'tasks'; + } $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); @@ -596,15 +587,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Title $morehtmlref .= $projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) - { + if ($projectstatic->thirdparty->id > 0) { $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -622,22 +611,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); @@ -647,8 +633,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Visibility print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '</td></tr>'; // Date start - end @@ -658,12 +647,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) print img_warning("Late"); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Budget print '<tr><td>'.$langs->trans("Budget").'</td><td>'; - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } print '</td></tr>'; // Other attributes @@ -708,14 +701,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $linktocreatetimeBtnStatus = 0; $linktocreatetimeUrl = ''; $linktocreatetimeHelpText = ''; - if ($user->rights->projet->all->lire || $user->rights->projet->lire) // To enter time, read permission is enough - { - if ($projectstatic->public || $userRead > 0) - { + if ($user->rights->projet->all->lire || $user->rights->projet->lire) { // To enter time, read permission is enough + if ($projectstatic->public || $userRead > 0) { $linktocreatetimeBtnStatus = 1; - if (!empty($projectidforalltimes)) // We are on tab 'Time Spent' of project - { + if (!empty($projectidforalltimes)) { // We are on tab 'Time Spent' of project $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject ? '&withproject=1' : ''); $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').'&projectid='.$projectstatic->id.'&action=createtime'.$param.'&backtopage='.urlencode($backtourl); } else // We are on tab 'Time Spent' of task @@ -733,42 +723,41 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } $massactionbutton = ''; - if ($projectstatic->usage_bill_time) - { + if ($projectstatic->usage_bill_time) { $arrayofmassactions = array( 'generateinvoice'=>$langs->trans("GenerateBill"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->projet->creer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete', 'generateinvoice'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete', 'generateinvoice'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); } // Show section with information of task. If id of task is not defined and project id defined, then $projectidforalltimes is not empty. - if (empty($projectidforalltimes)) - { + if (empty($projectidforalltimes)) { $head = task_prepare_head($object); print dol_get_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); - if ($action == 'deleteline') - { + if ($action == 'deleteline') { print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); } $param = ($withproject ? '&withproject=1' : ''); $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : ''; - if (!GETPOST('withproject') || empty($projectstatic->id)) - { + if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; - } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } else { + $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + } $morehtmlref = ''; // Project - if (empty($withproject)) - { + if (empty($withproject)) { $morehtmlref .= '<div class="refidno">'; $morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $projectstatic->getNomUrl(1); @@ -797,13 +786,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $end = dol_print_date($object->date_end, 'dayhour'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print '</td></tr>'; // Planned workload print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; - if ($object->planned_workload) - { + if ($object->planned_workload) { print convertSecondToTime($object->planned_workload, 'allhourmin'); } print '</td></tr>'; @@ -823,12 +813,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Progress calculated print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td>'; - if ($object->planned_workload) - { + if ($object->planned_workload) { $tmparray = $object->getSummaryOfTimeSpent(); - if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; - else print '0 %'; - } else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; + if ($tmparray['total_duration'] > 0) { + print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; + } else { + print '0 %'; + } + } else { + print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; + } print '</td>'; print '</tr>'; @@ -845,10 +839,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } - if ($projectstatic->id > 0) - { - if ($action == 'deleteline' && !empty($projectidforalltimes)) - { + if ($projectstatic->id > 0) { + if ($action == 'deleteline' && !empty($projectidforalltimes)) { print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); } @@ -858,8 +850,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Definition of fields for list $arrayfields = array(); $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); } @@ -874,33 +865,67 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $arrayfields = dol_sort_array($arrayfields, 'position'); $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_month > 0) $param .= '&search_month='.urlencode($search_month); - if ($search_year > 0) $param .= '&search_year='.urlencode($search_year); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_task_ref); - if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_task_label); - if ($search_note != '') $param .= '&search_note='.urlencode($search_note); - if ($search_duration != '') $param .= '&amp;search_field2='.urlencode($search_duration); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($search_month > 0) { + $param .= '&search_month='.urlencode($search_month); + } + if ($search_year > 0) { + $param .= '&search_year='.urlencode($search_year); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_task_ref != '') { + $param .= '&search_task_ref='.urlencode($search_task_ref); + } + if ($search_task_label != '') { + $param .= '&search_task_label='.urlencode($search_task_label); + } + if ($search_note != '') { + $param .= '&search_note='.urlencode($search_note); + } + if ($search_duration != '') { + $param .= '&amp;search_field2='.urlencode($search_duration); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } /* // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - if ($id) $param .= '&id='.urlencode($id); - if ($projectid) $param .= '&projectid='.urlencode($projectid); - if ($withproject) $param .= '&withproject='.urlencode($withproject); + if ($id) { + $param .= '&id='.urlencode($id); + } + if ($projectid) { + $param .= '&projectid='.urlencode($projectid); + } + if ($withproject) { + $param .= '&withproject='.urlencode($withproject); + } print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; + } print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - if ($action == 'editline') print '<input type="hidden" name="action" value="updateline">'; - elseif ($action == 'splitline') print '<input type="hidden" name="action" value="updatesplitline">'; - elseif ($action == 'createtime' && $user->rights->projet->lire) print '<input type="hidden" name="action" value="addtimespent">'; - elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire) print '<input type="hidden" name="action" value="confirm_generateinvoice">'; - else print '<input type="hidden" name="action" value="list">'; + if ($action == 'editline') { + print '<input type="hidden" name="action" value="updateline">'; + } elseif ($action == 'splitline') { + print '<input type="hidden" name="action" value="updatesplitline">'; + } elseif ($action == 'createtime' && $user->rights->projet->lire) { + print '<input type="hidden" name="action" value="addtimespent">'; + } elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire) { + print '<input type="hidden" name="action" value="confirm_generateinvoice">'; + } else { + print '<input type="hidden" name="action" value="list">'; + } print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; @@ -910,8 +935,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '<input type="hidden" name="tab" value="'.$tab.'">'; // Form to convert time spent into invoice - if ($massaction == 'generateinvoice') - { + if ($massaction == 'generateinvoice') { print '<input type="hidden" name="massaction" value="confirm_createbills">'; if ($projectstatic->thirdparty->id > 0) { @@ -939,8 +963,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '</td>'; print '</tr>'; - if ($conf->service->enabled) - { + if ($conf->service->enabled) { print '<tr>'; print '<td>'; print $langs->trans('ServiceToUseOnLines'); @@ -998,39 +1021,50 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture,"; $sql .= " ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; - else $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; - if ($search_note) $sql .= natural_search('t.note', $search_note); - if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); - if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); - if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user); - if ($search_valuebilled == '1') $sql .= ' AND t.invoice_id > 0'; - if ($search_valuebilled == '0') $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; + if (empty($projectidforalltimes)) { + $sql .= " AND t.fk_task =".$object->id; + } else { + $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; + } + if ($search_note) { + $sql .= natural_search('t.note', $search_note); + } + if ($search_task_ref) { + $sql .= natural_search('pt.ref', $search_task_ref); + } + if ($search_task_label) { + $sql .= natural_search('pt.label', $search_task_label); + } + if ($search_user > 0) { + $sql .= natural_search('t.fk_user', $search_user); + } + if ($search_valuebilled == '1') { + $sql .= ' AND t.invoice_id > 0'; + } + if ($search_valuebilled == '0') { + $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; + } $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. - if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) - { + if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -1038,10 +1072,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $num = $db->num_rows($resql); } - if ($num >= 0) - { - if (!empty($projectidforalltimes)) - { + if ($num >= 0) { + if (!empty($projectidforalltimes)) { print '<!-- List of time spent for project -->'."\n"; $title = $langs->trans("ListTaskTimeUserProject"); @@ -1056,8 +1088,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_object($resql); $tasks[$i] = $row; $i++; @@ -1070,23 +1101,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) /* * Form to add a new line of time spent */ - if ($action == 'createtime' && $user->rights->projet->lire) - { + if ($action == 'createtime' && $user->rights->projet->lire) { print '<!-- table to add time spent -->'."\n"; - if (!empty($id)) print '<input type="hidden" name="taskid" value="'.$id.'">'; + if (!empty($id)) { + print '<input type="hidden" name="taskid" value="'.$id.'">'; + } print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '<table class="noborder nohover centpercent">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Date").'</td>'; - if (empty($id)) print '<td>'.$langs->trans("Task").'</td>'; + if (empty($id)) { + print '<td>'.$langs->trans("Task").'</td>'; + } print '<td>'.$langs->trans("By").'</td>'; print '<td>'.$langs->trans("Note").'</td>'; print '<td>'.$langs->trans("NewTimeSpent").'</td>'; print '<td>'.$langs->trans("ProgressDeclared").'</td>'; - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<td></td>'; } print '<td></td>'; @@ -1103,8 +1136,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Task $nboftasks = 0; - if (empty($id)) - { + if (empty($id)) { print '<td class="maxwidthonsmartphone">'; $nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); print '</td>'; @@ -1113,13 +1145,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Contributor print '<td class="maxwidthonsmartphone nowraponall">'; $contactsofproject = $projectstatic->getListContactId('internal'); - if (count($contactsofproject) > 0) - { + if (count($contactsofproject) > 0) { print img_object('', 'user', 'class="hideonsmartphone"'); - if (in_array($user->id, $contactsofproject)) $userid = $user->id; - else $userid = $contactsofproject[0]; + if (in_array($user->id, $contactsofproject)) { + $userid = $user->id; + } else { + $userid = $contactsofproject[0]; + } - if ($projectstatic->public) $contactsofproject = array(); + if ($projectstatic->public) { + $contactsofproject = array(); + } print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth250'); } else { if ($nboftasks) { @@ -1136,8 +1172,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Duration - Time spent print '<td>'; $durationtouse = ($_POST['timespent_duration'] ? $_POST['timespent_duration'] : ''); - if (GETPOSTISSET('timespent_durationhour') || GETPOSTISSET('timespent_durationmin')) - { + if (GETPOSTISSET('timespent_durationhour') || GETPOSTISSET('timespent_durationmin')) { $durationtouse = (GETPOST('timespent_durationhour') * 3600 + GETPOST('timespent_durationmin') * 60); } print $form->select_duration('timespent_duration', $durationtouse, 0, 'text'); @@ -1149,8 +1184,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '</td>'; // Invoiced - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<td>'; print '</td>'; } @@ -1170,11 +1204,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -1190,29 +1226,43 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Fields title search print '<tr class="liste_titre_filter">'; // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { + if (!empty($arrayfields['t.task_date']['checked'])) { print '<td class="liste_titre">'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; + } print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; $formother->select_year($search_year, 'search_year', 1, 20, 5); print '</td>'; } - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - if (!empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; - if (!empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + if (!empty($arrayfields['t.task_ref']['checked'])) { + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; + } + if (!empty($arrayfields['t.task_label']['checked'])) { + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; + } } // Author - if (!empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250').'</td>'; + if (!empty($arrayfields['author']['checked'])) { + print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250').'</td>'; + } // Note - if (!empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; + if (!empty($arrayfields['t.note']['checked'])) { + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; + } // Duration - if (!empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; + if (!empty($arrayfields['t.task_duration']['checked'])) { + print '<td class="liste_titre right"></td>'; + } // Value in main currency - if (!empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['value']['checked'])) { + print '<td class="liste_titre"></td>'; + } // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).'</td>'; + if (!empty($arrayfields['valuebilled']['checked'])) { + print '<td class="liste_titre center">'.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).'</td>'; + } /* // Extra fields @@ -1230,17 +1280,32 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '</tr>'."\n"; print '<tr class="liste_titre">'; - if (!empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - if (!empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.task_date']['checked'])) { + print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); + } + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + if (!empty($arrayfields['t.task_ref']['checked'])) { + print_liste_field_titre($arrayfields['t.task_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['t.task_label']['checked'])) { + print_liste_field_titre($arrayfields['t.task_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); + } + } + if (!empty($arrayfields['author']['checked'])) { + print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['t.note']['checked'])) { + print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['t.task_duration']['checked'])) { + print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['value']['checked'])) { + print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['valuebilled']['checked'])) { + print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, '', $sortfield, $sortorder, 'center '); } - if (!empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, '', $sortfield, $sortorder, 'center '); /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1262,9 +1327,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $total = 0; $totalvalue = 0; $totalarray = array(); - foreach ($tasks as $task_time) - { - if ($i >= $limit) break; + foreach ($tasks as $task_time) { + if ($i >= $limit) { + break; + } print '<tr class="oddeven">'; @@ -1272,30 +1338,28 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $date2 = $db->jdate($task_time->task_datehour); // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { + if (!empty($arrayfields['t.task_date']['checked'])) { print '<td class="nowrap">'; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($task_time->task_date_withhour)) - { + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($task_time->task_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); - } else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } else { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } } else { print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_ref']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td class="nowrap">'; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { $formproject->selectTasks(-1, GETPOST('taskid', 'int') ?GETPOST('taskid', 'int') : $task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); } else { $tasktmp->id = $task_time->fk_task; @@ -1304,31 +1368,33 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print $tasktmp->getNomUrl(1, 'withproject', 'time'); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } } else { print '<input type="hidden" name="taskid" value="'.$id.'">'; } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_label']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td class="nowrap">'; print $task_time->label; print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } } // By User - if (!empty($arrayfields['author']['checked'])) - { + if (!empty($arrayfields['author']['checked'])) { print '<td class="nowrap">'; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($object->id)) { + $object->fetch($id); + } $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { $contactsoftask[] = $task_time->fk_user; @@ -1348,72 +1414,77 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print $userstatic->getNomUrl(-1); } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Note - if (!empty($arrayfields['t.note']['checked'])) - { + if (!empty($arrayfields['t.note']['checked'])) { print '<td class="left">'; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print '<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; } else { print dol_nl2br($task_time->note); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - } elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { + if (!$i) { + $totalarray['nbfield']++; + } + } elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="timespent_note_line" value="'.$task_time->note.'">'; } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { + if (!empty($arrayfields['t.task_duration']['checked'])) { print '<td class="right">'; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); } else { print convertSecondToTime($task_time->task_duration, 'allhourmin'); } print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.task_duration'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.task_duration'; + } $totalarray['val']['t.task_duration'] += $task_time->task_duration; - if (!$i) $totalarray['totaldurationfield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['totaldurationfield'] = $totalarray['nbfield']; + } $totalarray['totalduration'] += $task_time->task_duration; } // Value spent - if (!empty($arrayfields['value']['checked'])) - { + if (!empty($arrayfields['value']['checked'])) { print '<td class="nowraponall right">'; $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); print price($value, 1, $langs, 1, -1, -1, $conf->currency); print '</td>'; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'value'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'value'; + } $totalarray['val']['value'] += $value; - if (!$i) $totalarray['totalvaluefield'] = $totalarray['nbfield']; + if (!$i) { + $totalarray['totalvaluefield'] = $totalarray['nbfield']; + } $totalarray['totalvalue'] += $value; } // Invoiced - if (!empty($arrayfields['valuebilled']['checked'])) - { + if (!empty($arrayfields['valuebilled']['checked'])) { print '<td class="center">'; // invoice_id and invoice_line_id - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { - if ($projectstatic->usage_bill_time) - { - if ($task_time->invoice_id) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + if ($projectstatic->usage_bill_time) { + if ($task_time->invoice_id) { $result = $tmpinvoice->fetch($task_time->invoice_id); - if ($result > 0) - { + if ($result > 0) { print $tmpinvoice->getNomUrl(1); } } else { @@ -1424,7 +1495,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } /* @@ -1439,18 +1512,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Action column print '<td class="center nowraponall">'; - if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid) - { + if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="lineid" value="'.$_GET['lineid'].'">'; print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans("Save").'">'; print '<br>'; print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - } elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks - { - if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) - { - if ($conf->MAIN_FEATURES_LEVEL >= 2) - { + } elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) { // Read project and enter time consumed on assigned tasks + if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) { + if ($conf->MAIN_FEATURES_LEVEL >= 2) { print '&nbsp;'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=splitline&amp;lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; print img_split(); @@ -1467,37 +1536,38 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print img_delete('default', 'class="pictodelete paddingleft"'); print '</a>'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($task_time->rowid, $arrayofselected)) $selected = 1; + if (in_array($task_time->rowid, $arrayofselected)) { + $selected = 1; + } print '&nbsp;'; print '<input id="cb'.$task_time->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$task_time->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } } } print '</td>'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "</tr>\n"; // Add line to split - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<tr class="oddeven">'; // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { + if (!empty($arrayfields['t.task_date']['checked'])) { print '<td class="nowrap">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($task_time->task_date_withhour)) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($task_time->task_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); - } else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } else { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } } else { print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } @@ -1505,10 +1575,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_ref']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td class="nowrap">'; $tasktmp->id = $task_time->fk_task; $tasktmp->ref = $task_time->ref; @@ -1519,10 +1587,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_label']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td>'; print $task_time->label; print '</td>'; @@ -1530,12 +1596,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // User - if (!empty($arrayfields['author']['checked'])) - { + if (!empty($arrayfields['author']['checked'])) { print '<td>'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($object->id)) { + $object->fetch($id); + } $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { $contactsoftask[] = $task_time->fk_user; @@ -1558,27 +1624,22 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Note - if (!empty($arrayfields['t.note']['checked'])) - { + if (!empty($arrayfields['t.note']['checked'])) { print '<td class="left">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; } else { print dol_nl2br($task_time->note); } print '</td>'; - } elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + } elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="timespent_note_line" value="'.$task_time->note.'">'; } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { + if (!empty($arrayfields['t.task_duration']['checked'])) { print '<td class="right">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); } else { @@ -1588,8 +1649,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Value spent - if (!empty($arrayfields['value']['checked'])) - { + if (!empty($arrayfields['value']['checked'])) { print '<td class="right">'; $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); print price($value, 1, $langs, 1, -1, -1, $conf->currency); @@ -1597,11 +1657,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) - { + if (!empty($arrayfields['valuebilled']['checked'])) { print '<td class="right">'; $valuebilled = price2num($task_time->total_ht, '', 1); - if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + if (isset($task_time->total_ht)) { + print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + } print '</td>'; } @@ -1627,15 +1688,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '<tr class="oddeven">'; // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { + if (!empty($arrayfields['t.task_date']['checked'])) { print '<td class="nowrap">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($task_time->task_date_withhour)) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($task_time->task_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); - } else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); + } else { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); + } } else { print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } @@ -1643,10 +1703,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_ref']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td class="nowrap">'; $tasktmp->id = $task_time->fk_task; $tasktmp->ref = $task_time->ref; @@ -1657,10 +1715,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { + if (!empty($arrayfields['t.task_label']['checked'])) { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print '<td class="nowrap">'; print $task_time->label; print '</td>'; @@ -1668,12 +1724,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // User - if (!empty($arrayfields['author']['checked'])) - { + if (!empty($arrayfields['author']['checked'])) { print '<td>'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { + if (empty($object->id)) { + $object->fetch($id); + } $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { $contactsoftask[] = $task_time->fk_user; @@ -1696,27 +1752,22 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Note - if (!empty($arrayfields['t.note']['checked'])) - { + if (!empty($arrayfields['t.note']['checked'])) { print '<td class="left">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<textarea name="timespent_note_line_2" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; } else { print dol_nl2br($task_time->note); } print '</td>'; - } elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + } elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="timespent_note_line_2" value="'.$task_time->note.'">'; } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { + if (!empty($arrayfields['t.task_duration']['checked'])) { print '<td class="right">'; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { print '<input type="hidden" name="old_duration_2" value="0">'; print $form->select_duration('new_duration_2', 0, 0, 'text'); } else { @@ -1726,8 +1777,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Value spent - if (!empty($arrayfields['value']['checked'])) - { + if (!empty($arrayfields['value']['checked'])) { print '<td class="right">'; $value = 0; print price($value, 1, $langs, 1, -1, -1, $conf->currency); @@ -1735,11 +1785,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) - { + if (!empty($arrayfields['valuebilled']['checked'])) { print '<td class="right">'; $valuebilled = price2num($task_time->total_ht, '', 1); - if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + if (isset($task_time->total_ht)) { + print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + } print '</td>'; } @@ -1765,31 +1816,35 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Show total line //include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) - { + if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) { print '<tr class="liste_total">'; $i = 0; - while ($i < $totalarray['nbfield']) - { + while ($i < $totalarray['nbfield']) { $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>'; - else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; - } elseif ($totalarray['totaldurationfield'] == $i) print '<td class="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>'; - elseif ($totalarray['totalvaluefield'] == $i) print '<td class="right">'.price($totalarray['totalvalue']).'</td>'; - //elseif ($totalarray['totalvaluebilledfield'] == $i) print '<td class="center">'.price($totalarray['totalvaluebilled']).'</td>'; - else print '<td></td>'; + if ($i == 1) { + if ($num < $limit && empty($offset)) { + print '<td class="left">'.$langs->trans("Total").'</td>'; + } else { + print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; + } + } elseif ($totalarray['totaldurationfield'] == $i) { + print '<td class="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>'; + } elseif ($totalarray['totalvaluefield'] == $i) { + print '<td class="right">'.price($totalarray['totalvalue']).'</td>'; + //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print '<td class="center">'.price($totalarray['totalvaluebilled']).'</td>'; + } else { + print '<td></td>'; + } } print '</tr>'; } - if (!count($tasks)) - { + if (!count($tasks)) { $totalnboffields = 1; - foreach ($arrayfields as $value) - { - if ($value['checked']) $totalnboffields++; + foreach ($arrayfields as $value) { + if ($value['checked']) { + $totalnboffields++; + } } print '<tr class="oddeven"><td colspan="'.$totalnboffields.'">'; print '<span class="opacitymedium">'.$langs->trans("None").'</span>'; From d5566dbf8f4d5d71fe655f923506fbb550941f11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 19:18:03 +0100 Subject: [PATCH 160/173] FIX #16431 --- .../bookkeeping/balancebymonth.php | 136 ------------------ .../thirdparty_lettering_customer.php | 2 +- .../thirdparty_lettering_supplier.php | 2 +- .../class/accountancyexport.class.php | 64 ++++----- .../accountancy/class/bookkeeping.class.php | 26 ++-- htdocs/core/modules/modAccounting.class.php | 6 +- .../install/mysql/migration/12.0.0-13.0.0.sql | 5 + .../tables/llx_accounting_bookkeeping.sql | 2 +- 8 files changed, 61 insertions(+), 182 deletions(-) delete mode 100644 htdocs/accountancy/bookkeeping/balancebymonth.php diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php deleted file mode 100644 index f27d535f57c..00000000000 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php -/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr> - * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - */ - -/** - * \file htdocs/accountancy/bookkeeping/balancebymonth.php - * \ingroup Accountancy (Double entries) - * \brief Balance by month - */ -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("bills", "compta", "accountancy", "other")); - -// Filter -$year = GETPOST("year", 'int'); -if ($year == 0) { - $year_current = strftime("%Y", time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} - - -/* - * View - */ - -llxHeader('', $langs->trans("Bookkeeping")); - -$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>'; -$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>'; - -print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear); - -$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f"; -$sql .= " WHERE fd.fk_code_ventilation = 0"; -$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; - -dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql); -$result = $db->query($sql); -if ($result) { - $row = $db->fetch_row($result); - $nbfac = $row[0]; - - $db->free($result); -} - -$y = $year_current; - -print '<table class="noborder centpercent">'; -print '<tr class="liste_titre">'; -print '<td width=150>'.$langs->trans("Label").'</td>'; -for ($i = 1; $i <= 12; $i++) -{ - print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>'; -} -print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>'; -print '</tr>'; - -$sql = "SELECT bk.numero_compte AS 'compte',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; -$sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; -$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; -$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; -$sql .= " GROUP BY bk.numero_compte"; - -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($i < $num) { - $row = $db->fetch_row($resql); - - print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[1]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[2]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[3]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[4]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[5]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[6]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[7]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[8]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[9]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[10]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[11]).'</td>'; - print '<td class="right" width="6.5%">'.price($row[12]).'</td>'; - print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>'; - print '</tr>'; - - $i++; - } - $db->free($resql); -} else { - print $db->lasterror(); -} -print "</table>\n"; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index e831e21f814..8635946ad38 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -145,7 +145,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index b5620f3ec25..1558fe9b288 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -144,7 +144,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )"; if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3e8aab64479..25bea39f22f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -359,7 +359,7 @@ class AccountancyExport print length_accountg($line->numero_compte).$separator; print length_accounta($line->subledger_account).$separator; print $line->sens.$separator; - print price2fec(abs($line->montant)).$separator; + print price2fec(abs($line->debit - $line->credit)).$separator; print dol_string_unaccent($line->label_operation).$separator; print dol_string_unaccent($line->doc_ref); print $end_line; @@ -387,11 +387,11 @@ class AccountancyExport print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { - print price($line->montant).$separator; + print price($line->debit).$separator; print ''.$separator; } elseif ($line->sens == 'C') { print ''.$separator; - print price($line->montant).$separator; + print price($line->credit).$separator; } print $line->doc_ref.$separator; print $line->label_operation.$separator; @@ -492,7 +492,7 @@ class AccountancyExport $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25); - $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34); @@ -539,6 +539,7 @@ class AccountancyExport $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); // Credit invoice - invert sens + /* if ($data->montant < 0) { if ($data->sens == 'C') { $Tab['sens'] = 'D'; @@ -549,10 +550,12 @@ class AccountancyExport } else { $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; - } - + }*/ + $Tab['sens'] = $data->sens; // C or D + $Tab['signe_montant'] = '+'; + // The amount must be in centimes without decimal points. - $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); // Force date format : %d%m%y @@ -637,13 +640,13 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); - $Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_crebit'] = str_pad(number_format($data->credit), 2, ',', ''), 13, ' ', STR_PAD_LEFT); } $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30); @@ -704,7 +707,7 @@ class AccountancyExport //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; - print price2num(abs($line->montant)).$separator; + print price2num(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $date.$separator; //print 'EUR'; @@ -744,7 +747,7 @@ class AccountancyExport print self::toAnsi($line->doc_ref).$separator; print price($line->debit).$separator; print price($line->credit).$separator; - print price($line->montant).$separator; + print price(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $line->lettering_code.$separator; print $line->code_journal; @@ -807,7 +810,7 @@ class AccountancyExport $tab[] = length_accounta($line->subledger_account); $tab[] = price2num($line->debit); $tab[] = price2num($line->credit); - $tab[] = price2num($line->montant); + $tab[] = price2num($line->debit - $line->credit); $tab[] = $line->code_journal; print implode($separator, $tab).$this->end_line; @@ -849,7 +852,7 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); @@ -950,7 +953,7 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); @@ -1105,12 +1108,7 @@ class AccountancyExport // Code print '""'.$this->separator; // Netto - if ($line->montant >= 0) - { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } + print abs($line->debit - $line->credit).$this->separator; // Steuer print "0.00".$this->separator; // FW-Betrag @@ -1190,13 +1188,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1220,7 +1218,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1452,13 +1450,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1482,7 +1480,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1602,7 +1600,7 @@ class AccountancyExport print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->doc_ref, 20).$separator; //Piece print self::trunc($line->label_operation, 60).$separator; //Operation label - print price(abs($line->montant)).$separator; //Amount + print price(abs($line->debit - $line->credit)).$separator; //Amount print $line->sens.$separator; //Direction print $separator; //Analytic print $separator; //Analytic @@ -1631,7 +1629,7 @@ class AccountancyExport $supplier_invoices_infos = array(); foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); @@ -1699,8 +1697,8 @@ class AccountancyExport print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; //Devise print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; + //Amount + print price2num(abs($line->debit - $line->credit)) . $this->separator; //Sens print $line->sens . $this->separator; //Code lettrage @@ -1726,14 +1724,14 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->id . $this->separator; print $date . $this->separator; print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value print length_accountg($line->subledger_account) . $this->separator; } else { print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; @@ -1742,7 +1740,7 @@ class AccountancyExport //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator; - print price2num($line->montant) . $this->separator; + print price2num(abs($line->debit - $line->credit)) . $this->separator; print $line->sens . $this->separator; print $date . $this->separator; print $this->separator; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0c7dd333901..957259c946c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -135,6 +135,7 @@ class BookKeeping extends CommonObject /** * @var float FEC:Amount (Not necessary) + * @deprecated No more used */ public $amount; @@ -239,6 +240,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = (float) $this->montant; } + if (isset($this->amount)) { + $this->amount = (float) $this->amount; + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -554,6 +558,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = trim($this->montant); } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -695,7 +702,7 @@ class BookKeeping extends CommonObject $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; @@ -734,7 +741,8 @@ class BookKeeping extends CommonObject $this->label_operation = $obj->label_operation; $this->debit = $obj->debit; $this->credit = $obj->credit; - $this->montant = $obj->montant; + $this->montant = $obj->amount; + $this->amount = $obj->amount; $this->sens = $obj->sens; $this->fk_user_author = $obj->fk_user_author; $this->import_key = $obj->import_key; @@ -1197,8 +1205,8 @@ class BookKeeping extends CommonObject if (isset($this->credit)) { $this->credit = trim($this->credit); } - if (isset($this->montant)) { - $this->montant = trim($this->montant); + if (isset($this->amount)) { + $this->amount = trim($this->amount); } if (isset($this->sens)) { $this->sens = trim($this->sens); @@ -1641,7 +1649,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".$piecenum; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -1667,7 +1675,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; @@ -1700,7 +1709,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE entity IN (".getEntity('accountancy').")"; @@ -1730,7 +1739,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 811dd57544e..057122ec648 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -292,7 +292,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', 'b.debit'=>"Debit", - 'b.credit'=>"Credit" + 'b.credit'=>"Credit", + 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); $this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); @@ -309,7 +310,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'', 'b.label_operation'=>"Sale of ABC", 'b.debit'=>"0", - 'b.credit'=>"100" + 'b.credit'=>"100", + 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); // Chart of accounts diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index a19f8d34279..cc0bb4224b2 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -579,3 +579,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4); + +-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL; +-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL; + + diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index cf7897bf7a2..90de3fd02fe 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -35,7 +35,7 @@ CREATE TABLE llx_accounting_bookkeeping label_operation varchar(255), -- FEC:EcritureLib | label of the operation debit double(24,8) NOT NULL, -- FEC:Debit credit double(24,8) NOT NULL, -- FEC:Credit - montant double(24,8) NOT NULL, -- FEC:Montant (Not necessary) + montant double(24,8) NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) multicurrency_amount double(24,8), -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise From 0315fb5fc3feffaa76da3cb1c74517d253344f4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 26 Feb 2021 19:19:48 +0100 Subject: [PATCH 161/173] Fix missing in v13 --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index eaad793b47f..edee25169c9 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -40,6 +40,9 @@ ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object); insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4); +-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL; +-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL; + -- For v14 ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0; From 8e632d08b8c997a52677f7b8eacc9305d56b0c70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 00:31:29 +0100 Subject: [PATCH 162/173] NEW Add link picto to the stock movement on the detail of production --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/fourn/js/lib_dispatch.js.php | 4 +- htdocs/mrp/js/lib_dispatch.js.php | 6 +- htdocs/mrp/mo_production.php | 93 +++++++++++++++----------- htdocs/product/class/product.class.php | 3 + 5 files changed, 61 insertions(+), 47 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e4f04bde0a2..155cbdddca1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3420,7 +3420,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', - 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next', + 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index 254fac29f28..fd15894b4ec 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -93,9 +93,7 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr $row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_")); //create new select2 to avoid duplicate id of cloned one diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index 179c7a15129..8a5eef60211 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -94,9 +94,9 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched >= qtyOrdered) { + window.alert("No remain qty to dispatch"); + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr var re1 = new RegExp('_'+index+'_1', 'g'); var re2 = new RegExp('-'+index+'-1', 'g'); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 0b50bcf8e9a..5b01aff6207 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -259,32 +259,33 @@ if (empty($reshook)) { $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); $pricetoprocess = GETPOST('pricetoproduce-'.$line->id.'-'.$i) ? price2num(GETPOST('pricetoproduce-'.$line->id.'-'.$i)) : 0; - // Check warehouse is set if we should have to - if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); - $error++; - } - if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); - $error++; - } - } - - $idstockmove = 0; - if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { - // Record stock movement - $id_product_batch = 0; - $stockmove->origin = $object; - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); - if ($idstockmove < 0) { - $error++; - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } - } if ($qtytoprocess != 0) { + // Check warehouse is set if we should have to + if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set + if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); + $error++; + } + if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); + $error++; + } + } + + $idstockmove = 0; + if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $object; + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } + } + if (!$error) { // Record production $moline = new MoLine($db); @@ -414,6 +415,7 @@ $formproject = new FormProjets($db); $formproduct = new FormProduct($db); $tmpwarehouse = new Entrepot($db); $tmpbatch = new Productlot($db); +$tmpstockmovement = new MouvementStock($db); $help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, array('/mrp/js/lib_dispatch.js.php')); @@ -654,8 +656,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref); print '<div class="center'.(in_array($action, array('consumeorproduce', 'consumeandproduceall')) ? ' formconsumeproduce' : '').'">'; - print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></span>'; - print '<span class="fieldrequired">'.$langs->trans("InventoryCode").':</span> <input type="text" class="maxwidth200" name="inventorycode" value="'.$defaultstockmovementcode.'"> &nbsp; '; + print '<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></div>'; + print '<span class="fieldrequired">'.$langs->trans("InventoryCode").':</span> <input type="text" class="minwidth200 maxwidth250" name="inventorycode" value="'.$defaultstockmovementcode.'"> &nbsp; '; print '<span class="clearbothonsmartphone"></span>'; print $langs->trans("MovementLabel").': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.'"><br><br>'; print '<input type="checkbox" id="autoclose" name="autoclose" value="1"'.(GETPOSTISSET('inventorylabel') ? (GETPOST('autoclose') ? ' checked="checked"' : '') : ' checked="checked"').'> <label for="autoclose">'.$langs->trans("AutoCloseMO").'</label><br>'; @@ -688,7 +690,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - // consumtion + // Lines to consume print '<div class="fichecenter">'; print '<div class="fichehalfleft">'; @@ -706,7 +708,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Product").'</td>'; print '<td class="right">'.$langs->trans("Qty").'</td>'; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print '<td class="right">'.$langs->trans("UnitCost").'</td>'; } print '<td class="right">'.$langs->trans("QtyAlreadyConsumed").'</td>'; @@ -731,7 +733,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); print '</td>'; print '<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>'; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print '<td></td>'; } print '<td class="right"></td>'; @@ -809,7 +811,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $line->qty; } print '</td>'; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print '<td class="right nowraponall">'; print price($linecost); print '</td>'; @@ -853,11 +855,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print '<tr class="expanddetail'.$line->id.' hideobject opacitylow">'; print '<td>'; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.'">'.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').'</a>'; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print '</td>'; print '<td></td>'; print '<td class="right">'.$line2['qty'].'</td>'; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print '<td></td>'; } print '<td class="tdoverflowmax150">'; @@ -888,7 +892,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $preselected = 0; } print '<td class="right"><input type="text" class="width50 right" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print '<td></td>'; } print '<td></td>'; @@ -922,6 +926,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '</table>'; print '</div>'; + // Lines to produce print '</div>'; @@ -1039,13 +1044,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print '<tr class="expanddetailtoproduce'.$line->id.' hideobject opacitylow">'; print '<td>'; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.'">'.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').'</a>'; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print '</td>'; + // Qty print '<td></td>'; - print '<td class="right">'.$line2['qty'].'</td>'; + // Cost price if ($permissiontoupdatecost) { print '<td></td>'; } + // Qty already produced + print '<td class="right">'.$line2['qty'].'</td>'; print '<td class="tdoverflowmax150">'; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); @@ -1076,10 +1086,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print '<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.'-'.$i.'" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; if ($permissiontoupdatecost) { - $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost)); - print '<td class="right"><input type="text" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; - } else { - print '<input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$bomcost.'"></td>'; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost)); + print '<td class="right"><input type="text" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>'; + } else { + print '<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$bomcost.'"></td>'; + } } print '<td></td>'; print '<td>'; @@ -1097,6 +1109,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '<input type="text" class="width50" name="batchtoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'">'; } print '</td>'; + // Batch number in same column than the stock movement picto print '<td>'; if ($tmpproduct->status_batch) { $type = 'batch'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bea9e1173a7..548afb3037a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4580,6 +4580,9 @@ class Product extends CommonObject $label .= "<br>".$labelsurfacevolume; } } + if (!empty($this->pmp) && $this->pmp) { + $label .= "<br><b>".$langs->trans("PMPValue").'</b>: '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); + } if (!empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; From 84219689a6eb4f929fe24dc43c442760a2d46af6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 02:00:00 +0100 Subject: [PATCH 163/173] Look and feel v14 --- htdocs/langs/en_US/productbatch.lang | 4 +- htdocs/mrp/mo_movements.php | 62 +++++++++++------- htdocs/product/card.php | 3 +- htdocs/product/class/product.class.php | 5 ++ htdocs/product/stats/card.php | 2 +- htdocs/product/stock/movement_list.php | 90 +++++++++++--------------- htdocs/product/traduction.php | 75 ++++++++++++--------- htdocs/theme/eldy/btn.inc.php | 7 +- 8 files changed, 134 insertions(+), 114 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index aa13c745c96..3ab83908ff5 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,7 +1,7 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Use lot/serial number -ProductStatusOnBatch=Lot (required) -ProductStatusOnSerial=Unique Serial Number (required) +ProductStatusOnBatch=Yes (lot required) +ProductStatusOnSerial=Yes (unique serial number required) ProductStatusNotOnBatch=No (lot/serial not used) ProductStatusOnBatchShort=Lot ProductStatusOnSerialShort=Serial diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 98c78b948fb..59b4b07fe82 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -114,23 +114,24 @@ $objectlist = new MouvementStock($db); // Definition of fields for list $arrayfields = array( - 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>1), - 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1, 'position'=>2), - 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100', 'position'=>10), - 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1, 'position'=>15), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>20), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>21), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>22), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'position'=>30), - 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0, 'position'=>40), - 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1, 'position'=>42), - 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1, 'position'=>45), - 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1, 'position'=>48), - 'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0, 'position'=>50), - 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1, 'position'=>60), - 'm.price'=>array('label'=>$langs->trans("UnitCost"), 'enabled'=>0, 'checked'=>0, 'position'=>62), - //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) + 'm.rowid'=>array('label'=>"Ref", 'checked'=>1, 'position'=>1), + 'm.datem'=>array('label'=>"Date", 'checked'=>1, 'position'=>2), + 'p.ref'=>array('label'=>"ProductRef", 'checked'=>1, 'css'=>'maxwidth100', 'position'=>3), + 'p.label'=>array('label'=>"ProductLabel", 'checked'=>0, 'position'=>5), + 'm.batch'=>array('label'=>"BatchNumberShort", 'checked'=>1, 'position'=>8, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>"EatByDate", 'checked'=>0, 'position'=>9, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>"SellByDate", 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>"Warehouse", 'checked'=>1, 'position'=>100, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it + 'm.fk_user_author'=>array('label'=>"Author", 'checked'=>0, 'position'=>120), + 'm.inventorycode'=>array('label'=>"InventoryCodeShort", 'checked'=>1, 'position'=>130), + 'm.label'=>array('label'=>"MovementLabel", 'checked'=>1, 'position'=>140), + 'm.type_mouvement'=>array('label'=>"TypeMovement", 'checked'=>0, 'position'=>150), + 'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155), + 'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180), + 'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200), + 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210) + //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) ); if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { unset($arrayfields['pl.eatby']); @@ -678,6 +679,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '&nbsp; '; print '</td>'; } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + // fk_project + print '<td class="liste_titre" align="left">'; + print '&nbsp; '; + print '</td>'; + } if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; @@ -757,6 +764,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); } @@ -837,13 +847,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!empty($arrayfields['p.label']['checked'])) { // Product label - print '<td>'; - /* - * $productstatic->id=$objp->rowid; - * $productstatic->ref=$objp->produit; - * $productstatic->type=$objp->type; - * print $productstatic->getNomUrl(1,'',16); - */ + print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">'; print $productstatic->label; print "</td>\n"; } @@ -884,7 +888,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!empty($arrayfields['m.label']['checked'])) { // Label of movement - print '<td class="tdoverflowmax100aaa">'.$objp->label.'</td>'; + print '<td class="tdoverflowmax300" title="'.dol_escape_htmltag($objp->label).'">'.$objp->label.'</td>'; } if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement @@ -907,6 +911,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Origin of movement print '<td class="nowraponall">'.$origin.'</td>'; } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + // fk_project + print '<td>'; + if ($objp->fk_project != 0) { + print $movement->get_origin($objp->fk_project, 'project'); + } + print '</td>'; + } if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a50eb7bede2..3eccae1e114 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1841,6 +1841,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '</form>'; } else { // Fiche en mode visu + $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; @@ -1930,7 +1931,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '</form>'; } else { - print $object->barcode; + print showValueWithClipboardCPButton($object->barcode); } print '</td></tr>'."\n"; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 548afb3037a..b8ddb6c8672 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1350,6 +1350,11 @@ class Product extends CommonObject return -1; } } elseif (isset($this->multilangs[$key])) { + if (empty($this->multilangs["$key"]["label"])) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); + return -1; + } + $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$this->id; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index b55976bface..a47bc79c84a 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -209,7 +209,7 @@ if ($result || empty($id)) { print '</td></tr>'; print '</table>'; print '<div class="center"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></div>'; - print '</form>'; + print '</form><br>'; print '<br>'; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index b4d1c9a1fe8..38c49a44f4c 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -116,24 +116,24 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields = array( - 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), - 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), - 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>0), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it - 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), - 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), - 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), - 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>0), - 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), - 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), - 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0), - 'm.fk_projet'=>array('label'=>$langs->trans('Project'), 'checked'=>0) - //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) + 'm.rowid'=>array('label'=>"Ref", 'checked'=>1, 'position'=>1), + 'm.datem'=>array('label'=>"Date", 'checked'=>1, 'position'=>2), + 'p.ref'=>array('label'=>"ProductRef", 'checked'=>1, 'css'=>'maxwidth100', 'position'=>3), + 'p.label'=>array('label'=>"ProductLabel", 'checked'=>0, 'position'=>5), + 'm.batch'=>array('label'=>"BatchNumberShort", 'checked'=>1, 'position'=>8, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>"EatByDate", 'checked'=>0, 'position'=>9, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>"SellByDate", 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>"Warehouse", 'checked'=>1, 'position'=>100, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it + 'm.fk_user_author'=>array('label'=>"Author", 'checked'=>0, 'position'=>120), + 'm.inventorycode'=>array('label'=>"InventoryCodeShort", 'checked'=>1, 'position'=>130), + 'm.label'=>array('label'=>"MovementLabel", 'checked'=>1, 'position'=>140), + 'm.type_mouvement'=>array('label'=>"TypeMovement", 'checked'=>0, 'position'=>150), + 'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155), + 'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180), + 'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200), + 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210) + //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) ); if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { unset($arrayfields['pl.eatby']); @@ -470,7 +470,6 @@ $warehousestatic = new Entrepot($db); $movement = new MouvementStock($db); $userstatic = new User($db); $form = new Form($db); -$formother = new FormOther($db); $formproduct = new FormProduct($db); if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); @@ -574,20 +573,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } -if (empty($search_inventorycode)) { - $sql .= $db->plimit($limit + 1, $offset); -} else { - $limit = 0; -} +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if (!empty($search_inventorycode)) { - $limit = $db->num_rows($resql); -} - if ($resql) { $product = new Product($db); $object = new Entrepot($db); @@ -978,6 +969,12 @@ if ($resql) { print '&nbsp; '; print '</td>'; } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + // fk_project + print '<td class="liste_titre" align="left">'; + print '&nbsp; '; + print '</td>'; + } if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; @@ -990,13 +987,6 @@ if ($resql) { print '&nbsp; '; print '</td>'; } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print '<td class="liste_titre" align="left">'; - print '&nbsp; '; - print '</td>'; - } - // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -1063,15 +1053,15 @@ if ($resql) { if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['m.price']['checked'])) { print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, 'align="right"', $sortfield, $sortorder); - } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1183,15 +1173,11 @@ if ($resql) { } if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code - print '<td><a href="' - .DOL_URL_ROOT.'/product/stock/movement_card.php?id='.urlencode($objp->entrepot_id) - .'&search_inventorycode='.urlencode($objp->inventorycode) - .'&search_type_mouvement='.urlencode($objp->type_mouvement) - .'">'.$objp->inventorycode.'</a></td>'; + print '<td><a href="'.$_SERVER["PHP_SELF"].'?search_inventorycode='.urlencode('^'.$objp->inventorycode.'$').'&search_type_mouvement='.urlencode($objp->type_mouvement).'">'.$objp->inventorycode.'</a></td>'; } if (!empty($arrayfields['m.label']['checked'])) { // Label of movement - print '<td class="tdoverflowmax100aaa">'.$objp->label.'</td>'; + print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->label).'">'.$objp->label.'</td>'; } if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement @@ -1214,6 +1200,14 @@ if ($resql) { // Origin of movement print '<td class="nowraponall">'.$origin.'</td>'; } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + // fk_project + print '<td>'; + if ($objp->fk_project != 0) { + print $movement->get_origin($objp->fk_project, 'project'); + } + print '</td>'; + } if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; @@ -1231,14 +1225,6 @@ if ($resql) { } print '</td>'; } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print '<td align="right">'; - if ($objp->fk_project != 0) { - print $movement->get_origin($objp->fk_project, 'project'); - } - print '</td>'; - } // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index d1d2289fb24..57f08f81866 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -61,30 +61,38 @@ if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) { $object = new Product($db); $object->fetch($id); $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user); + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + $action = ''; } // Add translation -if ($action == 'vadd' && -$cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet - if ($_POST["forcelangprod"] == $current_lang) { - $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); - $object->other = dol_htmlcleanlastbr($_POST["other"]); + if (GETPOST("forcelangprod") == $current_lang) { + $object->label = GETPOST("libelle"); + $object->description = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); + $object->update($object->id, $user); } else { - $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); - $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); + $object->multilangs[GETPOST("forcelangprod")]["label"] = GETPOST("libelle"); + $object->multilangs[GETPOST("forcelangprod")]["description"] = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->multilangs[GETPOST("forcelangprod")]["other"] = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); } - // sauvegarde en base - if ($object->setMultiLangs($user) > 0) { + // save in database + if (GETPOST("forcelangprod")) { + $result = $object->setMultiLangs($user); + } else { + $object->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")); + $result = -1; + } + + if ($result > 0) { $action = ''; } else { $action = 'add'; @@ -93,26 +101,25 @@ $cancel != $langs->trans("Cancel") && } // Edit translation -if ($action == 'vedit' && -$cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); foreach ($object->multilangs as $key => $value) { // enregistrement des nouvelles valeurs dans l'objet if ($key == $current_lang) { - $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->label = GETPOST("libelle-".$key); + $object->description = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } else { - $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->multilangs[$key]["label"] = GETPOST("libelle-".$key); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } } - if ($object->setMultiLangs($user) > 0) { + $result = $object->setMultiLangs($user); + if ($result > 0) { $action = ''; } else { $action = 'edit'; @@ -121,15 +128,13 @@ $cancel != $langs->trans("Cancel") && } // Delete translation -if ($action == 'vdelete' && -$cancel != $langs->trans("Cancel") && -($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); - - if ($object->delMultiLangs($langtodelete, $user) > 0) { + $result = $object->delMultiLangs($langtodelete, $user); + if ($result > 0) { $action = ''; } else { $action = 'edit'; @@ -197,7 +202,7 @@ print dol_get_fiche_end(); /* */ /* ************************************************************************** */ -print "\n<div class=\"tabsAction\">\n"; +print "\n".'<div class="tabsAction">'."\n"; if ($action == '') { if ($user->rights->produit->creer || $user->rights->service->creer) { @@ -208,7 +213,7 @@ if ($action == '') { } } -print "\n</div>\n"; +print "\n".'</div>'."\n"; @@ -222,9 +227,12 @@ if ($action == 'edit') { print '<input type="hidden" name="id" value="'.$object->id.'">'; if (!empty($object->multilangs)) { + $i = 0; foreach ($object->multilangs as $key => $value) { + $i++; + $s = picto_from_langcode($key); - print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>"; + print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; @@ -254,9 +262,12 @@ if ($action == 'edit') { print '</form>'; } elseif ($action != 'add') { if (!empty($object->multilangs)) { + $i = 0; foreach ($object->multilangs as $key => $value) { + $i++; + $s = picto_from_langcode($key); - print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>'; + print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; @@ -295,7 +306,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print '<table class="border centpercent">'; print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>'; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print $formadmin->select_language(GETPOST('forcelangprod'), 'forcelangprod', 0, $object->multilangs, 1); print '</td></tr>'; print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 8cb51a152d4..a6da55bea60 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -66,9 +66,14 @@ span.butAction, span.butActionDelete { .butAction { background: var(--butactionbg); color: #FFF !important; - border-radius: 3px; /* background: rgb(230, 232, 239); */ } +.butActionRefused, .butAction, .butActionDelete { + border-radius: 3px; +} +.butActionRefused:last-child, .butAction:last-child, .butActionDelete:last-child { + margin-right: 0px !important; +} .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { text-decoration: none; text-transform: uppercase; From 56508816d2c55a0fdcf79f27279c6432ced9b12a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 02:02:35 +0100 Subject: [PATCH 164/173] Look and feel v14 --- htdocs/product/traduction.php | 4 ++-- htdocs/theme/md/btn.inc.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 57f08f81866..67c2dccab71 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -232,7 +232,7 @@ if ($action == 'edit') { $i++; $s = picto_from_langcode($key); - print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; + print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block margintop marginbottomonly"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; @@ -267,7 +267,7 @@ if ($action == 'edit') { $i++; $s = picto_from_langcode($key); - print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; + print ($i > 1 ? "<br>" : "").($s ? $s.' ' : '').' <div class="inline-block marginbottomonly"><b>'.$langs->trans('Language_'.$key).'</b></div><div class="inline-block floatright"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom marginrightonly"').'</a></div>'; print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php index 8fc5fe1aacc..6313575e70b 100644 --- a/htdocs/theme/md/btn.inc.php +++ b/htdocs/theme/md/btn.inc.php @@ -62,9 +62,14 @@ span.butAction, span.butActionDelete { .butAction { background: var(--butactionbg); color: #FFF !important; - border-radius: 3px; /* background: rgb(230, 232, 239); */ } +.butActionRefused, .butAction, .butActionDelete { + border-radius: 3px; +} +.butActionRefused:last-child, .butAction:last-child, .butActionDelete:last-child { + margin-right: 0px !important; +} .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { text-decoration: none; text-transform: uppercase; From 34d00e5d5e49f422ab690cc917a128df006033f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 02:44:52 +0100 Subject: [PATCH 165/173] Look and feel v14 --- htdocs/comm/card.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/fourn/card.php | 2 +- htdocs/fourn/class/fournisseur.product.class.php | 2 +- htdocs/langs/en_US/companies.lang | 8 ++++---- htdocs/margin/tabs/thirdpartyMargins.php | 4 ++-- htdocs/product/composition/card.php | 4 ++-- htdocs/product/fournisseurs.php | 4 ++-- htdocs/societe/card.php | 13 ++++++++++--- htdocs/societe/consumption.php | 4 ++-- htdocs/societe/document.php | 4 ++-- htdocs/societe/note.php | 4 ++-- htdocs/societe/project.php | 4 ++-- 14 files changed, 36 insertions(+), 29 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fcd6471604a..2a074b984f5 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -340,7 +340,7 @@ if ($object->id > 0) { print '<tr><td>'; print $langs->trans('CustomerCode').'</td><td>'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 483d356891c..5f2497a5827 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1040,10 +1040,10 @@ class Form } $out .= '</select>'; - $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="'.$location_incoterms.'">'; + $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone nomargintop nomarginbottom" name="location_incoterms" value="'.$location_incoterms.'">'; if (!empty($page)) { - $out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'"></form>'; + $out .= '<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="'.$langs->trans("Modify").'"></form>'; } } else { dol_print_error($this->db); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 155cbdddca1..349c6088f39 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3438,7 +3438,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'off', 'on', 'order', 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', - 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', + 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', 'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'shipment', 'supplier_invoice', 'technic', 'ticket', @@ -3456,7 +3456,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } - if (in_array($pictowithouttext, array('black-tie', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { + if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { $fa = 'fab'; } @@ -3572,7 +3572,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $arrayconvpictotocolor = array( 'address'=>'#6c6aa8', 'building'=>'#6c6aa8', 'bom'=>'#a69944', 'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'dynamicprice'=>'#a69944', - 'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', + 'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555', 'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', 'lot'=>'#a69944', 'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944', 'other'=>'#ddd', diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 1d7f5cce418..2d0b526a438 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -209,7 +209,7 @@ if ($object->id > 0) { if ($object->fournisseur) { print '<tr>'; print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index e0eea961b9e..db2b6dd749a 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -952,7 +952,7 @@ class ProductFournisseur extends Product } $out .= '</table>'; } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); + $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; <span class="opacitymedium">(</span>' : '').($showsuptitle ? '<span class="opacitymedium">'.$langs->trans("Supplier").'</span>: ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / <span class="opacitymedium">'.$langs->trans("SupplierRef").'</span>: '.$this->fourn_ref.($showunitprice ? '<span class="opacitymedium">)</span>' : ''); } return $out; } diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index d4c9f95b0b9..42180dde04f 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -172,13 +172,13 @@ ProfId1ES=Prof Id 1 (CIF/NIF) ProfId2ES=Prof Id 2 (Social security number) ProfId3ES=Prof Id 3 (CNAE) ProfId4ES=Prof Id 4 (Collegiate number) -ProfId5ES=EORI number +ProfId5ES=Prof Id 5 (EORI number) ProfId6ES=- ProfId1FR=Prof Id 1 (SIREN) ProfId2FR=Prof Id 2 (SIRET) ProfId3FR=Prof Id 3 (NAF, old APE) ProfId4FR=Prof Id 4 (RCS/RM) -ProfId5FR=EORI number +ProfId5FR=Prof Id 5 (numéro EORI) ProfId6FR=- ProfId1GB=Registration Number ProfId2GB=- @@ -232,7 +232,7 @@ ProfId1PT=Prof Id 1 (NIPC) ProfId2PT=Prof Id 2 (Social security number) ProfId3PT=Prof Id 3 (Commercial Record number) ProfId4PT=Prof Id 4 (Conservatory) -ProfId5PT=EORI number +ProfId5PT=Prof Id 5 (EORI number) ProfId6PT=- ProfId1SN=RC ProfId2SN=NINEA @@ -256,7 +256,7 @@ ProfId1RO=Prof Id 1 (CUI) ProfId2RO=Prof Id 2 (Nr. Înmatriculare) ProfId3RO=Prof Id 3 (CAEN) ProfId4RO=Prof Id 5 (EUID) -ProfId5RO=EORI number +ProfId5RO=Prof Id 5 (EORI number) ProfId6RO=- ProfId1RU=Prof Id 1 (OGRN) ProfId2RU=Prof Id 2 (INN) diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 054f2ae5f93..0103bd03aca 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -112,7 +112,7 @@ if ($socid > 0) { if ($object->client) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -123,7 +123,7 @@ if ($socid > 0) { if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 08dae5169e2..9a1fa1adf69 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -208,14 +208,14 @@ if ($id > 0 || !empty($ref)) { // Nature if ($object->type != Product::TYPE_SERVICE) { - print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td>'; + print '<tr><td class="titlefieldcreate">'.$langs->trans("Nature").'</td><td>'; print $object->getLibFinished(); print '</td></tr>'; } if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price - print '<tr><td class="titlefield">'.$langs->trans("SellingPrice").'</td><td>'; + print '<tr><td class="titlefieldcreate">'.$langs->trans("SellingPrice").'</td><td>'; if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 9a4518f509e..d5d3128071a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -358,6 +358,8 @@ if (empty($reshook)) { * view */ +$form = new Form($db); + $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); @@ -372,8 +374,6 @@ if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs'); -$form = new Form($db); - if ($id > 0 || $ref) { if ($result) { if ($action == 'ask_remove_pf') { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5a7de9d9450..ea7ab623a87 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1411,6 +1411,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr>'; print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>'; print '<td colspan="3">'; + if (!empty($value['icon'])) { + print '<span class="fa '.$value['icon'].'"></span>'; + } print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key])).'">'; print '</td>'; print '</tr>'; @@ -1606,7 +1609,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print '</td></tr>'; - // Ajout du logo + // Add logo print '<tr class="hideonsmartphone">'; print '<td>'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).'</td>'; print '<td colspan="3">'; @@ -2061,6 +2064,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '<tr>'; print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>'; print '<td colspan="3">'; + if (!empty($value['icon'])) { + print '<span class="fa '.$value['icon'].'"></span>'; + } print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.$object->socialnetworks[$key].'">'; print '</td>'; print '</tr>'; @@ -2201,7 +2207,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->global->MAIN_MULTILANGS)) { print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n"; - print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); + print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); print '</td>'; print '</tr>'; } @@ -2587,7 +2593,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if ($object->tva_intra) { $s = ''; - $s .= dol_escape_htmltag($object->tva_intra); + $s .= showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); $s .= '<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.'">'; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) @@ -2677,6 +2683,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) //print ($s?$s.' ':''); $langs->load("languages"); $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly"'); print $labellang; print '</td></tr>'; } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index fe8c2adb7bc..f2ba112b3d0 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -129,7 +129,7 @@ if ($object->client) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -155,7 +155,7 @@ if ($object->fournisseur) $langs->load("supplier_proposal"); print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 034522a3652..fdd5ef08756 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -135,7 +135,7 @@ if ($object->id) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -147,7 +147,7 @@ if ($object->id) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 516fb95e464..e4f060c6e7c 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -97,7 +97,7 @@ if ($object->id > 0) if ($object->client) { print '<tr><td class="'.$cssclass.'">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -108,7 +108,7 @@ if ($object->id > 0) if ($object->fournisseur) { print '<tr><td class="'.$cssclass.'">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 54be485d6cd..ea6449fff6f 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -98,7 +98,7 @@ if ($socid) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -110,7 +110,7 @@ if ($socid) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; From 0f9d9625addfffa9895360194c4faded7ac64f53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 02:49:24 +0100 Subject: [PATCH 166/173] Look and feel v14 --- htdocs/societe/card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ea7ab623a87..aa02d27fac9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1339,7 +1339,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->barcode->enabled)) { print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>'; - print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">'; + print '<td colspan="3">'; + print img_picto('', 'barcode'); + print '<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">'; print '</td></tr>'; } @@ -1994,10 +1996,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Barcode - if (!empty($conf->barcode->enabled)) - { + if (!empty($conf->barcode->enabled)) { print '<tr><td class="tdtop">'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>'; - print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">'; + print '<td colspan="3">'; + print img_picto('', 'barcode'); + print '<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">'; print '</td></tr>'; } From cf23df9f283f1eed50e03878486ec4804e5ab133 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 03:06:05 +0100 Subject: [PATCH 167/173] Fix field hidden by default (not used) --- 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 2a074b984f5..c3cb5fe257b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -533,7 +533,7 @@ if ($object->id > 0) { print '</tr>'; } // Warehouse - if (!empty($conf->stock->enabled)) { + if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); From 4c7d78ffaacf7f5d171224e0517c1bc9abdadee8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 03:06:21 +0100 Subject: [PATCH 168/173] Look and feel v14 --- htdocs/fourn/card.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/societe/notify/card.php | 4 ++-- htdocs/societe/paymentmodes.php | 4 ++-- htdocs/ticket/list.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 2d0b526a438..5d3c5b0358d 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -195,7 +195,7 @@ if ($object->id > 0) { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="underbanner clearboth"></div>'; - print '<table width="100%" class="border">'; + print '<table class="border centpercent tableforfield">'; // Type Prospect/Customer/Supplier print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>'; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index aa02d27fac9..97f3758b991 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1534,7 +1534,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->global->MAIN_MULTILANGS)) { print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n"; - print $formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print img_picto('', 'language').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '</td>'; print '</tr>'; } diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index b911bfb034e..d650802d7e4 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -169,7 +169,7 @@ if ($result > 0) if ($object->client) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -180,7 +180,7 @@ if ($result > 0) if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 8956a80d0d8..ce1a0562e9f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -807,7 +807,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td colspan="2">'; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -862,7 +862,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td colspan="2">'; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index f4482399495..7a1cf699c3e 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -492,7 +492,7 @@ if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { if ($socstat->client && !empty($socstat->code_client)) { print '<tr><td class="titlefield">'; print $langs->trans('CustomerCode').'</td><td>'; - print $socstat->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client)); $tmpcheck = $socstat->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; @@ -504,7 +504,7 @@ if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { print '<tr><td class="titlefield">'; print $langs->trans('SupplierCode').'</td><td>'; - print $socstat->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur)); $tmpcheck = $socstat->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; From 5c0ea476e1841b319afacc5976c1b201e4d4c02a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 12:45:07 +0100 Subject: [PATCH 169/173] Look and feel v14 --- htdocs/comm/propal/card.php | 34 +++++++------- htdocs/commande/card.php | 48 ++++++++++---------- htdocs/core/class/commonobject.class.php | 4 +- htdocs/core/lib/admin.lib.php | 28 ++++++------ htdocs/core/lib/date.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 19 ++++---- htdocs/core/lib/project.lib.php | 8 ++-- htdocs/core/menus/standard/eldy.lib.php | 12 ++--- htdocs/core/modules/modTakePos.class.php | 1 + htdocs/core/tpl/commonfields_add.tpl.php | 4 +- htdocs/core/tpl/commonfields_edit.tpl.php | 4 +- htdocs/core/tpl/commonfields_view.tpl.php | 4 +- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/install/check.php | 3 +- htdocs/install/default.css | 9 +++- htdocs/install/inc.php | 7 ++- htdocs/install/step5.php | 18 ++++---- htdocs/install/upgrade.php | 3 +- htdocs/install/upgrade2.php | 53 ++++++++++++++++++---- htdocs/product/list.php | 12 ++--- htdocs/supplier_proposal/card.php | 31 ++++++------- htdocs/theme/eldy/global.inc.php | 8 +++- htdocs/theme/md/main_menu_fa_icons.inc.php | 5 +- htdocs/theme/md/style.css.php | 4 +- 24 files changed, 194 insertions(+), 129 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2834edb3427..1790150206b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2047,7 +2047,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -2074,7 +2074,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editecheance&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -2104,7 +2104,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { @@ -2117,7 +2117,7 @@ if ($action == 'create') { $langs->load('deliveries'); print '<tr><td>'; print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker'); - print '</td><td>'; + print '</td><td class="valuefield">'; print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker'); print '</td>'; print '</tr>'; @@ -2134,7 +2134,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editavailability&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -2154,7 +2154,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editshippingmethod' && $usercancreate) { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { @@ -2172,7 +2172,7 @@ if ($action == 'create') { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefieldcreate">'; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); } else { @@ -2191,7 +2191,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -2202,7 +2202,7 @@ if ($action == 'create') { // Payment mode print '<tr>'; - print '<td>'; + print '<td class="valuefield">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('PaymentMode'); print '</td>'; @@ -2210,7 +2210,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefieldcreate">'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { @@ -2230,7 +2230,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -2250,7 +2250,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -2272,7 +2272,7 @@ if ($action == 'create') { // Outstanding Bill print '<tr><td>'; print $langs->trans('OutstandingBill'); - print '</td><td class="right">'; + print '</td><td class="valuefield">'; $arrayoutstandingbills = $soc->getOutstandingBills(); print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); @@ -2290,7 +2290,7 @@ if ($action == 'create') { print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; } print '</tr></table>'; - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2305,13 +2305,13 @@ if ($action == 'create') { $totalVolume = $tmparray['volume']; if ($totalWeight) { print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>'; - print '<td>'; + print '<td class="valuefield">'; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print '</td></tr>'; } if ($totalVolume) { print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>'; - print '<td>'; + print '<td class="valuefield">'; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print '</td></tr>'; } @@ -2329,7 +2329,7 @@ if ($action == 'create') { } print '</td></tr></table>'; print '</td>'; - print '<td>'; + print '<td class="valuefield">'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 889eb036ab4..9453764f7eb 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2067,7 +2067,7 @@ if ($action == 'create' && $usercancreate) { // Outstanding Bill print '<tr><td class="titlefield">'; print $langs->trans('OutstandingBill'); - print '</td><td>'; + print '</td><td class="valuefield">'; $arrayoutstandingbills = $soc->getOutstandingBills(); print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); @@ -2088,7 +2088,7 @@ if ($action == 'create' && $usercancreate) { $addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("EditGlobalDiscounts").'</a>'; $addcreditnote = '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$soc->id.'&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddCreditNote").'</a>'; - print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td class="valuefield">'; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2106,7 +2106,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Date", 'date', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editdate') { print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -2127,7 +2127,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editdate_livraison') { print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -2149,7 +2149,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editshippingmethod') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { @@ -2167,7 +2167,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); } else { @@ -2181,7 +2181,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { @@ -2195,7 +2195,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { @@ -2210,7 +2210,7 @@ if ($action == 'create' && $usercancreate) { print '<td>'; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -2224,7 +2224,7 @@ if ($action == 'create' && $usercancreate) { print '<td>'; $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT; print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -2246,7 +2246,7 @@ if ($action == 'create' && $usercancreate) { print '<tr class="fielddeliverydelay"><td>'; $editenable = $usercancreate; print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -2258,7 +2258,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -2285,13 +2285,13 @@ if ($action == 'create' && $usercancreate) { $totalVolume = $tmparray['volume']; if ($totalWeight) { print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>'; - print '<td>'; + print '<td class="valuefield">'; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print '</td></tr>'; } if ($totalVolume) { print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>'; - print '<td>'; + print '<td class="valuefield">'; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print '</td></tr>'; } @@ -2304,7 +2304,7 @@ if ($action == 'create' && $usercancreate) { $editenable = $usercancreate; print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print '</td>'; - print '<td>'; + print '<td class="valuefield">'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { @@ -2318,7 +2318,7 @@ if ($action == 'create' && $usercancreate) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); - print '</td><td>'; + print '</td><td class="valuefield">'; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2343,17 +2343,17 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; - print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; - print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; - print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } @@ -2363,23 +2363,23 @@ if ($action == 'create' && $usercancreate) { $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); } print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; - print '<td>'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>'; + print '<td class="valuefield">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>'; // Total VAT - print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td class="valuefield">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; - print '<td>'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; + print '<td class="valuefield">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; - print '<td>'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; + print '<td class="valuefield">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; } // Total TTC - print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="valuefield">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; // Statut //print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 008a1b21e40..81820c29390 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7395,10 +7395,10 @@ abstract class CommonObject $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); if ($display_type == 'card') { - $out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >'; + $out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldcreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >'; $out .= '<td class="wordbreak'; } elseif ($display_type == 'line') { - $out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >'; + $out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldlinecreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >'; $out .= '<div style="display: inline-block; padding-right:4px" class="wordbreak'; } //$out .= "titlefield"; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 9810f032ffa..15b8e8bb188 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -457,22 +457,24 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle } else { print '<span class="error">'.$langs->trans("Error").'</span>'; } - //if (! empty($conf->use_javascript_ajax)) { - print '<script type="text/javascript" language="javascript"> - jQuery(document).ready(function() { - function init_trrunsql() - { - console.log("toggle .trforrunsql"); - jQuery(".trforrunsql").toggle(); - } + + //if (!empty($conf->use_javascript_ajax)) { // use_javascript_ajax is not defined + print '<script type="text/javascript" language="javascript"> + jQuery(document).ready(function() { + function init_trrunsql() + { + console.log("toggle .trforrunsql"); + jQuery(".trforrunsql").toggle(); + } + init_trrunsql(); + jQuery(".trforrunsqlshowhide").click(function() { init_trrunsql(); - jQuery(".trforrunsqlshowhide").click(function() { - init_trrunsql(); - }); }); - </script>'; - print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>'; + }); + </script>'; + print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>'; //} + print '</td></tr>'."\n"; } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b57117ffb79..6ec53bd5f48 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -252,7 +252,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l if ($sDay > 1) { $dayTranslate = $langs->trans("Days"); } - $sTime .= $sDay.' '.$dayTranslate.' '; + $sTime .= $sDay.' '.strtolower(dol_substr($dayTranslate, 0, 1)).'. '; } if ($format == 'all') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 349c6088f39..de446221750 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3436,7 +3436,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', 'off', 'on', 'order', - 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', + 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', @@ -3444,8 +3444,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'shipment', 'supplier_invoice', 'technic', 'ticket', 'error', 'warning', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', - 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'user-cog', - 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', + 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', + 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', + 'user-cog', 'eventorganization', 'object_eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); @@ -3453,7 +3454,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; $fa = 'fas'; - if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { + if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { @@ -3480,13 +3481,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', - 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', + 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'resource'=>'laptop-house', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', - 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', + 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', 'uparrow'=>'mail-forward', 'vcard'=>'address-card', 'jabber'=>'comment-o', @@ -3524,7 +3525,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('holiday', 'dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) { $morecss = 'em092'; } - if (in_array($pictowithouttext, array('holiday'))) { + if (in_array($pictowithouttext, array('holiday', 'project'))) { $morecss = 'em088'; } if (in_array($pictowithouttext, array('intervention', 'payment', 'loan', 'stock', 'technic'))) { @@ -3555,7 +3556,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'user'=>'infobox-adherent', 'users'=>'infobox-adherent', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'holiday'=>'infobox-holiday', 'invoice'=>'infobox-commande', 'loan'=>'infobox-bank_account', - 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', + 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', 'salary'=>'infobox-bank_account', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', @@ -3577,7 +3578,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944', 'other'=>'#ddd', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba', - 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa', + 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa', 'website'=>'#304' ); if (isset($arrayconvpictotocolor[$pictowithouttext])) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 1222fa120fe..49ed4c536c0 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2413,18 +2413,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { - print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); } - print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("OpportunityAmount", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); if (!in_array('plannedworkload', $hiddenfields)) { - print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); } if (!in_array('declaredprogress', $hiddenfields)) { - print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared")); } } if (!in_array('projectstatus', $hiddenfields)) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 42304cc7be2..e0447d5523a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1524,7 +1524,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Cash Control if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) { $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run); - $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol'); + $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"')); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence); } @@ -1724,12 +1724,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Project affected to user - $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'task', 'class="pictofixedwidth"')); + $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'projecttask', 'class="pictofixedwidth"')); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); - $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire); + $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', 'project', 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"')); } } } @@ -1770,7 +1770,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Trips and expenses (old module) if (!empty($conf->deplacement->enabled)) { $langs->load("trips"); - $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses'); + $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"')); $newmenu->add("/compta/deplacement/card.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer); $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire); $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire); @@ -1779,7 +1779,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Expense report if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); - $newmenu->add("/expensereport/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport'); + $newmenu->add("/expensereport/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"')); $newmenu->add("/expensereport/card.php?action=create&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer); $newmenu->add("/expensereport/list.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire); if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") { @@ -1799,7 +1799,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $search_project_user = GETPOST('search_project_user', 'int'); - $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire); + $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"')); } } } diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index a5ab8491643..b4fbb1f2e97 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -216,6 +216,7 @@ class modTakePos extends DolibarrModules 'titre'=>'PointOfSaleShort', 'mainmenu'=>'takepos', 'leftmenu'=>'', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'url'=>'/takepos/index.php', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 526d640b62a..407859037d7 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -44,7 +44,7 @@ foreach ($object->fields as $key => $val) { continue; // We don't want this field } - print '<tr id="field_'.$key.'">'; + print '<tr class="field_'.$key.'">'; print '<td'; print ' class="titlefieldcreate'; if ($val['notnull'] > 0) { @@ -61,7 +61,7 @@ foreach ($object->fields as $key => $val) { print $langs->trans($val['label']); } print '</td>'; - print '<td>'; + print '<td class="valuefieldcreate">'; if (!empty($val['picto'])) { print img_picto('', $val['picto']); } diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 8ea1befa009..a2c6868472f 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -46,7 +46,7 @@ foreach ($object->fields as $key => $val) { continue; // We don't want this field } - print '<tr><td'; + print '<tr class="field_'.$key.'"><td'; print ' class="titlefieldcreate'; if ($val['notnull'] > 0) { print ' fieldrequired'; @@ -61,7 +61,7 @@ foreach ($object->fields as $key => $val) { print $langs->trans($val['label']); } print '</td>'; - print '<td>'; + print '<td class="valuefieldcreate">'; if (!empty($val['picto'])) { print img_picto('', $val['picto']); } diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 8fbd5aa2fb3..0e661c6e078 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -57,7 +57,7 @@ foreach ($object->fields as $key => $val) { $value = $object->$key; - print '<tr><td'; + print '<tr class="field_'.$key.'"><td'; print ' class="titlefield fieldname_'.$key; //if ($val['notnull'] > 0) print ' fieldrequired'; // No fieldrequired on the view output if ($val['type'] == 'text' || $val['type'] == 'html') { @@ -70,7 +70,7 @@ foreach ($object->fields as $key => $val) { print $langs->trans($val['label']); } print '</td>'; - print '<td class="valuefield fieldname_'.$key; + print '<td class="valuefield'; if ($val['type'] == 'text') { print ' wordbreak'; } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 1721f686776..214f14adb75 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -198,7 +198,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] $html_id = !empty($object->id) ? $object->element.'_extras_'.$tmpkeyextra.'_'.$object->id : ''; - print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>'; + print '<td id="'.$html_id.'" class="valuefield '.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>'; // Convert date into timestamp format if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) { diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 7594ead39a4..79c8e590ab9 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -64,7 +64,8 @@ pHeader('', ''); // No next step for navigation buttons. Next step is defined by //print "<br>\n"; //print $langs->trans("InstallEasy")."<br><br>\n"; -print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '.$langs->trans("MiscellaneousChecks").":</h3>\n"; +print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '; +print '<span class="inline-block">'.$langs->trans("MiscellaneousChecks")."</span></h3>\n"; // Check browser $useragent = $_SERVER['HTTP_USER_AGENT']; diff --git a/htdocs/install/default.css b/htdocs/install/default.css index ca397d1ca40..eaefd6d5b2b 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -20,6 +20,10 @@ opacity: 0.5; } +.inline-block { + display: inline-block; +} + body { font-size:14px; font-family: roboto,arial,tahoma,verdana,helvetica; @@ -353,15 +357,16 @@ tr.choiceselected td.listofchoicesdesc { } tr.choiceselected td .button { - background: rgb(0,113,121); + background: rgba(150, 110, 162, 0.95); color: #fff; } a.button:link,a.button:visited,a.button:active { color: #888; + } .button { - background: #ddd; + background: rgb(234,228,225); color: #fff; /* border: 1px solid #e0e0e0; */ padding: 0.5em 0.7em; diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 3f7cb019521..91ceae9eaaa 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -483,9 +483,10 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl * @param string $setuplang Language code * @param string $jscheckfunction Add a javascript check function * @param integer $withpleasewait Add also please wait tags + * @param string $morehtml Add more HTML content * @return void */ -function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0) +function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0, $morehtml = '') { global $conf, $langs; @@ -494,6 +495,10 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '</td></tr></table>'."\n"; print '</td></tr></table>'."\n"; + print '<!-- pFooter -->'."\n"; + + print $morehtml; + if (!$nonext || ($nonext == '2')) { print '<div class="nextbutton" id="nextbutton">'; if ($nonext == '2') { diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 6ae3bffc59b..8c6f1147e94 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -112,6 +112,8 @@ if ($action == "set") { * View */ +$morehtml = ''; + pHeader($langs->trans("SetupEnd"), "step5"); print '<br>'; @@ -424,11 +426,11 @@ if ($action == "set" && $success) { print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>"; } - print "<br><br>"; + print "<br>"; - print '<div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">'; - print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...'; - print '</a></div><br>'; + $morehtml = '<br><div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">'; + $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...'; + $morehtml .= '</a></div><br>'; } else { // If here MAIN_VERSION_LAST_UPGRADE is not empty print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</span></b><br>'; @@ -436,9 +438,9 @@ if ($action == "set" && $success) { print "<br>"; - print '<div class="center"><a href="../install/index.php">'; - print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage"); - print '</a></div>'; + $morehtml = '<br><div class="center"><a href="../install/index.php">'; + $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage"); + $morehtml .= '</a></div>'; } } else { dol_print_error('', 'step5.php: unknown choice of action'); @@ -455,7 +457,7 @@ dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step5: Dolibarr setup finished"); -pFooter(1, $setuplang); +pFooter(1, $setuplang, '', 0, $morehtml); // Return code if ran from command line if ($ret) { diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 25e3b95af84..c985a50806d 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -110,7 +110,8 @@ $actiondone = 0; if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { $actiondone = 1; - print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("DatabaseMigration").'</h3>'; + print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '; + print '<span class="inline-block">'.$langs->trans("DatabaseMigration").'</span></h3>'; print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; $error = 0; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d9656231a2c..f3ae7df6ed3 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -117,7 +117,8 @@ pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upg if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { - print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans('DataMigration').'</h3>'; + print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '; + print '<span class="inline-block">'.$langs->trans('DataMigration').'</span></h3>'; print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; @@ -455,6 +456,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BANQUE'=>'menuonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', 'MAIN_MODULE_CRON'=>'newboxdefonly', 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', @@ -472,11 +474,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', 'MAIN_MODULE_PRINTING'=>'newboxdefonly', 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_RECRUITMENT'=>'menuonly', 'MAIN_MODULE_RESOURCE'=>'noboxes', 'MAIN_MODULE_SALARIES'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_STRIPE'=>'menuonly', 'MAIN_MODULE_TICKET'=>'newboxdefonly', 'MAIN_MODULE_TAKEPOS'=>'newboxdefonly', 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) @@ -521,7 +525,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print "<!-- (".$reshook.") -->"; print '</td></tr>'; } else { - print '<tr><td colspan="4">'; + print '<tr class="trforrunsql"><td colspan="4">'; print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: <span class="ok">OK</span>'; print "<!-- (".$reshook.") -->"; print '</td></tr>'; @@ -529,7 +533,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } else { //if (! empty($conf->modules)) if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done - print '<tr><td colspan="4">'; + print '<tr class="trforrunsql"><td colspan="4">'; print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None"); print '</td></tr>'; } @@ -539,6 +543,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print '</table>'; + // Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK) $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; $db->query($sql, 1); @@ -563,7 +568,39 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Actions for all versions (no database change but rename some directories) migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); - print '<div><br>'.$langs->trans("MigrationFinished").'</div>'; + $silent = 0; + if (!$silent) { + print '<table width="100%">'; + print '<tr><td style="width: 30%">'.$langs->trans("MigrationFinished").'</td>'; + print '<td class="right">'; + if ($error == 0) { + //print '<span class="ok">'.$langs->trans("OK").'</span> - '; // $error = 0 does not mean there is no error (error are not always trapped) + } else { + print '<span class="error">'.$langs->trans("Error").'</span> - '; + } + + //if (!empty($conf->use_javascript_ajax)) { // use_javascript_ajax is not defined + print '<script type="text/javascript" language="javascript"> + jQuery(document).ready(function() { + function init_trrunsql() + { + console.log("toggle .trforrunsql"); + jQuery(".trforrunsql").toggle(); + } + init_trrunsql(); + jQuery(".trforrunsqlshowhide").click(function() { + init_trrunsql(); + }); + }); + </script>'; + print '<a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>'; + //} + + print '</td></tr>'."\n"; + print '</table>'; + } + + //print '<div><br>'.$langs->trans("MigrationFinished").'</div>'; } else { print '<div class="error">'.$langs->trans('ErrorWrongParameters').'</div>'; $error++; @@ -4296,7 +4333,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod = new $classname($db); //$mod->remove('noboxes'); - $mod->delete_menus(); // We must delete to be sure it is insert with new values + $mod->delete_menus(); // We must delete to be sure it is inserted with new values $mod->init($reloadmode); } else { dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); @@ -4320,7 +4357,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } if (!empty($mod) && is_object($mod)) { - print '<tr><td colspan="4">'; + print '<tr class="trforrunsql"><td colspan="4">'; print '<b>'.$langs->trans('Upgrade').'</b>: '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated print "<!-- (".$reloadmode.") -->"; @@ -4355,7 +4392,7 @@ function migrate_reload_menu($db, $langs, $conf) } foreach ($listofmenuhandler as $key => $val) { - print '<tr><td colspan="4">'; + print '<tr class="trforrunsql"><td colspan="4">'; //print "x".$key; print '<br>'; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 76f81e43243..1e96e7d97f8 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1030,12 +1030,12 @@ if ($resql) { print '</td>'; } if (!empty($arrayfields['p.tosell']['checked'])) { - print '<td class="liste_titre right">'; + print '<td class="liste_titre center">'; print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'), '1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); print '</td >'; } if (!empty($arrayfields['p.tobuy']['checked'])) { - print '<td class="liste_titre right">'; + print '<td class="liste_titre center">'; print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'), '1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); print '</td>'; } @@ -1188,10 +1188,10 @@ if ($resql) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['p.tosell']['checked'])) { - print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.tobuy']['checked'])) { - print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; @@ -1765,7 +1765,7 @@ if ($resql) { // Status (to sell) if (!empty($arrayfields['p.tosell']['checked'])) { - print '<td class="right nowrap">'; + print '<td class="center nowrap">'; if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { @@ -1778,7 +1778,7 @@ if ($resql) { } // Status (to buy) if (!empty($arrayfields['p.tobuy']['checked'])) { - print '<td class="right nowrap">'; + print '<td class="center nowrap">'; if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 9b69d12776a..64a67abac2f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1541,7 +1541,7 @@ if ($action == 'create') if ($action != 'editconditions' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { @@ -1559,7 +1559,7 @@ if ($action == 'create') if ($action != 'editdate_livraison' && $object->statut == SupplierProposal::STATUS_VALIDATED) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editdate_livraison') { print '<form name="editdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" class="formconsumeproduce">'; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -1582,7 +1582,7 @@ if ($action == 'create') if ($action != 'editmode' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { @@ -1602,7 +1602,7 @@ if ($action == 'create') if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -1621,7 +1621,7 @@ if ($action == 'create') if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -1645,7 +1645,7 @@ if ($action == 'create') // Outstanding Bill print '<tr><td>'; print $langs->trans('OutstandingBill'); - print '</td><td class=right colspan="3">'; + print '</td><td class="valuefield">'; $arrayoutstandingbills = $soc->getOutstandingBills('supplier'); $outstandingBills = $arrayoutstandingbills['opened']; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); @@ -1663,7 +1663,7 @@ if ($action == 'create') if ($action != 'editbankaccount' && $usercancreate) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; print '</tr></table>'; - print '</td><td colspan="3">'; + print '</td><td class="valuefield">'; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -1674,7 +1674,6 @@ if ($action == 'create') } // Other attributes - $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -1690,47 +1689,47 @@ if ($action == 'create') { // Multicurrency Amount HT print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; - print '<td>'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; - print '<td>'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; - print '<td>'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; + print '<td class="valuefield">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } // Amount HT print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; - print '<td>'.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; + print '<td class="valuefield">'.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount VAT print '<tr><td>'.$langs->trans('AmountVAT').'</td>'; - print '<td>'.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; + print '<td class="valuefield">'.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; - print '<td class="nowrap">'.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; + print '<td class="valuefield nowrap">'.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { print '<tr><td height="10">'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; - print '<td class="nowrap">'.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; + print '<td class="valuefield nowrap">'.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } // Amount TTC print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>'; - print '<td class="nowrap">'.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; + print '<td class="valuefield nowrap">'.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; print '</table>'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 6a92e16fdb0..dc1fb6241bb 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -502,6 +502,12 @@ hr { border: 0; border-top: 1px solid #ccc; } text-transform: uppercase; color: #444; } +.valuefield .button, .valuefieldcreate .button { + margin-top: 0 !important; + margin-bottom: 0 !important; + font-size: 0.85em !important; + padding: 5px !important; +} .button:focus, .buttonDelete:focus { -webkit-box-shadow: 0px 0px 5px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); box-shadow: 0px 0px 5px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); @@ -1979,7 +1985,7 @@ span.widthpictotitle.pictotitle { } .pictofixedwidth { text-align: left; - width: 18px; + width: 20px; padding-right: 0; } diff --git a/htdocs/theme/md/main_menu_fa_icons.inc.php b/htdocs/theme/md/main_menu_fa_icons.inc.php index eec79b951eb..23121d94991 100644 --- a/htdocs/theme/md/main_menu_fa_icons.inc.php +++ b/htdocs/theme/md/main_menu_fa_icons.inc.php @@ -100,11 +100,14 @@ div.mainmenu.generic4::before { margin-left: 30px; } - .menu_titre .em092 { font-size: 0.92em; } +.menu_titre .em088 { + font-size: 0.88em; +} + .menu_titre .em080 { font-size: 0.80em; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index def22ff87de..e602cadb6a6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1961,9 +1961,11 @@ div.nopadding { img.hideonsmartphone.pictoactionview { vertical-align: bottom; } + .pictofixedwidth { text-align: left; - width: 16px; + width: 20px; + padding-right: 0; } .colorthumb { From 9cf4222d3a6ef01642ae0981d2f012bfc8b02251 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 17:15:40 +0100 Subject: [PATCH 170/173] Look and feel v14 --- htdocs/accountancy/index.php | 6 +++-- htdocs/comm/action/document.php | 7 ++++-- htdocs/comm/card.php | 2 +- htdocs/compta/paiement/cheque/index.php | 2 +- htdocs/compta/paymentbybanktransfer/index.php | 2 +- htdocs/compta/prelevement/index.php | 3 ++- htdocs/contrat/services_list.php | 22 +++++++++---------- htdocs/core/lib/functions.lib.php | 14 ++++++------ htdocs/core/menus/standard/eldy.lib.php | 16 +++++++------- htdocs/fourn/card.php | 4 ++-- htdocs/societe/card.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 6 +++-- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 4 +++- 14 files changed, 51 insertions(+), 41 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 32f3dfef3d5..5b2f807fcd7 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -63,7 +63,9 @@ if (GETPOST('addbox')) { * View */ -llxHeader('', $langs->trans("AccountancyArea")); +$help_url = ''; + +llxHeader('', $langs->trans("AccountancyArea"), $help_url); if ($conf->accounting->enabled) { $step = 0; @@ -91,7 +93,7 @@ if ($conf->accounting->enabled) { } - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); + print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden print "<br>\n"; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 6739d277192..493cfb1a109 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -180,9 +180,12 @@ if ($object->id > 0) { // Affichage fiche action en mode visu print '<table class="border tableforfield centpercent">'; - // Type + // Type of event if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; + print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'; + print $object->getTypePicto(); + print $langs->trans("Action".$object->type_code); + print '</td></tr>'; } // Full day event diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index c3cb5fe257b..07ab4f797de 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -388,7 +388,7 @@ if ($object->id > 0) { // TVA Intra print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>'; - print $object->tva_intra; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); print '</td></tr>'; // default terms of the settlement diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 0595e144f7b..8bdbb7478a7 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -48,7 +48,7 @@ $accountstatic = new Account($db); llxHeader('', $langs->trans("ChequesArea")); -print load_fiche_titre($langs->trans("ChequesArea"), '', 'bank_account'); +print load_fiche_titre($langs->trans("ChequesArea"), '', $checkdepositstatic->picto); print '<div class="fichecenter"><div class="fichethirdleft">'; diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index f74783e038c..92bc7ec6ff8 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -59,7 +59,7 @@ llxHeader('', $langs->trans("SuppliersStandingOrdersArea")); if (prelevement_check_config('bank-transfer') < 0) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("PaymentByBankTransfer")), null, 'errors'); } print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea")); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index f8a056e9e4c..2da8e1f0812 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -165,7 +165,8 @@ if ($resql) { $i++; } } else { - print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).'</td></tr>'; + $titlefortab = $langs->transnoentitiesnoconv("StandingOrders"); + print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $titlefortab, $titlefortab).'</td></tr>'; } print "</table></div><br>"; } else { diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 072982e56eb..0d295357c09 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -131,19 +131,19 @@ $companystatic = new Societe($db); $arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80), 'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80), - 'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>100), - 'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>100), - 'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>100), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>90), 'cd.tva_tx'=>array('label'=>$langs->trans("VAT"), 'checked'=>0, 'position'=>100), - 'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>100), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>100), - 'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0")), - 'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0)), - 'cd.date_fin_validite'=>array('label'=>$langs->trans("DateEndPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode < 5)), - 'cd.date_cloture'=>array('label'=>$langs->trans("DateEndRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5)), - 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1), + 'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>105), + 'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>108), + 'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>109), + 'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>110), + 'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0"), 'position'=>150), + 'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0), 'position'=>160), + 'cd.date_fin_validite'=>array('label'=>$langs->trans("DateEndPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode < 5), 'position'=>170), + 'cd.date_cloture'=>array('label'=>$langs->trans("DateEndRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5), 'position'=>180), //'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) + 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index de446221750..673ad8206e7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3415,11 +3415,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', - 'cash-register', 'category', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes', + 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', - 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', + 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', @@ -3437,7 +3437,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', 'off', 'on', 'order', 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', - 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', + 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', @@ -3457,15 +3457,15 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } - if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { + if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { $fa = 'fab'; } $arrayconvpictotofa = array( - 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', + 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'shapes', - 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', + 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', @@ -3486,7 +3486,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'resource'=>'laptop-house', - 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', + 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', 'uparrow'=>'mail-forward', 'vcard'=>'address-card', diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e0447d5523a..749765886b4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1185,7 +1185,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); // Configuration - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1, '', '', '', img_picto('', 'setup', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); @@ -1220,7 +1220,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Transfer in accounting - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1, '', '', '', img_picto('', 'long-arrow-alt-right', 'class="paddingright pictofixedwidth"')); // Binding // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); @@ -1318,7 +1318,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Accounting - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"')); // Balance $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire); @@ -1447,7 +1447,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Assets if (!empty($conf->asset->enabled)) { - $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); + $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); $newmenu->add("/asset/card.php?leftmenu=asset&amp;action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); @@ -1468,7 +1468,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Bank-Cash account if (!empty($conf->banque->enabled)) { - $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank'); + $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank', 0, '', '', '', img_picto('', 'bank_account', 'class="paddingright pictofixedwidth"')); $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer); $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->lire, '', $mainmenu, 'bank'); @@ -1486,7 +1486,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Direct debit order if (!empty($conf->prelevement->enabled)) { - $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); + $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer); @@ -1500,7 +1500,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Bank transfer order if (!empty($conf->paymentbybanktransfer->enabled)) { - $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer'); + $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") { $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->rights->paymentbybanktransfer->create); @@ -1514,7 +1514,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Management of checks if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) { - $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks'); + $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if (preg_match('/checks/', $leftmenu)) { $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&amp;action=new&amp;mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque); $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&amp;mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 5d3c5b0358d..3b9a0df399b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -99,7 +99,7 @@ if (empty($reshook)) { if ($action == 'setsupplieraccountancycode') { $result = $object->fetch($id); - $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); $result = $object->update($object->id, $user, 1, 0, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -250,7 +250,7 @@ if ($object->id > 0) { // TVA Intra print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>'; - print $object->tva_intra; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); print '</td></tr>'; // Default terms of the settlement diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 97f3758b991..8b54144cbff 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2686,7 +2686,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) //print ($s?$s.' ':''); $langs->load("languages"); $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); - print picto_from_langcode($object->default_lang, 'class="paddingrightonly"'); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; print '</td></tr>'; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index dc1fb6241bb..b2af9eaa460 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -502,7 +502,7 @@ hr { border: 0; border-top: 1px solid #ccc; } text-transform: uppercase; color: #444; } -.valuefield .button, .valuefieldcreate .button { +.valuefield .button, .valuefieldcreate .button, .refidno .button { margin-top: 0 !important; margin-bottom: 0 !important; font-size: 0.85em !important; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 04e4c035b4a..ad47245eec5 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -295,7 +295,7 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { <?php echo $prefix; ?>color: #b06080 !important; } .bg-infobox-propal, .bg-infobox-facture, .bg-infobox-commande { - <?php echo $prefix; ?>color: #55955d !important; + <?php echo $prefix; ?>color: #65953d !important; } .bg-infobox-supplier_proposal, .bg-infobox-invoice_supplier, .bg-infobox-order_supplier { <?php echo $prefix; ?>color: #599caf !important; @@ -325,11 +325,13 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { .infobox-action{ color: #b06080 !important; } +/* Color for customer object */ .infobox-propal:not(.pictotitle), .infobox-facture:not(.pictotitle), .infobox-commande:not(.pictotitle) { - color: #65955d !important; + color: #65953d !important; } +/* Color for vendor object */ .infobox-supplier_proposal:not(.pictotitle), .infobox-invoice_supplier:not(.pictotitle), .infobox-order_supplier:not(.pictotitle){ diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 14421e38db7..e9f6893ca98 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -40,7 +40,9 @@ div.mainmenu.billing::before { } div.mainmenu.accountancy::before { - content: "\f53d"; + /* content: "\f53d"; */ + content: "\f688"; + font-size: 1.2em; } div.mainmenu.agenda::before { From 3705409d564f1a686baf00a32ea8bf5632c8038f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 18:33:01 +0100 Subject: [PATCH 171/173] Code change to follow modulebuilder template --- htdocs/expedition/list.php | 1091 ++++++++++++++++++------------------ htdocs/reception/list.php | 744 ++++++++++++------------ 2 files changed, 929 insertions(+), 906 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index f325fc286a5..327e9a030e0 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -383,602 +383,611 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $arrayofselected = is_array($toselect) ? $toselect : array(); +$num = $db->num_rows($resql); - $expedition = new Expedition($db); +$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); - } - if ($sall) { - $param .= "&amp;sall=".urlencode($sall); - } - if ($search_ref_exp) { - $param .= "&amp;search_ref_exp=".urlencode($search_ref_exp); - } - if ($search_ref_liv) { - $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv); - } - if ($search_ref_customer) { - $param .= "&amp;search_ref_customer=".urlencode($search_ref_customer); - } - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_company) { - $param .= "&amp;search_company=".urlencode($search_company); - } - if ($search_tracking) { - $param .= "&amp;search_tracking=".urlencode($search_tracking); - } - if ($search_town) { - $param .= '&search_town='.urlencode($search_town); - } - if ($search_zip) { - $param .= '&search_zip='.urlencode($search_zip); - } - if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); - } +$expedition = new Expedition($db); - if ($search_datedelivery_start) { - $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); - } - if ($search_datedelivery_end) { - $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); - } - if ($search_datereceipt_start) { - $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start); - } - if ($search_datereceipt_end) { - $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end); - } +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall) { + $param .= "&amp;sall=".urlencode($sall); +} +if ($search_ref_exp) { + $param .= "&amp;search_ref_exp=".urlencode($search_ref_exp); +} +if ($search_ref_liv) { + $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv); +} +if ($search_ref_customer) { + $param .= "&amp;search_ref_customer=".urlencode($search_ref_customer); +} +if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); +} +if ($search_company) { + $param .= "&amp;search_company=".urlencode($search_company); +} +if ($search_tracking) { + $param .= "&amp;search_tracking=".urlencode($search_tracking); +} +if ($search_town) { + $param .= '&search_town='.urlencode($search_town); +} +if ($search_zip) { + $param .= '&search_zip='.urlencode($search_zip); +} +if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); +} - if ($search_product_category != '') { - $param .= '&search_product_category='.urlencode($search_product_category); - } - if ($search_categ_cus > 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +if ($search_datedelivery_start) { + $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); +} +if ($search_datedelivery_end) { + $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); +} +if ($search_datereceipt_start) { + $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start); +} +if ($search_datereceipt_end) { + $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end); +} - $arrayofmassactions = array( - 'builddoc' => $langs->trans("PDFMerge"), - //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged - 'presend' => $langs->trans("SendByMail"), - ); - if (in_array($massaction, array('presend'))) { - $arrayofmassactions = array(); +if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); +} +if ($search_categ_cus > 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); +} +if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +$arrayofmassactions = array( + 'builddoc' => $langs->trans("PDFMerge"), + //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged + 'presend' => $langs->trans("SendByMail"), +); +if (in_array($massaction, array('presend'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +// Currently: a sending can't create from sending list +// $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; +// if (!empty($socid)) $url .= '&socid='.$socid; +// $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); +$newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); + +$i = 0; +print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; +if ($optioncss != '') { + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +} +print '<input type="hidden" name="token" value="'.newToken().'">'; +print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; +print '<input type="hidden" name="action" value="list">'; +print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; +print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; + +print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); + +$topicmail = "SendShippingRef"; +$modelmail = "shipping_send"; +$objecttmp = new Expedition($db); +$trackid = 'shi'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; +} - // Currently: a sending can't create from sending list - // $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; - // if (!empty($socid)) $url .= '&socid='.$socid; - // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); - $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); +$moreforfilter = ''; - $i = 0; - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') { - print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; - } - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - print '<input type="hidden" name="action" value="list">'; - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; +// If the user can view prospects other than his' +if ($user->rights->societe->client->voir || $socid) { + $langs->load("commercial"); + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; +} +// If the user can view other users +if ($user->rights->user->user->lire) { + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; +} +// If the user can view prospects other than his' +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; +} +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '</div>'; +} +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} - print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); +if (!empty($moreforfilter)) { + print '<div class="liste_titre liste_titre_bydiv centpercent">'; + print $moreforfilter; + print '</div>'; +} - $topicmail = "SendShippingRef"; - $modelmail = "shipping_send"; - $objecttmp = new Expedition($db); - $trackid = 'shi'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields +} - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; - } +print '<div class="div-table-responsive">'; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; - $moreforfilter = ''; +// Fields title search +print '<tr class="liste_titre_filter">'; +// Ref +if (!empty($arrayfields['e.ref']['checked'])) { + print '<td class="liste_titre">'; + print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">'; + print '</td>'; +} +// Ref customer +if (!empty($arrayfields['e.ref_customer']['checked'])) { + print '<td class="liste_titre">'; + print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">'; + print '</td>'; +} +// Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) { + print '<td class="liste_titre left">'; + print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; + print '</td>'; +} +// Town +if (!empty($arrayfields['s.town']['checked'])) { + print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; +} +// Zip +if (!empty($arrayfields['s.zip']['checked'])) { + print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; +} +// State +if (!empty($arrayfields['state.nom']['checked'])) { + print '<td class="liste_titre">'; + print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; + print '</td>'; +} +// Country +if (!empty($arrayfields['country.code_iso']['checked'])) { + print '<td class="liste_titre center">'; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print '</td>'; +} +// Company type +if (!empty($arrayfields['typent.code']['checked'])) { + print '<td class="liste_titre maxwidthonsmartphone center">'; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print '</td>'; +} +// Weight +if (!empty($arrayfields['e.weight']['checked'])) { + print '<td class="liste_titre maxwidthonsmartphone center">'; - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { - $langs->load("commercial"); - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter .= '</div>'; - } - // If the user can view other users - if ($user->rights->user->user->lire) { - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter .= '</div>'; - } - // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter .= '</div>'; - } - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '<div class="divsearchfield">'; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter .= '</div>'; - } - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } + print '</td>'; +} +// Date delivery planned +if (!empty($arrayfields['e.date_delivery']['checked'])) { + print '<td class="liste_titre center">'; + print '<div class="nowrap">'; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '</div>'; + print '<div class="nowrap">'; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '</div>'; + print '</td>'; +} +// Tracking number +if (!empty($arrayfields['e.tracking_number']['checked'])) { + print '<td class="liste_titre center">'; + print '<input class="flat" size="6" type="text" name="search_tracking" value="'.dol_escape_htmltag($search_tracking).'">'; + print '</td>'; +} +if (!empty($arrayfields['l.ref']['checked'])) { + // Delivery ref + print '<td class="liste_titre">'; + print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.dol_escape_htmltag($search_ref_liv).'"'; + print '</td>'; +} +if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print '<td class="liste_titre center">'; + print '<div class="nowrap">'; + print $form->selectDate($search_datereceipt_start ? $search_datereceipt_start : -1, 'search_datereceipt_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '</div>'; + print '<div class="nowrap">'; + print $form->selectDate($search_datereceipt_end ? $search_datereceipt_end : -1, 'search_datereceipt_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '</div>'; + print '</td>'; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - if (!empty($moreforfilter)) { - print '<div class="liste_titre liste_titre_bydiv centpercent">'; - print $moreforfilter; - print '</div>'; - } +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (!empty($arrayfields['e.datec']['checked'])) { + print '<td class="liste_titre">'; + print '</td>'; +} +// Date modification +if (!empty($arrayfields['e.tms']['checked'])) { + print '<td class="liste_titre">'; + print '</td>'; +} +// Status +if (!empty($arrayfields['e.fk_statut']['checked'])) { + print '<td class="liste_titre maxwidthonsmartphone right">'; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1); + print '</td>'; +} +// Status billed +if (!empty($arrayfields['e.billed']['checked'])) { + print '<td class="liste_titre maxwidthonsmartphone center">'; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); + print '</td>'; +} +// Action column +print '<td class="liste_titre middle">'; +$searchpicto = $form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '</td>'; +print "</tr>\n"; - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); - if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields - } +print '<tr class="liste_titre">'; +if (!empty($arrayfields['e.ref']['checked'])) { + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['e.ref_customer']['checked'])) { + print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); +} +if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.weight']['checked'])) { + print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.tracking_number']['checked'])) { + print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['l.ref']['checked'])) { + print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['l.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (!empty($arrayfields['e.datec']['checked'])) { + print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['e.tms']['checked'])) { + print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['e.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['e.billed']['checked'])) { + print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); +} +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "</tr>\n"; - print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; +$typenArray = $formcompany->typent_array(1); +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $obj = $db->fetch_object($resql); + + $shipment->id = $obj->rowid; + $shipment->ref = $obj->ref; + + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; + + $object = new Expedition($db); + $object->fetch($obj->rowid); + + print '<tr class="oddeven">'; - // Fields title search - print '<tr class="liste_titre_filter">'; // Ref if (!empty($arrayfields['e.ref']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">'; - print '</td>'; + print "<td>"; + print $shipment->getNomUrl(1); + print "</td>\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Ref customer if (!empty($arrayfields['e.ref_customer']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">'; - print '</td>'; + print "<td>"; + print $obj->ref_customer; + print "</td>\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - // Thirdparty + + // Third party if (!empty($arrayfields['s.nom']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; + print '<td>'; + print $companystatic->getNomUrl(1); print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } // Town if (!empty($arrayfields['s.town']['checked'])) { - print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; + print '<td class="nocellnopadd">'; + print $obj->town; + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; + print '<td class="nocellnopadd">'; + print $obj->zip; + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } // State if (!empty($arrayfields['state.nom']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; - print '</td>'; + print "<td>".$obj->state_name."</td>\n"; + if (!$i) { + $totalarray['nbfield']++; + } } // Country if (!empty($arrayfields['country.code_iso']['checked'])) { - print '<td class="liste_titre center">'; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print '<td class="center">'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } - // Company type + // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); - print '</td>'; - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone center">'; - - print '</td>'; - } - // Date delivery planned - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print '<td class="liste_titre center">'; - print '<div class="nowrap">'; - print $langs->trans('From').' '; - print $form->selectDate($search_delivery_start ? $search_delivery_start : -1, 'search_delivery_start', 0, 0, 1); - print '</div>'; - print '<div class="nowrap">'; - print $langs->trans('to').' '; - print $form->selectDate($search_delivery_end ? $search_delivery_end : -1, 'search_delivery_end', 0, 0, 1); - print '</div>'; - print '</td>'; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print '<td class="liste_titre center">'; - print '<input class="flat" size="6" type="text" name="search_tracking" value="'.dol_escape_htmltag($search_tracking).'">'; - print '</td>'; - } - if (!empty($arrayfields['l.ref']['checked'])) { - // Delivery ref - print '<td class="liste_titre">'; - print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"'; - print '</td>'; - } - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print '<td class="liste_titre center">'; - print '<div class="nowrap">'; - print $langs->trans('From').' '; - print $form->selectDate($search_receipt_start ? $search_receipt_start : -1, 'search_receipt_start', 0, 0, 1); - print '</div>'; - print '<div class="nowrap">'; - print $langs->trans('to').' '; - print $form->selectDate($search_receipt_end ? $search_receipt_end : -1, 'search_receipt_end', 0, 0, 1); - print '</div>'; - print '</td>'; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print '<td class="liste_titre">'; - print '</td>'; - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print '<td class="liste_titre">'; - print '</td>'; - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone right">'; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1); - print '</td>'; - } - // Status billed - if (!empty($arrayfields['e.billed']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); - print '</td>'; - } - // Action column - print '<td class="liste_titre middle">'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '</td>'; - print "</tr>\n"; - - print '<tr class="liste_titre">'; - if (!empty($arrayfields['e.ref']['checked'])) { - print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - } - if (!empty($arrayfields['s.town']['checked'])) { - print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['s.zip']['checked'])) { - print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.weight']['checked'])) { - print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['l.ref']['checked'])) { - print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['l.date_delivery']['checked'])) { - print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['e.datec']['checked'])) { - print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - if (!empty($arrayfields['e.tms']['checked'])) { - print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - } - if (!empty($arrayfields['e.billed']['checked'])) { - print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); - } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - print "</tr>\n"; - - $typenArray = $formcompany->typent_array(1); - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - - $shipment->id = $obj->rowid; - $shipment->ref = $obj->ref; - - $companystatic->id = $obj->socid; - $companystatic->ref = $obj->name; - $companystatic->name = $obj->name; - - $object = new Expedition($db); - $object->fetch($obj->rowid); - - print '<tr class="oddeven">'; - - // Ref - if (!empty($arrayfields['e.ref']['checked'])) { - print "<td>"; - print $shipment->getNomUrl(1); - print "</td>\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print "<td>"; - print $obj->ref_customer; - print "</td>\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print '<td>'; - print $companystatic->getNomUrl(1); - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print '<td class="nocellnopadd">'; - print $obj->town; - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print '<td class="nocellnopadd">'; - print $obj->zip; - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "<td>".$obj->state_name."</td>\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print '<td class="center">'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print '<td class="center">'; - if (isset($typenArray[$obj->typent_code])) { - print $typenArray[$obj->typent_code]; - } - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print '<td class="center">'; - if (empty($object->trueWeight)) { - $tmparray = $object->getTotalWeightVolume(); - print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery planed - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print '<td class="center">'; - print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); - /*$now = time(); - if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 ) - { - }*/ - print "</td>\n"; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print '<td class="center">'.$obj->tracking_number."</td>\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { - $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving = ''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { - $receiving = reset($shipment->linkedObjects['delivery']); - } - - if (!empty($arrayfields['l.ref']['checked'])) { - // Ref - print '<td>'; - print !empty($receiving) ? $receiving->getNomUrl($db) : ''; - print '</td>'; - } - - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print '<td class="center">'; - print dol_print_date($db->jdate($obj->date_reception), "day"); - print '</td>'."\n"; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print '<td class="center nowrap">'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print '<td class="center nowrap">'; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print '</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['e.billed']['checked'])) { - print '<td class="center">'.yn($obj->billed).'</td>'; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - print '<td class="nowrap" align="center">'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; + print '<td class="center">'; + if (isset($typenArray[$obj->typent_code])) { + print $typenArray[$obj->typent_code]; } print '</td>'; if (!$i) { $totalarray['nbfield']++; } - - print "</tr>\n"; - - $i++; } - $db->free($resql); + // Weight + if (!empty($arrayfields['e.weight']['checked'])) { + print '<td class="center">'; + if (empty($object->trueWeight)) { + $tmparray = $object->getTotalWeightVolume(); + print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery planed + if (!empty($arrayfields['e.date_delivery']['checked'])) { + print '<td class="center">'; + print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); + /*$now = time(); + if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 ) + { + }*/ + print "</td>\n"; + } + // Tracking number + if (!empty($arrayfields['e.tracking_number']['checked'])) { + print '<td class="center">'.$obj->tracking_number."</td>\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } - $parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { + $shipment->fetchObjectLinked($shipment->id, $shipment->element); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { + $receiving = reset($shipment->linkedObjects['delivery']); + } + + if (!empty($arrayfields['l.ref']['checked'])) { + // Ref + print '<td>'; + print !empty($receiving) ? $receiving->getNomUrl($db) : ''; + print '</td>'; + } + + if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print '<td class="center">'; + print dol_print_date($db->jdate($obj->date_reception), "day"); + print '</td>'."\n"; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - - print "</table>"; - print "</div>"; - print '</form>'; - - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; + // Date creation + if (!empty($arrayfields['e.datec']['checked'])) { + print '<td class="center nowrap">'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['e.tms']['checked'])) { + print '<td class="center nowrap">'; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['e.fk_statut']['checked'])) { + print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>'; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['e.billed']['checked'])) { + print '<td class="center">'.yn($obj->billed).'</td>'; + if (!$i) { + $totalarray['nbfield']++; + } } - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&amp;', '&', $param); + // Action column + print '<td class="nowrap" align="center">'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; + } + print '</td>'; + if (!$i) { + $totalarray['nbfield']++; + } - $filedir = $diroutputmassaction; - $genallowed = $user->rights->expedition->lire; - $delallowed = $user->rights->expedition->creer; - $title = ''; + print "</tr>\n"; - print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} else { - dol_print_error($db); + $i++; } +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; +} + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print "</table>"; +print "</div>"; +print '</form>'; + +$hidegeneratedfilelistifempty = 1; +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; +} + +// Show list of available documents +$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; +$urlsource .= str_replace('&amp;', '&', $param); + +$filedir = $diroutputmassaction; +$genallowed = $user->rights->expedition->lire; +$delallowed = $user->rights->expedition->creer; +$title = ''; + +print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index cb9bc100f79..7e108636962 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -117,6 +117,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$error = 0; + /* * Actions @@ -485,444 +487,456 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +$reception = new Reception($db); + +$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); +if ($sall) $param .= "&amp;sall=".urlencode($sall); +if ($search_ref_rcp) $param .= "&amp;search_ref_rcp=".urlencode($search_ref_rcp); +if ($search_ref_liv) $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv); +if ($search_company) $param .= "&amp;search_company=".urlencode($search_company); +if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss); +if ($search_billed != '' && $search_billed >= 0) $param .= "&amp;search_billed=".urlencode($search_billed); +if ($search_town) $param .= "&amp;search_town=".urlencode($search_town); +if ($search_zip) $param .= "&amp;search_zip=".urlencode($search_zip); +if ($search_state) $param .= "&amp;search_state=".urlencode($search_state); +if ($search_status != '') $param .= "&amp;search_status=".urlencode($search_status); +if ($search_country) $param .= "&amp;search_country=".urlencode($search_country); +if ($search_type_thirdparty) $param .= "&amp;search_type_thirdparty=".urlencode($search_type_thirdparty); +if ($search_ref_supplier) $param .= "&amp;search_ref_supplier=".urlencode($search_ref_supplier); +// Add $param from extra fields +foreach ($search_array_options as $key => $val) { - $num = $db->num_rows($resql); - - $reception = new Reception($db); - - $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); - if ($sall) $param .= "&amp;sall=".urlencode($sall); - if ($search_ref_rcp) $param .= "&amp;search_ref_rcp=".urlencode($search_ref_rcp); - if ($search_ref_liv) $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv); - if ($search_company) $param .= "&amp;search_company=".urlencode($search_company); - if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss); - if ($search_billed != '' && $search_billed >= 0) $param .= "&amp;search_billed=".urlencode($search_billed); - if ($search_town) $param .= "&amp;search_town=".urlencode($search_town); - if ($search_zip) $param .= "&amp;search_zip=".urlencode($search_zip); - if ($search_state) $param .= "&amp;search_state=".urlencode($search_state); - if ($search_status != '') $param .= "&amp;search_status=".urlencode($search_status); - if ($search_country) $param .= "&amp;search_country=".urlencode($search_country); - if ($search_type_thirdparty) $param .= "&amp;search_type_thirdparty=".urlencode($search_type_thirdparty); - if ($search_ref_supplier) $param .= "&amp;search_ref_supplier=".urlencode($search_ref_supplier); - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit = $val; - $tmpkey = preg_replace('/search_options_/', '', $key); - if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); - } + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); +} - $arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), - ); +); - if ($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); - if ($massaction == 'createbills') $arrayofmassactions = array(); - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); +if ($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); +if ($massaction == 'createbills') $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); +//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $i = 0; - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - print '<input type="hidden" name="action" value="list">'; - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; +$i = 0; +print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; +if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; +print '<input type="hidden" name="token" value="'.newToken().'">'; +print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; +print '<input type="hidden" name="action" value="list">'; +print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; +print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; - print_barre_liste($langs->trans('ListOfReceptions'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, '', '', $limit, 0, 0, 1); +print_barre_liste($langs->trans('ListOfReceptions'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, '', '', $limit, 0, 0, 1); - if ($massaction == 'createbills') +if ($massaction == 'createbills') +{ + //var_dump($_REQUEST); + print '<input type="hidden" name="massaction" value="confirm_createbills">'; + + print '<table class="noborder" width="100%" >'; + print '<tr>'; + print '<td class="titlefieldmiddle">'; + print $langs->trans('DateInvoice'); + print '</td>'; + print '<td>'; + print $form->selectDate('', '', '', '', '', '', 1, 1); + print '</td>'; + print '</tr>'; + print '<tr>'; + print '<td>'; + print $langs->trans('CreateOneBillByThird'); + print '</td>'; + print '<td>'; + print $form->selectyesno('createbills_onebythird', '', 1); + print '</td>'; + print '</tr>'; + print '<tr>'; + print '<td>'; + print $langs->trans('ValidateInvoices'); + print '</td>'; + print '<td>'; + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { - //var_dump($_REQUEST); - print '<input type="hidden" name="massaction" value="confirm_createbills">'; - - print '<table class="noborder" width="100%" >'; - print '<tr>'; - print '<td class="titlefieldmiddle">'; - print $langs->trans('DateInvoice'); - print '</td>'; - print '<td>'; - print $form->selectDate('', '', '', '', '', '', 1, 1); - print '</td>'; - print '</tr>'; - print '<tr>'; - print '<td>'; - print $langs->trans('CreateOneBillByThird'); - print '</td>'; - print '<td>'; - print $form->selectyesno('createbills_onebythird', '', 1); - print '</td>'; - print '</tr>'; - print '<tr>'; - print '<td>'; - print $langs->trans('ValidateInvoices'); - print '</td>'; - print '<td>'; - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { - print $form->selectyesno('validate_invoices', 0, 1, 1); - print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; - } else { - print $form->selectyesno('validate_invoices', 0, 1); - } - print '</td>'; - print '</tr>'; - print '</table>'; - - print '<br>'; - print '<div class="center">'; - print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisSupplier').'"> '; - print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</div>'; - print '<br>'; + print $form->selectyesno('validate_invoices', 0, 1, 1); + print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + } else { + print $form->selectyesno('validate_invoices', 0, 1); } + print '</td>'; + print '</tr>'; + print '</table>'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall); - } + print '<br>'; + print '<div class="center">'; + print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisSupplier').'"> '; + print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '</div>'; + print '<br>'; +} - $moreforfilter = ''; - if (!empty($moreforfilter)) - { - print '<div class="liste_titre liste_titre_bydiv centpercent">'; - print $moreforfilter; - $parameters = array('type'=>$type); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '</div>'; - } +if ($sall) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall); +} - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +$moreforfilter = ''; +if (!empty($moreforfilter)) +{ + print '<div class="liste_titre liste_titre_bydiv centpercent">'; + print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '</div>'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; +print '<div class="div-table-responsive">'; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print '<tr class="liste_titre_filter">'; +// Ref +if (!empty($arrayfields['e.ref']['checked'])) +{ + print '<td class="liste_titre">'; + print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">'; + print '</td>'; +} +// Ref customer +if (!empty($arrayfields['e.ref_supplier']['checked'])) +{ + print '<td class="liste_titre">'; + print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">'; + print '</td>'; +} +// Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; + print '</td>'; +} +// Town +if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; +// Zip +if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; +// State +if (!empty($arrayfields['state.nom']['checked'])) +{ + print '<td class="liste_titre">'; + print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; + print '</td>'; +} +// Country +if (!empty($arrayfields['country.code_iso']['checked'])) +{ + print '<td class="liste_titre center">'; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print '</td>'; +} +// Company type +if (!empty($arrayfields['typent.code']['checked'])) +{ + print '<td class="liste_titre maxwidthonsmartphone center">'; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print '</td>'; +} +// Date delivery planned +if (!empty($arrayfields['e.date_delivery']['checked'])) +{ + print '<td class="liste_titre">&nbsp;</td>'; +} +if (!empty($arrayfields['l.ref']['checked'])) +{ + // Delivery ref + print '<td class="liste_titre">'; + print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"'; + print '</td>'; +} +if (!empty($arrayfields['l.date_delivery']['checked'])) +{ + // Date received + print '<td class="liste_titre">&nbsp;</td>'; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (!empty($arrayfields['e.datec']['checked'])) +{ + print '<td class="liste_titre">'; + print '</td>'; +} +// Date modification +if (!empty($arrayfields['e.tms']['checked'])) +{ + print '<td class="liste_titre">'; + print '</td>'; +} +// Status +if (!empty($arrayfields['e.fk_statut']['checked'])) +{ + print '<td class="liste_titre maxwidthonsmartphone right">'; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1); + print '</td>'; +} +// Status billed +if (!empty($arrayfields['e.billed']['checked'])) +{ + print '<td class="liste_titre maxwidthonsmartphone center">'; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); + print '</td>'; +} +// Action column +print '<td class="liste_titre middle">'; +$searchpicto = $form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '</td>'; +print "</tr>\n"; + +print '<tr class="liste_titre">'; +if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); +if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "</tr>\n"; + +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + + $reception->id = $obj->rowid; + $reception->ref = $obj->ref; + + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; + + + print '<tr class="oddeven">'; - // Fields title search - // -------------------------------------------------------------------- - print '<tr class="liste_titre_filter">'; // Ref if (!empty($arrayfields['e.ref']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">'; - print '</td>'; + print "<td>"; + print $reception->getNomUrl(1); + $filename = dol_sanitizeFileName($reception->ref); + $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id; + print $formfile->getDocumentsLink($reception->element, $filename, $filedir); + print "</td>\n"; + + if (!$i) $totalarray['nbfield']++; } + // Ref customer if (!empty($arrayfields['e.ref_supplier']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">'; - print '</td>'; + print "<td>"; + print $obj->ref_supplier; + print "</td>\n"; + if (!$i) $totalarray['nbfield']++; } - // Thirdparty + + // Third party if (!empty($arrayfields['s.nom']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; + print '<td>'; + print $companystatic->getNomUrl(1); print '</td>'; + if (!$i) $totalarray['nbfield']++; } // Town - if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) + { + print '<td class="nocellnopadd">'; + print $obj->town; + print '</td>'; + if (!$i) $totalarray['nbfield']++; + } // Zip - if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) + { + print '<td class="nocellnopadd">'; + print $obj->zip; + print '</td>'; + if (!$i) $totalarray['nbfield']++; + } // State if (!empty($arrayfields['state.nom']['checked'])) { - print '<td class="liste_titre">'; - print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; - print '</td>'; + print "<td>".$obj->state_name."</td>\n"; + if (!$i) $totalarray['nbfield']++; } // Country if (!empty($arrayfields['country.code_iso']['checked'])) { - print '<td class="liste_titre center">'; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print '<td class="center">'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; print '</td>'; + if (!$i) $totalarray['nbfield']++; } - // Company type + // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print '<td class="center">'; + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; print '</td>'; + if (!$i) $totalarray['nbfield']++; } - // Date delivery planned + + // Date delivery planed if (!empty($arrayfields['e.date_delivery']['checked'])) { - print '<td class="liste_titre">&nbsp;</td>'; + print '<td class="center">'; + print dol_print_date($db->jdate($obj->delivery_date), "day"); + /*$now = time(); + if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 ) + { + }*/ + print "</td>\n"; } - if (!empty($arrayfields['l.ref']['checked'])) + + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { - // Delivery ref - print '<td class="liste_titre">'; - print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"'; - print '</td>'; - } - if (!empty($arrayfields['l.date_delivery']['checked'])) - { - // Date received - print '<td class="liste_titre">&nbsp;</td>'; + $reception->fetchObjectLinked($reception->id, $reception->element); + $receiving = ''; + if (count($reception->linkedObjects['delivery']) > 0) $receiving = reset($reception->linkedObjects['delivery']); + + if (!empty($arrayfields['l.ref']['checked'])) + { + // Ref + print '<td>'; + print !empty($receiving) ? $receiving->getNomUrl($db) : ''; + print '</td>'; + } + + if (!empty($arrayfields['l.date_delivery']['checked'])) + { + // Date received + print '<td class="center">'; + print dol_print_date($db->jdate($obj->date_reception), "day"); + print '</td>'."\n"; + } } + // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['e.datec']['checked'])) { - print '<td class="liste_titre">'; + print '<td class="center nowrap">'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print '</td>'; + if (!$i) $totalarray['nbfield']++; } // Date modification if (!empty($arrayfields['e.tms']['checked'])) { - print '<td class="liste_titre">'; + print '<td class="center nowrap">'; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print '</td>'; + if (!$i) $totalarray['nbfield']++; } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone right">'; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1); - print '</td>'; + print '<td class="right nowrap">'.$reception->LibStatut($obj->fk_statut, 5).'</td>'; + if (!$i) $totalarray['nbfield']++; } - // Status billed + // Billed if (!empty($arrayfields['e.billed']['checked'])) { - print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); - print '</td>'; - } - // Action column - print '<td class="liste_titre middle">'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '</td>'; - print "</tr>\n"; - - print '<tr class="liste_titre">'; - if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - print "</tr>\n"; - - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); - - $reception->id = $obj->rowid; - $reception->ref = $obj->ref; - - $companystatic->id = $obj->socid; - $companystatic->ref = $obj->name; - $companystatic->name = $obj->name; - - - print '<tr class="oddeven">'; - - // Ref - if (!empty($arrayfields['e.ref']['checked'])) - { - print "<td>"; - print $reception->getNomUrl(1); - $filename = dol_sanitizeFileName($reception->ref); - $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id; - print $formfile->getDocumentsLink($reception->element, $filename, $filedir); - print "</td>\n"; - - if (!$i) $totalarray['nbfield']++; - } - - // Ref customer - if (!empty($arrayfields['e.ref_supplier']['checked'])) - { - print "<td>"; - print $obj->ref_supplier; - print "</td>\n"; - if (!$i) $totalarray['nbfield']++; - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) - { - print '<td>'; - print $companystatic->getNomUrl(1); - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Town - if (!empty($arrayfields['s.town']['checked'])) - { - print '<td class="nocellnopadd">'; - print $obj->town; - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) - { - print '<td class="nocellnopadd">'; - print $obj->zip; - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // State - if (!empty($arrayfields['state.nom']['checked'])) - { - print "<td>".$obj->state_name."</td>\n"; - if (!$i) $totalarray['nbfield']++; - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) - { - print '<td class="center">'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) - { - print '<td class="center">'; - if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); - print $typenArray[$obj->typent_code]; - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - - // Date delivery planed - if (!empty($arrayfields['e.date_delivery']['checked'])) - { - print '<td class="center">'; - print dol_print_date($db->jdate($obj->delivery_date), "day"); - /*$now = time(); - if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 ) - { - }*/ - print "</td>\n"; - } - - if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) - { - $reception->fetchObjectLinked($reception->id, $reception->element); - $receiving = ''; - if (count($reception->linkedObjects['delivery']) > 0) $receiving = reset($reception->linkedObjects['delivery']); - - if (!empty($arrayfields['l.ref']['checked'])) - { - // Ref - print '<td>'; - print !empty($receiving) ? $receiving->getNomUrl($db) : ''; - print '</td>'; - } - - if (!empty($arrayfields['l.date_delivery']['checked'])) - { - // Date received - print '<td class="center">'; - print dol_print_date($db->jdate($obj->date_reception), "day"); - print '</td>'."\n"; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) - { - print '<td class="center nowrap">'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) - { - print '<td class="center nowrap">'; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print '</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) - { - print '<td class="right nowrap">'.$reception->LibStatut($obj->fk_statut, 5).'</td>'; - if (!$i) $totalarray['nbfield']++; - } - // Billed - if (!empty($arrayfields['e.billed']['checked'])) - { - print '<td class="center">'.yn($obj->billed).'</td>'; - if (!$i) $totalarray['nbfield']++; - } - - // Action column - print '<td class="center">'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; - } - print '</td>'; + print '<td class="center">'.yn($obj->billed).'</td>'; if (!$i) $totalarray['nbfield']++; - - print "</tr>\n"; - - $i++; } - print "</table>"; - print "</div>"; - print '</form>'; - $db->free($resql); -} else { - dol_print_error($db); + // Action column + print '<td class="center">'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; + } + print '</td>'; + if (!$i) $totalarray['nbfield']++; + + print "</tr>\n"; + + $i++; } +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; +} + +print "</table>"; +print "</div>"; +print '</form>'; + +$db->free($resql); + llxFooter(); $db->close(); From 7dace2f4594dde0787bb84416681124b5cc9b8a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 18:38:32 +0100 Subject: [PATCH 172/173] Show 3 years in graph of widget by default. --- htdocs/core/boxes/box_graph_invoices_permonth.php | 2 +- htdocs/core/boxes/box_graph_invoices_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_orders_permonth.php | 2 +- htdocs/core/boxes/box_graph_orders_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_propales_permonth.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 843c64bbd44..ab39a14e2cd 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -128,7 +128,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (empty($endyear)) { $endyear = $nowarray['year']; } - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1)); $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 124e6e8dd24..75b58a28de1 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -128,7 +128,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if (empty($endyear)) { $endyear = $nowarray['year']; } - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1)); $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 82e3452c151..3fafa464993 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -128,7 +128,7 @@ class box_graph_orders_permonth extends ModeleBoxes if (empty($endyear)) { $endyear = $nowarray['year']; } - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1)); $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index a4a764e6d57..419e3afba83 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -127,7 +127,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if (empty($endyear)) { $endyear = $nowarray['year']; } - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1)); $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 116beb0e30f..8193e81d060 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -128,7 +128,7 @@ class box_graph_propales_permonth extends ModeleBoxes if (empty($endyear)) { $endyear = $nowarray['year']; } - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1)); $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; From 747acd6764a69a3620ccd34adc843e8857cdd5af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 27 Feb 2021 18:53:27 +0100 Subject: [PATCH 173/173] Trans --- htdocs/langs/en_US/mrp.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 5ca0dbc6981..fceeb1a15f1 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -89,7 +89,7 @@ ConfirmEnableWorkstation=Are you sure you want to enable workstation <b>%s</b> ? EnableAWorkstation=Enable a workstation ConfirmDisableWorkstation=Are you sure you want to disable workstation <b>%s</b> ? DisableAWorkstation=Disable a workstation -DeleteWorkstation=Supprimer +DeleteWorkstation=Delete NbOperatorsRequired=Number of operators required THMOperatorEstimated=Estimated operator THM THMMachineEstimated=Estimated machine THM