}
// EMail
print '<tr><td>' . $langs->trans('EMail') . '</td><td colspan="3">';
print dol_print_email($soc->email, 0, $soc->id, 'AC_EMAIL');
print '</td></tr>';
// Web
print '<tr><td>' . $langs->trans('Web') . '</td><td colspan="3">';
print dol_print_url($soc->url);
print '</td></tr>';
// Phone / Fax
print '<tr><td>' . $langs->trans('Phone') . '</td><td>' . dol_print_phone($soc->tel, $soc->country_code, 0, $soc->id, 'AC_TEL') . '</td>';
print '<td>' . $langs->trans('Fax') . '</td><td>' . dol_print_phone($soc->fax, $soc->country_code, 0, $soc->id, 'AC_FAX') . '</td></tr>';
print '</table>';
print '</div>';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
    $prodcustprice = new Productcustomerprice($db);
    $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 = "soc.nom";
    }
 /**
  * Load an object from its id and create a new one in database
  *
  * @param int $fromid of object to clone
  * @return int id of clone
  */
 function createFromClone($fromid)
 {
     global $user, $langs;
     $error = 0;
     $object = new Productcustomerprice($this->db);
     $object->context['createfromclone'] = 'createfromclone';
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     // ...
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
     }
     unset($object->context['createfromclone']);
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
 /**
  *  Return product info
  *  @param 		int		$idProd		Id of Product
  *  @return      array				Product info
  */
 public static function getProductbyId($idProd, $idCust)
 {
     global $db, $conf;
     if ($conf->global->PRODUIT_MULTIPRICES) {
         $sql = "SELECT price_level";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe";
         $sql .= " WHERE rowid = " . $idCust;
         $res = $db->query($sql);
         if ($res) {
             $obj = $db->fetch_object($res);
             if ($obj->price_level == NULL) {
                 $pricelevel = 1;
             } else {
                 $pricelevel = $obj->price_level;
             }
         }
     } else {
         $pricelevel = 1;
     }
     $function = "getProductbyId";
     $objp = new Product($db);
     $objp->fetch($idProd);
     $ret[0]["id"] = $objp->id;
     $ret[0]["ref"] = $objp->ref;
     $ret[0]["label"] = $objp->label;
     $ret[0]["description"] = $objp->description;
     $ret[0]["fk_product_type"] = $objp->type;
     $ret[0]["diff_price"] = 0;
     if (!empty($objp->multiprices[$pricelevel]) && $objp->multiprices[$pricelevel] > 0) {
         $ret[0]["tva_tx"] = $objp->multiprices_tva_tx[$pricelevel];
         $ret[0]["price_base_type"] = $objp->multiprices_base_type[$pricelevel];
         $ret[0]["price"] = $objp->multiprices[$pricelevel];
         $ret[0]["price_ttc"] = $objp->multiprices_ttc[$pricelevel];
         $ret[0]["price_min"] = $objp->multiprices_min[$pricelevel];
         $ret[0]["price_min_ttc"] = $objp->multiprices_min_ttc[$pricelevel];
     } else {
         if ($conf->global->PRODUIT_CUSTOMER_PRICES) {
             require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
             $prodcustprice = new Productcustomerprice($db);
             $filter = array('t.fk_product' => $objp->id, 't.fk_soc' => $idCust);
             $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
             if ($result >= 0) {
                 if (count($prodcustprice->lines) > 0) {
                     $ret[0]["price"] = $prodcustprice->lines[0]->price;
                     $ret[0]["price_ttc"] = $prodcustprice->lines[0]->price_ttc;
                     $ret[0]["price_min"] = $prodcustprice->lines[0]->price_min;
                     $ret[0]["price_min_ttc"] = $prodcustprice->lines[0]->price_min_ttc;
                     $ret[0]["price_base_type"] = $prodcustprice->lines[0]->price_base_type;
                     $ret[0]["tva_tx"] = $prodcustprice->lines[0]->tva_tx;
                 } else {
                     $ret[0]["price"] = $objp->price;
                     $ret[0]["price_ttc"] = $objp->price_ttc;
                     $ret[0]["price_min"] = $objp->price_min;
                     $ret[0]["price_min_ttc"] = $objp->price_base_type;
                     $ret[0]["price_base_type"] = $objp->price_base_type;
                     $ret[0]["tva_tx"] = $objp->tva_tx;
                 }
             }
         } else {
             $ret[0]["tva_tx"] = $objp->tva_tx;
             $ret[0]["price_base_type"] = $objp->price_base_type;
             $ret[0]["price"] = $objp->price;
             $ret[0]["price_ttc"] = $objp->price_ttc;
             $ret[0]["price_min"] = $objp->price_min;
             $ret[0]["price_min_ttc"] = $objp->price_min_ttc;
             if ($conf->global->PRODUIT_MULTIPRICES) {
                 $ret[0]["diff_price"] = 1;
             }
         }
     }
     $ret[0]["localtax1_tx"] = $objp->localtax1_tx;
     $ret[0]["localtax2_tx"] = $objp->localtax2_tx;
     $ret[0]["image"] = self::getImageProduct($objp->id, false);
     $ret[0]["thumb"] = self::getImageProduct($objp->id, true);
     return Errorcontrol($ret, $function);
 }
