--- /tmp/dsg/dolibarr/htdocs/fourn/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/fourn/client_card.php @@ -10 +9,0 @@ - * Copyright (C) 2021 Frédéric France @@ -32 +30,0 @@ -// Load Dolibarr environment @@ -40,9 +38,2 @@ -if (isModEnabled('adherent')) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -} -if (isModEnabled('categorie')) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -} -if (!empty($conf->accounting->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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'; @@ -61 +52 @@ -$cancel = GETPOST('cancel', 'alpha'); +$cancelbutton = GETPOST('cancel', 'alpha'); @@ -65,3 +56 @@ -if ($user->socid) { - $id = $user->socid; -} +if ($user->socid) $id = $user->socid; @@ -77,10 +66 @@ -$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); - -// Security check -$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); - -if ($object->id > 0) { - if (!($object->fournisseur > 0) || !$user->hasRight("fournisseur", "lire")) { - accessforbidden(); - } -} +$hookmanager->initHooks(array('suppliercard', 'globalcard')); @@ -95,6 +75,6 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - if ($cancel) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancelbutton) + { @@ -104,2 +84,2 @@ - // Set supplier accounting account - if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) { + if ($action == 'setsupplieraccountancycode') + { @@ -107,18 +87,7 @@ - $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); - $result = $object->update($object->id, $user, 1, 0, 1); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'editsupplieraccountancycode'; - } - } - // Set vat number accounting account - if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) { - $result = $object->fetch($id); - $object->tva_intra = GETPOST("tva_intra"); - $result = $object->update($object->id, $user, 1, 0, 0); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - // Set payment terms of the settlement - if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { + $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $result = $object->update($object->id, $user, 1, 0, 1); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + // terms of the settlement + if ($action == 'setconditions' && $user->rights->societe->creer) + { @@ -127,6 +96,5 @@ - if ($result < 0) { - dol_print_error($db, $object->error); - } - } - // Payment mode - if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { + if ($result < 0) dol_print_error($db, $object->error); + } + // mode de reglement + if ($action == 'setmode' && $user->rights->societe->creer) + { @@ -135,12 +103 @@ - if ($result < 0) { - dol_print_error($db, $object->error); - } - } - - // Bank account - if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { - $object->fetch($id); - $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) dol_print_error($db, $object->error); @@ -150 +107,2 @@ - if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) { + if ($action == 'setsupplier_order_min_amount') + { @@ -154,29 +112,21 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) { - $object->fetch($id); - - $object->oldcopy = dol_clone($object, 2); - - // 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) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - - if ($error) { - $action = 'edit_extras'; - } - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + + if ($action == 'update_extras') { + $object->fetch($id); + + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + + if ($ret < 0) $error++; + + if (!$error) + { + $result = $object->insertExtraFields('COMPANY_MODIFY'); + if ($result < 0) $error++; + } + + if ($error) $action = 'edit_extras'; + } @@ -193 +143,2 @@ -if ($id > 0 && empty($object->id)) { +if ($id > 0 && empty($object->id)) +{ @@ -196,4 +147 @@ - if ($object->id <= 0) { - dol_print_error($db, $object->error); - exit(-1); - } + if ($object->id <= 0) dol_print_error($db, $object->error); @@ -202 +150,2 @@ -if ($object->id > 0) { +if ($object->id > 0) +{ @@ -204,3 +153 @@ - if (getDolGlobalString('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'); @@ -215 +162 @@ - print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); @@ -223,13 +170,10 @@ - print '
'; - print ''; - - // Type Prospect/Customer/Supplier - print ''; - - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; - } - - if ($object->fournisseur) { + print '
'; + print '
'.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + if ($object->fournisseur) + { @@ -237,8 +181,5 @@ - print ''; - print ''; + print ''; + print ''; @@ -247,7 +188,7 @@ - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; @@ -266 +207,2 @@ - if ($mysoc->useLocalTax(1)) { + if ($mysoc->useLocalTax(1)) + { @@ -271 +213,2 @@ - if ($mysoc->useLocalTax(2)) { + if ($mysoc->useLocalTax(2)) + { @@ -277,17 +220,4 @@ - // VAT reverse-charge by default on supplier invoice or not - print ''; - print ''; - print ''; - - // TVA Intra - print ''; + // TVA Intra + print ''; @@ -302,3 +232 @@ - if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) { - print ''; - } + if (($action != 'editconditions') && $user->rights->societe->creer) print ''; @@ -307,3 +235,6 @@ - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', 1); - } else { + 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 + { @@ -315 +246 @@ - // Default payment mode + // Mode de reglement par defaut @@ -320,3 +251 @@ - if (($action != 'editmode') && $user->hasRight('societe', 'creer')) { - print ''; - } + if (($action != 'editmode') && $user->rights->societe->creer) print ''; @@ -325 +254,2 @@ - if ($action == 'editmode') { + if ($action == 'editmode') + { @@ -327 +257,3 @@ - } else { + } + else + { @@ -332,20 +263,0 @@ - - if (isModEnabled("banque")) { - // Default bank account for payments - print '"; - print ''; - } @@ -358,2 +270,3 @@ - if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + if ($user->rights->societe->creer && !$user->socid > 0) + { + print ''.img_edit($langs->trans("Modify")).''; @@ -371,2 +284,3 @@ - if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + if ($user->rights->societe->creer && !$user->socid > 0) + { + print ''.img_edit($langs->trans("Modify")).''; @@ -378,6 +292,2 @@ - 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).''; @@ -388 +298,2 @@ - if (isModEnabled("supplier_order") && getDolGlobalString('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)) + { @@ -391 +302 @@ - print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer")); + print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer); @@ -393,2 +304,2 @@ - $limit_field_type = (getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) ? 'numeric' : 'amount'; - print $form->editfieldval("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer"), $limit_field_type, ($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); + $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; + print $form->editfieldval("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); @@ -400,6 +311,7 @@ - if (isModEnabled('categorie')) { - $langs->load("categories"); - print ''; - print '"; + if (!empty($conf->categorie->enabled)) + { + $langs->load("categories"); + print ''; + print '"; @@ -413,16 +325,20 @@ - if (isModEnabled('adherent')) { - $langs->load("members"); - $langs->load("users"); - print ''; - print ''; - print "\n"; - } + if (!empty($conf->adherent->enabled)) + { + $langs->load("members"); + $langs->load("users"); + print ''; + print ''; + print "\n"; + } @@ -433 +349 @@ - print '
'; + print '
'; @@ -440,2 +356 @@ - print '
'; - print '
'; + print '
'; @@ -444 +359 @@ - $boxstat .= '
'; + $boxstat .= '
'; @@ -448,102 +363,63 @@ - if (isModEnabled('supplier_proposal')) { - // Box proposals - $tmp = $object->getOutstandingProposals('supplier'); - $outstandingOpened = $tmp['opened']; - $outstandingTotal = $tmp['total_ht']; - $outstandingTotalIncTax = $tmp['total_ttc']; - $text = $langs->trans("OverAllSupplierProposals"); - $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id; - $icon = 'bill'; - if ($link) { - $boxstat .= ''; - } - $boxstat .= '
'; - $boxstat .= ''.img_object("", $icon).' '.$text.'
'; - $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat .= '
'; - if ($link) { - $boxstat .= '
'; - } - } - - if (isModEnabled("supplier_order")) { - // Box proposals - $tmp = $object->getOutstandingOrders('supplier'); - $outstandingOpened = $tmp['opened']; - $outstandingTotal = $tmp['total_ht']; - $outstandingTotalIncTax = $tmp['total_ttc']; - $text = $langs->trans("OverAllOrders"); - $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id; - $icon = 'bill'; - if ($link) { - $boxstat .= ''; - } - $boxstat .= '
'; - $boxstat .= ''.img_object("", $icon).' '.$text.'
'; - $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat .= '
'; - if ($link) { - $boxstat .= '
'; - } - } - - if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { - $warn = ''; - $tmp = $object->getOutstandingBills('supplier'); - $outstandingOpened = $tmp['opened']; - $outstandingTotal = $tmp['total_ht']; - $outstandingTotalIncTax = $tmp['total_ttc']; - - $text = $langs->trans("OverAllInvoices"); - $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id; - $icon = 'bill'; - if ($link) { - $boxstat .= ''; - } - $boxstat .= '
'; - $boxstat .= ''.img_object("", $icon).' '.$text.'
'; - $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat .= '
'; - if ($link) { - $boxstat .= '
'; - } - - // Box outstanding bill - $text = $langs->trans("CurrentOutstandingBill"); - $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; - $icon = 'bill'; - if ($link) { - $boxstat .= ''; - } - $boxstat .= '
'; - $boxstat .= ''.img_object("", $icon).' '.$text.'
'; - $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat .= '
'; - if ($link) { - $boxstat .= '
'; - } - - $tmp = $object->getOutstandingBills('supplier', 1); - $outstandingOpenedLate = $tmp['opened']; - if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { - $text = $langs->trans("CurrentOutstandingBillLate"); - $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; - $icon = 'bill'; - if ($link) { - $boxstat .= ''; - } - $boxstat .= '
'; - $boxstat .= ''.img_object("", $icon).' '.$text.'
'; - $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat .= '
'; - if ($link) { - $boxstat .= '
'; - } - } - } - - - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action); - if (empty($reshook)) { - $boxstat .= $hookmanager->resPrint; + if ($conf->supplier_proposal->enabled) + { + // Box proposals + $tmp = $object->getOutstandingProposals('supplier'); + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllSupplierProposals"); + $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; + } + + 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']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllOrders"); + $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; + } + + 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']; + $outstandingTotalIncTax = $tmp['total_ttc']; + + $text = $langs->trans("OverAllInvoices"); + $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; + + // Box outstanding bill + $text = $langs->trans("CurrentOutstandingBill"); + $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; @@ -560,0 +437,10 @@ + // Lien recap + /* + print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans("SupplierCode").''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
'.$langs->trans("SupplierCode").''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'; - print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer')); - print ''; - print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer')); - print '
'; + print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); + print ''; + print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); + print '
'; - print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc')); - print ''; - print 'vat_reverse_charge == '1' ? ' checked' : '').' disabled>'; - print '
'; - //print $langs->trans('VATIntra').''; - $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : ''); - print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer')); - print ''; - print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped'=>1)); - print '
'.$langs->trans('VATIntra').''; + print $object->tva_intra; + print '
id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; - print ''; - } - print '
'; - print $langs->trans('PaymentBankAccount'); - print ''; - if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) { - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print '
'; - 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'); - } - print "
'.$langs->trans("SuppliersCategoriesShort").''; - print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); - print "
'.$langs->trans("SuppliersCategoriesShort").''; + print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); + print "
'.$langs->trans("LinkedToDolibarrMember").''; - $adh = new Adherent($db); - $result = $adh->fetch('', '', $object->id); - if ($result > 0) { - $adh->ref = $adh->getFullName($langs); - print $adh->getNomUrl(1); - } else { - print $langs->trans("ThirdpartyNotLinkedToMember"); - } - print '
'.$langs->trans("LinkedToDolibarrMember").''; + $adh = new Adherent($db); + $result = $adh->fetch('', '', $object->id); + if ($result > 0) + { + $adh->ref = $adh->getFullName($langs); + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("ThirdpartyNotLinkedToMember"); + } + print '
'; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; + print '
'; + */ @@ -565 +451,2 @@ - if (isModEnabled("product") || isModEnabled("service")) { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) + { @@ -568 +455 @@ - $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity, p.tosell as status, p.tobuy as status_buy, p.tobatch as status_batch,'; + $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,'; @@ -573 +460 @@ - $sql .= ' AND pfp.fk_soc = '.((int) $object->id); + $sql .= ' AND pfp.fk_soc = '.$object->id; @@ -578,12 +465,9 @@ - if (!$query) { - dol_print_error($db); - } - - $num = $db->num_rows($query); - - print '
'; - print ''; - print ''; - print ''; + if (!$query) dol_print_error($db); + + $num = $db->num_rows($query); + + print '
'.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("AllProductReferencesOfSupplier").''.$object->nbOfProductRefs().''; - print '
'; + print ''; + print ''; @@ -592 +476,2 @@ - if ($num > 0) { + if ($num > 0) + { @@ -595 +480,2 @@ - while ($objp = $db->fetch_object($query)) { + while ($objp = $db->fetch_object($query)) + { @@ -601,3 +486,0 @@ - $productstatic->status = $objp->status; - $productstatic->status_buy = $objp->status_buy; - $productstatic->status_batch = $objp->status_batch; @@ -610 +493 @@ - print dol_escape_htmltag($objp->supplier_ref); + print $objp->supplier_ref; @@ -618,6 +501,8 @@ - if (isset($objp->price)) { - print ''.price($objp->price).''; - if ($objp->quantity > 1) { - print ' / '; - print $objp->quantity; - } + if (isset($objp->price)) + { + print price($objp->price); + if ($objp->quantity > 1) + { + print ' / '; + print $objp->quantity; + } @@ -631 +515,0 @@ - print ''; @@ -640,59 +524,63 @@ - if ($user->hasRight("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"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p "; - $sql .= " WHERE p.fk_soc = ".((int) $object->id); - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; - $sql .= " ORDER BY p.date_valid DESC"; - $sql .= $db->plimit($MAXLIST); - - $resql = $db->query($sql); - if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - if ($num > 0) { - print '
'; - print '
'.$langs->trans("ProductsAndServices").''; + print ''.$langs->trans("AllProductReferencesOfSupplier").''.$object->nbOfProductRefs().''; + print '
'; - - print ''; - print ''; - } - - while ($i < $num && $i <= $MAXLIST) { - $obj = $db->fetch_object($resql); - - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - $db->free($resql); - - if ($num > 0) { - print "
'; - print ''; - print ''; - // print ''; - print '
'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPriceRequests").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; - print '
'; - $proposalstatic->id = $obj->rowid; - $proposalstatic->ref = $obj->ref; - $proposalstatic->total_ht = $obj->total_ht; - $proposalstatic->total_tva = $obj->total_tva; - $proposalstatic->total_ttc = $obj->total_ttc; - print $proposalstatic->getNomUrl(1); - print ''; - if ($obj->dc) { - print dol_print_date($db->jdate($obj->dc), 'day'); - } else { - print "-"; - } - print ''.$proposalstatic->LibStatut($obj->fk_statut, 5).'
"; - } - } else { - dol_print_error($db); - } + if ($user->rights->supplier_proposal->lire) + { + $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p "; + $sql .= " WHERE p.fk_soc =".$object->id; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + $sql .= " ORDER BY p.date_valid DESC"; + $sql .= " ".$db->plimit($MAXLIST); + + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num > 0) + { + print ''; + + print ''; + print ''; + } + + while ($i < $num && $i <= $MAXLIST) + { + $obj = $db->fetch_object($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + $db->free($resql); + + if ($num > 0) print "
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPriceRequests").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; + print '
'; + $proposalstatic->id = $obj->rowid; + $proposalstatic->ref = $obj->ref; + $proposalstatic->total_ht = $obj->total_ht; + $proposalstatic->total_tva = $obj->total_tva; + $proposalstatic->total_ttc = $obj->total_ttc; + print $proposalstatic->getNomUrl(1); + print ''; + if ($obj->dc) + { + print dol_print_date($db->jdate($obj->dc), 'day'); + } + else + { + print "-"; + } + print ''.$proposalstatic->LibStatut($obj->fk_statut, 5).'
"; + } + else + { + dol_print_error($db); + } @@ -706 +594,2 @@ - if ($user->hasRight("fournisseur", "commande", "lire")) { + if ($user->rights->fournisseur->commande->lire) + { @@ -715 +604 @@ - $sql2 .= ' AND s.rowid = '.((int) $object->id); + $sql2 .= ' AND s.rowid = '.$object->id; @@ -717,3 +606,6 @@ - if (!getDolGlobalString('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 { + if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) + { + $sql2 .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/orderstoinvoice.php + } + else + { @@ -721 +613 @@ - $sql2 .= " AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; + $sql2 .= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; @@ -738 +630 @@ - $sql .= " WHERE p.fk_soc = ".((int) $object->id); + $sql .= " WHERE p.fk_soc =".$object->id; @@ -741 +633,2 @@ - if ($resql) { + if ($resql) + { @@ -746 +639 @@ - $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; + $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"; @@ -748 +641 @@ - $sql .= " WHERE p.fk_soc = ".((int) $object->id); + $sql .= " WHERE p.fk_soc =".$object->id; @@ -751,2 +644 @@ - $sql .= $db->plimit($MAXLIST); - + $sql .= " ".$db->plimit($MAXLIST); @@ -754 +646,2 @@ - if ($resql) { + if ($resql) + { @@ -757,11 +650,11 @@ - if ($num > 0) { - print '
'; - print ''; - - print ''; - print ''; + if ($num > 0) + { + print '
'; - print ''; - print ''; - print ''; - print '
'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; - print '
'; + + print ''; + print ''; @@ -770 +663,2 @@ - while ($i < $num && $i < $MAXLIST) { + while ($i < $num && $i < $MAXLIST) + { @@ -773,7 +666,0 @@ - $orderstatic->id = $obj->rowid; - $orderstatic->ref = $obj->ref; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - $orderstatic->date = $db->jdate($obj->date); - @@ -781,3 +668,8 @@ - print ''; + print ''; @@ -785,2 +677,7 @@ - if ($obj->date) { - print dol_print_date($orderstatic->date, 'day'); + if ($obj->dc) + { + print dol_print_date($db->jdate($obj->dc), 'day'); + } + else + { + print "-"; @@ -789 +685,0 @@ - print ''; @@ -796,4 +692,4 @@ - if ($num > 0) { - print "
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; + print '
'; - print $orderstatic->getNomUrl(1); - print ''; + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + print $orderstatic->getNomUrl(1); + print ''.price($orderstatic->total_ttc).'
"; - } - } else { + if ($num > 0) print ""; + } + else + { @@ -811 +707,2 @@ - if ($user->hasRight('fournisseur', 'facture', 'lire')) { + if ($user->rights->fournisseur->facture->lire) + { @@ -813 +710 @@ - $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, f.paye,'; + $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,'; @@ -817 +714 @@ - $sql .= ' WHERE f.fk_soc = '.((int) $object->id); + $sql .= ' WHERE f.fk_soc = '.$object->id; @@ -822 +719,2 @@ - if ($resql) { + if ($resql) + { @@ -825,11 +723,10 @@ - if ($num > 0) { - print '
'; - print ''; - - print ''; - print ''; + if ($num > 0) + { + print '
'; - print ''; - print ''; - print ''; - print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; - print '
'; + + print ''; + print ''; @@ -838 +735,2 @@ - while ($i < min($num, $MAXLIST)) { + while ($i < min($num, $MAXLIST)) + { @@ -840,0 +739,3 @@ + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; @@ -866,4 +763,4 @@ - if ($num > 0) { - print '
'; + print ''; + print ''; + print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; + print '
'; + print ''; @@ -847,7 +748,3 @@ - $facturestatic->total_tva = $obj->total_tva; - $facturestatic->total_ttc = $obj->total_ttc; - $facturestatic->date = $db->jdate($obj->df); - - print '
'; - print ''.$facturestatic->getNomUrl(1).''; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + print $facturestatic->getNomUrl(1); @@ -855 +752 @@ - print($obj->label ? ' - ' : '').dol_trunc($obj->label, 14); + print ($obj->label ? ' - ' : '').dol_trunc($obj->label, 14); @@ -857,2 +754,2 @@ - print ''.dol_print_date($facturestatic->date, 'day').''.price($facturestatic->total_ttc).''.dol_print_date($db->jdate($obj->df), 'day').''.price($obj->amount).'
'; - } - } else { + if ($num > 0) print ''; + } + else + { @@ -874,13 +771,4 @@ - // 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; - } - - print ''; - print '
'; - - print dol_get_fiche_end(); + print ''; + print '
'; + + dol_fiche_end(); @@ -890 +778 @@ - * Action bar + * Barre d'actions @@ -897,6 +785,9 @@ - if (empty($reshook)) { - if ($object->status != 1) { - print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('ThirdPartyIsClosed'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - - if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "creer")) { + if (empty($reshook)) + { + if ($object->status != 1) + { + print '
'.$langs->trans("ThirdPartyIsClosed").'
'; + } + + if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) + { @@ -904,4 +795,30 @@ - if ($object->status == 1) { - print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&socid='.$object->id, ''); - } else { - print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'].'#', '', false); + if ($object->status == 1) { + print ''.$langs->trans("AddSupplierProposal").''; + } else { + print ''.$langs->trans("AddSupplierProposal").''; + } + } + + if ($user->rights->fournisseur->commande->creer) + { + $langs->load("orders"); + if ($object->status == 1) { + print ''.$langs->trans("AddOrder").''; + } else { + print ''.$langs->trans("AddOrder").''; + } + } + + if ($user->rights->fournisseur->facture->creer) + { + if (!empty($orders2invoice) && $orders2invoice > 0) + { + if ($object->status == 1) + { + // Company is open + print '
'.$langs->trans("CreateInvoiceForThisCustomer").'
'; + } + else + { + print '
'.$langs->trans("CreateInvoiceForThisCustomer").'
'; + } @@ -909,25 +826,5 @@ - } - - if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) { - $langs->load("orders"); - if ($object->status == 1) { - print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&token='.newToken().'&socid='.$object->id, ''); - } else { - print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - } - - if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) { - if (!empty($orders2invoice) && $orders2invoice > 0) { - if ($object->status == 1) { - // Company is open - print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1', ''); - } else { - print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - } else { - print dolGetButtonAction($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - } - - if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) { + else print '
trans("WithReceptionFinished").')').'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'
'; + } + + if ($user->rights->fournisseur->facture->creer) + { @@ -935,15 +832,19 @@ - if ($object->status == 1) { - print dolGetButtonAction('', $langs->trans('AddBill'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id, ''); - } else { - print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddBill'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - } - - // Add action - if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) { - if ($user->hasRight("agenda", "myactions", "create")) { - print dolGetButtonAction('', $langs->trans('AddAction'), 'default', DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id, ''); - } else { - print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddAction'), 'default', $_SERVER['PHP_SELF'].'#', '', false); - } - } + if ($object->status == 1) { + print ''.$langs->trans("AddBill").''; + } else { + print ''.$langs->trans("AddBill").''; + } + } + + // Add action + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) + { + if ($user->rights->agenda->myactions->create) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } @@ -955,16 +856,20 @@ - if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) { - print '
'; - // List of contacts - show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) { - print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); - - // List of todo actions - show_actions_todo($conf, $langs, $db, $object); - - // List of done actions - show_actions_done($conf, $langs, $db, $object); - } -} else { + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) + { + print '
'; + // List of contacts + show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); + + // List of todo actions + show_actions_todo($conf, $langs, $db, $object); + + // List of done actions + show_actions_done($conf, $langs, $db, $object); + } +} +else +{ --- /tmp/dsg/dolibarr/htdocs/fourn/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/fourn/client_contact.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -39,3 +38,4 @@ -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; @@ -45,2 +45,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -48,3 +48 @@ -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 @@ -54,7 +52,3 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "p.name"; -} -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "p.name"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -68,3 +62 @@ -if (!$user->hasRight("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 "; @@ -72,3 +64 @@ -if (!$user->hasRight("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"; @@ -79,3 +69 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -84 +72 @@ - $sql .= " AND s.fk_stcomm=$stcomm"; + $sql .= " AND s.fk_stcomm=$stcomm"; @@ -88 +76 @@ - $sql .= " AND p.name LIKE '$begin%'"; + $sql .= " AND p.name LIKE '$begin%'"; @@ -92,3 +80,3 @@ - $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'"; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'"; + $sortfield = "p.name"; + $sortorder = "ASC"; @@ -98 +86 @@ - $sql .= " AND s.rowid = ".((int) $socid); + $sql .= " AND s.rowid = ".$socid; @@ -105,2 +93,3 @@ -if ($result) { - $num = $db->num_rows($result); +if ($result) +{ + $num = $db->num_rows($result); @@ -108,2 +97,2 @@ - $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); - print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); + print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); @@ -111,8 +100,8 @@ - print ''; - print ''; - print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, "", "", $sortfield, $sortorder); - print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder); - print_liste_field_titre("Email"); - print_liste_field_titre("Phone"); - print "\n"; + print '
'; + print ''; + print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, "", "", $sortfield, $sortorder); + print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder); + print_liste_field_titre("Email"); + print_liste_field_titre("Phone"); + print "\n"; @@ -120,3 +109,4 @@ - $i = 0; - while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $i = 0; + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($result); @@ -124 +114 @@ - print ''; + print ''; @@ -126,5 +116,5 @@ - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; @@ -132,7 +122,9 @@ - print "\n"; - $i++; - } - print "
'.img_object($langs->trans("ShowContact"), "contact").' '.$obj->lastname.''.$obj->firstname.''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.''.$obj->email.''.$obj->phone.''.img_object($langs->trans("ShowContact"), "contact").' '.$obj->lastname.''.$obj->firstname.''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.''.$obj->email.''.$obj->phone.'
"; - $db->free($result); -} else { - dol_print_error($db); + print "\n"; + $i++; + } + print ""; + $db->free($result); +} +else +{ + dol_print_error($db); --- /tmp/dsg/dolibarr/htdocs/fourn/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/fourn/client_index.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -36,3 +35 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -64,3 +61 @@ -if (!$user->hasRight("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"; @@ -68,3 +63 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND sc.fk_user = ".((int) $user->id); -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; @@ -75 +68,2 @@ -if ($resql) { +if ($resql) +{ @@ -83 +77,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -97 +92,3 @@ -} else { +} +else +{ @@ -103 +100,2 @@ -if (isModEnabled("supplier_order")) { +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) +{ @@ -110,3 +108 @@ - if (!$user->hasRight("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"; @@ -114,3 +110 @@ - if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND sc.fk_user = ".((int) $user->id); - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; @@ -119,3 +113 @@ - if ($socid) { - $sql .= " AND cf.fk_soc = ".((int) $socid); - } + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; @@ -124 +116,2 @@ - if ($resql) { + if ($resql) + { @@ -127 +120,2 @@ - if ($num) { + if ($num) + { @@ -133 +127,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -151 +146,2 @@ - if ($total > 0) { + if ($total > 0) + { @@ -161 +157,2 @@ -if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +{ @@ -166,3 +163 @@ - if (!$user->hasRight("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"; @@ -170,3 +165 @@ - if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND sc.fk_user = ".((int) $user->id); - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; @@ -175,3 +168 @@ - if ($socid) { - $sql .= " AND f.fk_soc = ".((int) $socid); - } + if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -181 +172,2 @@ - if ($resql) { + if ($resql) + { @@ -183 +175,2 @@ - if ($num) { + if ($num) + { @@ -190 +183,2 @@ - while ($i < $num && $i < 20) { + while ($i < $num && $i < 20) + { @@ -219 +213,3 @@ - } else { + } + else + { @@ -225 +221,2 @@ -print '
'; +//print ''; +print '
'; @@ -232,6 +229 @@ -$sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur"; -if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur"; -} else { - $sql .= ", s.code_compta_fournisseur"; -} +$sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur"; @@ -240,3 +231,0 @@ -if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); -} @@ -244,3 +233 @@ -if (!$user->hasRight("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"; @@ -250,6 +237,2 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if ($socid) { - $sql .= " AND s.rowid = ".((int) $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; @@ -260 +243,2 @@ -if ($resql) { +if ($resql) +{ @@ -271 +255,2 @@ - while ($obj = $db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) + { @@ -282 +267,3 @@ -} else { +} +else +{ @@ -293 +280,2 @@ -if (count($companystatic->SupplierCategories)) { +if (count($companystatic->SupplierCategories)) +{ @@ -301 +289,2 @@ - foreach ($companystatic->SupplierCategories as $rowid => $label) { + foreach ($companystatic->SupplierCategories as $rowid => $label) + { @@ -321 +310,2 @@ -print '
'; +//print "\n"; +print ''; --- /tmp/dsg/dolibarr/htdocs/fourn/github_19.0.3_recap-fourn.php +++ /tmp/dsg/dolibarr/htdocs/fourn/client_recap-fourn.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -36,3 +35,4 @@ -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; @@ -54,3 +54,4 @@ -if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); +if ($socid > 0) +{ + $societe = new Societe($db); + $societe->fetch($socid); @@ -58,4 +59,4 @@ - /* - * Affichage onglets - */ - $head = societe_prepare_head($societe); + /* + * Affichage onglets + */ + $head = societe_prepare_head($societe); @@ -63 +64 @@ - print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company'); @@ -65 +66 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -67,3 +68,4 @@ - if ((isModEnabled("fournisseur") && $user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_invoice") && $user->hasRight("supplier_invoice", "lire"))) { - // Invoice list - print load_fiche_titre($langs->trans("SupplierPreview")); + 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")); @@ -71 +73 @@ - print ''; + print '
'; @@ -73,8 +75,8 @@ - $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,"; - $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; - $sql .= " u.login, u.rowid as userid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $societe->id); - $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany - $sql .= " AND f.fk_user_valid = u.rowid"; - $sql .= " ORDER BY f.datef DESC"; + $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,"; + $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; + $sql .= " u.login, u.rowid as userid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; + $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany + $sql .= " AND f.fk_user_valid = u.rowid"; + $sql .= " ORDER BY f.datef DESC"; @@ -82,3 +84,4 @@ - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); @@ -86,9 +89,9 @@ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; @@ -96,3 +99,4 @@ - if ($num <= 0) { - print ''; - } + if (!$num > 0) + { + print ''; + } @@ -100 +104 @@ - $solde = 0; + $solde = 0; @@ -102,3 +106,4 @@ - // Boucle sur chaque facture - for ($i = 0; $i < $num; $i++) { - $objf = $db->fetch_object($resql); + // Boucle sur chaque facture + for ($i = 0; $i < $num; $i++) + { + $objf = $db->fetch_object($resql); @@ -106,7 +111,8 @@ - $fac = new FactureFournisseur($db); - $ret = $fac->fetch($objf->facid); - if ($ret < 0) { - print $fac->error."
"; - continue; - } - $totalpaid = $fac->getSommePaiement(); + $fac = new FactureFournisseur($db); + $ret = $fac->fetch($objf->facid); + if ($ret < 0) + { + print $fac->error."
"; + continue; + } + $totalpaye = $fac->getSommePaiement(); @@ -114 +120 @@ - print ''; + print ''; @@ -116,2 +122,2 @@ - print '\n"; - print "\n"; + print "\n"; + print "\n"; @@ -119,3 +125,3 @@ - print ''; - print '\n"; - $solde = $solde + $fac->total_ttc; + print ''; + print '\n"; + $solde = $solde + $fac->total_ttc; @@ -123,2 +129,2 @@ - print ''; - print '\n"; + print ''; + print '\n"; @@ -126,2 +132,2 @@ - // Author - print ''; + // Author + print ''; @@ -129 +135 @@ - print "\n"; + print "\n"; @@ -131,8 +137,8 @@ - // Payments - $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,"; - $sql .= " p.fk_user_author, u.login, u.rowid as userid"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,"; - $sql .= " ".MAIN_DB_PREFIX."paiementfourn as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid"; - $sql .= " WHERE pf.fk_paiementfourn = p.rowid"; - $sql .= " AND pf.fk_facturefourn = ".((int) $fac->id); + // Payments + $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,"; + $sql .= " p.fk_user_author, u.login, u.rowid as userid"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,"; + $sql .= " ".MAIN_DB_PREFIX."paiementfourn as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid"; + $sql .= " WHERE pf.fk_paiementfourn = p.rowid"; + $sql .= " AND pf.fk_facturefourn = ".$fac->id; @@ -140,4 +146,5 @@ - $resqlp = $db->query($sql); - if ($resqlp) { - $nump = $db->num_rows($resqlp); - $j = 0; + $resqlp = $db->query($sql); + if ($resqlp) + { + $nump = $db->num_rows($resqlp); + $j = 0; @@ -145,13 +152,14 @@ - while ($j < $nump) { - $objp = $db->fetch_object($resqlp); - // - print ''; - print '\n"; - print ''; - print "\n"; - print "\n"; - print ''; - $solde = $solde - $objp->amount; - print '\n"; + while ($j < $nump) + { + $objp = $db->fetch_object($resqlp); + // + print ''; + print '\n"; + print ''; + print "\n"; + print "\n"; + print ''; + $solde = $solde - $objp->amount; + print '\n"; @@ -159,2 +167,2 @@ - // Auteur - print ''; + // Auteur + print ''; @@ -162 +170 @@ - print ''; + print ''; @@ -164,2 +172,2 @@ - $j++; - } + $j++; + } @@ -167,8 +175,12 @@ - $db->free($resqlp); - } else { - dol_print_error($db); - } - } - } else { - dol_print_error($db); - } + $db->free($resqlp); + } + else + { + dol_print_error($db); + } + } + } + else + { + dol_print_error($db); + } @@ -176,4 +188,6 @@ - print "
'.$langs->trans("Date").' '.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
'.$langs->trans("Date").' '.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
'.$langs->trans("NoInvoice").'
'.$langs->trans("NoInvoice").'
'.dol_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"), "bill")." ".$fac->ref."".dol_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"), "bill")." ".$fac->ref."'.$fac->getLibStatut(2, $totalpaid).''.price($fac->total_ttc)."'.$fac->getLibStatut(2, $totalpaye).''.price($fac->total_ttc)." '.price($solde)." '.price($solde)."'.img_object($langs->trans("ShowUser"), 'user').' '.$objf->login.''.img_object($langs->trans("ShowUser"), 'user').' '.$objf->login.'
'.dol_print_date($db->jdate($objp->dp))."'; - print '      '; // Decalage - print ''.img_object($langs->trans("ShowPayment"), "payment").' '.$langs->trans("Payment").' '.$objp->rowid.'  '.price($objp->amount).''.price($solde)."
'.dol_print_date($db->jdate($objp->dp))."'; + print '      '; // Decalage + print ''.img_object($langs->trans("ShowPayment"), "payment").' '.$langs->trans("Payment").' '.$objp->rowid.'  '.price($objp->amount).''.price($solde)."'.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.''.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.'
"; - } -} else { - dol_print_error($db); + print ""; + } +} +else +{ + dol_print_error($db);