Ejemplo n.º 1
0
 function addItem()
 {
     global $router;
     $product_type = isset($this->params['product_type']) ? $this->params['product_type'] : 'product';
     $product = new product();
     //eDebug($this->params);
     //if we're trying to add a parent product ONLY, then we redirect to it's show view
     $c = null;
     if (isset($this->params['product_id']) && empty($this->params['children'])) {
         $c = $product->find('first', 'parent_id=' . $this->params['product_id']);
     }
     if (!empty($c->id)) {
         flash('message', gt("Please select a product and quantity from the options listed below to add to your cart."));
         redirect_to(array('controller' => 'store', 'action' => 'show', 'id' => $this->params['product_id']));
     }
     //check for multiple product adding
     if (isset($this->params['prod-quantity'])) {
         //we are adding multiple children, so we approach a bit different
         //we'll send over the product_id of the parent, along with id's and quantities of children we're adding
         foreach ($this->params['prod-quantity'] as $qkey => &$quantity) {
             if (in_array($qkey, $this->params['prod-check'])) {
                 //this might not be working...FJD
                 $child = new $product_type($qkey);
                 /*if ($quantity < $child->minimum_order_quantity)                       
                   {
                       flash('message', $child->title . " - " . $child->model . " has a minimum order quantity of " . $child->minimum_order_quantity . 
                       '. Your quantity has been adjusted accordingly.');
                       $quantity = $child->minimum_order_quantity;
                       
                   }*/
                 $this->params['children'][$qkey] = $quantity;
             }
             if (isset($child)) {
                 $this->params['product_id'] = $child->parent_id;
             }
         }
     }
     $product = new $product_type($this->params['product_id'], true, true);
     //need true here?
     //Check the Main Product quantity
     if (isset($this->params['quantity'])) {
         if ((int) $this->params['quantity'] < $product->minimum_order_quantity) {
             flash('message', gt("Please enter a quantity equal or greater than the minimum order quantity."));
             redirect_to(array('controller' => 'store', 'action' => 'show', 'id' => $this->params['product_id']));
         } else {
         }
     }
     if ($product->product_type == "product" || $product->product_type == "childProduct") {
         if (($product->hasOptions() || $product->hasUserInputFields()) && (!isset($this->params['options_shown']) || $this->params['options_shown'] != $product->id)) {
             // if we hit here it means this product type was missing some
             // information it needs to add the item to the cart..so we need to help
             // it display its addToCart form
             /*redirect_to(array(
             				'controller'=>'cart',
             				'action'=>'displayForm',
             				'form'=>'addToCart',
             				'product_id'=>$this->params['product_id'],
             				'product_type'=>$this->params['product_type'],
             				'children'=>serialize($this->params['children']), 
             		));*/
             $product->displayForm('addToCart', $this->params);
             return false;
         }
     }
     //product either has no options, user input fields, or has already seen and passed the options page, so we try adding to cart
     //it will validate and fail back to the options page if data is incorrect for whatever reason (eg, bad form post)
     //eDebug($this->params, true);
     //$this->params['qty'] = 1; //REMOVE ME
     if ($product->addToCart($this->params)) {
         if (empty($this->params['quick'])) {
             flash('message', gt("Added") . " " . $product->title . " " . gt("to your cart.") . " <a href='" . $router->makeLink(array('controller' => 'cart', 'action' => 'checkout'), false, true) . "'>" . gt("Click here to checkout now.") . "</a>");
             //expHistory::back();
             //eDebug(show_msg_queue(false),true);
             redirect_to(array('controller' => 'cart', 'action' => 'show'));
             //expHistory::lastNotEditable();
         } else {
             redirect_to(array('controller' => 'cart', 'action' => 'quickPay'));
         }
     } else {
         //expHistory::back();
     }
 }
Ejemplo n.º 2
0
 function get_id($id)
 {
     return product::find($id);
 }
Ejemplo n.º 3
0
            <div id="contact-area">
                <div class="container">
                    <div class="order-form">

						<?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
						

						
						<?php 
echo $form->field($model, 'username')->textInput(['value' => Yii::$app->user->identity->username]);
?>

						<?php 
echo $form->field($model, 'product_id')->dropDownlist(ArrayHelper::map(product::find()->all(), 'id', 'name'), ['prompt' => 'Select product']);
?>
						 <?php 
echo $form->field($model, 'qty')->textInput(['maxlength' => 45]);
?>
 
						 
						
						 <?php 
