当前位置: 首页>>代码示例>>PHP>>正文


PHP Societe::setMysoc方法代码示例

本文整理汇总了PHP中Societe::setMysoc方法的典型用法代码示例。如果您正苦于以下问题:PHP Societe::setMysoc方法的具体用法?PHP Societe::setMysoc怎么用?PHP Societe::setMysoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Societe的用法示例。


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

示例1: calcul_price_total

/**
 *		Calculate totals (net, vat, ...) of a line.
 *		Value for localtaxX_type are	'0' : local tax not applied
 *										'1' : local tax apply on products and services without vat (localtax is calculated on amount without tax)
 *										'2' : local tax apply on products and services including vat (localtax is calculated on amount + tax)
 *										'3' : local tax apply on products without vat (localtax is calculated on amount without tax)
 *										'4' : local tax apply on products including vat (localtax is calculated on amount + tax)
 *										'5' : local tax apply on services without vat (localtax is calculated on amount without tax)
 *										'6' : local tax apply on services including vat (localtax is calculated on amount + tax)
 *
 *		@param	int		$qty						Quantity
 * 		@param 	float	$pu                         Unit price (HT or TTC selon price_base_type)
 *		@param 	float	$remise_percent_ligne       Discount for line
 *		@param 	float	$txtva                      0=do not apply standard tax, Vat rate=apply
 *		@param  float	$uselocaltax1_rate          0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
 *		@param  float	$uselocaltax2_rate          0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
 *		@param 	float	$remise_percent_global		0
 *		@param	string	$price_base_type 			HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
 *		@param	int		$info_bits					Miscellaneous informations on line
 *		@param	int		$type						0/1=Product/service
 *		@param  Societe	$seller						Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
 *		@param  array	$localtaxes_array			Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
 *		@param  integer	$progress                   Situation invoices progress (value from 0 to 100, 100 by default)
 *		@return result[ 0=total_ht,
 *						 1=total_vat, (main vat only)
 *						 2=total_ttc, (total_ht + main vat + local taxes)
 *						 3=pu_ht,
 *						 4=pu_vat, (main vat only)
 *						 5=pu_ttc,
 *						 6=total_ht_without_discount,
 *						 7=total_vat_without_discount, (main vat only)
 *						 8=total_ttc_without_discount, (total_ht + main vat + local taxes)
 *						 9=total_tax1 for total_ht,
 *						10=total_tax2 for total_ht,
 *						11=pu_tax1 for pu_ht, !! should not be used
 *						12=pu_tax2 for pu_ht, !! should not be used
 *						13=!! should not be used
 *						14=total_tax1 for total_ht_without_discount,
 *						15=total_tax2 for total_ht_without_discount]
 */
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100)
{
    global $conf, $mysoc, $db;
    $result = array();
    // Clean parameters
    if (empty($txtva)) {
        $txtva = 0;
    }
    if (empty($seller) || !is_object($seller)) {
        dol_syslog("calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING);
        if (!is_object($mysoc)) {
            $mysoc = new Societe($db);
            $mysoc->setMysoc($conf);
        }
        $seller = $mysoc;
        // If sell is done to a customer, $seller is not provided, we use $mysoc
        //var_dump($seller->country_id);exit;
    }
    if (empty($localtaxes_array) || !is_array($localtaxes_array)) {
        dol_syslog("calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING);
    }
    // Too verbose. Enable for debug only
    //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);
    $countryid = $seller->country_id;
    if (is_numeric($uselocaltax1_rate)) {
        $uselocaltax1_rate = (double) $uselocaltax1_rate;
    }
    if (is_numeric($uselocaltax2_rate)) {
        $uselocaltax2_rate = (double) $uselocaltax2_rate;
    }
    if ($uselocaltax1_rate < 0) {
        $uselocaltax1_rate = $seller->localtax1_assuj;
    }
    if ($uselocaltax2_rate < 0) {
        $uselocaltax2_rate = $seller->localtax2_assuj;
    }
    dol_syslog('Price.lib::calcul_price_total qty=' . $qty . ' pu=' . $pu . ' remise_percent_ligne=' . $remise_percent_ligne . ' txtva=' . $txtva . ' uselocaltax1_rate=' . $uselocaltax1_rate . ' uselocaltax2_rate=' . $uselocaltax2_rate . ' remise_percent_global=' . $remise_percent_global . ' price_base_type=' . $price_base_type . ' type=' . $type . ' progress=' . $progress);
    // Now we search localtaxes information ourself (rates and types).
    $localtax1_type = 0;
    $localtax2_type = 0;
    if (is_array($localtaxes_array)) {
        $localtax1_type = $localtaxes_array[0];
        $localtax1_rate = $localtaxes_array[1];
        $localtax2_type = $localtaxes_array[2];
        $localtax2_rate = $localtaxes_array[3];
    } else {
        $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type";
        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as cv";
        $sql .= " WHERE cv.taux = " . $txtva;
        $sql .= " AND cv.fk_pays = " . $countryid;
        dol_syslog("calcul_price_total search vat information using old deprecated method", LOG_WARNING);
        $resql = $db->query($sql);
        if ($resql) {
            $obj = $db->fetch_object($resql);
            if ($obj) {
                $localtax1_rate = $obj->localtax1;
                $localtax2_rate = $obj->localtax2;
                $localtax1_type = $obj->localtax1_type;
                $localtax2_type = $obj->localtax2_type;
                //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit;
//.........这里部分代码省略.........
开发者ID:Albertopf,项目名称:prueba,代码行数:101,代码来源:price.lib.php

示例2: migrate_price_contrat

/**
 * Update total of contract lines
 *
 * @param	DoliDB		$db		Database handler
 * @param	Translate	$langs	Object langs
 * @param	Conf		$conf	Object conf
 * @return	void
 */
function migrate_price_contrat($db, $langs, $conf)
{
    $db->begin();
    $tmpmysoc = new Societe($db);
    $tmpmysoc->setMysoc($conf);
    if (empty($tmpmysoc->country_id)) {
        $tmpmysoc->country_id = 0;
    }
    // Ti not have this set to '' or will make sql syntax error.
    print '<tr><td colspan="4">';
    print '<br>';
    print '<b>' . $langs->trans('MigrationContract') . "</b><br>\n";
    // Liste des lignes contrat non a jour
    $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
    $sql .= " c.rowid as contratid";
    $sql .= " FROM " . MAIN_DB_PREFIX . "contratdet as cd, " . MAIN_DB_PREFIX . "contrat as c";
    $sql .= " WHERE cd.fk_contrat = c.rowid";
    $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)";
    dolibarr_install_syslog("upgrade2::migrate_price_contrat", LOG_DEBUG);
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        if ($num) {
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $rowid = $obj->rowid;
                $qty = $obj->qty;
                $pu = $obj->subprice;
                $txtva = $obj->tva_taux;
                $remise_percent = $obj->remise_percent;
                $info_bits = $obj->info_bits;
                // On met a jour les 3 nouveaux champs
                $contratligne = new ContratLigne($db);
                //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
                $contratligne->id = $rowid;
                $result = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, 'HT', $info_bits, 0, $tmpmysoc);
                $total_ht = $result[0];
                $total_tva = $result[1];
                $total_ttc = $result[2];
                $contratligne->total_ht = $total_ht;
                $contratligne->total_tva = $total_tva;
                $contratligne->total_ttc = $total_ttc;
                dolibarr_install_syslog("upgrade2: Line {$rowid}: contratdetid={$obj->rowid} pu={$pu} qty={$qty} tva_taux={$txtva} remise_percent={$remise_percent} -> {$total_ht}, {$total_tva}, {$total_ttc}");
                print ". ";
                $contratligne->update_total();
                $i++;
            }
        } else {
            print $langs->trans("AlreadyDone");
        }
        $db->free($resql);
        $db->commit();
    } else {
        print "Error #1 " . $db->error();
        $db->rollback();
    }
    print '<br>';
    print '</td></tr>';
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:68,代码来源:upgrade2.php

示例3: Societe

            print 'You are logged with user "' . $_SESSION["dol_login"] . '" and only administrator user "' . $conf->global->MAIN_ONLY_LOGIN_ALLOWED . '" is allowed to connect for the moment.' . "\n";
            $nexturl = DOL_URL_ROOT . '/user/logout.php';
            print 'Please try later or <a href="' . $nexturl . '">click here to disconnect and change login user</a>...' . "\n";
        } else {
            print 'Sorry, your application is offline. Only administrator user "' . $conf->global->MAIN_ONLY_LOGIN_ALLOWED . '" is allowed to connect for the moment.' . "\n";
            $nexturl = DOL_URL_ROOT . '/';
            print 'Please try later or <a href="' . $nexturl . '">click here to change login user</a>...' . "\n";
        }
        exit;
    }
}
// Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) {
    require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
    $mysoc = new Societe($db);
    $mysoc->setMysoc($conf);
    // For some countries, we need to invert our address with customer address
    if ($mysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
        $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
    }
}
// Set default language (must be after the setValues setting global $conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later)
if (!defined('NOREQUIRETRAN')) {
    $langcode = GETPOST('lang') ? GETPOST('lang', 'alpha', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
    $langs->setDefaultLang($langcode);
}
// Create the global $hookmanager object
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
if (!defined('MAIN_LABEL_MENTION_NPR')) {
    define('MAIN_LABEL_MENTION_NPR', 'NPR');
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:master.inc.php

示例4: migrate_price_commande_fournisseur

/**
 * Mise a jour des totaux lignes de commande fournisseur
 *
 * @param	DoliDB		$db		Database handler
 * @param	Translate	$langs	Object langs
 * @param	Conf		$conf	Object conf
 * @return	void
 */
function migrate_price_commande_fournisseur($db, $langs, $conf)
{
    $db->begin();
    $tmpmysoc = new Societe($db);
    $tmpmysoc->setMysoc($conf);
    print '<tr><td colspan="4">';
    print '<br>';
    print '<b>' . $langs->trans('MigrationSupplierOrder') . "</b><br>\n";
    // Liste des lignes commande non a jour
    $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,";
    $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
    $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd, " . MAIN_DB_PREFIX . "commande_fournisseur as c";
    $sql .= " WHERE cd.fk_commande = c.rowid";
    $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
    dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur");
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        if ($num) {
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $rowid = $obj->rowid;
                $qty = $obj->qty;
                $pu = $obj->subprice;
                $vatrate = $obj->vatrate;
                $remise_percent = $obj->remise_percent;
                $remise_percent_global = $obj->remise_percent_global;
                $info_bits = $obj->info_bits;
                // On met a jour les 3 nouveaux champs
                $commandeligne = new CommandeFournisseurLigne($db);
                $commandeligne->fetch($rowid);
                $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc);
                $total_ht = $result[0];
                $total_tva = $result[1];
                $total_ttc = $result[2];
                $commandeligne->total_ht = $total_ht;
                $commandeligne->total_tva = $total_tva;
                $commandeligne->total_ttc = $total_ttc;
                dolibarr_install_syslog("upgrade2: Line " . $rowid . ": commandeid=" . $obj->rowid . " pu=" . $pu . "  qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc);
                print ". ";
                $commandeligne->update_total();
                /* On touche pas a facture mere
                   $commande = new Commande($db);
                   $commande->id = $obj->rowid;
                   if ( $commande->fetch($commande->id) >= 0 )
                   {
                   if ( $commande->update_price() > 0 )
                   {
                   print ". ";
                   }
                   else
                   {
                   print "Error id=".$commande->id;
                   }
                   }
                   else
                   {
                   print "Error #3";
                   }
                   */
                $i++;
            }
        } else {
            print $langs->trans("AlreadyDone");
        }
        $db->free($resql);
        /*
        $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
        $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
        $resql=$db->query($sql);
        if (! $resql)
        {
        dol_print_error($db);
        }
        */
        $db->commit();
    } else {
        print "Error #1 " . $db->error();
        $db->rollback();
    }
    print '<br>';
    print '</td></tr>';
}
开发者ID:Albertopf,项目名称:prueba,代码行数:92,代码来源:upgrade2.php


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