/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $thirdpartystatic = new Societe($db); include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; $sql .= " s.code_fournisseur,"; $sql .= " s.logo"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE s.fournisseur = 1"; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY s.tms DESC "; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $line = 0; while ($line < $num) { $objp = $db->fetch_object($result); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $thirdpartytmp->getNomUrl(1, '', 40), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status, 3)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedSuppliers")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
public function update(Fournisseur $fournisseur) { $query = $this->_db->prepare('UPDATE t_fournisseur SET nom=:nom, adresse=:adresse, email=:email, telephone1=:telephone1, telephone2=:telephone2, fax=:fax, updated=:updated, updatedBy=:updatedBy WHERE id=:id') or die(print_r($this->_db->errorInfo())); $query->bindValue(':id', $fournisseur->id()); $query->bindValue(':nom', $fournisseur->nom()); $query->bindValue(':adresse', $fournisseur->adresse()); $query->bindValue(':email', $fournisseur->email()); $query->bindValue(':telephone1', $fournisseur->telephone1()); $query->bindValue(':telephone2', $fournisseur->telephone2()); $query->bindValue(':fax', $fournisseur->fax()); $query->bindValue(':updated', $fournisseur->updated()); $query->bindValue(':updatedBy', $fournisseur->updatedBy()); $query->execute(); $query->closeCursor(); }
public function update(Fournisseur $fournisseur) { $query = $this->_db->prepare('UPDATE t_fournisseur SET nom=:nom, societe=:societe, adresse=:adresse, email=:email, telephone1=:telephone1, nature=:nature, fax=:fax WHERE id=:id') or die(print_r($this->_db->errorInfo())); $query->bindValue(':nom', $fournisseur->nom()); $query->bindValue(':societe', $fournisseur->societe()); $query->bindValue(':adresse', $fournisseur->adresse()); $query->bindValue(':email', $fournisseur->email()); $query->bindValue(':telephone1', $fournisseur->telephone1()); $query->bindValue(':nature', $fournisseur->nature()); $query->bindValue(':fax', $fournisseur->fax()); $query->bindValue(':id', $fournisseur->id()); $query->execute(); $query->closeCursor(); }
<?php require "../config.php"; dol_include_once('/product/class/product.class.php'); dol_include_once('/fourn/class/fournisseur.product.class.php'); $get = GETPOST('get'); $put = GETPOST('put'); switch ($put) { case 'updateprice': ob_start(); $product = new ProductFournisseur($db); $id_prod = (int) GETPOST('idprod'); $ref_search = GETPOST('ref_search'); $product->fetch($id_prod, $ref_search); $npr = preg_match('/\\*/', GETPOST('tvatx')) ? 1 : 0; $fourn = new Fournisseur($db); $fourn->fetch(GETPOST('fk_supplier')); $ret = $product->update_buyprice(GETPOST('qty'), GETPOST("price"), $user, 'HT', $fourn, 1, GETPOST('ref'), GETPOST('tvatx'), 0, 0, 0); $res = $db->query("SELECT MAX(rowid) as 'rowid' FROM " . MAIN_DB_PREFIX . "product_fournisseur_price WHERE fk_product=" . $product->id); $obj = $db->fetch_object($res); ob_clean(); if ($ret != 0) { print json_encode(array('id' => $ret, 'error' => $product->error)); } else { print json_encode(array('id' => $obj->rowid, 'error' => '', 'dp_desc' => $product->description)); } break; }
$langs->load("suppliers"); 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 { print load_fiche_titre($langs->trans("AddSupplierPrice")); } print '<form action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '" method="POST">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="updateprice">'; dol_fiche_head(); print '<table class="border" width="100%">'; print '<tr><td class="fieldrequired" width="25%">' . $langs->trans("Supplier") . '</td><td>'; if ($rowid) { $supplier = new Fournisseur($db); $supplier->fetch($socid); print $supplier->getNomUrl(1); print '<input type="hidden" name="id_fourn" value="' . $socid . '">'; print '<input type="hidden" name="ref_fourn" value="' . $object->fourn_ref . '">'; print '<input type="hidden" name="ref_fourn_price_id" value="' . $rowid . '">'; print '<input type="hidden" name="rowid" value="' . $rowid . '">'; print '<input type="hidden" name="socid" value="' . $socid . '">'; } else { $events = array(); $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); print $form->select_company(GETPOST("id_fourn"), 'id_fourn', 'fournisseur=1', 1, 0, 0, $events); $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 ($_GET["rowid"]) { $product->fetch_product_fournisseur_price($_GET["rowid"]); print_fiche_titre($langs->trans("ChangeSupplierPrice")); } else { print_fiche_titre($langs->trans("AddSupplierPrice")); } print '<table class="border" width="100%">'; print '<form action="fournisseurs.php?id='.$product->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="updateprice">'; print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">'; if ($_GET["rowid"]) { $supplier=new Fournisseur($db); $supplier->fetch($_GET["socid"]); print $supplier->getNomUrl(1); print '<input type="hidden" name="id_fourn" value="'.$_GET["socid"].'">'; print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">'; print '<input type="hidden" name="ref_fourn_price_id" value="'.$_GET["rowid"].'">'; } else { $html=new Form($db); $html->select_societes($_POST["id_fourn"],'id_fourn','fournisseur=1',1); } print '</td></tr>'; print '<tr><td>'.$langs->trans("SupplierRef").'</td><td colspan="3">'; if ($_GET["rowid"])
/** * Display supplier of product * * @param int $withpicto Add picto * @return string String with supplier price */ function getSocNomUrl($withpicto = 0) { $cust = new Fournisseur($this->db); $cust->fetch($this->fourn_id); return $cust->getNomUrl($withpicto); }
/* * Mode Liste * */ $productstatic = new Product($db); $companystatic = new Societe($db); $title=$langs->trans("ProductsAndServices"); if ($fourn_id) { $supplier = new Fournisseur($db); $supplier->fetch($fourn_id); } $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type,"; $sql .= " pf.fk_soc, pf.ref_fourn,"; $sql .= " ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql .= " s.rowid as socid, s.nom"; $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"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_product_fournisseur = pf.rowid";
require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent.class.php"; } $langs->load('suppliers'); $langs->load('products'); $langs->load('bills'); $langs->load('orders'); $langs->load('companies'); $langs->load('commercial'); $action = GETPOST('action'); // Security check $id = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); if ($user->societe_id) { $id = $user->societe_id; } $result = restrictedArea($user, 'societe&fournisseur', $id, ''); $object = new Fournisseur($db); /* * Action */ if ($action == 'setsupplieraccountancycode') { $result = $object->fetch($id); $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; $result = $object->update($object->id, $user, 1, 0, 1); if ($result < 0) { $mesg = join(',', $object->errors); } $action = ""; } /* * View */
$result = $cat->del_type($object, $elementtype); if ($result < 0) { setEventMessages($cat->error, $cat->errors, 'errors'); } } // Add object into a category if ($parent > 0) { if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $object = new Product($db); $result = $object->fetch($id, $ref); $elementtype = 'product'; } if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; $object = new Fournisseur($db); $result = $object->fetch($objectid); $elementtype = 'fournisseur'; } if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); $elementtype = 'societe'; } if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $object = new Adherent($db); $result = $object->fetch($objectid); $elementtype = 'member'; } if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
if ($_GET['facid'] > 0) { /* *************************************************************************** */ /* */ /* Fiche en mode visu ou edition */ /* */ /* *************************************************************************** */ $now=dol_now(); $productstatic = new Product($db); $fac = new FactureFournisseur($db); $fac->fetch($_GET['facid']); $societe = new Fournisseur($db); $societe->fetch($fac->socid); if ($_GET['action'] == 'edit') { print_fiche_titre($langs->trans('SupplierInvoice')); print '<form name="update" action="fiche.php?facid='.$fac->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="update">'; print '<table class="border" width="100%">'; print '<tr><td class="fieldrequired">'.$langs->trans('Company').'</td>'; print '<td>'.$societe->getNomUrl(1).'</td>'; print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</td>';
} } else { if ($id > 0) { /* *************************************************************************** */ /* */ /* Fiche en mode visu ou edition */ /* */ /* *************************************************************************** */ $now = dol_now(); $productstatic = new Product($db); $object->fetch($id); $result = $object->fetch_thirdparty(); if ($result < 0) { dol_print_error($db); } $societe = new Fournisseur($db); $result = $societe->fetch($object->socid); if ($result < 0) { dol_print_error($db); } /* * View card */ $head = facturefourn_prepare_head($object); $titre = $langs->trans('SupplierInvoice'); dol_fiche_head($head, 'card', $titre, 0, 'bill'); dol_htmloutput_mesg($mesg); dol_htmloutput_errors('', $errors); // Confirmation de la suppression d'une ligne produit if ($action == 'confirm_delete_line') { $ret = $form->form_confirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 1, 1);
dol_print_error($db); } /* * Show result array */ print "<table class=\"noborder\" width=\"100%\">"; print "<tr class=\"liste_titre\">"; ///print "<td>".$langs->trans("JournalNum")."</td>"; print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "</tr>\n"; $var = false; $invoicestatic = new FactureFournisseur($db); $companystatic = new Fournisseur($db); foreach ($tabfac as $key => $val) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $lines = array(array('var' => $tabht[$key], 'label' => $langs->trans('Products')), array('var' => $tabtva[$key], 'label' => $langs->trans('VAT')), array('var' => $tablocaltax1[$key], 'label' => $langs->transcountry('LT1', $mysoc->country_code)), array('var' => $tablocaltax2[$key], 'label' => $langs->transcountry('LT2', $mysoc->country_code)), array('var' => $tabttc[$key], 'label' => $langs->trans('ThirdParty') . ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')', 'nomtcheck' => true, 'inv' => true)); foreach ($lines as $line) { foreach ($line['var'] as $k => $mt) { if (isset($line['nomtcheck']) || $mt) { print "<tr " . $bc[$var] . " >"; print "<td>" . dol_print_date($val["date"]) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $k . "</td><td>" . $line['label'] . "</td>"; if (isset($line['inv'])) {
if (count($TProdVentil) > 0) { $status = $commandefourn->statut; foreach ($TProdVentil as $id_prod => $item) { //Fonction standard ventilation commande fournisseur //TODO AA dans la 3.9 il y a l'id de la ligne concernée... Ce qui implique de ne plus sélectionner un produit mais une ligne à ventiler. Adaptation à faire dans une future version if ($conf->global->DISPATCH_UPDATE_ORDER_PRICE_ON_RECEPTION) { $sup_price = $item['supplier_price']; $lineprod = searchProductInCommandeLine($commandefourn->lines, $id_prod); $unitaire = $sup_price / $lineprod->qty; $prix = $unitaire * $lineprod->qty; if ($conf->global->DISPATCH_CREATE_SUPPLIER_PRICE) { $sup_qty = $item['supplier_qty']; $generate = $item['generate_supplier_tarif'] == 'on' ? true : false; // On va générer le prix s'il est coché if ($generate) { $fourn = new Fournisseur($db); $fourn->fetch($commandefourn->socid); $prix = $unitaire * $sup_qty; $fournisseurproduct = new ProductFournisseur($db); $fournisseurproduct->id = $id_prod; $fournisseurproduct->update_buyprice($sup_qty, $prix, $user, 'HT', $fourn, 0, $lineprod->ref_supplier, '20'); } } else { $sup_qty += $lineprod->qty; } if ($lineprod->subprice != $unitaire && $unitaire > 0) { $prixtva = $prix * ($lineprod->tva_tx / 100); $total = $prix + $prixtva; $lineprod->subprice = '' . $unitaire; $lineprod->total_ht = '' . $prix; $lineprod->total_tva = '' . $prixtva;
/** * Saisie une commande fournisseur * @param user Objet user de celui qui demande * @return int <0 si ko, >0 si ok */ function fastappro($user) { include_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php"; $list = $this->list_suppliers(); if (sizeof($list) > 0) { dol_syslog("Product::fastappro"); $fournisseur = new Fournisseur($this->db); $fournisseur->fetch($this->fourn_appro_open); $fournisseur->ProductCommande($user, $this->id); } return 1; }
} // Delete file in doc form if ($action == 'remove_file') { require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php"; if ($object->fetch($id)) { $upload_dir = $conf->fournisseur->commande->dir_output . "/"; $file = $upload_dir . '/' . $_GET['file']; dol_delete_file($file); $mesg = '<div class="ok">' . $langs->trans("FileWasRemoved") . '</div>'; } } /* * Create an order */ if ($action == 'create') { $fourn = new Fournisseur($db); $result = $fourn->fetch($socid); $db->begin(); $orderid = $fourn->create_commande($user); if ($orderid > 0) { $idc = $fourn->single_open_commande; if ($comclientid != '') { $fourn->updateFromCommandeClient($user, $idc, $comclientid); } $id = $orderid; $db->commit(); } else { $db->rollback(); $mesg = $fourn->error; } }
} } else { if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer) { require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; if ($object->fetch($id)) { $object->fetch_thirdparty(); $langs->load("other"); $upload_dir = $conf->fournisseur->commande->dir_output; $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file, 0, 0, 0, $object); $mesg = '<div class="ok">' . $langs->trans("FileWasRemoved", GETPOST('file')) . '</div>'; } } else { if ($action == 'create' && $user->rights->fournisseur->commande->creer) { $error = 0; $fourn = new Fournisseur($db); $result = $fourn->fetch($socid); $object->socid = $fourn->id; $db->begin(); $orderid = $object->create($user); if (!$orderid > 0) { $error++; $mesg = $object->error; } if (!$error) { if ($comclientid != '') { $object->updateFromCommandeClient($user, $orderid, $comclientid); } $id = $orderid; $db->commit(); } else {
$langs->load("suppliers"); if ($rowid) { $product->fetch_product_fournisseur_price($rowid, 1); //Ignore the math expression when getting the price print_fiche_titre($langs->trans("ChangeSupplierPrice")); } else { print_fiche_titre($langs->trans("AddSupplierPrice")); } print '<form action="' . $_SERVER['PHP_SELF'] . '?id=' . $product->id . '" method="POST">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="updateprice">'; dol_fiche_head(); print '<table class="border" width="100%">'; print '<tr><td class="fieldrequired" width="25%">' . $langs->trans("Supplier") . '</td><td>'; if ($rowid) { $supplier = new Fournisseur($db); $supplier->fetch($socid); print $supplier->getNomUrl(1); print '<input type="hidden" name="id_fourn" value="' . $socid . '">'; print '<input type="hidden" name="ref_fourn" value="' . $product->fourn_ref . '">'; print '<input type="hidden" name="ref_fourn_price_id" value="' . $rowid . '">'; print '<input type="hidden" name="rowid" value="' . $rowid . '">'; print '<input type="hidden" name="socid" value="' . $socid . '">'; } else { $events = array(); $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); print $form->select_company(GETPOST("id_fourn"), 'id_fourn', 'fournisseur=1', 1, 0, 0, $events); $parameters = array('filtre' => "fournisseur=1", 'html_name' => 'id_fourn', 'selected' => GETPOST("id_fourn"), 'showempty' => 1, 'prod_id' => $product->id); $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); if (empty($reshook)) { if (empty($form->result)) {
print '<td class="liste_titre"> </td>'; print '<td class="liste_titre" align="left">'; print '<input class="flat" size="16" type="text" name="search_libelle" value="' . GETPOST("search_libelle") . '">'; print '</td>'; print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" size="8" name="search_societe" value="' . GETPOST("search_societe") . '">'; print '</td><td class="liste_titre" align="right">'; print '<input class="flat" type="text" size="8" name="search_montant_ht" value="' . GETPOST("search_montant_ht") . '">'; print '</td><td class="liste_titre" align="right">'; print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="' . GETPOST("search_montant_ttc") . '">'; print '</td><td class="liste_titre" colspan="2" align="center">'; print '<input type="image" class="liste_titre" align="right" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print '</td>'; print "</tr>\n"; $facturestatic = new FactureFournisseur($db); $supplierstatic = new Fournisseur($db); $var = true; $total = 0; $total_ttc = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td nowrap="nowrap">'; $facturestatic->id = $obj->facid; $facturestatic->ref = $obj->ref; $facturestatic->ref_supplier = $obj->facnumber; print $facturestatic->getNomUrl(1); print "</td>\n"; print '<td nowrap="nowrap">' . dol_trunc($obj->facnumber, 10) . "</td>"; print '<td align="center" nowrap="nowrap">' . dol_print_date($db->jdate($obj->datef), 'day') . '</td>';
// on passe donc par une variable pour avoir un affichage coherent $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value; } // On active le modele $ret = delDocumentModel($value, $type); if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } else { if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } else { if ($action == 'addcat') { $fourn = new Fournisseur($db); $fourn->CreateCategory($user, $_POST["cat"]); } else { if ($action == 'set_SUPPLIER_ORDER_OTHER') { $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string $doubleapproval = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL', 'alpha'); $doubleapproval = price2num($doubleapproval); $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL", $doubleapproval, 'chaine', 0, '', $conf->entity); // TODO We add/delete permission here until permission can have a condition on a global var include_once DOL_DOCUMENT_ROOT . '/core/modules/modFournisseur.class.php'; $newmodule = new modFournisseur($db); // clear default rights array $newmodule->rights = array(); // add new right
/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; $facturestatic = new FactureFournisseur($db); $thirdpartytmp = new Fournisseur($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "SupplierBills", $max)); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql .= " s.code_fournisseur,"; $sql .= " s.logo,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; $sql .= " f.total_ht,"; $sql .= " f.total_tva,"; $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut,"; $sql .= ' f.datef as df,'; $sql .= ' f.datec as datec,'; $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { $sql .= " ORDER BY f.datef DESC, f.ref DESC "; } else { $sql .= " ORDER BY f.tms DESC, f.ref DESC "; } $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $line = 0; $l_due_date = $langs->trans('Late') . ' (' . $langs->trans('DateEcheance') . ': %s)'; while ($line < $num) { $objp = $db->fetch_object($result); $datelimite = $db->jdate($objp->datelimite); $date = $db->jdate($objp->df); $datem = $db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; $late = ''; if ($objp->paye == 0 && $datelimite && $datelimite < $now - $conf->facture->fournisseur->warning_delay) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2' => $late, 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $objp->ref_supplier, 'tooltip' => $langs->trans('SupplierInvoice') . ': ' . ($objp->ref ? $objp->ref : $objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier, 'url' => DOL_URL_ROOT . "/fourn/facture/card.php?facid=" . $objp->facid); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency)); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day')); $fac = new FactureFournisseur($db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoModifiedSupplierBills")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->transnoentities("ReadPermissionNotAllowed")); } }
} } else { if ($id > 0 || !empty($ref)) { /* *************************************************************************** */ /* */ /* Fiche en mode visu ou edition */ /* */ /* *************************************************************************** */ $now = dol_now(); $productstatic = new Product($db); $object->fetch($id, $ref); $result = $object->fetch_thirdparty(); if ($result < 0) { dol_print_error($db); } $societe = new Fournisseur($db); $result = $societe->fetch($object->socid); if ($result < 0) { dol_print_error($db); } // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); /* * View card */ $head = facturefourn_prepare_head($object); $titre = $langs->trans('SupplierInvoice'); dol_fiche_head($head, 'card', $titre, 0, 'bill'); // Clone confirmation if ($action == 'clone') { // Create an array for form
$result=$societe->update($societe->id,$user,1,0,1); if ($result < 0) { $mesg=join(',',$societe->errors); } $POST["action"]=""; $socid=$_POST["socid"]; } /* * View */ $societe = new Fournisseur($db); $contactstatic = new Contact($db); $form = new Form($db); if ( $societe->fetch($socid) ) { llxHeader('',$langs->trans('SupplierCard')); /* * Affichage onglets */ $head = societe_prepare_head($societe); dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company');
/** * Display supplier of product * * @param int $withpicto Add picto * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') * @return string String with supplier price * TODO Remove this method. Use getNomUrl directly. */ function getSocNomUrl($withpicto = 0, $option = 'supplier') { $cust = new Fournisseur($this->db); $cust->fetch($this->fourn_id); return $cust->getNomUrl($withpicto, $option); }
/* * Show result array */ $i = 0; print "<table class=\"noborder\" width=\"100%\">"; print "<tr class=\"liste_titre\">"; ///print "<td>".$langs->trans("JournalNum")."</td>"; print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Account") . "</td>"; print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "</tr>\n"; $var = true; $r = ''; $invoicestatic = new FactureFournisseur($db); $companystatic = new Fournisseur($db); foreach ($tabfac as $key => $val) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; // product foreach ($tabht[$key] as $k => $mt) { if ($mt) { print "<tr " . $bc[$var] . " >"; //print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>"; print "<td>" . $val["date"] . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $k . "</td><td>" . $langs->trans("Products") . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; print "</tr>";
} // List of fields to search into when doing a "search in all" $fieldstosearchall = array('cf.ref' => 'Ref', 'cf.ref_supplier' => 'RefSupplier', 's.nom' => "ThirdParty", 'cf.note_public' => 'NotePublic'); if (empty($user->socid)) { $fieldstosearchall["cf.note_private"] = "NotePrivate"; } /* * View */ $thirdpartytmp = new Fournisseur($db); $commandestatic = new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $title = $langs->trans("SuppliersOrders"); if ($socid > 0) { $fourn = new Fournisseur($db); $fourn->fetch($socid); $title .= ' - ' . $fourn->name; } if ($status) { if ($status == '1,2,3') { $title .= ' - ' . $langs->trans("StatusOrderToProcessShort"); } if ($status == '6,7') { $title .= ' - ' . $langs->trans("StatusOrderCanceled"); } else { $title .= ' - ' . $langs->trans($commandestatic->statuts[$status]); } } if ($billed) { $title .= ' - ' . $langs->trans("Billed");
/** * Display supplier of product * * @param int $withpicto Add picto * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') * @param int $maxlen Max length of name * @param integer $notooltip 1=Disable tooltip * @return string String with supplier price * TODO Remove this method. Use getNomUrl directly. */ function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) { $thirdparty = new Fournisseur($this->db); $thirdparty->fetch($this->fourn_id); return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); }