function _liste(&$PDOdb) { global $langs, $db, $user, $conf; llxHeader('', $langs->trans('ListOFAsset'), '', ''); //getStandartJS(); if (isset($_REQUEST['delete_ok'])) { ?> <br><div class="error"><?php echo $langs->trans('OFAssetDeleted'); ?> </div><br> <?php } $fk_soc = __get('fk_soc', 0, 'integer'); $fk_product = __get('fk_product', 0, 'integer'); $fk_commande = __get('fk_commande', 0, 'integer'); if ($fk_product > 0) { dol_include_once('/core/lib/product.lib.php'); $product = new Product($db); $result = $product->fetch($fk_product); $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); $picto = $product->type == 1 ? 'service' : 'product'; dol_fiche_head($head, 'tabOF2', $titre, 0, $picto); } elseif ($fk_commande > 0) { dol_include_once("/core/lib/order.lib.php"); $commande = new Commande($db); $result = $commande->fetch($fk_commande); $head = commande_prepare_head($commande, $user); $titre = $langs->trans("CustomerOrder" . $product->type); dol_fiche_head($head, 'tabOF3', $titre, 0, "order"); } $form = new TFormCore(); $assetOf = new TAssetOF(); $r = new TSSRenderControler($assetOf); $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(ofel.qty) as nb_product_to_make\n\t\t, GROUP_CONCAT(DISTINCT ofel.fk_product SEPARATOR ',') as fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin, ofe.fk_commande,ofe.fk_project\n\t\t, ofe.status, ofe.fk_user,ofe.total_estimated_cost, ofe.total_cost, '' AS printTicket\n\t\t FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'TO_MAKE')\n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "product p ON (p.rowid = ofel.fk_product)\n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON (s.rowid = ofe.fk_soc)\n\t\t WHERE ofe.entity=" . $conf->entity; if ($fk_soc > 0) { $sql .= " AND ofe.fk_soc=" . $fk_soc; } if ($fk_product > 0) { $sql .= " AND ofel.fk_product=" . $fk_product; } if ($fk_commande > 0) { $sql .= " AND ofe.fk_commande=" . $fk_commande; } $sql .= " GROUP BY ofe.rowid "; // TODO je me rappelle plus pourquoi j'ai fait cette merde mais ça fait planter le tri, donc à virer. /*if($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) $orderBy['ofe.rowid']='DESC'; else $orderBy['ofe.date_cre']='DESC';*/ $TMath = array(); $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc'); if ($fk_commande > 0) { $THide[] = 'fk_commande'; } if ($conf->global->OF_NB_TICKET_PER_PAGE == -1) { $THide[] = 'printTicket'; } if (empty($user->rights->of->of->price)) { $THide[] = 'total_cost'; $THide[] = 'total_estimated_cost'; } else { $TMath['total_estimated_cost'] = 'sum'; $TMath['total_cost'] = 'sum'; } if (!empty($fk_product)) { $TMath['nb_product_to_make'] = 'sum'; } $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'GET'); echo $form->hidden('action', ''); if ($fk_commande > 0) { echo $form->hidden('fk_commande', $fk_commande); } if ($fk_product > 0) { echo $form->hidden('fk_product', $fk_product); } // permet de garder le filtre produit quand on est sur l'onglet OF d'une fiche produit $r->liste($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@"', 2) . '>' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'printTicket' => '<input style=width:40px;"" type="number" value="' . (int) $conf->global->OF_NB_TICKET_PER_PAGE . '" name="printTicket[@rowid@]" min="0" />'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'total_estimated_cost' => 'money', 'nb_product_to_make' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messageNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'fk_commande' => 'Commande client', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_to_make' => 'Nb produits à fabriquer', 'total_cost' => 'Coût réel', 'total_estimated_cost' => 'Coût prévu', 'printTicket' => 'impression<br />étiquette', 'fk_project' => 'Projet'), 'orderBy' => array('rowid' => 'DESC'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit("@fk_product@")', 'client' => 'get_format_libelle_societe(@fk_soc@)', 'fk_commande' => 'get_format_libelle_commande(@fk_commande@)', 'fk_project' => 'get_format_libelle_projet(@fk_project@)'), 'search' => array('numero' => array('recherche' => true, 'table' => 'ofe'), 'date_lancement' => array('recherche' => 'calendars', 'table' => 'ofe'), 'date_besoin' => array('recherche' => 'calendars', 'table' => 'ofe'), 'status' => array('recherche' => TAssetOF::$TStatus, 'table' => 'ofe')))); if ($conf->global->OF_NB_TICKET_PER_PAGE != -1) { echo '<p align="right"><input class="button" type="button" onclick="$(this).closest(\'form\').find(\'input[name=action]\').val(\'printTicket\'); $(this).closest(\'form\').submit(); " name="print" value="' . $langs->trans('ofPrintTicket') . '" /></p>'; } $form->end(); // On n'affiche pas le bouton de création d'OF si on est sur la liste OF depuis l'onglet "OF" de la fiche commande if ($fk_commande) { $commande = new Commande($db); $commande->fetch($fk_commande); $r2 = new TSSRenderControler($assetOf); $sql = "SELECT c.rowid as fk_commandedet, p.rowid as rowid, p.ref as refProd, p.label as nomProd, c.qty as qteCommandee, c.description, c.product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet c LEFT JOIN " . MAIN_DB_PREFIX . "product p"; $sql .= " ON (c.fk_product = p.rowid)"; $sql .= " WHERE c.product_type IN (0,9) AND c.fk_commande = " . $fk_commande; $resql = $db->query($sql); //var_dump($db); $num = $db->num_rows($resql); print_barre_liste($langs->trans('ListOrderProducts'), $page, "liste.php", $param, $sortfield, $sortorder, '', $num); $i = 0; $form = new TFormCore($_SERVER['PHP_SELF'], 'formMakeOk', 'post'); echo $form->hidden('fk_commande', __get('fk_commande', 0, 'int')); echo $form->hidden('action', 'createOFCommande'); echo $form->hidden('fk_soc', $commande->socid); echo $form->hidden('token', $_SESSION['newtoken']); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre("#"); print_liste_field_titre($langs->trans("Ref"), "liste_of.php", "ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), "liste_of.php", "label", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Quantité à produire"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Produits à ajouter à un OF"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder); print "</tr>\n"; $var = 1; $bc = array(1 => 'class="pair"', -1 => 'class="impair"'); while ($prod = $db->fetch_object($resql)) { $var = !$var; //print "<tr ".$bc[$var].">"; if ($prod->product_type == 9) { print "<tr>"; print "<td> </td>"; print "<td colspan=\"4\"><strong>"; print $prod->description; print '</strong></td>'; } else { if (empty($prod->rowid)) { // ligne libre print "<tr>"; print "<td> </td>"; print "<td colspan=\"4\">"; print $prod->description; print '</td>'; } else { print "<tr " . $bc[$var] . ">"; print "<td>" . ($i + 1) . "</td>"; print "<td>"; $p_static = new Product($db); $p_static->ref = $prod->refProd; $p_static->id = $prod->rowid; print $p_static->getNomUrl(1); print "</td>\n"; print '<td>'; print $prod->nomProd; print '</td>'; print "<td>"; print $form->texte('', 'TQuantites[' . $prod->fk_commandedet . ']', $prod->qteCommandee, 3, 255); print "</td>"; print "<td>" . $form->checkbox1('', 'TProducts[' . $prod->fk_commandedet . '][' . (int) $prod->rowid . ']', false, true, '', 'checkOF'); print "</td>"; print "</tr>\n"; $i++; } } } print '<tr class="liste_titre">'; echo '<th class="liste_titre" colspan="2"> </th><th class="liste_titre"> </th><th class="liste_titre"> </th> <th class="liste_titre"><input type="checkbox" id="checkall" checked="checked" value="1"></th> '; print '</tr>'; print "</table>"; ?> <script type="text/javascript"> $('input#checkall').change(function() { $('input.checkOF').prop('checked',$(this).is(':checked')); }); </script> <?php echo '<p align="right">' . $form->btsubmit('Créer OFs', 'subForm') . ' ' . $form->btsubmit('Créer un seul OF', 'subFormAlone') . '</p>'; $form->end(); echo '</div>'; $db->free($resql); } else { if (!empty($fk_product)) { $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(IF(ofel.qty>0,ofel.qty,ofel.qty_needed) ) as nb_product_needed, ofel.fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin\n , ofe.status, ofe.fk_user, ofe.total_cost\n FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'NEEDED')\n LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = ofel.fk_product\n LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = ofe.fk_soc\n WHERE ofe.entity=" . $conf->entity . " AND ofel.fk_product=" . $fk_product . " AND ofe.status!='CLOSE'"; $sql .= " GROUP BY ofe.rowid "; if ($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) { $orderBy['ofe.rowid'] = 'DESC'; } else { $orderBy['ofe.date_cre'] = 'DESC'; } $TMath = array(); $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc'); if (empty($user->rights->asset->of->price)) { $THide[] = 'total_cost'; } else { $TMath['total_cost'] = 'sum'; } $TMath['nb_product_needed'] = 'sum'; $l = new TListviewTBS('listeofproductneeded'); echo $langs->trans('ofListProductNeeded'); echo $l->render($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@', 2) . '">' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'product' => '<a href="' . dol_buildpath('/product/card.php?id=@fk_product@', 2) . '">' . img_picto('', 'object_product.png', '', 0) . ' @val@</a>', 'client' => '<a href="' . dol_buildpath('/societe/soc.php?id=@fk_soc@', 2) . '">' . img_picto('', 'object_company.png', '', 0) . ' @val@</a>'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'nb_product_needed' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messa geNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_needed' => 'Nb produits nécessaire', 'total_cost' => 'Coût'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit(@fk_product@)', 'client' => 'get_format_libelle_societe(@fk_soc@)'))); } echo '<div class="tabsAction">'; echo '<a id="bt_createOf" class="butAction" href="fiche_of.php?action=new' . (!empty($fk_product) ? '&fk_product=' . $fk_product : '') . '">' . $langs->trans('CreateOFAsset') . '</a>'; if ($conf->nomenclature->enabled && !empty($fk_product)) { dol_include_once('/core/class/html.form.class.php'); dol_include_once('/asset/lib/asset.lib.php'); dol_include_once('/nomenclature/class/nomenclature.class.php'); $doliForm = new Form($db); echo $doliForm->selectarray('fk_nomenclature', TNomenclature::get($PDOdb, $fk_product, true)); echo '<script type="text/javascript"> var url_create_of = $("#bt_createOf").attr("href"); $("#bt_createOf").attr("href","#"); $("#bt_createOf").click(function() { var fk_nomenclature = $("select[name=fk_nomenclature]").val(); var href = url_create_of + "&fk_nomenclature=" + fk_nomenclature; $(this).attr("href", href); }); </script>'; } echo '</div>'; } $PDOdb->close(); llxFooter(''); }
/* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ $now = dol_now(); if ($id > 0 || !empty($ref)) { dol_htmloutput_mesg($mesg, $mesgs); $product_static = new Product($db); $result = $object->fetch($id, $ref); if ($result > 0) { $soc = new Societe($db); $soc->fetch($object->socid); $author = new User($db); $author->fetch($object->user_author_id); $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); $formconfirm = ''; /* * Confirmation de la suppression de la commande */ if ($action == 'delete') { $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } /* * Confirmation de la validation */ if ($action == 'validate') { // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') {
/* * View */ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); $html = new Form($db); if ($id > 0 || ! empty($ref)) { $soc = new Societe($db, $commande->socid); $soc->fetch($commande->socid); $head = commande_prepare_head($commande); dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order'); print '<table class="border" width="100%">'; // Ref print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">'; print $html->showrefnav($commande,'ref','',1,'ref','ref'); print "</td></tr>"; // Ref commande client print '<tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; print $langs->trans('RefCustomer').'</td><td align="left">'; print '</td>';
function fiche_import(&$object, $error) { global $langs, $user; $origin = GETPOST('origin'); $head = null; if ($origin == 'propal') { $head = propal_prepare_head($object); } else { $head = commande_prepare_head($object); } if (empty($user->rights->importdevis->myactions)) { accessforbidden(); } else { llxHeader(); $title = $langs->trans('Import'); if ($origin == 'propal') { dol_fiche_head($head, 'importdevis', $title, 0, 'propal'); } else { dol_fiche_head($head, 'importdevis', $title, 0, 'commande'); } ?> <table width="100%" class="border"> <tr> <td width="25%"><?php echo $langs->trans('Ref'); ?> </td> <td colspan="3"><div style="vertical-align: middle"><div class="inline-block floatleft refid"><?php echo $object->ref; ?> </div></div></td> </tr> <tr> <td><?php echo $langs->trans('Company'); ?> </td> <td colspan="3"><?php echo $object->thirdparty->getNomUrl(1); ?> </td> </tr> <?php if (!$error) { ?> <tr> <td><?php echo $langs->trans('FileToImport'); ?> </td> <td> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="POST" enctype="multipart/form-data"> <input name="action" type="hidden" value="send_file" /> <input name="id" type="hidden" value="<?php echo $object->id; ?> " /> <input name="origin" type="hidden" value="<?php echo $origin; ?> "/> <input name="token" type="hidden" value="<?php echo $_SESSION['newtoken']; ?> " /> <input name="fileDGPF" type="file" /> <?php echo $langs->trans('NbLineToAvoid'); ?> <input name="nb_line_to_avoid" type="number" value="<?php echo (int) $conf->global->IMPORTPROPAL_NB_LINE_TO_AVOID; ?> " size="2" /> <input class="button" type="submit" value="<?php echo $langs->trans('SendFile'); ?> " /> </form> </td> </tr> <?php } ?> </table> <?php dol_fiche_end(); llxFooter(); } }