• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_default_npr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_default_npr函数的典型用法代码示例。如果您正苦于以下问题:PHP get_default_npr函数的具体用法?PHP get_default_npr怎么用?PHP get_default_npr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_default_npr函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: dol_concatdesc

 }
 // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1)
 if (GETPOST('idprodfournprice') > 0) {
     $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty);
     // Just to see if a price exists for the quantity. Not used to found vat.
 }
 //Replaces $fk_unit with the product's
 if ($idprod > 0) {
     $result = $productsupplier->fetch($idprod);
     $label = $productsupplier->label;
     $desc = $productsupplier->description;
     if (trim($product_desc) != trim($desc)) {
         $desc = dol_concatdesc($desc, $product_desc);
     }
     $tvatx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']);
     $npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']);
     $localtax1_tx = get_localtax($tvatx, 1, $mysoc, $object->thirdparty);
     $localtax2_tx = get_localtax($tvatx, 2, $mysoc, $object->thirdparty);
     $type = $productsupplier->type;
     $price_base_type = 'HT';
     // TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first)
     $result = $object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, $date_start, $date_end, 0, $npr, $price_base_type, $type, -1, 0, $array_options, $productsupplier->fk_unit);
 }
 if ($idprod == -2 || $idprod == 0) {
     // Product not selected
     $error++;
     $langs->load("errors");
     setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")), null, 'errors');
 }
 if ($idprod == -1) {
     // Quantity too low
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:card.php


示例2: GETPOST

 $price_base_type = GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT';
 // Define special_code for special lines
 $special_code = 0;
 // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices
 // Ecrase $pu par celui du produit
 // Ecrase $desc par celui du produit
 // Ecrase $txtva par celui du produit
 // Ecrase $base_price_type par celui du produit
 // Replaces $fk_unit with the product's
 if (!empty($idprod)) {
     $prod = new Product($db);
     $prod->fetch($idprod);
     $label = GETPOST('product_label') && GETPOST('product_label') != $prod->label ? GETPOST('product_label') : '';
     // Update if prices fields are defined
     $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
     $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
     $pu_ht = $prod->price;
     $pu_ttc = $prod->price_ttc;
     $price_min = $prod->price_min;
     $price_base_type = $prod->price_base_type;
     // We define price for product
     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])) {
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:facture.php


示例3: Product

        $date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']);
        $date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']);

        $price_base_type = 'HT';

        // Ecrase $pu par celui du produit
        // Ecrase $desc par celui du produit
        // Ecrase $txtva par celui du produit
        // Ecrase $base_price_type par celui du produit
        if ($_POST['idprod'])
        {
            $prod = new Product($db, $_POST['idprod']);
            $prod->fetch($_POST['idprod']);

            $tva_tx = get_default_tva($mysoc,$object->client,$prod->id);
            $tva_npr = get_default_npr($mysoc,$object->client,$prod->id);

            // We define price for product
            if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level)
            {
                $pu_ht = $prod->multiprices[$object->client->price_level];
                $pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
                $price_min = $prod->multiprices_min[$object->client->price_level];
                $price_base_type = $prod->multiprices_base_type[$object->client->price_level];
            }
            else
            {
                $pu_ht = $prod->price;
                $pu_ttc = $prod->price_ttc;
                $price_min = $prod->price_min;
                $price_base_type = $prod->price_base_type;
开发者ID:remyyounes,项目名称:dolibarr,代码行数:31,代码来源:facture.php


示例4: dol_print_error

     if ($result <= 0) {
         dol_print_error($db, $facture->error);
         exit;
     }
     $thirpdartyid = $facture->socid;
 }
 if ($thirpdartyid > 0) {
     $soc = new Societe($db);
     $result = $soc->fetch($thirpdartyid);
     if ($result <= 0) {
         dol_print_error($db, $soc->error);
         exit;
     }
     $desc = $object->description;
     $tva_tx = get_default_tva($mysoc, $soc, $object->id);
     $tva_npr = get_default_npr($mysoc, $soc, $object->id);
     if (empty($tva_tx)) {
         $tva_npr = 0;
     }
     $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
     $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
     $pu_ht = $object->price;
     $pu_ttc = $object->price_ttc;
     $price_base_type = $object->price_base_type;
     // If multiprice
     if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
         $pu_ht = $object->multiprices[$soc->price_level];
         $pu_ttc = $object->multiprices_ttc[$soc->price_level];
         $price_base_type = $object->multiprices_base_type[$soc->price_level];
     } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
         require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:card.php


示例5: dol_concatdesc

 }
 // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
 if (GETPOST('idprodfournprice') > 0) {
     $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty);
     // Just to see if a price exists for the quantity. Not used to found vat.
 }
 if ($idprod > 0) {
     $res = $productsupplier->fetch($idprod);
     $label = $productsupplier->label;
     $desc = $productsupplier->description;
     if (trim($product_desc) != trim($desc)) {
         $desc = dol_concatdesc($desc, $product_desc);
     }
     $type = $productsupplier->type;
     $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
     $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
     if (empty($tva_tx)) {
         $tva_npr = 0;
     }
     $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
     $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
     $result = $object->addline($desc, $productsupplier->fourn_pu, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $productsupplier->id, GETPOST('idprodfournprice'), $productsupplier->fourn_ref, $remise_percent, 'HT', $pu_ttc, $type, $tva_npr, '', $date_start, $date_end, $array_options, $productsupplier->fk_unit);
 }
 if ($idprod == -99 || $idprod == 0) {
     // Product not selected
     $error++;
     $langs->load("errors");
     setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")) . ' ' . $langs->trans("or") . ' ' . $langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors');
 }
 if ($idprod == -1) {
     // Quantity too low
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:card.php


示例6: add_product

 /**
  *	Add line into array
  *	$this->client must be loaded
  *
  *	@param		int				$idproduct			Product Id
  *	@param		float			$qty				Quantity
  *	@param		float			$remise_percent		Product discount relative
  * 	@param    	int		$date_start         Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
  * 	@param    	int		$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.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);
         $tva_npr = get_default_npr($mysoc, $this->client, $prod->id);
         if (empty($tva_tx)) {
             $tva_npr = 0;
         }
         $localtax1_tx = get_localtax($tva_tx, 1, $this->client, $mysoc, $tva_npr);
         $localtax2_tx = get_localtax($tva_tx, 2, $this->client, $mysoc, $tva_npr);
         // 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->context = $this->context;
         $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->label;
         $line->product_desc = $prod->description;
         $line->fk_unit = $prod->fk_unit;
         // 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);
                      $prod->fetch($idproduct);
                      $prod -> get_sousproduits_arbo ();
                      $prods_arbo = $prod->get_each_prod();
                      if(count($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]);
         
                      }
                      }
         
                      }
                      **/
     }
 }
