function _product_link($fk_product) { global $db, $langs, $conf; $p = new Product($db); $p->fetch($fk_product); return $p->getNomUrl(1) . ' ' . $p->label; }
function formObjectOptions($parameters, &$object, &$action, $hookmanager) { global $conf, $langs, $db; if ((in_array('ordercard', explode(':', $parameters['context'])) || in_array('propalcard', explode(':', $parameters['context']))) && $conf->global->REMISE_USE_WEIGHT) { print '<script type="text/javascript"> $(document).ready(function() { '; foreach ($object->lines as &$line) { if ($line->fk_product_type == 0 && $line->fk_product > 0) { dol_include_once('/product/class/product.class.php', 'Product'); $p = new Product($db); $p->fetch($line->fk_product); if ($p->id > 0) { $weight_kg = $p->weight * $line->qty * pow(10, $p->weight_units); $id_line = !empty($line->id) ? $line->id : $line->rowid; if (!empty($weight_kg)) { print '$("tr#row-' . $id_line . ' td:first").append(" - ' . $langs->trans('Weight') . ' : ' . $weight_kg . 'Kg");'; } } } } print '}); </script>'; } return 0; }
/** * Delete product * * @param int $id Product ID * @return array * * @url DELETE product/{id} */ function delete($id) { if (!DolibarrApiAccess::$user->rights->product->supprimer) { throw new RestException(401); } $result = $this->product->fetch($id); if (!$result) { throw new RestException(404, 'Product not found'); } if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } return $this->product->delete($id); }
function isLineShippable(&$line, &$TSomme) { global $conf, $user; $db =& $this->db; $TSomme[$line->fk_product] += $line->qty_toship; if (!isset($line->stock) && $line->fk_product > 0) { if (empty($this->TProduct[$line->fk_product])) { $produit = new Product($db); $produit->fetch($line->fk_product); $produit->load_stock(false); $this->TProduct[$line->fk_product] = $produit; } else { $produit =& $this->TProduct[$line->fk_product]; } $line->stock = $produit->stock_reel; // Filtre par entrepot de l'utilisateur if (!empty($conf->global->SHIPPABLEORDER_ENTREPOT_BY_USER) && !empty($user->array_options['options_entrepot_preferentiel'])) { $line->stock = $produit->stock_warehouse[$user->array_options['options_entrepot_preferentiel']]->real; } elseif (!empty($conf->global->SHIPPABLEORDER_SPECIFIC_WAREHOUSE)) { $line->stock = 0; //Récupération des entrepôts valide $TIdWarehouse = explode(',', $conf->global->SHIPPABLEORDER_SPECIFIC_WAREHOUSE); foreach ($produit->stock_warehouse as $identrepot => $objecttemp) { if (in_array($identrepot, $TIdWarehouse)) { $line->stock += $objecttemp->real; } } } } if ($conf->global->SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK) { $isShippable = 1; $qtyShippable = $line->qty; $line->stock = $line->qty; } else { if ($line->stock <= 0 || $line->qty_toship <= 0) { $isShippable = 0; $qtyShippable = 0; } else { if ($TSomme[$line->fk_product] <= $line->stock) { $isShippable = 1; $qtyShippable = $line->qty_toship; } else { $isShippable = 2; $qtyShippable = $line->qty_toship - $TSomme[$line->fk_product] + $line->stock; } } } $this->TlinesShippable[$line->id] = array('stock' => $line->stock, 'shippable' => $isShippable, 'to_ship' => $line->qty_toship, 'qty_shippable' => $qtyShippable); return $isShippable; }
function mouvement(&$PDOdb, &$object, $fk_product, $qty, $fk_warehouse_from, $fk_warehouse_to) { global $db, $user, $langs; dol_include_once('/product/stock/class/mouvementstock.class.php'); dol_include_once('/product/class/product.class.php'); /*var_dump($fk_product, $qty,$fk_warehouse_from, $fk_warehouse_to); exit; */ $stock = new MouvementStock($db); $label = ''; if (method_exists($object, 'getNomUrl')) { $label .= $object->getNomUrl(1); } if (!empty($conf->global->ROUTING_INFO_ALERT)) { $product = new Product($db); $product->fetch($fk_product); $msg = $product->getNomUrl(0) . ' ' . $product->label . ' ' . $langs->trans('MoveFrom') . ' ' . $wh_from_label . ' ' . $langs->trans('MoveTo') . ' ' . $wh_to_label; setEventMessage($msg); } $stock->origin = $object; $stock->reception($user, $fk_product, $fk_warehouse_to, $qty, 0, $label); $stock->livraison($user, $fk_product, $fk_warehouse_from, $qty, 0, $label); }
if ($idproduct > 0) { $sql .= " AND p.rowid = '" . $idproduct . "'"; } if ($head_check != '') { $sql .= " AND m.checked = 1"; } else { $sql .= " AND m.checked = -1"; } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($idproduct) { $product = new Product($db); $product->fetch($idproduct); } if ($id > 0) { $entrepot = new Entrepot($db); $result = $entrepot->fetch($id); if ($result < 0) { dol_print_error($db); } } $i = 0; $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $texte = $langs->trans("ListOfStockMovements"); if ($id) { $texte .= ' (' . $langs->trans("ForThisWarehouse") . ')'; } llxHeader("", $texte, $help_url);
/** * Function to build pdf onto disk * * @param Object $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $nblignes = count($object->lines); // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) { for ($i = 0; $i < $nblignes; $i++) { if (empty($object->lines[$i]->fk_product)) { continue; } $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product . "/photos/"; $dir = $conf->product->dir_output . '/' . $pdir; $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir . $filename; break; } if ($realpath) { $realpatharray[$i] = $realpath; } } } if (count($realpatharray) == 0) { $this->posxpicture = $this->posxtva; } if ($conf->facture->dir_output) { $object->fetch_thirdparty(); $deja_regle = $object->getSommePaiement(); $amount_credit_notes_included = $object->getSumCreditNotesUsed(); $amount_deposits_included = $object->getSumDepositsUsed(); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->facture->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0; $i < $nblignes; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxpicture += $this->postotalht - $this->posxdiscount; $this->posxtva += $this->postotalht - $this->posxdiscount; $this->posxup += $this->postotalht - $this->posxdiscount; $this->posxqty += $this->postotalht - $this->posxdiscount; $this->posxdiscount += $this->postotalht - $this->posxdiscount; //$this->postotalht; } // Situation invoice handling if ($object->situation_cycle_ref) { $this->situationinvoice = True; $progress_width = 14; $this->posxtva -= $progress_width; $this->posxup -= $progress_width; $this->posxqty -= $progress_width; $this->posxdiscount -= $progress_width; $this->posxprogress -= $progress_width; } // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10; $tab_height = 130; $tab_height_newpage = 150; // Incoterm $height_incoterms = 0; if ($conf->incoterm->enabled) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); $tab_top = $nexY + 6; $height_incoterms += 4; } } // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); if (!empty($salerepobj->signature)) { $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } } if ($notetoshow) { $tab_top = 88 + $height_incoterms; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Loop on each lines for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it $imglinesize = array(); if (!empty($realpatharray[$i])) { $imglinesize = pdf_getSizeForImage($realpatharray[$i]); } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; $posYAfterImage = 0; $posYAfterDescription = 0; // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && $curY + $imglinesize['height'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { $curX = $this->posxpicture - 1; $pdf->Image($realpatharray[$i], $curX + ($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2, $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line $curX = $this->posxdesc - 1; $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { if ($i == $nblignes - 1) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposafter + 1); } } else { // We found a page break $showpricebeforepagebreak = 0; } } else { $pdf->commitTransaction(); } $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars if ($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } else { $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } // Unit if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount - 2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); } if ($this->situationinvoice) { // Situation progress $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell($this->postotalht - $this->posxprogress, 3, $progress, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress(); if ($prev_progress > 0) { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } } else { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva; } else { $tvaligne = $object->lines[$i]->total_tva; } } $localtax1ligne = $object->lines[$i]->total_localtax1; $localtax2ligne = $object->lines[$i]->total_localtax2; $localtax1_rate = $object->lines[$i]->localtax1_tx; $localtax2_rate = $object->lines[$i]->localtax2_tx; $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; if ($object->remise_percent) { $tvaligne -= $tvaligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax1ligne -= $localtax1ligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax2ligne -= $localtax2ligne * $object->remise_percent / 100; } $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') && (!empty($localtax1_rate) || !empty($localtax2_rate))) { $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; } if ($localtax2_type && $localtax2ligne != 0) { $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } if (($object->lines[$i]->info_bits & 0x1) == 0x1) { $vatrate .= '*'; } if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = ''; } $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; } // Add line if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < $nblignes - 1) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash' => 0)); } $nexY += 2; // Passe espace entre les lignes // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; // Pas d'erreur } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
if ($modulepart == 'holiday' && !$user->rights->holiday->read) { accessforbidden(); } $accessallowed = 1; } // Security: // Limit access if permissions are wrong if (!$accessallowed) { accessforbidden(); } // Define dir according to modulepart if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $object = new Product($db); if ($id > 0) { $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db, 'Failed to load object'); } $dir = $conf->product->multidir_output[$object->entity]; // By default if ($object->type == Product::TYPE_PRODUCT) { $dir = $conf->product->multidir_output[$object->entity]; } if ($object->type == Product::TYPE_SERVICE) { $dir = $conf->service->multidir_output[$object->entity]; } } } elseif ($modulepart == 'holiday') { require_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; $object = new Holiday($db);
if ($result < 0) { dol_print_error('', $object->error); } } if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($user) >= 0) { header("Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $newobject = new Product($db); $result = $newobject->fetch($elemid); $elementtype = 'product'; // TODO Add into categ $result = $object->add_type($newobject, $elementtype); if ($result >= 0) { setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } } /* * View
static function getHeadForObject($tab_object, $fk_object) { global $db, $conf, $langs, $user; $head = array(); if (empty($tab_object)) { return $head; } if ($tab_object === 'product') { dol_include_once('/product/class/product.class.php'); dol_include_once('/core/lib/product.lib.php'); $object = new Product($db); $object->fetch($fk_object); $head = product_prepare_head($object); } else { if ($tab_object === 'thirdparty') { dol_include_once('/societe/class/societe.class.php'); dol_include_once('/core/lib/company.lib.php'); $object = new Societe($db); $object->fetch($fk_object); $head = societe_prepare_head($object); } else { if ($tab_object === 'contact') { dol_include_once('/contact/class/contact.class.php'); dol_include_once('/core/lib/contact.lib.php'); $object = new Contact($db); $object->fetch($fk_object); $head = contact_prepare_head($object); } else { if ($tab_object === 'user') { dol_include_once('/user/class/user.class.php'); dol_include_once('/core/lib/usergroups.lib.php'); $object = new User($db); $object->fetch($fk_object); $head = user_prepare_head($object); } else { if ($tab_object === 'group') { dol_include_once('/user/class/usergroup.class.php'); dol_include_once('/lib/usergroups.lib.php'); $object = new UserGroup($db); $object->fetch($fk_object); $head = group_prepare_head($object); } else { if ($tab_object === 'project') { dol_include_once('/projet/class/project.class.php'); dol_include_once('/core/lib/project.lib.php'); $object = new Project($db); $object->fetch($fk_object); $head = project_prepare_head($object); } } } } } } return $head; }
/** * Assign custom values for canvas (for example into this->tpl to be used by templates) * * @param string &$action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void */ function assign_values(&$action, $id=0, $ref='') { global $conf, $langs, $user, $mysoc, $canvas; global $form, $formproduct; $tmpobject = new Product($this->db); if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref); $this->object = $tmpobject; //parent::assign_values($action); foreach($this->object as $key => $value) { $this->tpl[$key] = $value; } $this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors); // canvas $this->tpl['canvas'] = $this->canvas; // id $this->tpl['id'] = $this->id; // Ref $this->tpl['ref'] = $this->ref; // Label $this->tpl['label'] = $this->libelle; // Description $this->tpl['description'] = nl2br($this->description); // Statut $this->tpl['status'] = $this->getLibStatut(2); // Note $this->tpl['note'] = nl2br($this->note); if ($action == 'create') { // Price $this->tpl['price'] = $this->price; $this->tpl['price_min'] = $this->price_min; $this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type"); // VAT $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); } if ($action == 'create' || $action == 'edit') { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status); //To Buy $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); $this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy); $this->tpl['description'] = $this->description; $this->tpl['note'] = $this->note; } if ($action == 'view') { $head = product_prepare_head($this->object,$user); $this->tpl['showrefnav'] = $form->showrefnav($this->object,'ref','',1,'ref'); $titre=$langs->trans("CardProduct".$this->object->type); $picto=($this->object->type==1?'service':'product'); $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $titre, 0, $picto); $this->tpl['showend']=dol_get_fiche_end(); // Accountancy buy code $this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer); $this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer); // Accountancy sell code $this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer); $this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer); } $this->tpl['finished'] = $this->object->finished; $this->tpl['ref'] = $this->object->ref; $this->tpl['label'] = $this->object->label; $this->tpl['id'] = $this->object->id; $this->tpl['type'] = $this->object->type; $this->tpl['note'] = $this->object->note; $this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte; // Duration $this->tpl['duration_value'] = $this->object->duration_value; if ($action == 'create') { // Title $this->tpl['title'] = $langs->trans("NewService"); } if ($action == 'edit') { $this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->object->ref; } if ($action == 'create' || $action == 'edit') { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); $this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]); $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); // Duration unit // TODO creer fonction $duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->object->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); $duration_unit.= ' '; $duration_unit.= '<input name="duration_unit" type="radio" value="d"'.($this->object->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); $duration_unit.= ' '; $duration_unit.= '<input name="duration_unit" type="radio" value="w"'.($this->object->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); $duration_unit.= ' '; $duration_unit.= '<input name="duration_unit" type="radio" value="m"'.($this->object->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); $duration_unit.= ' '; $duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); $this->tpl['duration_unit'] = $duration_unit; } if ($action == 'view') { // Status $this->tpl['status'] = $this->object->getLibStatut(2,0); $this->tpl['status_buy'] = $this->object->getLibStatut(2,1); // Photo $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) { $this->tpl['photos'] = $this->object->show_photos($conf->service->multidir_output[$this->object->entity],1,1,0,0,0,80); } // Duration if ($this->object->duration_value > 1) { $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); } else if ($this->object->duration_value > 0) { $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); } $this->tpl['duration_unit'] = $langs->trans($dur[$this->object->duration_unit]); $this->tpl['fiche_end']=dol_get_fiche_end(); } if ($action == 'list') { $this->LoadListDatas($GLOBALS['limit'], $GLOBALS['offset'], $GLOBALS['sortfield'], $GLOBALS['sortorder']); } }
/** * Add line into array * $this->client doit etre charge * @param idproduct Id du produit a ajouter * @param qty Quantite * @param remise_percent Remise relative effectuee sur le produit * @param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @return void * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ function add_product($idproduct, $qty, $remise_percent = 0, $date_start = '', $date_end = '') { global $conf, $mysoc; if (!$qty) { $qty = 1; } if ($idproduct > 0) { $prod = new Product($this->db); $prod->fetch($idproduct); $tva_tx = get_default_tva($mysoc, $this->client, $prod->id); $localtax1_tx = get_localtax($tva_tx, 1, $this->client); $localtax2_tx = get_localtax($tva_tx, 2, $this->client); // multiprix if ($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) { $price = $prod->multiprices[$this->client->price_level]; } else { $price = $prod->price; } $line = new OrderLine($this->db); $line->fk_product = $idproduct; $line->desc = $prod->description; $line->qty = $qty; $line->subprice = $price; $line->remise_percent = $remise_percent; $line->tva_tx = $tva_tx; $line->localtax1_tx = $localtax1_tx; $line->localtax2_tx = $localtax2_tx; $line->ref = $prod->ref; $line->libelle = $prod->libelle; $line->product_desc = $prod->description; // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Save the start and end date of the line in the object if ($date_start) { $line->date_start = $date_start; } if ($date_end) { $line->date_end = $date_end; } $this->lines[] = $line; /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) { $prod = new Product($this->db, $idproduct); $prod -> get_sousproduits_arbo (); $prods_arbo = $prod->get_each_prod(); if(sizeof($prods_arbo) > 0) { foreach($prods_arbo as $key => $value) { // print "id : ".$value[1].' :qty: '.$value[0].'<br>'; if(! in_array($value[1],$this->products)) $this->add_product($value[1], $value[0]); } } } **/ } }
function _genInfoEtiquette(&$db, &$PDOdb, &$TPrintTicket) { global $conf; $TInfoEtiquette = array(); if (empty($TPrintTicket)) { return $TInfoEtiquette; } dol_include_once('/commande/class/commande.class.php'); $assetOf = new TAssetOF(); $cmd = new Commande($db); $product = new Product($db); $pos = 1; $cpt = 0; foreach ($TPrintTicket as $fk_assetOf => $qty) { if ($qty <= 0) { continue; } $load = $assetOf->load($PDOdb, $fk_assetOf); if ($load === true) { $cmd->fetch($assetOf->fk_commande); foreach ($assetOf->TAssetOFLine as &$assetOfLine) { if ($assetOfLine->type == 'TO_MAKE' && $product->fetch($assetOfLine->fk_product) > 0) { for ($i = 0; $i < $qty; $i++) { $cpt++; if ($cpt % 2 == 0) { $div = 'pair'; } else { $div = 'impair'; } $TInfoEtiquette[] = array('numOf' => $assetOf->numero, 'float' => $div, 'refCmd' => $cmd->ref, 'refCliCmd' => $cmd->ref_client, 'refProd' => $product->ref, 'qty_to_print' => $qty, 'qty_to_make' => $assetOfLine->qty, 'label' => wordwrap(preg_replace('/\\s\\s+/', ' ', $product->label), 20, $conf->global->DEFAULT_ETIQUETTES == 2 ? "\n" : "</br>"), 'pos' => ceil($pos / 8)); //var_dump($TInfoEtiquette);exit; $pos++; //var_dump($TInfoEtiquette); } } } } } //exit; return $TInfoEtiquette; }
$line = $object->lines[$indiceAsked]; $var = !$var; // Show product and description $type = $line->product_type ? $line->product_type : $line->fk_product_type; // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. if (!empty($line->date_start)) { $type = 1; } if (!empty($line->date_end)) { $type = 1; } print "<tr " . $bc[$var] . ">\n"; // Product label if ($line->fk_product > 0) { $product->fetch($line->fk_product); $product->load_stock(); print '<td>'; print '<a name="' . $line->rowid . '"></a>'; // ancre pour retourner sur la ligne // Show product and description $product_static->type = $line->fk_product_type; $product_static->id = $line->fk_product; $product_static->ref = $line->ref; $product_static->libelle = $line->product_label; $text = $product_static->getNomUrl(1); $text .= ' - ' . $line->product_label; $description = $conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc); print $html->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
/** * Return line description translated in outputlangs and encoded into htmlentities and with <br> * * @param Object $object Object * @param int $i Current line number (0 = first line, 1 = second line, ...) * @param Translate $outputlangs Object langs for output * @param int $hideref Hide reference * @param int $hidedesc Hide description * @param int $issupplierline Is it a line for a supplier object ? * @return string String with line */ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { global $db, $conf, $langs; $idprod = !empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false; $label = !empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''); $desc = !empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''); $ref_supplier = !empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : ''); // TODO Not yet saved for supplier invoices, only supplier orders $note = !empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''; $dbatch = !empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false; if ($issupplierline) { $prodser = new ProductFournisseur($db); } else { $prodser = new Product($db); } if ($idprod) { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated if (!empty($conf->global->MAIN_MULTILANGS) && $outputlangs->defaultlang != $langs->defaultlang) { $translatealsoifmodified = !empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). // Set label // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; $textwasmodified = $label == $prodser->label; if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) { $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; } // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no $textwasmodified = false; if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { $textwasmodified = strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false; } else { $textwasmodified = $desc == $prodser->description; } if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) { $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; } // Set note $textwasmodified = $note == $prodser->note; if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) { $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } } // Description short of product line $libelleproduitservice = $label; // Description long of product line if (!empty($desc) && $desc != $label) { if ($libelleproduitservice && empty($hidedesc)) { $libelleproduitservice .= '__N__'; } if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source); // Add date of deposit if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { echo ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')'; } } else { if ($idprod) { if (empty($hidedesc)) { $libelleproduitservice .= $desc; } } else { $libelleproduitservice .= $desc; } } } // If line linked to a product if ($idprod) { // We add ref if ($prodser->ref) { $prefix_prodserv = ""; $ref_prodserv = ""; if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " "; } else { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " "; } } if (empty($hideref)) { if ($issupplierline) { $ref_prodserv = $prodser->ref . ($ref_supplier ? ' (' . $outputlangs->transnoentitiesnoconv("SupplierRef") . ' ' . $ref_supplier . ')' : ''); } else { $ref_prodserv = $prodser->ref; } // Show local ref only if (!empty($libelleproduitservice)) { $ref_prodserv .= " - "; } } $libelleproduitservice = $prefix_prodserv . $ref_prodserv . $libelleproduitservice; } } // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $categstatic = new Categorie($db); // recovering the list of all the categories linked to product $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT); foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled $desccateg = $cate->add_description; if ($desccateg) { $libelleproduitservice .= '__N__' . $desccateg; } } } if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) { $format = 'day'; // Show duration if exists if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')'; } if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)) . ')'; } if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')'; } //print '>'.$outputlangs->charset_output.','.$period; $libelleproduitservice .= "__N__" . $period; //print $libelleproduitservice; } if ($dbatch) { $format = 'day'; foreach ($dbatch as $detail) { $dte = array(); if ($detail->eatby) { $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); } if ($detail->sellby) { $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); } if ($detail->batch) { $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); } $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->dluo_qty); $libelleproduitservice .= "__N__ " . implode($dte, "-"); } } // Now we convert \n into br if (dol_textishtml($libelleproduitservice)) { $libelleproduitservice = preg_replace('/__N__/', '<br>', $libelleproduitservice); } else { $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); } $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1); return $libelleproduitservice; }
header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["id"].'&action=addthumb&file='.urldecode($_POST["file"])); exit; } else { $mesg=$result; $_GET['file']=$_POST["file"]; $_GET['id']=$_POST["id"]; } } // Crop d'une image if ($_POST["action"] == 'confirm_crop') { $product=new Product($db); $result=$product->fetch($_POST["id"]); if ($result <= 0) dol_print_error($db,'Failed to load object'); $dir=$conf->product->dir_output; // By default if ($product->type == 0) $dir=$conf->product->dir_output; if ($product->type == 1) $dir=$conf->service->dir_output; $fullpath=$dir."/".$original_file; $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); if ($result == $fullpath) { header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["id"].'&action=addthumb&file='.urldecode($_POST["file"])); exit; } else {
/* * View */ $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { $product = new Product($db); if ($_GET["ref"]) { $result = $product->fetch('',$_GET["ref"]); $_GET["id"]=$product->id; } if ($_GET["id"]) $result = $product->fetch($_GET["id"]); llxHeader("","",$langs->trans("CardProduct".$product->type)); if ($result > 0) { $head=product_prepare_head($product,$user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); print '<table class="border" width="100%">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<table class="noborder tableforservicepart2" width="100%">'; // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; if (GETPOST('remonth')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); } elseif (!$dateactstart) { $dateactstart = time(); } $dateactend = $objp->date_fin_reelle; if (GETPOST('endmonth')) { $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); } elseif (!$dateactend) { if ($objp->fk_product > 0) { $product = new Product($db); $product->fetch($objp->fk_product); $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); } } $now = dol_now(); if ($dateactend > $now) { $dateactend = $now; } print '<tr ' . $bc[$var] . '><td colspan="2">'; if ($objp->statut >= 4) { if ($objp->statut == 4) { print $langs->trans("DateEndReal") . ' '; print $form->select_date($dateactend, "end", $usehm, $usehm, $objp->date_fin_reelle > 0 ? 0 : 1, "closeline", 1, 1, 1); } } print '</td>';
$result = $contract->fetch($contractline->fk_contrat); if ($result > 0) { $result = $contract->fetch_thirdparty($contract->socid); } else { $mesg = $contract->error; $error++; } } else { $mesg = 'ErrorRecordNotFound'; $error++; } } $amount = $contractline->total_ttc; if ($contractline->fk_product) { $product = new Product($db); $result = $product->fetch($contractline->fk_product); // We define price for product (TODO Put this in a method in product class) if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; } else { $pu_ht = $product->price; $pu_ttc = $product->price_ttc; $price_base_type = $product->price_base_type; } $amount = $pu_ttc; if (empty($amount)) { dol_print_error('', 'ErrorNoPriceDefinedForThisProduct'); exit; }
$error = 0; $db->begin(); $user->fetch($_SESSION['uid']); $user->getrights(); $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $societe = new Societe($db); $societe->fetch($thirdpartyid); $invoice = new Facture($db); // Get content of cart $tab_liste = $_SESSION['poscart']; // Loop on each product $tab_liste_size = count($tab_liste); for ($i = 0; $i < $tab_liste_size; $i++) { // Recuperation de l'article $product = new Product($db); $product->fetch($tab_liste[$i]['fk_article']); $ret = array('label' => $product->label, 'tva_tx' => $product->tva_tx, 'price' => $product->price); if ($conf->global->PRODUIT_MULTIPRICES) { if (isset($product->multiprices[$societe->price_level])) { $ret['price'] = $product->multiprices[$societe->price_level]; } } $tab_article = $ret; $res = $db->query('SELECT taux FROM ' . MAIN_DB_PREFIX . 'c_tva WHERE rowid = ' . $tab_liste[$i]['fk_tva']); $ret = array(); $tab = $db->fetch_array($res); foreach ($tab as $cle => $valeur) { $ret[$cle] = $valeur; } $tab_tva = $ret; $invoiceline = new FactureLigne($db);
$special_code = 3; } $line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); $percent = $line->get_prev_progress(); if (GETPOST('progress') < $percent) { $mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>'; setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; } // Check minimum price $productid = GETPOST('productid', 'int'); if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); $type = $product->type; $price_min = $product->price_min; if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) { $price_min = $product->multiprices_min[$object->thirdparty->price_level]; } $label = GETPOST('update_label') && GETPOST('product_label') ? GETPOST('product_label') : ''; // Check price is not lower than minimum (check is done only for standard or replacement invoices) if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)), null, 'errors'); $error++; } } else { $type = GETPOST('type'); $label = GETPOST('product_label') ? GETPOST('product_label') : ''; // Check parameters
print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; dol_syslog($script_file . " launched with arg " . join(',', $argv)); if (!isset($argv[1]) || $argv[1] != 'product') { print "Usage: {$script_file} product\n"; exit(-1); } print '--- start' . "\n"; // Case to migrate products path if ($argv[1] == 'product') { $product = new Product($db); $sql = "SELECT rowid as pid from " . MAIN_DB_PREFIX . "product"; // Get list of all products $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { $product->fetch($obj->pid); print " migrating product id=" . $product->id . " ref=" . $product->ref . "\n"; migrate_product_photospath($product); } } else { print "\n sql error " . $sql; exit; } } $db->close(); // Close $db database opened handler exit($error); /** * Migrate file from old path to new one for product $product * * @param Product $product Object product
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; print '<td> </td>'; print '</tr>'; print '<tr class="liste_titre">'; print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>'; print '<td colspan="8"> </td>'; // Print the search button print '<td class="liste_titre" align="right">'; print '<input class="liste_titre" name="button_search" type="image" 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>'; $var = True; foreach ($prodcustprice->lines as $line) { print "<tr {$bc[$var]}>"; $staticprod = new Product($db); $staticprod->fetch($line->fk_product); print "<td>" . $staticprod->getNomUrl(1) . "</td>"; print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>"; print '<td align="right">' . price($line->price) . "</td>"; print '<td align="right">' . price($line->price_ttc) . "</td>"; print '<td align="right">' . price($line->price_min) . '</td>'; print '<td align="right">' . price($line->price_min_ttc) . '</td>'; // User $userstatic = new User($db); $userstatic->fetch($line->fk_user); print '<td align="right">'; print $userstatic->getLoginUrl(1); print '</td>'; // Todo Edit or delete button
if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } } for ($i = 0; $i < $num_prod; $i++) { print "<tr " . $bc[$var] . ">"; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td align="center">' . ($i + 1) . '</td>'; } // Predefined product or service if ($lines[$i]->fk_product > 0) { // Define output language if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->fetch($lines[$i]->fk_product); $label = !empty($prod->multilangs[$outputlangs->defaultlang]["label"]) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; } else { $label = !empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label; } print '<td>'; // Show product and description $product_static->type = $lines[$i]->fk_product_type; $product_static->id = $lines[$i]->fk_product; $product_static->ref = $lines[$i]->ref; $text = $product_static->getNomUrl(1); $text .= ' - ' . $label; $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->description); print $form->textwithtooltip($text, $description, 3, '', '', $i); print_date_range($lines[$i]->date_start, $lines[$i]->date_end); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
/** * Get list of products for a category * * @param array $authentication Array of authentication information * @param array $id Category id * @param $lang $lang Force lang * @return array Array result */ function getProductsForCategory($authentication, $id, $lang = '') { global $db, $conf, $langs; $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); dol_syslog("Function: getProductsForCategory login="******" id=" . $id); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if (!$error && !$id) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided."; } if (!$error) { $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); $fuser->getrights(); if ($fuser->rights->produit->lire) { $categorie = new Categorie($db); $result = $categorie->fetch($id); if ($result > 0) { $table = "product"; $field = "product"; $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table; $sql .= " WHERE fk_categorie = " . $id; $sql .= " ORDER BY fk_" . $field . " ASC"; dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG); $res = $db->query($sql); if ($res) { while ($rec = $db->fetch_array($res)) { $obj = new Product($db); $obj->fetch($rec['fk_' . $field]); $iProduct = 0; if ($obj->status > 0) { $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output; $pdir = get_exdir($obj->id, 2) . $obj->id . "/photos/"; $dir = $dir . '/' . $pdir; $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10)); //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); //Get extrafield values $product->fetch_optionals($obj->id, $extralabels); foreach ($extrafields->attribute_label as $key => $label) { $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $product->array_options['options_' . $key])); } $iProduct++; } } // Retour $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products); } else { $errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated' . $sql; $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG); } } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id; } } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
/** * Add an invoice line into database (linked to product/service or not). * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * * @param string $desc Description of line * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity * @param double $txtva Force vat rate, -1 for auto * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id of predefined product/service * @param double $remise_percent Percent of discount on line * @param int $date_start Date start of service * @param int $date_end Date end of service * @param int $ventil Code of dispatching into accountancy * @param int $info_bits Bits de type de lignes * @param int $fk_remise_except Id discount used * @param string $price_base_type 'HT' or 'TTC' * @param double $pu_ttc Unit price with tax (> 0 even for credit note) * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @param int $fk_parent_line Id of parent line * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' * @param string $label Label of the line (deprecated, do not use) * @param array $array_options extrafields array * @param int $situation_percent Situation advance percentage * @param int $fk_prev_id Previous situation line id reference * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int <0 if KO, Id of line if OK */ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = '', $fk_unit = null) { // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); } global $mysoc, $conf, $langs; dol_syslog(get_class($this) . "::addline facid={$this->id},desc={$desc},pu_ht={$pu_ht},qty={$qty},txtva={$txtva}, txlocaltax1={$txlocaltax1}, txlocaltax2={$txlocaltax2}, fk_product={$fk_product},remise_percent={$remise_percent},date_start={$date_start},date_end={$date_end},ventil={$ventil},info_bits={$info_bits},fk_remise_except={$fk_remise_except},price_base_type={$price_base_type},pu_ttc={$pu_ttc},type={$type}, fk_unit={$fk_unit}", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; // Clean parameters if (empty($remise_percent)) { $remise_percent = 0; } if (empty($qty)) { $qty = 0; } if (empty($info_bits)) { $info_bits = 0; } if (empty($rang)) { $rang = 0; } if (empty($ventil)) { $ventil = 0; } if (empty($txtva)) { $txtva = 0; } if (empty($txlocaltax1)) { $txlocaltax1 = 0; } if (empty($txlocaltax2)) { $txlocaltax2 = 0; } if (empty($fk_parent_line) || $fk_parent_line < 0) { $fk_parent_line = 0; } if (empty($fk_prev_id)) { $fk_prev_id = 'null'; } if (is_null($situation_percent) || $situation_percent > 100) { $situation_percent = 100; } $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $pa_ht = price2num($pa_ht); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); if ($price_base_type == 'HT') { $pu = $pu_ht; } else { $pu = $pu_ttc; } // Check parameters if ($type < 0) { return -1; } if (!empty($this->brouillon)) { $this->db->begin(); $product_type = $type; if (!empty($fk_product)) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $this->error = $langs->trans('ErrorStockIsNotEnough'); $this->db->rollback(); return -3; } } // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); $txtva = preg_replace('/\\s*\\(.*\\)/', '', $txtva); // Remove code into vatrate. $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; // Rank to use $rangtouse = $rang; if ($rangtouse == -1) { $rangmax = $this->line_max($fk_parent_line); $rangtouse = $rangmax + 1; } // Insert line $this->line = new FactureLigne($this->db); $this->line->context = $this->context; $this->line->fk_facture = $this->id; $this->line->label = $label; // deprecated $this->line->desc = $desc; $this->line->qty = $this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty; // For credit note, quantity is always positive and unit price negative $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; $this->line->fk_product = $fk_product; $this->line->product_type = $product_type; $this->line->remise_percent = $remise_percent; $this->line->subprice = $this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht; // For credit note, unit price always negative, always positive otherwise $this->line->date_start = $date_start; $this->line->date_end = $date_end; $this->line->ventil = $ventil; $this->line->rang = $rangtouse; $this->line->info_bits = $info_bits; $this->line->fk_remise_except = $fk_remise_except; $this->line->total_ht = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_ht) : $total_ht; // For credit note and if qty is negative, total is negative $this->line->total_tva = $total_tva; $this->line->total_localtax1 = $total_localtax1; $this->line->total_localtax2 = $total_localtax2; $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->total_ttc = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_ttc) : $total_ttc; $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; $this->line->origin = $origin; $this->line->origin_id = $origin_id; $this->line->situation_percent = $situation_percent; $this->line->fk_prev_id = $fk_prev_id; $this->line->fk_unit = $fk_unit; // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; } $result = $this->line->insert(); if ($result > 0) { // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); return $this->line->rowid; } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; } } else { $this->error = $this->line->error; $this->db->rollback(); return -2; } } }
$langs->load("bills"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = !empty($id) ? $id : (!empty($ref) ? $ref : ''); $fieldtype = !empty($ref) ? 'ref' : 'rowid'; if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $mesg = ''; $object = new Product($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $dir = !empty($conf->product->multidir_output[$object->entity]) ? $conf->product->multidir_output[$object->entity] : $conf->service->multidir_output[$object->entity]; } /* * Actions */ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { $result = $object->add_photo($dir, $_FILES['userfile']); } } if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) { $object->delete_photo($dir . "/" . $_GET["file"]); } if ($action == 'addthumb' && $_GET["file"]) { $object->add_thumb($dir . "/" . $_GET["file"]);
$mode = GETPOST('mode'); $modellabel = GETPOST("modellabel"); // Doc template to use $numberofsticker = GETPOST('numberofsticker', 'int'); $mesg = ''; $action = GETPOST('action'); $producttmp = new Product($db); $thirdpartytmp = new Societe($db); /* * Actions */ if (GETPOST('submitproduct') && GETPOST('submitproduct')) { $action = ''; // We reset because we don't want to build doc if (GETPOST('productid') > 0) { $producttmp->fetch(GETPOST('productid')); $forbarcode = $producttmp->barcode; $fk_barcode_type = $thirdpartytmp->barcode_type_code; if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; } if (empty($forbarcode) || empty($fk_barcode_type)) { setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete", $producttmp->getNomUrl()), null, 'warnings'); } } } if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) { $action = ''; // We reset because we don't want to build doc if (GETPOST('socid') > 0) { $thirdpartytmp->fetch(GETPOST('socid'));
print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Products").'</td>'; print '<td align="center">'.$langs->trans("QtyOrdered").'</td>'; print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; print "</tr>\n"; } $var=true; while ($i < $num_prod) { $var=!$var; print "<tr $bc[$var]>"; if ($delivery->lines[$i]->fk_product > 0) { $product = new Product($db); $product->fetch($delivery->lines[$i]->fk_product); print '<td>'; // Affiche ligne produit $text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$delivery->lines[$i]->fk_product.'">'; if ($delivery->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); else $text.= img_object($langs->trans('ShowProduct'),'product'); $text.= ' '.$delivery->lines[$i]->ref.'</a>'; $text.= ' - '.$delivery->lines[$i]->label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($delivery->lines[$i]->description)); //print $description; print $html->textwithtooltip($text,$description,3,'','',$i); print_date_range($delivery->lines[$i]->date_start,$delivery->lines[$i]->date_end); if ($conf->global->PRODUIT_DESC_IN_FORM) {
$offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "DESC"; } if (!$sortfield) { $sortfield = "c.date_commande"; } /* * View */ $form = new Form($db); if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } llxHeader("", "", $langs->trans("CardProduct" . $product->type)); if ($result > 0) { $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); $picto = $product->type == 1 ? 'service' : 'product'; dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) {