Beispiel #1
0
 public function actionSingle($id)
 {
     $brand = Brands::model()->findByPk($id);
     $sales = Sales::model()->findAll(array('condition' => 'status=1 and brand_id=:brandId and ((start=finish and start<=:now) OR :now between start and finish)', 'params' => array(':brandId' => $brand->id, ':now' => date('Y-m-d H:i:s'))));
     $data = array('brand' => $brand, 'sales' => $sales, 'title' => $brand->name);
     $this->render('single', $data);
 }
Beispiel #2
0
 /**
  *@return singleton
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Sales();
     }
     return self::$instance;
 }
Beispiel #3
0
 public function actionDefault()
 {
     $main_rubric = Rubrics::model()->find(array('condition' => 'main=1'));
     $order = 'start desc, id desc';
     $sales = Sales::model()->findAll(array('condition' => 'start<=:now and finish>=:now and (sale>0 or action=1) and status=1', 'params' => array(':now' => date('Y-m-d')), 'order' => $order));
     $new = Sales::model()->findAll(array('condition' => 'start<=:now and finish>=:now and new=1 and status=1', 'params' => array(':now' => date('Y-m-d')), 'order' => 'finish'));
     $data = array('sales' => $sales, 'new' => $new, 'rubric' => $main_rubric, 'title' => $main_rubric->title ? $main_rubric->title : $main_rubric->name, 'keywords' => $main_rubric->keywords, 'description' => $main_rubric->description, 'metaImage' => 'http://' . $_SERVER['HTTP_HOST'] . '/static/img/logo_big.png');
     $this->render('main', $data);
 }
 public function getSalesInfo()
 {
     $res = Sales::getInstance()->getSalesByCategory(intval($_GET['active']), intval($_GET['records']), intval($_GET['id_shop_session']));
     while ($row = PDOQuery::getInstance()->next_row($res)) {
         $this->sale_info[] = array('quantity' => $row['quantity'], 'total' => $row['total'], 'category' => explode(',', $row['category']), 'category_color' => explode(',', $row['category_color']), 'session_date' => date('d/m/Y', $row['session_date']), 'total_cash' => $this->getTotalBySaleType(1, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'cash_movements' => $this->getOperationsQty(1, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_credit' => $this->getTotalBySaleType(2, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'credit_movements' => $this->getOperationsQty(2, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_check' => $this->getTotalBySaleType(3, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'check_movements' => $this->getOperationsQty(3, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_other' => $this->getTotalBySaleType(4, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'other_movements' => $this->getOperationsQty(4, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_refund' => $this->getTotalBySaleType(5, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'refund_movements' => $this->getOperationsQty(5, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_cancellation' => $this->getTotalBySaleType(6, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'cancellation_movements' => $this->getOperationsQty(6, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_replacement' => $this->getTotalBySaleType(7, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'replacement_movements' => $this->getOperationsQty(7, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_otherC' => $this->getTotalBySaleType(8, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'otherC_movements' => $this->getOperationsQty(8, explode(',', $row['id_payment_type']), explode(',', $row['amount'])), 'total_invoice' => $this->getTotalBySaleType(1, explode(',', $row['invoice']), explode(',', $row['amount'])), 'invoice_movements' => $this->getOperationsQty(1, explode(',', $row['invoice']), explode(',', $row['amount'])), 'total_ticket' => $this->getTotalBySaleType(0, explode(',', $row['invoice']), explode(',', $row['amount'])), 'ticket_movements' => $this->getOperationsQty(0, explode(',', $row['invoice']), explode(',', $row['amount'])));
     }
     $this->context->smarty->assign("sale_info", $this->sale_info);
     $this->context->smarty->assign("pagination", Sales::getInstance()->pagination_render);
 }
 /**
  * [extractInfo Extract data from files]
  * @method extractInfo
  * @param  [string] $filename [Filename content data]
  * @return [type]
  */
 private function extractInfo($filename)
 {
     $modelSellers = new Sellers();
     $modelConsumers = new Consumers();
     $modelSales = new Sales();
     $arrSalesman = array();
     $pathFile = $this->input_dir . '/' . $filename;
     $fileContent = file($pathFile);
     natsort($fileContent);
     foreach ($fileContent as $line) {
         $arrLine = explode('ç', $line);
         if ($arrLine[0] == '001') {
             $cpf = $arrLine[1];
             $name = $arrLine[2];
             $salary = $arrLine[3];
             $modelSellers->addSalesman($cpf, $name, $salary);
         } elseif ($arrLine[0] == '002') {
             $cnpj = $arrLine[1];
             $name = $arrLine[2];
             $business_area = $arrLine[3];
             $modelConsumers->addConsumer($cnpj, $name, $business_area);
         } elseif ($arrLine[0] == '003') {
             $id = $arrLine[1];
             $items = $arrLine[2];
             $salesman_name = $arrLine[3];
             $modelSales->addSale($id, $salesman_name, $items, $modelSellers->getAll());
         }
     }
     $totalConsumers = $totalSellers = $expensivesaleID = 0;
     $worstSellerName = '';
     $totalSellers = $modelSellers->getTotalSellers();
     if ($totalSellers > 0) {
         $arrSellersAmount = $modelSales->getSellersAmount();
         foreach ($arrSellersAmount as $obj) {
             $modelSellers->updateTotalSales($obj->name, $obj->total);
         }
         $worstSellerName = $modelSellers->getWorstSeller()->name;
         $expensivesaleID = $modelSales->getMostExpensiveSale()->id;
     }
     $totalConsumers = $modelConsumers->getTotalConsumers();
     $reportFilename = basename($filename, '.' . pathinfo($filename, PATHINFO_EXTENSION));
     $this->generateReport($reportFilename, $totalConsumers, $totalSellers, $expensivesaleID, $worstSellerName);
 }