示例#4
0
 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
     $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
     $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
     $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
     $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
     if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
         if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
             $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
         }
         if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
             $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
         }
     }
 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
     require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
     $prodcustprice = new Productcustomerprice($db);
     $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
     $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
     if ($result) {
         if (count($prodcustprice->lines) > 0) {
             $pu_ht = price($prodcustprice->lines[0]->price);
             $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
             $price_base_type = $prodcustprice->lines[0]->price_base_type;
             $prod->tva_tx = $prodcustprice->lines[0]->tva_tx;
         }
     }
 }
 // if price ht was forced (ie: from gui when calculated by margin rate and cost price)
 if (!empty($price_ht)) {
     $pu_ht = price2num($price_ht, 'MU');
     $pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
 /**
  * Adds a product to the order
  *
  * @param Commande $object Order object
  * @param Product $prod Product to add
  * @param int $qty Quantity of the product
  * @throws Exception
  */
 public static function addOrderLine(Commande $object, Product $prod, $qty)
 {
     global $db, $conf, $mysoc, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
     $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
     $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
     if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
         $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
         $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
         $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
         if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
             $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
         }
         if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
             $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
         }
     } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
         require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
         $prodcustprice = new Productcustomerprice($db);
         $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
         $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
         if ($result >= 0) {
             if (count($prodcustprice->lines) > 0) {
                 $pu_ht = price($prodcustprice->lines[0]->price);
                 $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
                 $price_base_type = $prodcustprice->lines[0]->price_base_type;
                 $prod->tva_tx = $prodcustprice->lines[0]->tva_tx;
             } else {
                 $pu_ht = $prod->price;
                 $pu_ttc = $prod->price_ttc;
                 $price_base_type = $prod->price_base_type;
             }
         } else {
             throw new Exception($prodcustprice->error);
         }
     } else {
         $pu_ht = $prod->price;
         $pu_ttc = $prod->price_ttc;
         $price_base_type = $prod->price_base_type;
     }
     // if price ht is forced (ie: calculated by margin rate and cost price)
     if (!empty($price_ht)) {
         $pu_ht = price2num($price_ht, 'MU');
         $pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
     } elseif ($tva_tx != $prod->tva_tx) {
         if ($price_base_type != 'HT') {
             $pu_ht = price2num($pu_ttc / (1 + $tva_tx / 100), 'MU');
         } else {
             $pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
         }
     }
     // Define output language
     if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
         $outputlangs = $langs;
         $newlang = '';
         if (empty($newlang) && GETPOST('lang_id')) {
             $newlang = GETPOST('lang_id');
         }
         if (empty($newlang)) {
             $newlang = $object->thirdparty->default_lang;
         }
         if (!empty($newlang)) {
             $outputlangs = new Translate("", $conf);
             $outputlangs->setDefaultLang($newlang);
         }
         $desc = !empty($prod->multilangs[$outputlangs->defaultlang]["description"]) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
     } else {
         $desc = $prod->description;
     }
     // Add custom code and origin country into description
     if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
         $tmptxt = '(';
         if (!empty($prod->customcode)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
         }
         if (!empty($prod->customcode) && !empty($prod->country_code)) {
             $tmptxt .= ' - ';
         }
         if (!empty($prod->country_code)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
         }
         $tmptxt .= ')';
         $desc = dol_concatdesc($desc, $tmptxt);
     }
     //3.9.0 version added support for price units
     if (versioncompare(versiondolibarrarray(), array(3, 9, 0)) >= 0) {
         $fk_unit = $prod->fk_unit;
     } else {
         $fk_unit = null;
     }
     // Local Taxes
     $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
     $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
     $info_bits = 0;
     if ($tva_npr) {
         $info_bits |= 0x1;
     }
     //Percent remise
     if (!empty($object->thirdparty->remise_percent)) {
         $percent_remise = $object->thirdparty->remise_percent;
     } else {
         $percent_remise = 0;
     }
     // Insert line
     $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $prod->id, $percent_remise, $info_bits, 0, $price_base_type, $pu_ttc, '', '', $prod->type, -1, 0, 0, null, 0, '', 0, $fk_unit);
     if ($result < 0) {
         throw new Exception($langs->trans('ErrorAddOrderLine', $prod->ref));
     }
 }