开发者ID:Albertopf,项目名称:prueba,代码行数:81,代码来源:commande.class.php


示例7: load_tva

 /**
  *      \brief      Output an HTML select vat rate
  *      \param      htmlname           Nom champ html
  *      \param      selectedrate       Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
  *      \param      societe_vendeuse   Objet societe vendeuse
  *      \param      societe_acheteuse  Objet societe acheteuse
  *      \param      idprod             Id product
  *      \param      info_bits          Miscellanous information on line
  *      \param      type               ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
  *      \remarks    Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
  *                  Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
  *                  Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  Sinon la TVA proposee par defaut=0. Fin de regle.
  */
 function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '')
 {
     global $langs, $conf, $mysoc;
     $return = '';
     $txtva = array();
     $libtva = array();
     $nprtva = array();
     // Define defaultnpr and defaultttx
     $defaultnpr = $info_bits & 0x1;
     $defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
     $defaulttx = str_replace('*', '', $selectedrate);
     // Check parameters
     if (is_object($societe_vendeuse) && !$societe_vendeuse->pays_code) {
         if ($societe_vendeuse->id == $mysoc->id) {
             $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
         }
         return $return;
     }
     //var_dump($societe_acheteuse);
     //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
     //exit;
     // Get list of all VAT rates to show
     // First we defined code_pays to use to find list
     if (is_object($societe_vendeuse)) {
         $code_pays = "'" . $societe_vendeuse->pays_code . "'";
     } else {
         $code_pays = "'" . $mysoc->pays_code . "'";
         // Pour compatibilite ascendente
     }
     if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
         if (!$societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany()) {
             // We also add the buyer
             if (is_numeric($type)) {
                 if ($type == 1) {
                     $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                 }
             } else {
                 if (!$idprod) {
                     $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                 } else {
                     $prodstatic = new Product($this->db);
                     $prodstatic->fetch($idprod);
                     if ($prodstatic->type == 1) {
                         $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                     }
                 }
             }
         }
     }
     // Now we get list
     $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
     $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_pays as p";
     $sql .= " WHERE t.fk_pays = p.rowid";
     $sql .= " AND t.active = 1";
     $sql .= " AND p.code in (" . $code_pays . ")";
     $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->num_rows($resql);
         if ($num) {
             for ($i = 0; $i < $num; $i++) {
                 $obj = $this->db->fetch_object($resql);
                 $txtva[$i] = $obj->taux;
                 $libtva[$i] = $obj->taux . '%';
                 $nprtva[$i] = $obj->recuperableonly;
             }
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $code_pays) . '</font>';
         }
     } else {
         $return .= '<font class="error">' . $this->db->error() . '</font>';
     }
     // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
     if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
         $defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
         $defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
     }
     // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
     // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
     if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
         $defaulttx = $txtva[sizeof($txtva) - 1];
     }
     $nbdetaux = sizeof($txtva);
