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 * @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); }
/** * 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); }
} 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 $formquestion = array();
$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 */ $contactstatic = new Contact($db); $form = new Form($db); if ($object->fetch($id)) { llxHeader('', $langs->trans('SupplierCard')); /*
/* * 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";
/** * 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; }
print '<table class="noborder" width="100%">'; $objectsrc->printOriginLinesList($hookmanager); print '</table>'; } } else { if ($id > 0) { /* *************************************************************************** */ /* */ /* Fiche en mode visu ou edition */ /* */ /* *************************************************************************** */ $now = dol_now(); $productstatic = new Product($db); $object->fetch($id); $societe = new Fournisseur($db); $societe->fetch($object->socid); /* * 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); if ($ret == 'html') { print '<br>'; } }
/** * 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); }
<?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; }
} $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'); print '<table width="100%" class="notopnoleftnoright">'; print '<tr><td valign="top" width="50%" class="notopnoleft">'; print '<table width="100%" class="border">';
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) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
{ /* *************************************************************************** */ /* */ /* 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>'; print '</tr>';
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)) { print ' - <a href="' . DOL_URL_ROOT . '/societe/soc.php?action=create&type=f&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=' . $action) . '">' . $langs->trans("CreateDolibarrThirdPartySupplier") . '</a>';
// 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; } } /*
// 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"); }
$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; $lineprod->total_ttc = '' . $total;