echo $form->field($model, 'specification')->textArea();
?>
   
						
						<?php 
echo $form->field($model, 'shippingaddress')->textInput(['maxlength' => 100]);
?>
Ejemplo n.º 4
0
 public function deleteChildren()
 {
     //eDebug($data[0],true);
     //if($id!=null) $this->params['id'] = $id;
     //eDebug($this->params,true);
     $product = new product($this->params['id']);
     //$product = $product->find("first", "previous_id =" . $previous_id);
     //eDebug($product, true);
     if (empty($product->id)) {
         flash('error', gt('There was an error deleting the child products.'));
         expHistory::back();
     }
     $childrenToDelete = $product->find('all', 'parent_id=' . $product->id);
     foreach ($childrenToDelete as $ctd) {
         //fwrite($lfh, "Deleting:" . $ctd->id . "\n");
         $ctd->delete();
     }
 }
Ejemplo n.º 5
0
 public function deleteProduct($id)
 {
     $product = product::find($id);
     $product->delete();
     return Redirect::to('all-products');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $product = product::find($id);
     return view('products.edit', compact('product', $product));
 }
Ejemplo n.º 7
0
 function status_export()
 {
     global $db;
     //eDebug($this->params);
     //$sql = "SELECT * INTO OUTFILE '" . BASE . "tmp/export.csv' FIELDS TERMINATED BY ','  FROM exponent_product WHERE 1 LIMIT 10";
     //is | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     $out = '"id","parent_id","model","warehouse_location","title","vendor","product_status","notes"' . chr(13) . chr(10);
     if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {
         $sql = expSession::get('product_export_query');
         //eDebug($sql);
         //expSession::set('product_export_query','');
         $prods = $db->selectArraysBySql($sql);
         //eDebug($prods);
     } else {
         foreach ($this->params['act-upon'] as $prod) {
             $prods[] = array('id' => $prod);
         }
     }
     $stats = new product_status();
     $stats = $stats->find('all');
     $statuses = array();
     foreach ($stats as $stat) {
         $statuses[$stat->id] = $stat->title;
     }
     eDebug($statuses);
     set_time_limit(0);
     $baseProd = new product();
     //$p = new product($pid['id'], false, false);
     //id | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     foreach ($prods as $pid) {
         $except = array('crosssellItem', 'optiongroup', 'childProduct');
         $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, null, true, true, $except, true);
         /*if(count($p->expSimpleNote))
           {
               eDebug($p,true);
           }
           else
           {
               continue;
           }*/
         $out .= $this->outputField($p->id);
         $out .= $this->outputField($p->parent_id);
         $out .= $this->outputField($p->model);
         $out .= $this->outputField($p->warehouse_location);
         $out .= $this->outputField($p->title);
         $out .= $this->outputField($p->company->title);
         $out .= $this->outputField($statuses[$p->product_status_id]);
         $noteString = '';
         foreach ($p->expSimpleNote as $note) {
             $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
         }
         $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         $cps = $baseProd->find('all', 'parent_id=' . $p->id, null, null, null, true, true, $except, true);
         foreach ($cps as $cp) {
             $out .= $this->outputField($cp->id);
             $out .= $this->outputField($cp->parent_id);
             $out .= $this->outputField($cp->model);
             $out .= $this->outputField($cp->warehouse_location);
             $out .= $this->outputField($cp->title);
             $out .= $this->outputField($cp->company->title);
             $out .= $this->outputField($statuses[$cp->product_status_id]);
             $noteString = '';
             foreach ($cp->expSimpleNote as $note) {
                 $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
             }
             $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         }
     }
     //eDebug($out,true);
     $outFile = 'tmp/product_export_' . time() . '.csv';
     $outHandle = fopen(BASE . $outFile, 'w');
     fwrite($outHandle, $out);
     fclose($outHandle);
     echo "<br/><br/>Download the file here: <a href='" . PATH_RELATIVE . $outFile . "'>Product Export</a>";
     /*eDebug(BASE . "tmp/export.csv");
       $db->sql($sql);
       eDebug($db->error());*/
     /*OPTIONALLY ENCLOSED BY '" . '"' . 
       "' ESCAPED BY '\\'
       LINES TERMINATED BY '" . '\\n' .
       "' */
 }
Ejemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = product::find($id);
     $product->delete();
     //Session::flash('flash_message', 'product successfully deleted!');
     return redirect('product/list');
 }