//.........这里部分代码省略.........
开发者ID:netors,项目名称:dolibarr,代码行数:101,代码来源:html.form.class.php


示例8: addOrderLine

 /**
  * 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);
//.........这里部分代码省略.........
开发者ID:marcosgdf,项目名称:dolibarr-importorderlines,代码行数:101,代码来源:Utils.php


示例9: add_product

 /**
  * 	Add line into array products
  *	$this->client doit etre charge
  *
  * 	@param  int		$idproduct       	Product Id to add
  * 	@param  int		$qty             	Quantity
  * 	@param  int		$remise_percent  	Discount effected on Product
  *  @return	int							<0 if KO, >0 if OK
  *
  *	TODO	Remplacer les appels a cette fonction par generation objet Ligne
  *			insere dans tableau $this->products
  */
 function add_product($idproduct, $qty, $remise_percent = 0)
 {
     global $conf, $mysoc;
     if (!$qty) {
         $qty = 1;
     }
     dol_syslog(get_class($this) . "::add_product {$idproduct}, {$qty}, {$remise_percent}");
     if ($idproduct > 0) {
         $prod = new Product($this->db);
         $prod->fetch($idproduct);
         $productdesc = $prod->description;
         $tva_tx = get_default_tva($mysoc, $this->client, $prod->id);
         $tva_npr = get_default_npr($mysoc, $this->client, $prod->id);
         if (empty($tva_tx)) {
             $tva_npr = 0;
         }
         $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $this->client, $tva_npr);
         $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $this->client, $tva_npr);
         // multiprix
         if ($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) {
             $price = $prod->multiprices[$this->client->price_level];
         } else {
             $price = $prod->price;
         }
         $line = new SupplierProposalLine($this->db);
         $line->fk_product = $idproduct;
         $line->desc = $productdesc;
         $line->qty = $qty;
         $line->subprice = $price;
         $line->remise_percent = $remise_percent;
         $line->tva_tx = $tva_tx;
         $this->lines[] = $line;
     }
 }
