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


PHP sqlGenID函数代码示例

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


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

示例1: invoice_item

 /**
  * Insert invoice_item_tax Records
  */
 function invoice_item($invoice_id, $invoice_item_id, $account_id, $tax_arr)
 {
     $db =& DB();
     if (!is_array($tax_arr)) {
         return false;
     }
     foreach ($tax_arr as $tax) {
         $sql = "INSERT INTO " . AGILE_DB_PREFIX . "invoice_item_tax SET id=" . sqlGenID($db, "invoice_item_tax") . ", site_id=" . DEFAULT_SITE . ", date_orig=" . time() . ", invoice_id={$invoice_id}, invoice_item_id={$invoice_item_id}, account_id={$account_id}, tax_id={$tax["id"]}, amount=" . $db->qstr($tax["rate"]);
         $db->Execute($sql);
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:14,代码来源:tax.inc.php

示例2: c_task

 /**
  * TODO: Accountcode based rating, Prepaid based rating
  */
 function c_task($VAR)
 {
     # set the PHP timeout and the don't abort flag
     set_time_limit(60 * 15);
     # normalize the CDR records
     if ($this->perform_normalization) {
         echo "Begin normalization...\n";
         $this->normalize($db);
         echo "Finished normalization...\n";
     }
     # Add in the prepaid rating pieces
     # Begin the postpaid rating
     $bDoCallType = false;
     if (strlen($this->voip_intrastate)) {
         $bDoCallType = true;
     }
     $db =& DB();
     $sql = "select * from " . AGILE_DB_PREFIX . "voip_cdr where \n\t\t(lastapp='Dial' or lastapp='VoiceMail' or lastapp='MeetMe' or lastapp='Hangup') \n\t\tAND disposition='ANSWERED' and rated=2 limit 1000";
     $rs = $db->Execute($sql);
     $i = 0;
     $total = 0.0;
     $st = $this->microtime_float();
     while (!$rs->EOF) {
         unset($match);
         # who does the number belong to?
         $account_id = 0;
         $service_id = 0;
         $product_id = 0;
         $callSQL = "";
         find_owner($rs->fields['src'], $account_id, $service_id, $product_id, $callSQL);
         $isInbound = 0;
         $calltype = 0;
         if ($bDoCallType) {
             $calltype = $this->isIntrastateCall($rs->fields['src'], $rs->fields['dst']);
         }
         #echo "Account: {$account_id} on src\n";
         if ($account_id === false) {
             find_owner($rs->fields['dst'], $account_id, $service_id, $product_id, $callSQL);
             $isInbound = 1;
             $calltype = 4;
             #echo "AccountL {$account_id} on dst\n";
         }
         if ($account_id !== false) {
             # echo "Account=$account_id Product=$product_id Service=$service_id<br />";
             # Retrieve the correct rate table
             $rt =& $this->c_load_rating_table($db, $product_id);
             if (is_resource($rt)) {
                 # Rate the call
                 $src = $isInbound ? $rs->fields['dst'] : $rs->fields['src'];
                 $dst = $isInbound ? $rs->fields['src'] : $rs->fields['dst'];
                 if ($match = agileco_search_rate_table($rt, strval($dst), intval($rs->fields['billsec']), intval($isInbound), strval($callSQL))) {
                     #echo "<pre>";
                     #echo "SRC=".$src."\n";
                     #echo "DST=".strval($dst)."\n";
                     #echo "BILLSEC=".intval($rs->fields['billsec'])."\n";
                     #echo "In Bound?=".intval($isInbound)."\n";
                     #echo "Call Type=".$calltype."\n";
                     #echo "callSQL=".$callSQL."\n\n";
                     #echo print_r($match,true);
                     #echo "\n";
                     #echo "</pre>";
                 } else {
                     #echo "SRC=".$src."\n";
                     #echo "DST=".strval($dst)."\n";
                     #echo "BILLSEC=".intval($rs->fields['billsec'])."\n";
                     #echo "In Bound?=".intval($isInbound)."\n";
                     #echo "Call Type=".$calltype."\n";
                     #echo 'Returned false.'."\n\n";
                     $match['amount'] = 0;
                     $match['quantity'] = 0;
                     $match['unit'] = 0;
                     $match['voip_rate_id'] = 0;
                 }
                 $rated = 1;
             } else {
                 echo "Product {$product_id} does not have a rating table.\n";
             }
         } else {
             $isInbound = 0;
             $account_id = 0;
             $calltype = 0;
             $rated = 3;
         }
         if (isset($match)) {
             $total += $match['amount'];
             $sql = "update " . AGILE_DB_PREFIX . "voip_cdr SET \n\t\t\t\t\taccount_id=" . $db->qstr($account_id) . ", \n\t\t\t\t\tamount=" . $db->qstr($match['amount']) . ", \n\t\t\t\t\tcalltype=" . $db->qstr($calltype) . ", \n\t\t\t\t\tvoip_rate_id=" . $db->qstr($match['voip_rate_id']) . ", \n\t\t\t\t\trated={$rated}, \n\t\t\t\t\tadjbillinterval=" . $db->qstr($match['quantity']) . ",\n\t\t\t\t\tsite_id=" . DEFAULT_SITE . "  \n\t\t\t\t\tWHERE id=" . $rs->fields['id'];
             #echo $sql."\n";
             if (!$db->Execute($sql)) {
                 echo $sql . "\n";
                 echo $db->ErrorMsg() . "\n";
             }
             $a = 'Source==' . $rs->fields['src'] . '\\r\\nDestination==' . $rs->fields['dst'];
             $a .= '\\r\\nvoip_cdr_id==' . $rs->fields['id'] . '\\r\\ndate_orig==' . $rs->fields['date_orig'];
             if (isset($match['connect_fee']) && $match['connect_fee']) {
                 $b = $a . '\\r\\nConnection Charge';
                 $cid = sqlGenID($db, "charge");
                 $sql = "INSERT INTO " . AGILE_DB_PREFIX . "charge SET\n\t\t\t\t\t\tid=" . $db->qstr($cid) . ",\n\t\t\t\t\t\tside_id=" . DEFAULT_SITE . ",\n\t\t\t\t\t\tdate_orig=." . $db->qstr($rs->fields['date_orig']) . ",\n\t\t\t\t\t\tstatus=0,\n\t\t\t\t\t\tsweep_type=6,\n\t\t\t\t\t\tproduct_id=" . $db->qstr($product_id) . ",\n\t\t\t\t\t\tservice_id=" . $db->qstr($service_id) . ",\n\t\t\t\t\t\tamount=" . $db->qstr($match['connect_fee']) . ",\n\t\t\t\t\t\tquantity=1,\n\t\t\t\t\t\ttaxable=0,\n\t\t\t\t\t\tattributes=" . $db->qstr($b);
//.........这里部分代码省略.........
开发者ID:supex,项目名称:agilebill,代码行数:101,代码来源:voip.inc.php

示例3: invoiceItemToService


//.........这里部分代码省略.........
         $price = $product->price_prod($prod->fields, $this->recurring_schedule, $invoice->fields['account_id'], false);
         $this->price = $price['base'] / $item->fields['quantity'];
         # Get the price of any attributes:
         $price = $product->price_attr($prod->fields, $item->fields['product_attr_cart'], $this->recurring_schedule, $invoice->fields['account_id'], false);
         $this->price += $price['base'] / $item->fields['quantity'];
     }
     # Service settings:
     $this->active = '1';
     $this->queue = 'new';
     $this->host_ip = '';
     $this->host_username = '';
     $this->host_password = '';
     $this->domain_host_tld_id = '';
     $this->domain_host_registrar_id = '';
     $this->domain_date_expire = '';
     # Parent ID
     $this->parent_id = $service_id;
     # determine if groups defined:
     $groups_defined = false;
     if (!empty($prod->fields['assoc_grant_group'])) {
         // type > 0 or num of days defined?
         if ($prod->fields['assoc_grant_group_type'] > 0 || $prod->fields['assoc_grant_group_days'] > 0) {
             // actual groups defined?
             $grant_groups = unserialize($prod->fields['assoc_grant_group']);
             if (is_array($grant_groups) && count($grant_groups) > 0) {
                 foreach ($grant_groups as $key => $group_id) {
                     if ($group_id > 0) {
                         $groups_defined = true;
                         break;
                     }
                 }
             }
         }
         if (!$groups_defined) {
             $prod->fields['assoc_grant_group'] = false;
             $prod->fields['assoc_grant_group_type'] = false;
             $prod->fields['assoc_grant_group_days'] = false;
         }
     }
     # Determine the Service Type:
     $this->type = 'none';
     if ($item->fields['item_type'] == '0') {
         # NONE, GROUP, PRODUCT, OR PRODUCT_GROUP:
         if (!$groups_defined && empty($prod->fields['prod_plugin'])) {
             $this->type = 'none';
         } else {
             if ($groups_defined && !empty($prod->fields['prod_plugin'])) {
                 $this->type = 'product_group';
             } elseif (!empty($prod->fields['prod_plugin'])) {
                 $this->type = 'product';
             } elseif ($groups_defined) {
                 $this->type = 'group';
             }
         }
     } elseif ($item->fields['item_type'] == '1') {
         # HOSTING:
         $this->type = 'host';
         $this->host_ip = '';
         $this->host_username = '';
         $this->host_password = '';
         # Is group access also defined?
         if (!empty($prod->fields['assoc_grant_group'])) {
             $this->type = 'host_group';
         }
     } elseif ($item->fields['item_type'] == '2') {
         # DOMAIN:
         $this->type = 'domain';
         $this->domain_date_expire = time() + $item->fields['domain_term'] * (86400 * 365);
         # Get the host_tld_id
         $q = "SELECT id, registrar_plugin_id FROM " . AGILE_DB_PREFIX . "host_tld WHERE\n\t\t        \t  name \t\t=  " . $db->qstr($item->fields['domain_tld']) . " AND\n\t\t        \t  site_id \t=  " . $db->qstr(DEFAULT_SITE);
         $tld = $db->Execute($q);
         $this->domain_host_tld_id = $tld->fields['id'];
         $this->domain_host_registrar_id = $tld->fields['registrar_plugin_id'];
     }
     if ($this->type == "none" && $this->recurring_schedule == "") {
         # do not create service for one-time charge with no hosting,domain, or group settings
     } else {
         # Create the service record(s):
         for ($iii = 0; $iii < $item->fields['quantity']; $iii++) {
             $this->id = sqlGenID($db, "service");
             $fields = array('date_orig' => time(), 'date_orig' => time(), 'parent_id' => $this->parent_id, 'invoice_id' => $item->fields['invoice_id'], 'invoice_item_id' => $invoice_item_id, 'account_id' => $invoice->fields['account_id'], 'account_billing_id' => $invoice->fields['account_billing_id'], 'product_id' => $item->fields['product_id'], 'sku' => $item->fields['sku'], 'active' => $this->active, 'bind' => $this->bind, 'type' => $this->type, 'queue' => $this->queue, 'price' => $this->price, 'price_type' => $item->fields['price_type'], 'taxable' => $prod->fields['taxable'], 'date_last_invoice' => $invoice->fields['date_orig'], 'date_next_invoice' => $this->next_invoice, 'recur_schedule' => $this->recurring_schedule, 'recur_type' => $prod->fields['price_recurr_type'], 'recur_weekday' => $prod->fields['price_recurr_weekday'], 'recur_week' => $prod->fields['price_recurr_week'], 'recur_schedule_change' => $prod->fields['price_recurr_schedule'], 'recur_cancel' => $prod->fields['price_recurr_cancel'], 'recur_modify' => $prod->fields['price_recurr_modify'], 'group_grant' => $prod->fields['assoc_grant_group'], 'group_type' => $prod->fields['assoc_grant_group_type'], 'group_days' => $prod->fields['assoc_grant_group_days'], 'host_server_id' => $prod->fields['host_server_id'], 'host_provision_plugin_data' => $prod->fields['host_provision_plugin_data'], 'host_ip' => $this->host_ip, 'host_username' => $this->host_username, 'host_password' => $this->host_password, 'domain_name' => $item->fields['domain_name'], 'domain_tld' => $item->fields['domain_tld'], 'domain_term' => $item->fields['domain_term'], 'domain_type' => $item->fields['domain_type'], 'domain_date_expire' => $this->domain_date_expire, 'domain_host_tld_id' => $this->domain_host_tld_id, 'domain_host_registrar_id' => $this->domain_host_registrar_id, 'prod_attr' => $item->fields['product_attr'], 'prod_attr_cart' => $item->fields['product_attr_cart'], 'prod_plugin_name' => @$prod->fields["prod_plugin_file"], 'prod_plugin_data' => @$prod->fields["prod_plugin_data"]);
             $rs =& $db->Execute(sqlInsert($db, "service", $fields, $this->id));
             if ($rs === false) {
                 global $C_debug;
                 $C_debug->error('service.inc.php', 'invoiceItemToService', $q . " | " . @$db->ErrorMsg());
             } else {
                 # Run the queue on this item:
                 $arr['id'] = $this->id;
                 $this->queue($arr, $this);
             }
         }
     }
     # Create any discount codes:
     if ($prod->fields['discount'] == '1' && !empty($prod->fields['discount_amount'])) {
         $id = $db->GenID(AGILE_DB_PREFIX . 'discount_id');
         $q = "INSERT INTO " . AGILE_DB_PREFIX . "discount SET\n\t        \tid\t\t\t\t\t= " . $db->qstr($id) . ",\n\t        \tsite_id\t\t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t        \tdate_orig\t\t\t= " . $db->qstr(time()) . ",\n\t        \tdate_start\t\t\t= " . $db->qstr(time()) . ",\n\t        \tstatus\t\t\t\t= " . $db->qstr('1') . ",\n\t        \tname\t\t\t\t= " . $db->qstr('DISCOUNT-' . $id) . ",\n\t        \tnotes\t\t\t\t= " . $db->qstr('Autogenerated for Invoice Number ' . $item->fields['invoice_id'] . ', SKU ' . $item->fields['sku']) . ",\n\t        \tmax_usage_account \t= " . $db->qstr('1') . ",\n\t        \tmax_usage_global\t= " . $db->qstr('1') . ",\n\t        \tavail_account_id\t= " . $db->qstr($invoice->fields['account_id']) . ",\n\t        \tnew_status\t\t\t= " . $db->qstr('1') . ",\n\t        \tnew_type\t\t\t= " . $db->qstr('1') . ",\n\t        \tnew_rate\t\t\t= " . $db->qstr($prod->fields['discount_amount']) . ",\n\t        \trecurr_status\t\t= " . $db->qstr('1') . ",\n\t        \trecurr_type\t\t\t= " . $db->qstr('1') . ",\n\t        \trecurr_rate\t\t\t= " . $db->qstr($prod->fields['discount_amount']);
         $db->Execute($q);
     }
     return true;
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:service.inc.php

示例4: provision_did_new

 /** provision did */
 function provision_did_new($obj)
 {
     @($a = unserialize($obj->service['prod_attr_cart']));
     $did = $a['station'];
     // new or top-up?
     $db =& DB();
     $didrs = $db->Execute($sql = sqlSelect($db, "voip_prepaid", "id,pin,balance", "pin = ::{$did}:: AND voip_did_id is not null AND voip_did_id <> 0 "));
     if ($didrs && $didrs->RecordCount() > 0) {
         $new = false;
     } else {
         $new = true;
     }
     // the balance from the invoice line item (not including setup fee)
     $itemid = $obj->service['invoice_item_id'];
     $invoiceItem = $db->Execute(sqlSelect($db, "invoice_item", "price_base", "id = {$itemid}"));
     if ($invoiceItem && $invoiceItem->RecordCount() > 0) {
         $balance = $invoiceItem->fields['price_base'];
     } else {
         $balance = $obj->service['price'];
     }
     /*
     		echo "<BR><BR>$sql<BR><BR>";
     		
     		echo $new;
      
     		echo "$".$balance;
     		
     		#print_r($obj->service);
     */
     if ($new) {
         // include voip plugin and provision the did
         include_once PATH_PLUGINS . 'product/VOIP.php';
         $voip = new plgn_prov_VOIP();
         if (!$voip->p_one($obj->service_id)) {
             return false;
         }
         # create the prepaid record
         $didrs = $db->Execute(sqlSelect($db, "voip_did", "id,did", "service_id = ::{$obj->service_id}::"));
         if ($didrs && $didrs->RecordCount() > 0) {
             $fields = array('account_id' => $obj->account['id'], 'product_id' => $obj->service['product_id'], 'voip_did_id' => $didrs->fields['id'], 'pin' => $didrs->fields['did'], 'balance' => $balance, 'in_use' => 0);
             $pin_id = sqlGenID($db, "voip_prepaid");
             $sql = sqlInsert($db, "voip_prepaid", $fields, $pin_id);
             $rs = $db->Execute($sql);
             return true;
         } else {
             return false;
         }
     } else {
         # top-up the prepaid balance
         $fields = array('balance' => $balance + $didrs->fields['balance']);
         $db->Execute($sql = sqlUpdate($db, "voip_prepaid", $fields, "id = {$didrs->fields['id']}"));
         return true;
     }
     return true;
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:56,代码来源:voip_prepaid.inc.php

示例5: sqlInsert

function sqlInsert(&$db, $table, $fields, $id = false)
{
    if (!$id) {
        $id = sqlGenID($db, $table);
    }
    $fields['id'] = $id;
    if (empty($fields['site_id'])) {
        $fields['site_id'] = DEFAULT_SITE;
    }
    $tab = AGILE_DB_PREFIX . '' . $table;
    return $db->GetInsertSQL($tab, $fields, get_magic_quotes_gpc());
}
开发者ID:hbustun,项目名称:agilebill,代码行数:12,代码来源:database.inc.php

示例6: invoice_item

 /**
  * Commit current discounts to the database (call after creating an invoice_item record)
  */
 function invoice_item($invoice_id, $invoice_item_id, $account_id, $discount_arr = false)
 {
     if ($discount_arr && is_array($discount_arr)) {
         $this->discount_arr = $discount_arr;
     }
     if (is_array($this->discount_arr)) {
         $db =& DB();
         foreach ($this->discount_arr as $dsc) {
             $sql = "INSERT INTO " . AGILE_DB_PREFIX . "invoice_item_discount SET id=" . sqlGenID($db, "invoice_item_discount") . ", site_id=" . DEFAULT_SITE . ", invoice_id={$invoice_id}, account_id={$account_id}, invoice_item_id={$invoice_item_id}, discount=" . $db->qstr($dsc["discount"]) . ", amount=" . $db->qstr($dsc["amount"]);
             $db->Execute($sql);
         }
     }
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:16,代码来源:discount.inc.php

示例7: upgrade

    function upgrade($VAR)
    {
        if (!isset($VAR['module_name']) || !isset($VAR['module_group'])) {
            echo "You must select both the module(s) to upgrade and the groups to grant access to new methods to.";
            return;
        }
        $module_count = 0;
        $method_count = 0;
        $fields_count = 0;
        $method_new_count = 0;
        $fields_new_count = 0;
        # loop through each module
        $modules = $VAR['module_name'];
        for ($i = 0; $i < count($modules); $i++) {
            # increment module count
            $module_count++;
            # get the module details
            $db =& DB();
            $db_module = $db->Execute(sqlSelect($db, "module", "*", "id=::{$modules[$i]}:: or name=::{$modules[$i]}::"));
            $module_name = $db_module->fields['name'];
            $module_id = $db_module->fields['id'];
            #########################################################################
            # Update the Methods from the <module>_install.xml file
            # get the install xml file
            #########################################################################
            $install_xml = PATH_MODULES . $module_name . '/' . $module_name . '_install.xml';
            if (is_file($install_xml)) {
                $C_xml = new CORE_xml();
                @($methods = $C_xml->xml_to_array($install_xml));
                @($methods = $methods['install']['sql_inserts']['module_method']);
                # loop through the methods
                if (is_array($methods)) {
                    while (list($key, $value) = each($methods)) {
                        # increment method count
                        $method_count++;
                        # see if this method exists
                        $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'module_method WHERE
								   name         =  ' . $db->qstr($key) . ' AND
								   module_id    =  ' . $db->qstr($module_id) . ' AND
								   site_id      =  ' . $db->qstr(DEFAULT_SITE);
                        $method_db = $db->Execute($sql);
                        if ($method_db === false) {
                            global $C_debug;
                            $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg());
                        }
                        if ($method_db->RecordCount() == 0) {
                            # increment method count
                            $method_new_count++;
                            ### add this method
                            @($notes = $methods[$key]["notes"]);
                            @($page = $methods[$key]["page"]);
                            @($menu_display = $methods[$key]["menu_display"]);
                            $method_id = sqlGenID($db, 'module_method');
                            $fields = array('name' => $key, 'module_id' => $module_id, 'notes' => $notes, 'page' => $page, 'menu_display' => $menu_display);
                            $db->Execute(sqlInsert($db, "module_method", $fields, $method_id));
                            if ($result === false) {
                                global $C_debug;
                                $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg());
                            }
                            ### Create the group_method records, with the ID from each
                            for ($ii = 0; $ii < count($VAR["module_group"]); $ii++) {
                                $group_method_id = $db->GenID(AGILE_DB_PREFIX . "" . 'group_method_id');
                                $q = 'INSERT INTO ' . AGILE_DB_PREFIX . 'group_method SET
									  id        = ' . $db->qstr($group_method_id) . ',
									  site_id   = ' . $db->qstr(DEFAULT_SITE) . ',
									  method_id = ' . $db->qstr($method_id) . ',
									  module_id = ' . $db->qstr($module_id) . ',
									  group_id  = ' . $db->qstr($VAR["module_group"][$ii]);
                                $result = $db->Execute($q);
                                if ($result === false) {
                                    global $C_debug;
                                    $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg());
                                }
                            }
                        }
                    }
                }
            }
            #########################################################################
            # Update the DB Fields from the <module>_construct.xml file
            # get the install xml file
            #########################################################################
            $construct_xml = PATH_MODULES . $module_name . '/' . $module_name . '_construct.xml';
            if (is_file($construct_xml)) {
                $C_xml = new CORE_xml();
                $construct = $C_xml->xml_to_array($construct_xml);
                @($fields = $construct['construct']['field']);
                ### Check that this Module has any db installation required...
                if (!empty($construct["construct"]["table"]) && $construct["construct"]["table"] == $module_name) {
                    ### Create the module DB table
                    $table = $construct["construct"]["table"];
                    $db =& DB();
                    $db_fields = $db->MetaColumns(AGILE_DB_PREFIX . $table, true);
                    ### Create the module DB fields
                    $arr_field = $construct["construct"]["field"];
                    ### Loop through the fields to build the list:
                    while (list($key, $value) = each($arr_field)) {
                        $field = $key;
                        $FIELD = strtoupper($key);
                        if (!isset($db_fields[$FIELD])) {
//.........这里部分代码省略.........
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:module.inc.php

示例8: add_radius

 /**
  * Add a radius entry
  */
 function add_radius($service_id, $radius_service_id, $username, $password = false)
 {
     // determine type of auth
     if (!$password) {
         $auth = 'wireless';
     } else {
         $auth = 'login';
     }
     // get the associated service
     $db =& DB();
     $rs = $db->Execute(sqlSelect($db, "service", "*", "id=::{$service_id}::"));
     if (!$rs || !$rs->RecordCount()) {
         return false;
     }
     $f['service_id'] = $service_id;
     $f['username'] = $username;
     $f['password'] = $password;
     $f['account_id'] = $rs->fields['account_id'];
     $f['sku'] = $rs->fields['sku'];
     $f['active'] = 1;
     // insert radius record
     $arr = unserialize($rs->fields['prod_plugin_data']);
     foreach ($arr as $a => $b) {
         if ($a != 'max') {
             $f[$a] = $b;
         }
     }
     $id = sqlGenID($db, "radius");
     $db->Execute($sql = sqlInsert($db, "radius", $f, $id));
     // update radius_service table
     $db->Execute(sqlUpdate($db, "radius_service", array('radius_id' => $id), "id = {$radius_service_id}"));
     return true;
 }
开发者ID:sluther,项目名称:agilebill,代码行数:36,代码来源:radius.inc.php

示例9: invoices


//.........这里部分代码省略.........
             $db->Execute($sql);
             # Insert the import record
             $this->import_transaction($this->plugin, $VAR['action'], 'invoice', $id, 'order_list', $rs->fields['iid'], &$db);
             ### Get / Insert Invoice Items:
             $dbr =& NewADOConnection($this->type);
             $dbr->Connect($this->host, $this->user, $this->pass, $this->db);
             $sql = "SELECT * FROM hosting_order WHERE oid = " . $dbr->qstr($rs->fields['oid']);
             $rs2 = $dbr->Execute($sql);
             if ($rs2 === false) {
                 $C_debug->alert("Query to the table 'hosting_order' failed!");
                 return false;
             }
             while (!$rs2->EOF) {
                 # Determine the domain type (DOMAIN-REGISTER or DOMAIN-TRANSFER or DOMAIN-PARK)
                 if (!empty($rs2->fields['domain_registration'])) {
                     $sku = 'DOMAIN-REGISTER';
                     $domain_type = 'register';
                 } else {
                     $sku = "DOMAIN-TRANSFER";
                     $domain_type = 'ns_transfer';
                 }
                 $domain_sku = $sku;
                 $domain = preg_replace("/^www\\./", "", $rs2->fields['domain_name']);
                 $parking = preg_replace("/(\\.)([a-zA-Z0-9.-]+)/", $domain, $ret);
                 $tld = preg_replace("/^\\./", "", $ret[0]);
                 $domain = preg_replace(",{$tld}\$,", "", $domain);
                 $domain = preg_replace("/\\./", "", $domain);
                 $domain_host_tld_id = 0;
                 $tldrs = $db->Execute(sqlSelect($db, "host_tld", "id", "name='{$tld}'"));
                 if ($tldrs && $tldrs->recordCount) {
                     $domain_host_tld_id = $tldrs->fields['id'];
                 }
                 // get product details
                 $pid = $rs2->fields['pid'];
                 $sql = "SELECT ab_id FROM {$p}import WHERE site_id = {$s} AND\n\t\t\t\t\t\t\t\tab_table = 'product' AND\n\t\t\t\t\t\t\t\tplugin = '{$this->plugin}' AND\n\t\t\t\t\t\t\t\tremote_id = '{$pid}'";
                 $produrs = $dba->Execute($sql);
                 if ($produrs && $produrs->RecordCount() && !empty($product_id)) {
                     $product_id = $produrs->fields['ab_id'];
                     $product = $db->Execute(sqlSelect($db, "product", "*", "id={$product_id}"));
                     if ($product && $product->RecordCount()) {
                         $sku = $product->fields['sku'];
                     }
                 }
                 // insert invoice item
                 $dbo =& DB();
                 $idx = sqlGenID($dbo, "invoice_item");
                 $sql = "INSERT INTO {$p}invoice_item SET\n\t\t\t\t\t\t\t\tid \t\t\t\t\t= {$idx},\n\t\t\t\t\t\t\t\tsite_id\t\t\t\t= 1,  \n\t\t\t\t\t\t\t\tparent_id\t\t\t= 0,\n\t\t\t\t\t\t\t\tinvoice_id\t\t\t= " . $db->qstr(@$invoice_id) . ", \n\t\t\t\t\t\t\t\tproduct_id\t\t\t= " . $db->qstr(@$product_id) . ",\n\t\t\t\t\t\t\t\tdate_orig\t\t\t= " . $db->qstr($rs->fields['created']) . ",  \n\t\t\t\t\t\t\t\tsku\t\t\t\t\t= " . $db->qstr($sku) . ",\n\t\t\t\t\t\t\t\tquantity\t\t\t= 1,\n\t\t\t\t\t\t\t\titem_type\t\t\t= 1,  \n\t\t\t\t\t\t\t\tprice_type\t\t\t= 1,\n\t\t\t\t\t\t\t\tprice_base\t\t\t= " . $db->qstr($rs->fields['total_due_today']) . ", \n\t\t\t\t\t\t\t\tdomain_name \t\t= " . $db->qstr($domain) . ", \n\t\t\t\t\t\t\t\tdomain_tld  \t\t= " . $db->qstr($tld);
                 $dbo->Execute($sql);
                 # Insert the import record
                 $this->import_transaction($this->plugin, $VAR['action'], 'invoice_item', $idx, 'hosting_order', $rs2->fields['oid'], &$db);
                 // SERVICE: insert domain record
                 if ($rs->fields['status'] == 1 && empty($rs2->fields['domain_registration'])) {
                     if (!empty($rs2->fields['domain_expire'])) {
                         $d = explode("/", $rs2->fields['domain_expire']);
                         @($anniversary_date = mktime(0, 0, 0, $d[0], $d[1], $d[2]));
                     } else {
                         $anniversary_date = $rs2->fields['ogcreate'] + 86400 * 1;
                     }
                     $dby =& DB();
                     $s_id = sqlGenID($dby, "service");
                     $sql = "INSERT INTO {$p}service SET\n\t\t\t\t\t\t\t\tid \t\t\t\t\t= {$s_id},\n\t\t\t\t\t\t\t\tsite_id\t\t\t\t= 1, \n\t\t\t\t\t\t\t\tqueue\t\t\t\t= 'none',\n\t\t\t\t\t\t\t\tdate_orig\t\t\t= " . $db->qstr($rs->fields['created']) . ",\n\t\t\t\t\t\t\t\tdate_last\t\t\t= " . $db->qstr(time()) . ",  \n\t\t\t\t\t\t\t\tinvoice_id\t\t\t= " . $db->qstr(@$invoice_id) . ", \n\t\t\t\t\t\t\t\taccount_id\t\t\t= " . $db->qstr(@$account_id) . ",\n\t\t\t\t\t\t\t\taccount_billing_id\t= " . $db->qstr(@$billing_id) . ", \n\t\t\t\t\t\t\t\tsku\t\t\t\t\t= " . $db->qstr($domain_sku) . ", \n\t\t\t\t\t\t\t\ttype\t\t\t\t= " . $db->qstr('domain') . ", \n\t\t\t\t\t\t\t\tactive\t\t\t\t= 1,  \n\t\t\t\t\t\t\t\tprice\t\t\t\t= " . $db->qstr($rs->fields['total_due_today']) . ",\n\t\t\t\t\t\t\t\tprice_type\t\t\t= " . $db->qstr('0') . ",\n\t\t\t\t\t\t\t\ttaxable\t\t\t\t= " . $db->qstr('0') . ",\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\tdomain_date_expire\t= " . $db->qstr($anniversary_date) . ",\n\t\t\t\t\t\t\t\tdomain_host_tld_id\t= " . $db->qstr($domain_host_tld_id) . ",\n\t\t\t\t\t\t\t\tdomain_host_registrar_id = 1,\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdomain_name \t\t= " . $db->qstr($domain) . ",\n\t\t\t\t\t\t\t\tdomain_term\t\t  \t= " . $db->qstr(1) . ",\n\t\t\t\t\t\t\t\tdomain_tld  \t\t= " . $db->qstr($tld) . ",\n\t\t\t\t\t\t\t\tdomain_type\t\t\t= " . $db->qstr($domain_type);
                     $dby->Execute($sql);
                     # Insert the import record
                     $this->import_transaction($this->plugin, $VAR['action'], 'service', $s_id, 'hosting_order', $rs2->fields['oid'], &$db);
                 }
                 //	SERVICE: Insert hosting record
                 if ($rs->fields['status'] == 1) {
                     $recur_schedule = 1;
                     switch ($rs2->fields['payment_term']) {
                         case "Monthly":
                             $recur_schedule = 1;
                             break;
                         case "Quarterly":
                             $recur_schedule = 2;
                             break;
                         case "Semi-Annual":
                             $recur_schedule = 3;
                             break;
                         case "Annual":
                             $recur_schedule = 4;
                             break;
                     }
                     $dbx =& DB();
                     $s2_id = sqlGenID($dbx, "service");
                     $sql = "INSERT INTO {$p}service SET\n\t\t\t\t\t\t\t\t\tid \t\t\t\t\t= {$s2_id},\n\t\t\t\t\t\t\t\t\tsite_id\t\t\t\t= 1, \n\t\t\t\t\t\t\t\t\tqueue\t\t\t\t= 'active',\n\t\t\t\t\t\t\t\t\tdate_orig\t\t\t= " . $db->qstr($rs->fields['created']) . ",\n\t\t\t\t\t\t\t\t\tdate_last\t\t\t= " . $db->qstr(time()) . ",  \n\t\t\t\t\t\t\t\t\tinvoice_id\t\t\t= " . $db->qstr(@$invoice_id) . ", \n\t\t\t\t\t\t\t\t\taccount_id\t\t\t= " . $db->qstr(@$account_id) . ",\n\t\t\t\t\t\t\t\t\taccount_billing_id\t= " . $db->qstr(@$billing_id) . ",\n\t\t\t\t\t\t\t\t\tproduct_id\t\t\t= " . $db->qstr(@$product_id) . ", \n\t\t\t\t\t\t\t\t\tsku\t\t\t\t\t= " . $db->qstr('HOSTING') . ",  \n\t\t\t\t\t\t\t\t\ttype\t\t\t\t= " . $db->qstr('host') . ", \n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tactive\t\t\t\t= 1, \n\t\t\t\t\t\t\t\t\tsuspend_billing\t\t= 0, \n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tdate_last_invoice\t= " . $db->qstr($rs->fields['created']) . ",\n\t\t\t\t\t\t\t\t\tdate_next_invoice\t= " . $db->qstr($rs2->fields['next_due_date']) . ",\n\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\tprice\t\t\t\t= " . $db->qstr($rs2->fields['total_due_reoccur']) . ",\n\t\t\t\t\t\t\t\t\tprice_type\t\t\t= 1,\n\t\t\t\t\t\t\t\t\ttaxable\t\t\t\t= 1,\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\trecur_type\t\t\t= " . $db->qstr(@$product->fields['price_recurr_type']) . ",\n\t\t\t\t\t\t\t\t\trecur_schedule\t\t= " . $db->qstr($recur_schedule) . ",\n\t\t\t\t\t\t\t\t\trecur_weekday\t\t= " . $db->qstr(@$product->fields['price_recurr_weekday']) . ",\n\t\t\t\t\t\t\t\t\trecur_week\t\t\t= " . $db->qstr(@$product->fields['price_recurr_week']) . ",\n\t\t\t\t\t\t\t\t\trecur_cancel\t\t= " . $db->qstr(@$product->fields['price_recurr_cancel']) . ",\n\t\t\t\t\t\t\t\t\trecur_schedule_change = " . $db->qstr(@$product->fields['price_recurr_modify']) . ",\n\t\t\t\n\t\t\t\t\t\t\t\t\thost_username\t\t= " . $db->qstr($rs2->fields['whm_username']) . ",\n\t\t\t\t\t\t\t\t\thost_password\t\t= " . $db->qstr($rs2->fields['whm_password']) . ",\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\thost_server_id\t\t\t= " . $db->qstr(@$product->fields['host_server_id']) . ",\n\t\t\t\t\t\t\t\t\thost_provision_plugin_data \t= " . $db->qstr(@$product->fields['host_provision_plugin_data']) . ",\n\t\t\t\t\t\t\t\t\thost_ip\t\t\t\t\t= " . $db->qstr($rs2->fields['ip']) . ",\n\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\tdomain_host_tld_id\t\t= " . $db->qstr($domain_host_tld_id) . ",\n\t\t\t\t\t\t\t\t\tdomain_host_registrar_id = 1,\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tdomain_name \t\t\t= " . $db->qstr($domain) . ", \n\t\t\t\t\t\t\t\t\tdomain_tld  \t\t\t= " . $db->qstr($tld);
                     $dbx->Execute($sql);
                     # Insert the import record
                     $this->import_transaction($this->plugin, $VAR['action'], 'service', $s2_id, 'hosting_order', $rs2->fields['oid'], &$db);
                 }
                 $rs2->MoveNext();
             }
         } else {
             echo "<BR><BR> No Account: <BR> {$sql}";
         }
         $rs->MoveNext();
     }
     $C_debug->alert($msg);
     $offset = $VAR['offset'] + $this->select_limit;
     echo "<script language=javascript> \n\t\t\t  setTimeout('document.location=\\'?_page=core:blank&offset={$offset}&action={$VAR['action']}&plugin={$VAR['plugin']}&do[]=import:do_action\\'', 1200);\n\t\t\t </script>";
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:WHM_AutoPilot.php

示例10: product_add_host

 /**
  * Add a product to the cart 
  */
 function product_add_host($VAR)
 {
     if (!empty($VAR["attr"])) {
         @($attr = serialize($VAR["attr"]));
     } else {
         $attr = serialize(array(""));
     }
     $db =& DB();
     $fields = array('date_orig' => time(), 'session_id' => $this->session_id, 'account_id' => @$VAR['account_id'], 'product_attr' => $attr, 'cart_type' => 1, 'quantity' => 1, 'product_id' => $VAR["product_id"], 'recurr_schedule' => @$VAR["recurr_schedule"], 'service_id' => @$VAR["service_id"], 'host_type' => $VAR["domain_type"], 'domain_name' => $VAR["domain_name"], 'domain_tld' => $VAR["domain_tld"]);
     $id = sqlGenID($db, "cart");
     $db->Execute(sqlInsert($db, "cart", $fields, $id));
     // Get the default domain registration length:
     if ($VAR["domain_type"] == "transfer" || $VAR["domain_type"] == "register") {
         $domain_term = 1;
         $result = $db->Execute(sqlSelect($db, "host_tld", "default_term_new", "name=::{$VAR["domain_tld"]}::"));
         if (!empty($result->fields["default_term_new"])) {
             $domain_term = $result->fields["default_term_new"];
         }
     }
     // add child domain if register or transfer
     if ($VAR["domain_type"] == "transfer" || $VAR['domain_type'] == "register") {
         $fields = array('date_orig' => time(), 'session_id' => $this->session_id, 'account_id' => @$VAR['account_id'], 'product_attr' => $attr, 'cart_type' => 2, 'quantity' => 1, 'host_type' => $VAR["domain_type"], 'domain_name' => $VAR["domain_name"], 'domain_tld' => $VAR["domain_tld"], 'domain_term' => $domain_term, 'cart_parent_id' => $id);
         $db->Execute(sqlInsert($db, "cart", $fields));
     }
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:28,代码来源:cart.inc.php

示例11: checkout_multiple_preview

 /**
  * Preview checkout of multiple invoices
  */
 function checkout_multiple_preview($VAR)
 {
     global $smarty, $C_list;
     if (!SESS_LOGGED) {
         return false;
     }
     $db =& DB();
     $total = $this->multiple_invoice_total(@$VAR['id'], SESS_ACCOUNT);
     if ($total > 0 && count($this->invoice) > 1) {
         // get country id for checkout options
         $account = sqlSelect($db, "account", "country_id", "id=" . SESS_ACCOUNT);
         // get payment options
         include_once PATH_MODULES . 'checkout/checkout.inc.php';
         $checkout = new checkout();
         $checkoutoptions = $checkout->get_checkout_options(SESS_ACCOUNT, $total, false, $account->fields['country_id'], true);
         // get a temporary id (48 hours)
         $id = sqlGenID($db, "temporary_data");
         $invoice["id"] = "MULTI-{$id}";
         $invoice["total"] = $total;
         $fields = array('date_orig' => time(), 'date_expire' => time() + 86400 * 3, 'field2' => $invoice['id'], 'field1' => $total, 'data' => serialize($this->invoice));
         $id =& $db->Execute(sqlInsert($db, "temporary_data", $fields));
         $smarty->assign('invoice', $invoice);
         $smarty->assign('total', $C_list->format_currency_num($total, SESS_CURRENCY));
         $smarty->assign('checkoutoptions', $checkoutoptions);
     } elseif (count($this->invoice) == 1) {
         $id = $this->invoice[0];
         echo "<script language=javascript>document.location.href='?_page=invoice:user_view&id=" . $id . "';</script>";
     } else {
         echo "No due invoices selected for payment.";
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:34,代码来源:invoice.inc.php

示例12: checkoutnow


//.........这里部分代码省略.........
             // validate recur day and recurring schedule are the same for both products
             foreach ($invoice->recur_arr as $a) {
                 foreach ($invoice->recur_arr as $b) {
                     foreach ($b as $key => $val) {
                         if ($key != 'price' && $key != 'recurr_week' && $a[$key] != $val) {
                             $recurring = false;
                             break;
                         }
                     }
                 }
             }
             if (!$recurring) {
                 echo '<script language=Javascript> alert("This payment option cannot be used when ordering both prorated and non-prorated subscriptions, or when ordering two or more subscriptions with different billing schedules selected. Please make sure all your subscriptions have the same billing schedule selected, try another payment option, or order one subscription at a time. We apologize for any inconvenience."); </script> ';
                 return false;
             }
         }
     }
     # Affiliate
     if (empty($this->affiliate_id)) {
         if (!empty($account->fields['affiliate_id'])) {
             $invoice->affiliate_id = $account->fields['affiliate_id'];
         } else {
             $invoice->affiliate_id = SESS_AFFILIATE;
         }
     }
     # Campaign
     if (empty($this->campaign_id)) {
         if (!empty($account->fields['campaign_id'])) {
             $invoice->campaign_id = $account->fields['campaign_id'];
         } else {
             $invoice->campaign_id = SESS_CAMPAIGN;
         }
     }
     $invoice->record_id = sqlGenID($db, "invoice");
     $invoice->actual_billed_currency_id = SESS_CURRENCY;
     $invoice->billed_currency_id = DEFAULT_CURRENCY;
     $invoice->checkout_type = $PLG->type;
     // initial invoice status
     if ($invoice->total_amt == 0 || $PLG->type == 'gateway') {
         $invoice->billing_status = 1;
         $invoice->actual_billed_amt = $C_list->format_currency_decimal($invoice->total_amt, SESS_CURRENCY);
         $invoice->billed_amt = $invoice->total_amt;
     }
     // Currency conversion:
     if (SESS_CURRENCY != DEFAULT_CURRENCY) {
         $bill_amt = $C_list->format_currency_decimal($invoice->total_amt, SESS_CURRENCY);
         $recur_amt = $C_list->format_currency_decimal($invoice->recur_amt, SESS_CURRENCY);
     } else {
         $bill_amt = round($invoice->total_amt, 2);
         $recur_amt = round($invoice->recur_amt, 2);
     }
     // Get currency ISO (three_digit) for checkout plugin
     $currrs = $db->Execute(sqlSelect($db, "currency", "three_digit", "id=" . SESS_CURRENCY));
     if ($currrs && $currrs->RecordCount()) {
         $currency_iso = $currrs->fields['three_digit'];
     }
     // Run the plugin bill_checkout() method:
     $currency_iso = $C_list->currency_iso(SESS_CURRENCY);
     $invoice->checkout_plugin_data = $PLG->bill_checkout($bill_amt, $invoice->record_id, $currency_iso, $account->fields, $recur_amt, $invoice->recur_arr);
     if ($invoice->checkout_plugin_data === false || $invoice->checkout_plugin_data == '') {
         if (!empty($PLG->redirect)) {
             echo $PLG->redirect;
         }
         return false;
     } elseif ($PLG->type == "gateway" || empty($PLG->redirect)) {
         $VAR['id'] = $invoice->record_id;
开发者ID:hbustun,项目名称:agilebill,代码行数:67,代码来源:checkout.inc.php


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