function ProductCommande($user, $fk_product) { include_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); include_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $commf = new CommandeFournisseur($this->db); $nbc = $this->nb_open_commande(); dol_syslog("Fournisseur::ProductCommande : nbc = ".$nbc); if ($nbc == 0) { if ( $this->create_commande($user) == 0 ) { $idc = $this->single_open_commande; } } elseif ($nbc == 1) { $idc = $this->single_open_commande; } if ($idc > 0) { $prod = new ProductFournisseur($this->db); $prod->fetch($fk_product); $prod->fetch_fourn_data($this->id); $commf->fetch($idc); $commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn); } }
/** * Delete preview files, pour le cas de regeneration de commande * @param $db data base object * @param $comfournid id de la commande a effacer * @param $comfournref reference de la commande si besoin * @return int */ function supplier_order_delete_preview($db, $comfournid, $comfournref='') { global $langs,$conf; require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); if (!$comfournref) { $comfourn = new CommandeFournisseur($db,"",$comfournid); $comfourn->fetch($comfournid); $comfournref = $comfourn->ref; $soc = new Societe($db); $soc->fetch($comfourn->socid); } if ($conf->fournisseur->dir_output.'/commande') { $suppordref = dol_sanitizeFileName($comfournref); $dir = $conf->fournisseur->dir_output . "/" . $suppordref ; $file = $dir . "/" . $suppordref . ".pdf.png"; $multiple = $file . "."; if ( file_exists( $file ) && is_writable( $file ) ) { if ( ! dol_delete_file($file,1) ) { $this->error=$langs->trans("ErrorFailedToOpenFile",$file); return 0; } } else { for ($i = 0; $i < 20; $i++) { $preview = $multiple.$i; if ( file_exists( $preview ) && is_writable( $preview ) ) { if ( ! dol_delete_file($preview,1) ) { $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); return 0; } } } } } return 1; }
$langs->load("sendings"); $langs->load("companies"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); $object = new CommandeFournisseur($db); /* * Ajout d'un nouveau contact */ if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { $contactid = GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); } else { setEventMessage($object->error, 'errors'); } }
$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } $object = new CommandeFournisseur($db); if ($object->fetch($id, $ref) < 0) { dol_print_error($db); exit; } $upload_dir = $conf->fournisseur->dir_output . '/commande/' . dol_sanitizeFileName($object->ref); $object->fetch_thirdparty(); /* * Actions */ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; /* * View */ $form = new Form($db); if ($object->id > 0) { llxHeader();
dol_include_once('/product/stock/class/entrepot.class.php'); dol_include_once('/core/lib/product.lib.php'); dol_include_once('/core/lib/fourn.lib.php'); dol_include_once('/asset/class/asset.class.php'); $PDOdb = new TPDOdb(); $langs->load('companies'); $langs->load('suppliers'); $langs->load('products'); $langs->load('bills'); $langs->load('orders'); $langs->load('commercial'); $langs->load('dispatch@dispatch'); $id = GETPOST('id'); $hookmanager->initHooks(array('receptionstockcard')); $commandefourn = new CommandeFournisseur($db); $commandefourn->fetch($id); $action = GETPOST('action'); $TImport = _loadDetail($PDOdb, $commandefourn); $parameters = array(); $hookmanager->executeHooks('doAction', $parameters, $commandefourn, $action); //var_dump($TImport);exit; function _loadDetail(&$PDOdb, &$commandefourn) { $TImport = array(); foreach ($commandefourn->lines as $line) { $sql = "SELECT ca.rowid as idline,ca.serial_number,p.ref,p.rowid, ca.fk_commandedet, ca.fk_warehouse, ca.imei, ca.firmware,ca.lot_number,ca.weight_reel,ca.weight_reel_unit, ca.dluo\n\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "commande_fournisseurdet_asset as ca\n\t\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "product as p ON (p.rowid = ca.fk_product)\n\t\t\t\t\tWHERE ca.fk_commandedet = " . $line->id . "\n\t\t\t\t\t\tORDER BY ca.rang ASC"; $PDOdb->Execute($sql); while ($PDOdb->Get_line()) { $TImport[] = array('ref' => $PDOdb->Get_field('ref'), 'numserie' => $PDOdb->Get_field('serial_number'), 'lot_number' => $PDOdb->Get_field('lot_number'), 'quantity' => $PDOdb->Get_field('weight_reel'), 'quantity_unit' => $PDOdb->Get_field('weight_reel_unit'), 'imei' => $PDOdb->Get_field('imei'), 'firmware' => $PDOdb->Get_field('firmware'), 'fk_product' => $PDOdb->Get_field('rowid'), 'fk_warehouse' => $PDOdb->Get_field('fk_warehouse'), 'dluo' => $PDOdb->Get_field('dluo'), 'commande_fournisseurdet_asset' => $PDOdb->Get_field('idline')); } }
if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) { $object->fetch($id); $result = $object->mode_reglement($_POST['mode_reglement_id']); } // Set project if ($action == 'classin') { $object->fetch($id); $object->setProject($projectid); } if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); } if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver) { $order = new CommandeFournisseur($db); $result = $order->fetch($id); if ($order->statut == 5 || $order->statut == 6 || $order->statut == 7 || $order->statut == 9) { if ($order->statut == 5) { $newstatus = 4; } // Received->Received partially if ($order->statut == 6) { $newstatus = 2; } // Canceled->Approved if ($order->statut == 7) { $newstatus = 3; } // Canceled->Process running if ($order->statut == 9) { $newstatus = 1;
/** * getProducts * * @param int $order_id Order id * @return void */ function getProducts($order_id) { global $db; $order = new CommandeFournisseur($db); $f = $order->fetch($order_id); $products = array(); if ($f) { foreach ($order->lines as $line) { if (!in_array($line->fk_product, $products)) { $products[] = $line->fk_product; } } } return $products; }
llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur"); $html = new Form($db); $warehouse_static = new Entrepot($db); $now=dol_now(); $id = $_GET['id']; $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { //if ($mesg) print $mesg.'<br>'; $commande = new CommandeFournisseur($db); $result=$commande->fetch($_GET['id'],$_GET['ref']); if ($result >= 0) { $soc = new Societe($db); $soc->fetch($commande->socid); $author = new User($db); $author->fetch($commande->user_author_id); $head = ordersupplier_prepare_head($commande); $title=$langs->trans("SupplierOrder"); dol_fiche_head($head, 'dispatch', $title, 0, 'order'); /* * Commande
/* * View */ $html = new Form($db); $now=gmmktime(); $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { $soc = new Societe($db); $commande = new CommandeFournisseur($db); $result=$commande->fetch($_GET["id"],$_GET['ref']); if ($result >= 0) { $soc->fetch($commande->socid); $author = new User($db); $author->fetch($commande->user_author_id); llxHeader('',$langs->trans("History"),"CommandeFournisseur"); $head = ordersupplier_prepare_head($commande); $title=$langs->trans("SupplierOrder"); dol_fiche_head($head, 'info', $title, 0, 'order');
// Payment mode print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">'; $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '</td></tr>'; // Project if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">'; $formproject->select_projects($soc->id, $projectid, 'projectid'); print '</td></tr>'; } $objectsrc = new CommandeFournisseur($db); $listoforders = array(); foreach ($selected as $sel) { $result = $objectsrc->fetch($sel); if ($result > 0) { $listoforders[] = $objectsrc->ref; } } // Other attributes $parameters = array('objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="3"'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook // Modele PDF print '<tr><td>' . $langs->trans('Model') . '</td>'; print '<td>'; $liste = ModelePDFSuppliersInvoices::liste_modeles($db); print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF); print "</td></tr>"; // Public note
$confirm = GETPOST('confirm', 'alpha'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $line = GETPOST('lineid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } //$result=restrictedArea($user,'produit'); $mesg = ''; /* * Actions */ // Add product to list if ($action == 'add') { $fac = new CommandeFournisseur($db); $fac->fetch($id); $error = 0; for ($i = 0; $i < sizeof($fac->lines); $i++) { $object = new Labelprint($db); $object->fk_product = $fac->lines[$i]->fk_product; $object->qty = $fac->lines[$i]->qty; $result = $object->create($user); if (!$result) { $error++; } } if ($error) { $mesg = '<div class="error">' . $object->error . '</div>'; } else { $mesg = '<font class="ok">' . $langs->trans("LinesAdded") . '</font>'; }
/** * @depends testCommandeFournisseurOther * The depends says test is run only if previous is ok */ public function testCommandeFournisseurDelete($id) { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $localobject=new CommandeFournisseur($this->savdb); $result=$localobject->fetch($id); $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); return $result; }
function _fiche(&$PDOdb, &$assetOf, $mode = 'edit', $fk_product_to_add = 0, $fk_nomenclature = 0) { global $langs, $db, $conf, $user, $hookmanager; /*************************************************** * PAGE * * Put here all code to build page ****************************************************/ $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('doActions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook //pre($assetOf,true); llxHeader('', $langs->trans('OFAsset'), '', ''); print dol_get_fiche_head(ofPrepareHead($assetOf, 'assetOF'), 'fiche', $langs->trans('OFAsset')); ?> <style type="text/css"> #assetChildContener .OFMaster { background:#fff; -webkit-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); -moz-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); margin-bottom:20px; } </style> <div class="OFContent" rel="<?php echo $assetOf->getId(); ?> "> <?php $TPrixFournisseurs = array(); //$form=new TFormCore($_SERVER['PHP_SELF'],'formeq'.$assetOf->getId(),'POST'); //Affichage des erreurs if (!empty($assetOf->errors)) { ?> <br><div class="error"> <?php foreach ($assetOf->errors as $error) { echo $error . "<br>"; setEventMessage($error, 'errors'); } $assetOf->errors = array(); ?> </div><br> <?php } $form = new TFormCore(); $form->Set_typeaff($mode); $doliform = new Form($db); if (!empty($_REQUEST['fk_product'])) { echo $form->hidden('fk_product', $_REQUEST['fk_product']); } $TBS = new TTemplateTBS(); $liste = new TListviewTBS('asset'); $TBS->TBS->protect = false; $TBS->TBS->noerr = true; $PDOdb = new TPDOdb(); $TNeeded = array(); $TToMake = array(); $TNeeded = _fiche_ligne($form, $assetOf, "NEEDED"); $TToMake = _fiche_ligne($form, $assetOf, "TO_MAKE"); $TIdCommandeFourn = $assetOf->getElementElement($PDOdb); $HtmlCmdFourn = ''; if (count($TIdCommandeFourn)) { foreach ($TIdCommandeFourn as $idcommandeFourn) { $cmd = new CommandeFournisseur($db); $cmd->fetch($idcommandeFourn); $HtmlCmdFourn .= $cmd->getNomUrl(1) . " - " . $cmd->getLibStatut(0); } } ob_start(); $doliform->select_produits('', 'fk_product', '', $conf->product->limit_size, 0, -1, 2, '', 3, array()); $select_product = ob_get_clean(); $Tid = array(); //$Tid[] = $assetOf->rowid; if ($assetOf->getId() > 0) { $assetOf->getListeOFEnfants($PDOdb, $Tid); } $TWorkstation = array(); foreach ($assetOf->TAssetWorkstationOF as $k => &$TAssetWorkstationOF) { $ws =& $TAssetWorkstationOF->ws; $TWorkstation[] = array('libelle' => '<a href="' . dol_buildpath('workstation/workstation.php?id=' . $ws->rowid . '&action=view', 2) . '">' . $ws->name . '</a>', 'fk_user' => visu_checkbox_user($PDOdb, $form, $ws->fk_usergroup, $TAssetWorkstationOF->users, 'TAssetWorkstationOF[' . $k . '][fk_user][]', $assetOf->status), 'fk_project_task' => visu_project_task($db, $TAssetWorkstationOF->fk_project_task, $form->type_aff, 'TAssetWorkstationOF[' . $k . '][progress]'), 'fk_task' => visu_checkbox_task($PDOdb, $form, $TAssetWorkstationOF->fk_asset_workstation, $TAssetWorkstationOF->tasks, 'TAssetWorkstationOF[' . $k . '][fk_task][]', $assetOf->status), 'nb_hour' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour]', $TAssetWorkstationOF->nb_hour, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour * 3600) : price($TAssetWorkstationOF->nb_hour)), 'nb_hour_real' => $assetOf->status == 'OPEN' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour_real]', $TAssetWorkstationOF->nb_hour_real, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour_real * 3600) : price($TAssetWorkstationOF->nb_hour_real)), 'nb_days_before_beginning' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_days_before_beginning]', $TAssetWorkstationOF->nb_days_before_beginning, 3, 10) : $TAssetWorkstationOF->nb_days_before_beginning, 'delete' => $mode == 'edit' && $assetOf->status == 'DRAFT' ? '<a href="javascript:deleteWS(' . $assetOf->getId() . ',' . $TAssetWorkstationOF->getId() . ');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'note_private' => $assetOf->status == 'DRAFT' && $mode == 'edit' ? $form->zonetexte('', 'TAssetWorkstationOF[' . $k . '][note_private]', $TAssetWorkstationOF->note_private, 50, 1) : $TAssetWorkstationOF->note_private, 'rang' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][rang]', $TAssetWorkstationOF->rang, 3, 10) : $TAssetWorkstationOF->rang, 'id' => $ws->getId()); } $client = new Societe($db); if ($assetOf->fk_soc > 0) { $client->fetch($assetOf->fk_soc); } $commande = new Commande($db); if ($assetOf->fk_commande > 0) { $commande->fetch($assetOf->fk_commande); } $TOFParent = array_merge(array(0 => ''), $assetOf->getCanBeParent($PDOdb)); $hasParent = false; if (!empty($assetOf->fk_assetOf_parent)) { $TAssetOFParent = new TAssetOF(); $TAssetOFParent->load($PDOdb, $assetOf->fk_assetOf_parent); $hasParent = true; } $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook if ($fk_product_to_add > 0) { $product_to_add = new Product($db); $product_to_add->fetch($fk_product_to_add); $link_product_to_add = $product_to_add->getNomUrl(1) . ' ' . $product_to_add->label; $quantity_to_create = $form->texte('', 'quantity_to_create', 1, 3, 255); } else { $link_product_to_add = ''; $quantity_to_create = ''; } print $TBS->render('tpl/fiche_of.tpl.php', array('TNeeded' => $TNeeded, 'TTomake' => $TToMake, 'workstation' => $TWorkstation), array('assetOf' => array('id' => $assetOf->getId(), 'numero' => $assetOf->getId() > 0 ? '<a href="fiche_of.php?id=' . $assetOf->getId() . '">' . $assetOf->getNumero($PDOdb) . '</a>' : $assetOf->getNumero($PDOdb), 'ordre' => $form->combo('', 'ordre', TAssetOf::$TOrdre, $assetOf->ordre), 'fk_commande' => $assetOf->fk_commande == 0 ? '' : $commande->getNomUrl(1), 'commande_fournisseur' => $HtmlCmdFourn, 'date_besoin' => $form->calendrier('', 'date_besoin', $assetOf->date_besoin, 12, 12), 'date_lancement' => $form->calendrier('', 'date_lancement', $assetOf->date_lancement, 12, 12), 'temps_estime_fabrication' => price($assetOf->temps_estime_fabrication, 0, '', 1, -1, 2), 'temps_reel_fabrication' => price($assetOf->temps_reel_fabrication, 0, '', 1, -1, 2), 'fk_soc' => $mode == 'edit' ? $doliform->select_company($assetOf->fk_soc, 'fk_soc', 'client=1', 1) : ($client->id ? $client->getNomUrl(1) : ''), 'fk_project' => custom_select_projects(-1, $assetOf->fk_project, 'fk_project', $mode), 'note' => $form->zonetexte('', 'note', $assetOf->note, 80, 5), 'quantity_to_create' => $quantity_to_create, 'product_to_create' => $link_product_to_add, 'status' => $form->combo('', 'status', TAssetOf::$TStatus, $assetOf->status), 'statustxt' => TAssetOf::$TStatus[$assetOf->status], 'idChild' => !empty($Tid) ? '"' . implode('","', $Tid) . '"' : '', 'url' => dol_buildpath('/of/fiche_of.php', 2), 'url_liste' => $assetOf->getId() ? dol_buildpath('/of/fiche_of.php?id=' . $assetOf->getId(), 2) : dol_buildpath('/of/liste_of.php', 2), 'fk_product_to_add' => $fk_product_to_add, 'fk_nomenclature' => $fk_nomenclature, 'fk_assetOf_parent' => $assetOf->fk_assetOf_parent ? $assetOf->fk_assetOf_parent : '', 'link_assetOf_parent' => $hasParent ? '<a href="' . dol_buildpath('/of/fiche_of.php?id=' . $TAssetOFParent->rowid, 2) . '">' . $TAssetOFParent->numero . '</a>' : '', 'total_cost' => price($assetOf->total_cost, 0, '', 1, -1, 2), 'total_estimated_cost' => price($assetOf->total_estimated_cost, 0, '', 1, -1, 2), 'mo_cost' => price($assetOf->mo_cost, 0, '', 1, -1, 2), 'mo_estimated_cost' => price($assetOf->mo_estimated_cost, 0, '', 1, -1, 2), 'compo_cost' => price($assetOf->compo_cost, 0, '', 1, -1, 2), 'compo_estimated_cost' => price($assetOf->compo_estimated_cost, 0, '', 1, -1, 2), 'current_cost_for_to_make' => price($assetOf->current_cost_for_to_make, 0, '', 1, -1, 2)), 'view' => array('mode' => $mode, 'status' => $assetOf->status, 'allow_delete_of_finish' => $user->rights->of->of->allow_delete_of_finish, 'ASSET_USE_MOD_NOMENCLATURE' => (int) $conf->nomenclature->enabled, 'OF_MINIMAL_VIEW_CHILD_OF' => (int) $conf->global->OF_MINIMAL_VIEW_CHILD_OF, 'select_product' => $select_product, 'select_workstation' => $form->combo('', 'fk_asset_workstation', TWorkstation::getWorstations($PDOdb), -1), 'actionChild' => $mode == 'edit' ? __get('actionChild', 'edit') : __get('actionChild', 'view'), 'use_lot_in_of' => (int) (!empty($conf->asset->enabled) && !empty($conf->global->USE_LOT_IN_OF)), 'use_project_task' => (int) $conf->global->ASSET_USE_PROJECT_TASK, 'defined_user_by_workstation' => (int) $conf->global->ASSET_DEFINED_USER_BY_WORKSTATION, 'defined_task_by_workstation' => (int) $conf->global->ASSET_DEFINED_OPERATION_BY_WORKSTATION, 'defined_workstation_by_needed' => (int) $conf->global->ASSET_DEFINED_WORKSTATION_BY_NEEDED, 'defined_manual_wharehouse' => (int) $conf->global->ASSET_MANUAL_WAREHOUSE, 'hasChildren' => (int) (!empty($Tid)), 'user_id' => $user->id, 'workstation_module_activate' => (int) $conf->workstation->enabled, 'show_cost' => (int) $user->rights->of->of->price), 'rights' => array('show_ws_time' => $user->rights->of->of->show_ws_time))); echo $form->end_form(); llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $'); }
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0); $hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ordersuppliercard')); $object = new CommandeFournisseur($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret < 0) { dol_print_error($db, $object->error); } $ret = $object->fetch_thirdparty(); if ($ret < 0) { dol_print_error($db, $object->error); } } else { if (!empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); $ret = $fourn->fetch($socid); if ($ret < 0) { dol_print_error($db, $object->error); } $object->socid = $fourn->id;
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0); $datelivraison = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ordersuppliercard', 'globalcard')); $object = new CommandeFournisseur($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret < 0) { dol_print_error($db, $object->error); } $ret = $object->fetch_thirdparty(); if ($ret < 0) { dol_print_error($db, $object->error); } } else { if (!empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); $ret = $fourn->fetch($socid); if ($ret < 0) { dol_print_error($db, $object->error); } $object->socid = $fourn->id;
$ref = GETPOST('ref', 'alpha'); // Security check $socid = ''; if (!empty($user->societe_id)) { $socid = $user->societe_id; } $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); /* * View */ $form = new Form($db); $now = dol_now(); if ($id > 0 || !empty($ref)) { $soc = new Societe($db); $commande = new CommandeFournisseur($db); $result = $commande->fetch($id, $ref); if ($result >= 0) { $soc->fetch($commande->socid); $author = new User($db); $author->fetch($commande->user_author_id); llxHeader('', $langs->trans("History"), "CommandeFournisseur"); $head = ordersupplier_prepare_head($commande); $title = $langs->trans("SupplierOrder"); dol_fiche_head($head, 'info', $title, 0, 'order'); /* * Commande */ print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/fourn/commande/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>';
} //we now know how many orders we need and what lines they have $i = 0; $orders = array(); $suppliersid = array_keys($suppliers); foreach ($suppliers as $supplier) { $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande_fournisseur"; $sql .= " WHERE fk_soc = " . $suppliersid[$i]; $sql .= " AND source = 42 AND fk_statut = 0"; $sql .= " ORDER BY date_creation DESC"; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) > 0) { $obj = $db->fetch_object($resql); $order->fetch($obj->rowid); foreach ($supplier['lines'] as $line) { $result = $order->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, 0, $line->ref_fourn, $line->remise_percent, 'HT', 0, $line->info_bits); } if ($result < 0) { $fail++; $msg = $langs->trans('OrderFail') . " : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } else { $id = $result; } } else { $order->socid = $suppliersid[$i]; $order->fetch_thirdparty(); //trick to know which orders have been generated this way
$result = restrictedArea($user, 'commande_fournisseur', $id,''); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; $commande = new CommandeFournisseur($db); if ($commande->fetch($_GET['id'],$_GET['ref']) < 0) { dol_print_error($db); exit; } /* * Actions */ // Envoi fichier if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
function checkCommandeFournisseur(&$PDOdb) { global $db; $res = true; $Tid = $this->getElementElement($PDOdb); foreach ($Tid as $id) { $cmdf = new CommandeFournisseur($db); $cmdf->fetch($id); //4 = livraison partielle # 5 = livraison total if (!in_array($cmdf->statut, array(4, 5))) { $res = false; break; } } return $res; }