开发者ID:Albertopf,项目名称:prueba,代码行数:46,代码来源:supplier_proposal.class.php


示例10: create


//.........这里部分代码省略.........
                 }
             }
         } else {
             $fk_parent_line = 0;
             dol_syslog("There is " . count($this->lines) . " lines that are array lines");
             foreach ($this->lines as $i => $val) {
                 if (($this->lines[$i]->info_bits & 0x1) == 0) {
                     // Reset fk_parent_line for no child products and special product
                     if ($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line) || $this->lines[$i]->product_type == 9) {
                         $fk_parent_line = 0;
                     }
                     $result = $this->addline($this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, $this->lines[$i]->tva_tx, $this->lines[$i]->localtax1_tx, $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, $this->lines[$i]->remise_percent, $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->fk_code_ventilation, $this->lines[$i]->info_bits, $this->lines[$i]->fk_remise_except, 'HT', 0, $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, $this->element, $this->lines[$i]->id, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, $this->lines[$i]->situation_percent, $this->lines[$i]->fk_prev_id, $this->lines[$i]->fk_unit);
                     if ($result < 0) {
                         $this->error = $this->db->lasterror();
                         dol_print_error($this->db);
                         $this->db->rollback();
                         return -1;
                     }
                     // Defined the new fk_parent_line
                     if ($result > 0 && $this->lines[$i]->product_type == 9) {
                         $fk_parent_line = $result;
                     }
                 }
             }
         }
         /*
          * Insert lines of predefined invoices
          */
         if (!$error && $this->fac_rec > 0) {
             foreach ($_facrec->lines as $i => $val) {
                 if ($_facrec->lines[$i]->fk_product) {
                     $prod = new Product($this->db);
                     $res = $prod->fetch($_facrec->lines[$i]->fk_product);
                 }
                 $tva_tx = get_default_tva($mysoc, $soc, $prod->id);
                 $tva_npr = get_default_npr($mysoc, $soc, $prod->id);
                 if (empty($tva_tx)) {
                     $tva_npr = 0;
                 }
                 $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
                 $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
                 $result_insert = $this->addline($_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, '', '', 0, $tva_npr, '', 'HT', 0, $_facrec->lines[$i]->product_type, $_facrec->lines[$i]->rang, $_facrec->lines[$i]->special_code, '', 0, 0, null, 0, $_facrec->lines[$i]->label, null, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit);
                 if ($result_insert < 0) {
                     $error++;
                     $this->error = $this->db->error();
                     break;
                 }
             }
         }
         if (!$error) {
             $result = $this->update_price(1);
             if ($result > 0) {
                 $action = 'create';
                 // Actions on extra fields (by external module or standard code)
                 // TODO le hook fait double emploi avec le trigger !!
                 $hookmanager->initHooks(array('invoicedao'));
                 $parameters = array('invoiceid' => $this->id);
                 $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action);
                 // Note that $action and $object may have been modified by some hooks
                 if (empty($reshook)) {
                     if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
                         $result = $this->insertExtraFields();
                         if ($result < 0) {
                             $error++;
                         }
                     }
                 } else {
                     if ($reshook < 0) {
                         $error++;
                     }
                 }
                 // Call trigger
                 $result = $this->call_trigger('BILL_CREATE', $user);
                 if ($result < 0) {
                     $error++;
                 }
                 // End call triggers
                 if (!$error) {
                     $this->db->commit();
                     return $this->id;
                 } else {
                     $this->db->rollback();
                     return -4;
                 }
             } else {
                 $this->error = $langs->trans('FailedToUpdatePrice');
                 $this->db->rollback();
                 return -3;
             }
         } else {
             dol_syslog(get_class($this) . "::create error " . $this->error, LOG_ERR);
             $this->db->rollback();
             return -2;
         }
     } else {
         $this->error = $this->db->error();
         $this->db->rollback();
         return -1;
     }
 }