Beispiel #6
0
 public function actionSingle($id)
 {
     $single = Sales::model()->findByPk($id);
     if (!$single) {
         $this->render('/errors/404');
     }
     $rubric = Rubrics::model()->findByPk($single->rubric_id);
     $data = array('rubric' => $rubric, 'data' => $single, 'title' => $single->name, 'keywords' => str_replace(' ', ',', $single->announce), 'description' => $single->announce, 'metaImage' => 'http://' . $_SERVER['HTTP_HOST'] . $this->getImageUrl($single, 'b'));
     $this->render('single', $data);
 }
 public function getSalesInfo()
 {
     $records = $this->getRecordsToShow();
     $res = Sales::getInstance()->getSessionSales(intval($_GET['active']), $records, intval($_GET['id_shop_session']));
     while ($row = PDOQuery::getInstance()->next_row($res)) {
         $this->summary_products[] = array('amount' => $row['amount'], 'employee_name' => $row['employee_name'], 'reference' => $row['reference'], 'price' => $row['price'], 'quantity' => $row['quantity'], 'product' => $row['product'], 'related_product' => $row['related_product'], 'related_reference' => $row['related_reference'], 'date_sale' => date('H:i ', $row['date_sale']), 'session_date' => date('d/m/Y', $row['session_date']), 'note' => htmlspecialchars($row['note']), 'payment_type' => $row['payment'], 'invoice' => $row['invoice'], 'color' => $row['color'], 'sale_type' => $row['id_sale_type'], 'id_payment_type' => $row['id_payment_type'], 'id_sale' => $row['id_sale'], 'position' => $row['position']);
     }
     $this->context->smarty->assign("summary_products", $this->summary_products);
     $this->context->smarty->assign("pagination", Sales::getInstance()->pagination_render);
 }
 public function getSalesHistory()
 {
     $res = Sales::getInstance()->getTotalSaleList(intval($_GET['orderBy']), intval($_GET['records']));
     $odd = true;
     while ($row = PDOQuery::getInstance()->next_row($res)) {
         $odd = $odd == true ? false : true;
         $this->sale_info[] = array('total' => $row['total'], 'id_shop_session' => $row['id_shop_session'], 'date' => date('d/m/Y - H:i', $row['date']), 'odd' => $odd);
     }
     $this->context->smarty->assign("sale_info", $this->sale_info);
     $this->context->smarty->assign("pagination", Sales::getInstance()->pagination_render);
 }
Beispiel #9
0
 public static function index()
 {
     return function ($request, $response) {
         if ($request->session('admin')) {
             switch ($request->method()) {
                 case 'GET':
                     #echo "GET";
                     $sales = Sales::all();
                     $response->json($sales->as_array());
                     break;
                 case 'POST':
                     $data = $request->data();
                     $sales = new Sales();
                     $sales->date = $data->date;
                     $sales->order = $data->order_id;
                     $sales->amount = $data->amount;
                     $sales->save();
                     $response->json($sales->as_array());
                     break;
                 case 'DELETE':
                     # code...
                     echo "DELETE";
                     break;
                 case 'PUT':
                     # code...
                     echo "PUT";
                     break;
                 default:
                     # code...
                     break;
             }
         } else {
             $response->code(403);
         }
     };
 }
 public function getCurrentMonthSalesInformation()
 {
     $month_info = array();
     $sales = Sales::getInstance();
     $res = $sales->getTotalMonthSales();
     $operations = 0;
     while ($row = PDOQuery::getInstance()->next_row($res)) {
         if (_CURRENT_MONTH_ == date('n', $row['date_sale'])) {
             $operations++;
             $total += $row['amount'];
         }
     }
     $month_info['operations'] = $operations > 0 ? $operations : 0;
     $month_info['total'] = $operations > 0 ? $total : 0;
     return $month_info;
 }
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
Beispiel #12
0
<?php

require "core/init.php";
include "../config/config.php";
$current_url = Crytion::encryt64($url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
//echo Crytion::encryt64("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
Session::put('current_url', $current_url);
//global declare;
$set = new Sales();
$total = 0;
$final_total = 0;
$srv_tax = $set->service_tax();
$govn_tax = $set->government_tax();
$pay = 0;
?>
<html>
<head>
	<title>Staff - Sales</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="description" content="Retail POS Sytem">
    <meta name="keywords" content="POS System">
    <meta name="author" content="Hafiq iqmal">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">	
    <!-- bootstrap -->
    <link href="../detail/bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="../detail/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
    <link href="../detail/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet" />

    <!-- libraries -->
    <link href="../detail/lib/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" />
Beispiel #13
0
 public function executeCheckout()
 {
     $this->user = $this->getUser()->getRaykuUser();
     $voucher_id = $this->getUser()->getAttribute('voucher_id');
     $offer = OfferVoucherPeer::retrieveByPK($voucher_id);
     //$_SESSION['offerid'] = $offer->getId();
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $c = new Criteria();
         $c->add(ShoppingCartPeer::IS_ACTIVE, true);
         $c->add(ShoppingCartPeer::USER_ID, $this->user->getId());
         $c->addDescendingOrderByColumn(ShoppingCartPeer::CREATED_AT);
         $this->cart_items = ShoppingCartPeer::doSelect($c);
         $purchase_detail = $this->getRequestParameter('purchase');
         foreach ($purchase_detail as $index => $value) {
             $purchaseDetail[$index] = trim($value);
         }
         if ($purchaseDetail['name'] == '' || $purchaseDetail['email'] == '' || $purchaseDetail['address_1'] == '' || $purchaseDetail['city'] == '' || $purchaseDetail['state'] == '' || $purchaseDetail['zip'] == '' || $purchaseDetail['country'] == '' || $purchaseDetail['tel'] == '') {
             sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Tag'));
             $this->msg = "<p>Please fill in all additional information on the <b>Purchase Cart</b> page.</p>";
             $this->msg .= "<p>" . link_to('Go back to the <b>Purchase Cart</b> page.', 'shop/checkoutPage') . "</p>";
         } else {
             if (count($this->cart_items) > 0) {
                 $count = 0;
                 $tot_price = 0;
                 $tot_item_price = 0;
                 $tot_shipping_price = 0;
                 $tot_quantity = 0;
                 foreach ($this->cart_items as $cart_item) {
                     $tot_price = $tot_price + $cart_item->getTotalPrice() + $cart_item->getTotalShippingCharge();
                     if ($tot_price > $this->user->getPoints()) {
                         break;
                     }
                     $sales_detail = new SalesDetail();
                     $sales_detail->setItemId($cart_item->getItemId());
                     $sales_detail->setTotalPrice($cart_item->getTotalPrice());
                     $sales_detail->setTotalShippingCharge($cart_item->getTotalShippingCharge());
                     $sales_detail->setQuantity($cart_item->getQuantity());
                     $sales_detail->save();
                     $count++;
                     $tot_item_price = $tot_item_price + $cart_item->getTotalPrice();
                     $tot_shipping_price = $tot_shipping_price + $cart_item->getTotalShippingCharge();
                     $tot_quantity = $tot_quantity + $cart_item->getQuantity();
                     $itemPurchased = ItemPeer::retrieveByPK($cart_item->getItemId());
                     if (empty($purchasedItems)) {
                         $purchasedItems = $itemPurchased->getTitle();
                     } else {
                         $purchasedItems = $purchasedItems . "," . $itemPurchased->getTitle();
                     }
                     $cart_item->delete();
                 }
                 $sales = new Sales();
                 if ($offer instanceof OfferVoucher) {
                     $tot_price = $tot_price - $offer->getPrice();
                     //$sales->setOfferVoucherId($offer->getId());
                     $offer->setIsUsed(true);
                     $offer->save();
                 }
                 $sales->setTotalSalePrice($tot_price);
                 $sales->setTotalItemPrice($tot_item_price);
                 $sales->setTotalShippingCharge($tot_shipping_price);
                 $sales->setQuantity($tot_quantity);
                 $sales->setStatusId(1);
                 $sales->save();
                 $this->user->setPoints($this->user->getPoints() - $tot_price);
                 $this->user->save();
                 $full_name = htmlentities($purchase_detail['name']);
                 $email = htmlentities($purchase_detail['email']);
                 $address_1 = htmlentities($purchase_detail['address_1']);
                 $address_2 = htmlentities($purchase_detail['address_2']);
                 $city = htmlentities($purchase_detail['city']);
                 $state = htmlentities($purchase_detail['state']);
                 $zip = htmlentities($purchase_detail['zip']);
                 $country = htmlentities($purchase_detail['country']);
                 $tel = htmlentities($purchase_detail['tel']);
                 $purchase_detail = new PurchaseDetail();
                 $purchase_detail->setFullName($full_name);
                 $purchase_detail->setUserId($this->user->getId());
                 $purchase_detail->setEmail($email);
                 $purchase_detail->setAddress1($address_1);
                 $purchase_detail->setAddress2($address_2);
                 $purchase_detail->setCity($city);
                 $purchase_detail->setZip($zip);
                 $purchase_detail->setState($state);
                 $purchase_detail->setCountry($country);
                 $purchase_detail->setSalesId($sales->getId());
                 $purchase_detail->save();
                 $user = $this->getUser()->getRaykuUser();
                 $this->mail = Mailman::createCleanMailer();
                 $this->mail->setSubject('Rayku.com Shoping Item Purchase Details');
                 $this->mail->setFrom($user->getName() . ' <' . $user->getEmail() . '>');
                 $to = "*****@*****.**";
                 $items = "<b>" . $purchasedItems . "</b>";
                 sfProjectConfiguration::getActive()->loadHelpers(array('Partial'));
                 $this->mail->setBody(get_partial('purchaseitem', array('name' => $user->getName(), 'user' => $user, 'items' => $items)));
                 $this->mail->setContentType('text/html');
                 $this->mail->addAddress($to);
                 $this->mail->send();
                 $this->msg = "<p style='font-size:14px;color:#444444'>You have just spent " . $tot_price . "RP to purchase " . $count . " item(s).<br /><br />A Rayku administrator has been notified, and will deliver your purchase as soon as possible. Once your order has been processed, you will be notified by private message here on Rayku.<br /><br />Thanks!<br />Rayku.com Staff</p>";
                 $this->getUser()->setAttribute('voucher_id', null);
             } else {
                 $this->msg = "<p style='font-size:14px;color:#444444'>No items in cart</p>";
             }
         }
     } else {
         $this->msg = "<p style='font-size:14px;color:#444444'>Unauthorized access.</p>";
     }
 }
        if ($errmsg == '') {
            function check_input($data)
            {
                $data = trim($data);
                $data = stripslashes($data);
                $data = htmlspecialchars($data);
                $data = mysql_real_escape_string($data);
                return $data;
            }
            $Campaignid = check_input($_POST['Campaignid']);
            $Productid = check_input($_POST['Productid']);
            $Starting_date = check_input($_POST['Starting_date']);
            $Ending_date = check_input($_POST['Ending_date']);
            $Estimated_sales = check_input($_POST['Estimated_sales']);
            $Estimated_budget = check_input($_POST['Estimated_budget']);
            $Salesobj = new Sales();
            if ($Salesobj->AddEstimation($Campaignid, $Productid, $Starting_date, $Ending_date, $Estimated_sales, $Estimated_budget)) {
                $msg .= 'New Estimation successfully crated.<br>';
            } else {
                $errmsg .= '!Opps Some thing went wrong.<br>';
            }
        }
    }
} else {
    $Campaignid = "";
    $Productid = "";
    $Starting_date = "";
    $Ending_date = "";
    $Estimated_sales = "";
    $Estimated_budget = "";
}
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id)
 {
     $validator = Validator::make(Input::all(), Sales::$rules);
     if ($validator->passes()) {
         $customerId = Input::get('customer_id', null);
         // Create customer if required
         $customer = new Customers();
         if ($customerId) {
             $customer = Customers::find($customerId);
         }
         if (Input::get('name')) {
             $customer->name = Input::get('name');
             $customer->address = Input::get('address');
             $customer->contact = Input::get('contact');
             $customer->save();
         }
         $sale = Sales::find($id);
         $sale->customer_id = $customer->id ? $customer->id : 0;
         $sale->outlet_id = $this->user->outlet_id;
         $sale->paid = Input::get('paid');
         $sale->notes = Input::get('notes');
         $sale->status = Input::get('paid') == Input::get('grandtotal') ? 'completed' : 'credit';
         $sale->save();
         return Redirect::route('sales.edit', $id)->with('success', 'Sale updated successfully');
     } else {
         return Redirect::route('sales.edit', $id)->withErrors($validator)->withInput(Input::all());
     }
 }
Beispiel #16
0
 public function getCountRubricSales($rubric_id)
 {
     $cnt = Sales::model()->count(array('condition' => 'status=1 and rubric_id=:rubricId', 'params' => array(':rubricId' => $rubric_id)));
     return $cnt;
 }
Beispiel #17
0
 /**
  * Declares an association between this object and a Sales object.
  *
  * @param      Sales $v
  * @return     PurchaseDetail The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setSales(Sales $v = null)
 {
     if ($v === null) {
         $this->setSalesId(NULL);
     } else {
         $this->setSalesId($v->getId());
     }
     $this->aSales = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Sales object, it will not be re-added.
     if ($v !== null) {
         $v->addPurchaseDetail($this);
     }
     return $this;
 }
Beispiel #18
0
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
?>


<?php 
echo '<div class="form no-border" style="float:left;width:590px;">';
$form = $this->beginWidget('CActiveForm', array('id' => 'sales-form', 'enableAjaxValidation' => false));
$attributeLabels = Sales::attributeLabels();
$fields = Fields::model()->findAllByAttributes(array('modelName' => 'Sales'));
if (isset($_GET['version'])) {
    $version = $_GET['version'];
    $version = FormVersions::model()->findByAttributes(array('name' => $version));
    $sizes = json_decode($version->sizes, true);
    $positions = json_decode($version->positions, true);
    $tempArr = array();
    foreach ($fields as $field) {
        if (isset($positions[$field->fieldName])) {
            $field->coordinates = $positions[$field->fieldName];
            $field->size = $sizes[$field->fieldName];
            $tempArr[] = $field;
        }
    }
    $fields = $tempArr;
Beispiel #19
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Sales $value A Sales object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Sales $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(SellingUpdateRequest $request, $id)
 {
     $sales = Sales::findOrFail($request->id);
     $sales->fill($request->postFillData());
     $sales->save();
     return redirect()->route('admin.sellings.index')->withSuccess('Transaction updated.');
 }
 public function actionAddSales()
 {
     $pid = $_POST['pid'];
     $saleDate = $_POST['saleDate'];
     $saleCount = $_POST['saleCount'];
     // $pid = 9;
     // $saleDate = '2012-03-10';
     // $saleCount = 7;
     $sql = "SELECT * FROM product WHERE id=" . $pid;
     $product = Product::model()->findBySql($sql);
     $result = false;
     if ($product) {
         // $sql = "SELECT * FROM sales WHERE pid=".$pid." AND timestamp=".$saleDate;
         $sql = "SELECT * FROM sales WHERE pid=" . $pid . " AND timestamp='" . $saleDate . "'";
         $haveSale = Sales::model()->findBySql($sql);
         // echo var_dump($haveSale);
         // die();
         if (null == $haveSale) {
             // echo "yes";
             $newSale = new Sales();
             $newSale->pid = $pid;
             $newSale->count = $saleCount;
             $newSale->timestamp = $saleDate;
             $newSale->save();
             $result = true;
         }
     }
     echo $result;
 }
Beispiel #22
0
 public static function getNames()
 {
     $arr = Sales::model()->findAll();
     $names = array(0 => "None");
     foreach ($arr as $sale) {
         $names[$sale->id] = $sale->name;
     }
     return $names;
 }
 public static function send_data($key_type, $key_value, $site_url, $user_id, $order)
 {
     $obj = NULL;
     try {
         $url = wskl_get_host_api_url() . '/logs/sales/';
         $body = json_encode(static::create_body($key_type, $key_value, $site_url, $user_id, $order));
         $headers = array('content-type' => 'application/json');
         $response = Rest_Api_Helper::request($url, 'POST', $body, array(201), $headers);
         $obj = Sales::from_response($response['body']);
     } catch (BadResponseException $e) {
         $e->handle_bad_response(__METHOD__);
     }
     return $obj;
 }
Beispiel #24
0
<?php

require_once "core/init.php";
$inv = new Sales();
//empty cart by destroying current session
if (Input::exists('emptycart') && Input::get('emptycart') === 1) {
    $return_url = Crytion::decryt64(Input::get("return_url"));
    $inv->emptycart();
    Redirect::to($return_url);
}
if (Input::get('check')) {
    $get = DB::getInstance()->get('tbl_goods', array('goods_id', '=', Input::get('check')));
    if ($get->count() == 0) {
        echo 0;
    } else {
        echo 1;
    }
}
//add item in shopping cart
if (Input::exists() && Input::get('type') == 'search') {
    $product_code = Input::get('scan_item');
    $return_url = Crytion::decryt64(Input::get("return_url"));
    $inv->add_item($product_code);
    Redirect::to($return_url);
}
//update item
if (Input::exists() && Input::get('type') == 'update') {
    $product_code = Input::get('goods_id');
    $qty = Input::get('goods_qty');
    $discount = Input::get('goods_discount');
    $return_url = Crytion::decryt64(Input::get("return_url"));
Beispiel #25
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSaless()
 {
     return $this->hasMany(Sales::className(), ['id_branch' => 'id_branch']);
 }
Beispiel #26
0
    echo $attributeLabels['assignedTo'];
    ?>
</td>
		<td><?php 
    echo $model->assignedTo;
    ?>
</td>
                <?php 
}
?>
		<td class="label"><?php 
echo Yii::t('sales', 'Sales');
?>
</td>
		<td colspan="3"><?php 
echo Sales::getSalesLinks($model->id);
?>
</td>
                
	</tr>
	<tr>
                <?php 
if ($nonCustom['associatedContacts']->visible == 1) {
    ?>
		<td class="label"><?php 
    echo $attributeLabels['associatedContacts'];
    ?>
</td>
		<td><?php 
    echo $model->associatedContacts;
    ?>
Beispiel #27
0
        $field = preg_replace('/^findBy(\\w*)$/', '${1}', $method);
        $query = "select * from " . static::$table . " where {$field} = '{$args['0']}'";
        return self::createDomain($query);
    }
    private static function createDomain($query)
    {
        $klass = get_called_class();
        $domain = new $klass();
        $domain->fieldvalue = array();
        $domain->select = $query;
        foreach ($klass::fields as $field => $type) {
            $domain->fieldvalue[$field] = 'TODO: set from sql result';
        }
        return $domain;
    }
}
class Customer extends ActiveRecord
{
    protected static $table = 'custdb';
    protected static $fields = array('id' => 'int', 'email' => 'varchar', 'lastname' => 'varchar');
}
class Sales extends ActiveRecord
{
    protected static $table = 'salesdb';
    protected static $fields = array('id' => 'int', 'item' => 'varchar', 'qty' => 'int');
}
Customer::findById(123)->select;
Customer::findById(123)->email;
Sales::findById(123)->select;
Sales::findByItem('item')->select;
Beispiel #28
0
<?php

$crumbs = Yii::app()->params['crumbs'];
$vert = Rubrics::model()->getMenu('vert');
if ($vert) {
    ?>
	<div id="vert_menu">		<h3>Категории:</h3>		<?php 
    foreach ($vert as $k => $v) {
        ?>
			<div>				<a href="<?php 
        echo $v->getLink();
        ?>
" class="<?php 
        if ($crumbs[0]->id == $v->id) {
            ?>
active<?php 
        }
        ?>
">					<?php 
        echo $v->name;
        ?>
					<!--sup>(<?php 
        echo Sales::model()->getCountRubricSales($v->id);
        ?>
)</sup-->				</a>			</div>		<?php 
    }
    ?>
	</div><?php 
}
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Sales::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
 public function actionGetStageMembers($workflowId, $stage)
 {
     // $contactIds = Yii::app()->db->createCommand()->select('contactId')->from('x2_list_items')->where('x2_list_items.listId='.$id)->queryColumn();
     // die(var_dump($contactIds));
     // $search = CActiveRecord::model('ContactChild')->findAllByPk($contactIds);
     // return $search;
     if (!is_numeric($workflowId) || !is_numeric($stage)) {
         return new CActiveDataProvider();
     }
     $actionDescription = $workflowId . ':' . $stage;
     $contactsSql = Yii::app()->db->createCommand()->select('x2_contacts.*')->from('x2_contacts')->join('x2_actions', 'x2_contacts.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0) AND (x2_contacts.visibility=1 OR x2_contacts.assignedTo='" . Yii::app()->user->getName() . "')")->getText();
     $contactsCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $contactsDataProvider = new CSqlDataProvider($contactsSql, array('totalItemCount' => $contactsCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     $salesSql = Yii::app()->db->createCommand()->select('x2_sales.*')->from('x2_sales')->join('x2_actions', 'x2_sales.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->getText();
     $salesCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $salesDataProvider = new CSqlDataProvider($salesSql, array('totalItemCount' => $salesCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     if (!empty($contactsDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('contacts', 'Contacts') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $contactsDataProvider, 'enableSorting' => false, 'columns' => array(array('name' => 'lastName', 'header' => Yii::t('contacts', 'Name'), 'value' => 'CHtml::link($data["firstName"]." ".$data["lastName"],array("/contacts/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '30%')), array('name' => 'phone', 'header' => Yii::t('contacts', 'Work Phone')), array('name' => 'createDate', 'header' => Yii::t('contacts', 'Create Date'), 'value' => 'date("Y-m-d",$data["createDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'lastUpdated', 'header' => Yii::t('contacts', 'Last Updated'), 'value' => 'date("Y-m-d",$data["lastUpdated"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'leadSource', 'header' => Yii::t('contacts', 'Lead Source')))));
     }
     if (!empty($salesDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('sales', 'Sales') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $salesDataProvider, 'columns' => array(array('header' => Sales::model()->getAttributeLabel('name'), 'name' => 'name', 'value' => 'CHtml::link($data["name"],array("/sales/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '40%')), array('header' => Sales::model()->getAttributeLabel('quoteAmount'), 'name' => 'quoteAmount', 'value' => 'Yii::app()->locale->numberFormatter->formatCurrency($data["quoteAmount"],Yii::app()->params->currency)', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('salesStage'), 'name' => 'salesStage', 'value' => 'Yii::t("sales",$data["salesStage"])', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('expectedCloseDate'), 'name' => 'expectedCloseDate', 'value' => 'empty($data->expectedCloseDate)?"":date("Y-m-d",$data["expectedCloseDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '13%')), array('header' => Sales::model()->getAttributeLabel('assignedTo'), 'name' => 'assignedTo', 'value' => 'empty($data["assignedTo"])?Yii::t("app","Anyone"):$data["assignedTo"]', 'type' => 'raw'))));
     }
 }