本文整理汇总了PHP中Shineisp_Commons_Utilities::add_date方法的典型用法代码示例。如果您正苦于以下问题:PHP Shineisp_Commons_Utilities::add_date方法的具体用法?PHP Shineisp_Commons_Utilities::add_date怎么用?PHP Shineisp_Commons_Utilities::add_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shineisp_Commons_Utilities
的用法示例。
在下文中一共展示了Shineisp_Commons_Utilities::add_date方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAll
/**
* 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 = null;
$percentage = null;
// Get the taxes applied
$tax = Taxes::getTaxbyProductID($params['product_id']);
if ($tax['percentage'] > 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']);
if ($tax['percentage'] > 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;
}
示例2: Create
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'];
}
}
示例3: createOrderWithMultiProducts
/**
* Create an order with many products
*
*
* @param $product
* @return integer $orderID
*/
public static function createOrderWithMultiProducts(array $products, $customer_id, $type = "domain")
{
$order = new Orders();
try {
$customer = Customers::getAllInfo($customer_id);
$isp_id = $customer['isp_id'];
// Creating a new Order.
$order->customer_id = $customer_id;
$order->isp_id = $isp_id;
$order->order_date = date('Y-m-d');
$order->status_id = Statuses::id("tobepaid", "orders");
// To pay
$order->save();
$id = $order->getIncremented();
// Add a fastlink to a order
$link_exist = Fastlinks::findlinks($id, $customer_id, 'orders');
if (count($link_exist) == 0) {
$link = new Fastlinks();
$link->controller = "orders";
$link->action = "edit";
$link->params = json_encode(array('id' => $id));
$link->customer_id = $customer_id;
$link->sqltable = "orders";
$link->id = $id;
$link->code = Shineisp_Commons_Utilities::GenerateRandomString();
$link->save();
}
foreach ($products as $product) {
$product = Domains::getAllInfo($product, null, null, true);
// Attaching the order item to the order previously created.
$orderitem = new OrdersItems();
$date_end = Shineisp_Commons_Utilities::add_date(date('d-m-Y'), null, 365);
// Fixed Renew
$orderitem->order_id = $id;
$orderitem->product_id = $product[0]['Products']['product_id'];
$orderitem->billing_cycle_id = 1;
$orderitem->date_start = date('Y-m-d H:i:s');
$orderitem->date_end = $date_end;
$orderitem->autorenew = true;
$orderitem->description = $product[0]['domain'] . "." . $product[0]['tld'];
$orderitem->quantity = 1;
$tax = Taxes::getTaxbyProductID($product[0]['Products']['product_id']);
$orderitem->price = $product[0]['Products']['price_1'];
$orderitem->cost = $product[0]['Products']['cost'];
$orderitem->status_id = Statuses::id("processing", "orders");
// Processing status set
$orderitem->save();
$detailid = $orderitem->getIncremented();
// Set the domains status as processing
Domains::setStatus($product[0]['domain_id'], 6);
}
// Update the total of the order
self::updateTotalsOrder($id);
return $id;
} catch (Exception $e) {
echo $e->getMessage();
die;
}
}
示例4: processAction
/**
* processAction
* Update the record previously selected
* @return unknown_type
*/
public function processAction()
{
$i = 0;
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$form = $this->getForm("/admin/services/process");
$request = $this->getRequest();
// Create the buttons in the edit form
$this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/services/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/services/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
// Check if we have a POST request
if (!$request->isPost()) {
return $this->_helper->redirector('list', 'services', 'admin');
}
if ($form->isValid($request->getPost())) {
// Get the id
$id = $this->getRequest()->getParam('detail_id');
// Set the new values
if (is_numeric($id)) {
$this->services = Doctrine::getTable('OrdersItems')->find($id);
}
// Get the values posted
$params = $form->getValues();
$datestart = explode(" ", $params['date_start']);
try {
$months = BillingCycle::getMonthsNumber($params['billing_cycle_id']);
if ($months > 0) {
$date_end = Shineisp_Commons_Utilities::add_date($datestart[0], null, $months);
} else {
$date_end = null;
}
$this->services->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']);
$this->services->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end);
$this->services->order_id = $params['order_id'];
$this->services->product_id = $params['product_id'];
$this->services->billing_cycle_id = $params['billing_cycle_id'];
$this->services->quantity = $params['quantity'];
$this->services->status_id = $params['status_id'];
$this->services->setup = $params['setup'];
$this->services->note = $params['note'];
// Save the data
$this->services->save();
$id = is_numeric($id) ? $id : $this->services->getIncremented();
// Set the autorenew
OrdersItems::setAutorenew($id, $params['autorenew']);
// Save the message note
if (!empty($params['message'])) {
$message = new Messages();
$message->dateposted = date('Y-m-d H:i:s');
$message->message = $params['message'];
$message->isp_id = 1;
$message->detail_id = $id;
$message->save();
}
// Clear the list from the DB
Doctrine::getTable('OrdersItemsDomains')->findBy('orderitem_id', $id)->delete();
if ($params['domains_selected']) {
$service_domains = new Doctrine_Collection('OrdersItemsDomains');
foreach ($params['domains_selected'] as $domain) {
$service_domains[$i]->domain_id = $domain;
$service_domains[$i]->order_id = $params['order_id'];
$service_domains[$i]->orderitem_id = $id;
$i++;
}
$service_domains->save();
}
$this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
} catch (Exception $e) {
$this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => $this->translator->translate('Unable to process the request at this time.') . ": " . $e->getMessage(), 'status' => 'danger'));
}
$redirector->gotoUrl("/admin/services/edit/id/{$id}");
} else {
$this->view->form = $form;
$this->view->title = $this->translator->translate("Service Details");
$this->view->description = $this->translator->translate("Here you can see the details of the service subscribed by the customer.");
return $this->render('applicantform');
}
}