开发者ID:Albertopf,项目名称:prueba,代码行数:101,代码来源:facture.class.php


示例11: load_tva

 /**
  *  Output an HTML select vat rate
  *
  *  @param	string	$htmlname           Nom champ html
  *  @param  float	$selectedrate       Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
  *  @param  Societe	$societe_vendeuse   Objet societe vendeuse
  *  @param  Societe	$societe_acheteuse  Objet societe acheteuse
  *  @param  int		$idprod             Id product
  *  @param  int		$info_bits          Miscellaneous information on line (1 for NPR)
  *  @param  int		$type               ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
  *                  					Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
  *                  					Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  					Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
  *                                      Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle.
  *                                      Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
  *                  					Sinon la TVA proposee par defaut=0. Fin de regle.
  *  @param	bool	$options_only		Return options only (for ajax treatment)
  *  @return	string
  */
 function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false)
 {
     global $langs, $conf, $mysoc;
     $return = '';
     $txtva = array();
     $libtva = array();
     $nprtva = array();
     // Define defaultnpr and defaultttx
     $defaultnpr = $info_bits & 0x1;
     $defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
     $defaulttx = str_replace('*', '', $selectedrate);
     // Check parameters
     if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
         if ($societe_vendeuse->id == $mysoc->id) {
             $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
         }
         return $return;
     }
     //var_dump($societe_acheteuse);
     //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->country_code." buyer=".$societe_acheteuse->country_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
     //exit;
     // Define list of countries to use to search VAT rates to show
     // First we defined code_country to use to find list
     if (is_object($societe_vendeuse)) {
         $code_country = "'" . $societe_vendeuse->country_code . "'";
     } else {
         $code_country = "'" . $mysoc->country_code . "'";
         // Pour compatibilite ascendente
     }
     if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
         if (!$societe_vendeuse->isInEEC() && (!is_object($societe_acheteuse) || $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany())) {
             // We also add the buyer
             if (is_numeric($type)) {
                 if ($type == 1) {
                     $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                 }
             } else {
                 if (!$idprod) {
                     $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                 } else {
                     $prodstatic = new Product($this->db);
                     $prodstatic->fetch($idprod);
                     if ($prodstatic->type == 1) {
                         $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                     }
                 }
             }
         }
     }
     // Now we get list
     $num = $this->load_cache_vatrates($code_country);
     if ($num > 0) {
         // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             $defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
             $defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
         }
         // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
         // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
                 $defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
             } else {
                 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
             }
         }
         // Disabled if seller is not subject to VAT
         $disabled = false;
         $title = '';
         if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") {
             $title = ' title="' . $langs->trans('VATIsNotUsed') . '"';
             $disabled = true;
         }
         if (!$options_only) {
             $return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled="disabled"' : '') . $title . '>';
         }
         foreach ($this->cache_vatrates as $rate) {
             // Keep only 0 if seller is not subject to VAT
             if ($disabled && $rate['txtva'] != 0) {
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:html.form.class.php


示例12: get_default_tva

 if ($rowid) {
     print '<input type="hidden" name="qty" value="' . $object->fourn_qty . '">';
     print $object->fourn_qty;
 } else {
     print '<input class="flat" name="qty" size="5" value="' . $quantity . '">';
 }
 print '</td></tr>';
 // Vat rate
 $default_vat = '';
 // We don't have supplier, so we try to guess.
 // For this we build a fictive supplier with same properties than user but using vat)
 $mysoc2 = clone $mysoc;
 $mysoc2->name = 'Fictive seller with same country';
 $mysoc2->tva_assuj = 1;
 $default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0);
 $default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0);
 if (empty($default_vat)) {
     $default_npr = $default_vat;
 }
 print '<tr><td class="fieldrequired">' . $langs->trans("VATRateForSupplierProduct") . '</td>';
 print '<td>';
 //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc);    // Do not use list here as it may be any vat rates for any country
 if (!empty($rowid)) {
     $tmpproductsupplier = new ProductFournisseur($db);
     $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
     $default_vat = $tmpproductsupplier->fourn_tva_tx;
     $default_npr = $tmpproductsupplier->fourn_tva_npr;
 } else {
     if (empty($default_vat)) {
         $default_vat = $object->tva_tx;
     }
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:fournisseurs.php


示例13: load_tva

 /**
  *  Output an HTML select vat rate
  *
  *  @param	string	$htmlname           Nom champ html
  *  @param  float	$selectedrate       Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
  *  @param  Societe	$societe_vendeuse   Objet societe vendeuse
  *  @param  Societe	$societe_acheteuse  Objet societe acheteuse
  *  @param  int		$idprod             Id product
  *  @param  int		$info_bits          Miscellaneous information on line (1 for NPR)
  *  @param  int		$type               ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
  *                  					Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
  *                  					Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  					Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
  *                  					Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  					Sinon la TVA proposee par defaut=0. Fin de regle.
  *  @param	bool	$options_only		Return options only (for ajax treatment)
  *  @return	void
  */
 function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false)
 {
     global $langs, $conf, $mysoc;
     $return = '';
     $txtva = array();
     $libtva = array();
     $nprtva = array();
     // Define defaultnpr and defaultttx
     $defaultnpr = $info_bits & 0x1;
     $defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
     $defaulttx = str_replace('*', '', $selectedrate);
     // Check parameters
     if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
         if ($societe_vendeuse->id == $mysoc->id) {
             $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
         }
         return $return;
     }
     //var_dump($societe_acheteuse);
     //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->country_code." buyer=".$societe_acheteuse->country_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
     //exit;
     // Get list of all VAT rates to show
     // First we defined code_pays to use to find list
     if (is_object($societe_vendeuse)) {
         $code_pays = "'" . $societe_vendeuse->country_code . "'";
     } else {
         $code_pays = "'" . $mysoc->country_code . "'";
         // Pour compatibilite ascendente
     }
     if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
         // If option to have vat for end customer for services is on
         if (!$societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany()) {
             // We also add the buyer
             if (is_numeric($type)) {
                 if ($type == 1) {
                     // We know product is a service
                     $code_pays .= ",'" . $societe_acheteuse->country_code . "'";
                 }
             } else {
                 if (!$idprod) {
                     // We don't know type of product
                     $code_pays .= ",'" . $societe_acheteuse->country_code . "'";
                 } else {
                     $prodstatic = new Product($this->db);
                     $prodstatic->fetch($idprod);
                     if ($prodstatic->type == 1) {
                         // We know product is a service
                         $code_pays .= ",'" . $societe_acheteuse->country_code . "'";
                     }
                 }
             }
         }
     }
     // Now we get list
     $num = $this->load_cache_vatrates($code_pays);
     if ($num > 0) {
         // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             $defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
             $defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
         }
         // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
         // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             $defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
         }
         if (!$options_only) {
             $return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
         }
         foreach ($this->cache_vatrates as $rate) {
             $return .= '<option value="' . $rate['txtva'];
             $return .= $rate['nprtva'] ? '*' : '';
             $return .= '"';
             if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) {
                 $return .= ' selected="selected"';
             }
             $return .= '>' . vatrate($rate['libtva']);
             $return .= $rate['nprtva'] ? ' *' : '';
             $return .= '</option>';
             $this->tva_taux_value[] = $rate['txtva'];
//.........这里部分代码省略.........
开发者ID:nrjacker4,项目名称:crm-php,代码行数:101,代码来源:html.form.class.php



注:本文中的get_default_npr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_default_post_to_edit函数代码示例发布时间:2022-05-15
下一篇:
PHP get_default_feed函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap