Ejemplo n.º 1
0
 /**
  * Get all include for a tranche id
  * 
  * @param integer $trancheid
  */
 public static function getIncludeForTrancheId($trancheid)
 {
     $includes = Doctrine_Query::create()->select()->from('ProductsTranchesIncludes i')->where('i.tranche_id = ?', $trancheid)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $data = array();
     foreach ($includes as $include) {
         if ($include['type'] == 'domains') {
             if (!array_key_exists('domains', $data)) {
                 $data['domains'] = array();
             }
             $tlds = DomainsTlds::getbyID($include['include_id']);
             $name = $tlds['DomainsTldsData'][0]['name'];
             $data['domains'][] = $name;
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 public static function Create($domain, $tld_id, $customerid, $orderitemid, $statusid = "", $authcode = "")
 {
     $thedomain = new Domains();
     if (!is_numeric($statusid)) {
         $statusid = Statuses::id("processing", "domains");
     }
     list($domain, $tld) = explode('.', $domain);
     $retval = self::findByDomainName($domain, $tld, null, true);
     $date_end = Shineisp_Commons_Utilities::add_date(date('d-m-Y'), null, 12);
     $tldInfo = DomainsTlds::getbyID($tld_id);
     if (count($retval) == 0) {
         $thedomain->domain = $domain;
         $thedomain->tld = $tldInfo['WhoisServers']['tld'];
         $thedomain->tld_id = $tldInfo['tld_id'];
         $thedomain->customer_id = $customerid;
         $thedomain->orderitem_id = $orderitemid;
         $thedomain->status_id = $statusid;
         $thedomain->registrars_id = Isp::getActiveISPID();
         $thedomain->creation_date = date('Y-m-d');
         $thedomain->expiring_date = Shineisp_Commons_Utilities::formatDateIn($date_end);
         $thedomain->modification_date = date('Y-m-d');
         $thedomain->authinfocode = $authcode;
         $thedomain->autorenew = true;
         $thedomain->save();
         return $thedomain->getIncremented();
     } else {
         return $retval[0]['domain_id'];
     }
 }
Ejemplo n.º 3
0
 /**
  * saveAll
  * Save all the data
  * @param $params
  * @return Boolean
  */
 public static function saveAll($id, $params)
 {
     $date_end = null;
     if (!is_array($params)) {
         return false;
     }
     $details = Doctrine::getTable('OrdersItems')->find($id);
     // Generic price setting
     $rowtotal = $params['price'];
     $vat = 0;
     $percentage = null;
     // Get the taxes applied
     $tax = Taxes::getTaxbyProductID($params['product_id']);
     if (!empty($tax) && $tax['percentage'] > 0 && $params['price'] > 0) {
         $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100;
         $vat = $params['price'] * $tax['percentage'] / 100;
         $percentage = $tax['percentage'];
     } else {
         if (!empty($params['parameters'])) {
             // it is a domain
             $domainparams = json_decode($params['parameters'], true);
             if (!empty($domainparams['domain']['tld'])) {
                 $tax = Taxes::getTaxbyTldID($domainparams['domain']['tld']);
                 $tldInfo = DomainsTlds::getbyID($domainparams['domain']['tld']);
                 if (!empty($domainparams['action']) && $domainparams['action'] == "transferDomain") {
                     $params['price'] = $tldInfo['transfer_price'];
                 } elseif (!empty($domainparams['action']) && $domainparams['action'] == "renewalDomain") {
                     $params['price'] = $tldInfo['renewal_price'];
                 } elseif (!empty($domainparams['action']) && $domainparams['action'] == "registerDomain") {
                     $params['price'] = $tldInfo['registration_price'];
                 }
                 // if the price is negative the tax MUST not be refunded
                 // because already payed by the hoster
                 if ($tax['percentage'] > 0 && $params['price'] > 0) {
                     $vat = $params['price'] * $tax['percentage'] / 100;
                     $percentage = $tax['percentage'];
                     $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100;
                 }
             }
         }
     }
     if (!empty($params['billing_cycle_id'])) {
         $months = BillingCycle::getMonthsNumber($params['billing_cycle_id']);
     }
     if ($months > 0 && is_numeric($params['product_id']) && $params['product_id'] > 0) {
         // only for the product and services. Domains excluded
         $rowtotal = $rowtotal * $months;
     }
     $params['date_end'] = Shineisp_Commons_Utilities::add_date($params['date_start'], null, $months);
     $details->quantity = $params['quantity'];
     $details->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']);
     $details->date_end = Shineisp_Commons_Utilities::formatDateIn($params['date_end']);
     $details->billing_cycle_id = !empty($params['billing_cycle_id']) ? $params['billing_cycle_id'] : null;
     $details->price = $params['price'];
     $details->vat = $vat;
     $details->percentage = $percentage;
     $details->cost = $params['cost'];
     $details->product_id = is_numeric($params['product_id']) && $params['product_id'] > 0 ? $params['product_id'] : NULL;
     $details->setupfee = $params['setupfee'];
     $details->discount = $params['discount'];
     $details->subtotal = $rowtotal * $params['quantity'];
     $details->status_id = $params['status_id'];
     $details->description = $params['description'];
     $details->parameters = $params['parameters'];
     if ($details->trySave()) {
         OrdersItems::setAutorenew($id, $params['autorenew']);
         // Remove all domains
         OrdersItemsDomains::removeAllDomains($id);
         if ($params['domains_selected']) {
             foreach ($params['domains_selected'] as $domain) {
                 OrdersItemsDomains::addDomain($details['order_id'], $domain);
             }
         }
         return true;
     }
     return false;
 }