Esempio n. 1
0
 public function send()
 {
     if (!expJavascript::inAjaxAction()) {
         if (isset($this->redirecturl)) {
             redirect_to($this->redirecturl);
         }
     } else {
         if (expJavascript::requiresJSON()) {
             echo json_encode($this->packet);
         } else {
             global $template;
             echo $template->render();
         }
         exit;
     }
 }
Esempio n. 2
0
 public static function pushToHead($params)
 {
     global $css_primer, $css_core, $css_links, $css_theme, $css_inline;
     // primer css
     if (isset($params['css_primer'])) {
         $primer_array = $params['css_primer'];
         foreach ($primer_array as $path) {
             //indexing the array by the filename
             $css_primer[$path] = $path;
         }
     }
     // files in framework/core/assets/css that is general to many views and the system overall
     if (isset($params['corecss'])) {
         $core_array = explode(",", $params['corecss']);
         foreach ($core_array as $filename) {
             $existspath = BASE . "framework/core/assets/css/" . $filename . ".css";
             $filepath = PATH_RELATIVE . "framework/core/assets/css/" . $filename . ".css";
             if (is_file($existspath)) {
                 $css_core[$filepath] = $filepath;
             }
         }
     }
     // css linked in through the css plugin
     if (isset($params['link'])) {
         $css_links[$params['link']] = $params['link'];
     }
     // CSS hard coded in a view
     if (!empty($params['css'])) {
         $tcss = trim($params['css']);
         if (!empty($tcss)) {
             $css_inline[$params['unique']] = $params['css'];
         }
     }
     if (expJavascript::inAjaxAction()) {
         echo "<div class=\"io-execute-response\">";
         if (isset($params['corecss']) && !empty($css_core)) {
             foreach ($css_core as $path) {
                 echo '<link rel="stylesheet" type="text/css" href="' . $path . '">';
             }
         }
         echo '<link rel="stylesheet" type="text/css" href="' . $params['link'] . '">';
         echo "</div>";
     }
 }
Esempio n. 3
0
 function updateQuantity()
 {
     global $order;
     if (expJavascript::inAjaxAction()) {
         $id = str_replace('quantity-', '', $this->params['id']);
         $item = new orderitem($id);
         if (!empty($item->id)) {
             //$newqty = $item->product->updateQuantity($this->params['value']);
             $newqty = $item->product->updateQuantity($this->params['value']);
             if ($newqty > $item->product->quantity) {
                 if ($item->product->availability_type == 1) {
                     $diff = $item->product->quantity <= 0 ? $newqty : $newqty - $item->product->quantity;
                     $updates->message = 'Only ' . $item->product->quantity . ' ' . $item->products_name . ' are currently in stock. Shipping may be delayed on the other ' . $diff;
                 } elseif ($item->product->availability_type == 2) {
                     $updates->message = $item->products_name . ' only has ' . $item->product->quantity . ' on hand. You can not add any more than that to your cart.';
                     $updates->cart_total = '$' . number_format($order->getCartTotal(), 2);
                     $updates->item_total = '$' . number_format($item->getTotal(), 2);
                     $updates->item_id = $id;
                     $updates->quantity = $item->product->quantity;
                     echo json_encode($updates);
                     return true;
                 }
             }
             $item->quantity = $newqty;
             $item->save();
             $order->refresh();
             $updates->cart_total = '$' . number_format($order->getCartTotal(), 2);
             $updates->item_total = '$' . number_format($item->getTotal(), 2);
             $updates->item_id = $id;
             $updates->quantity = $item->quantity;
             echo json_encode($updates);
         }
     } else {
         if (!is_numeric($this->params['quantity'])) {
             flash('error', gt('Please enter a valid quantity.'));
             expHistory::back();
         }
         $item = new orderitem($this->params['id']);
         if (!empty($item->id)) {
             //$newqty = $item->product->updateQuantity($this->params['quantity']);
             $newqty = $this->params['quantity'];
             //$oiObj = new orderitem();
             //$oi = $oiObj->find('all','product_id='.$item->product->id);
             $qCheck = 0;
             //$item->product->quantity;
             //if (!empty($oi))
             //{
             foreach ($order->orderitem as $orderItem) {
                 if ($orderItem->product_id == $item->product_id) {
                     $qCheck += $orderItem->quantity;
                 }
             }
             //eDebug("Done",true);
             //}
             /*eDebug($item->quantity);   
               eDebug($item->product->quantity); 
               eDebug($qCheck);                  
               eDebug($newqty,true);  */
             //check minimum quantity
             $qtyMessage = '';
             if ($newqty < $item->product->minimum_order_quantity) {
                 $qtyMessage = $item->product->title . ' has a minimum order quantity of ' . $item->product->minimum_order_quantity . '. The quantity has been adjusted and added to your cart.<br/><br/>';
                 $newqty = $item->product->minimum_order_quantity;
             }
             $itemMessage = '';
             if ($qCheck + ($newqty - $item->quantity) > $item->product->quantity) {
                 if ($item->product->availability_type == 1) {
                     $diff = $item->product->quantity <= 0 ? $newqty : $newqty - $item->product->quantity;
                     $itemMessage = gt('Only') . ' ' . $item->product->quantity . ' ' . $item->products_name . ' ' . gt('are currently in stock. Shipping may be delayed on the other') . ' ' . $diff . "<br/><br/>";
                     //$updates->message = 'Only '.$item->product->quantity.' '.$item->products_name.' are currently in stock. Shipping may be delayed on the other '.$diff;
                 } elseif ($item->product->availability_type == 2) {
                     flash('error', $item->products_name . ' ' . gt('only has') . ' ' . $item->product->quantity . ' ' . gt('on hand. You can not add any more than that to your cart.'));
                     /*$updates->message = $item->products_name.' only has '.$item->product->quantity.' on hand. You can not add any more to your cart.';                        
                       $updates->cart_total = '$'.number_format($order->getCartTotal(), 2);
                       $updates->item_total = '$'.number_format($item->quantity*$item->products_price, 2);
                       $updates->item_id = $id;
                       $updates->quantity = $item->product->quantity;
                       echo json_encode($updates);  */
                     expHistory::back();
                 }
             } else {
                 if ($newqty <= 0) {
                     $item->delete();
                     flash('message', $item->products_name . ' ' . gt('has been removed from your cart.'));
                     expHistory::back();
                 }
             }
             $item->quantity = $newqty;
             $item->save();
             $order->refresh();
             /*$updates->cart_total = '$'.number_format($order->getCartTotal(), 2);
               $updates->item_total = '$'.number_format($item->quantity*$item->products_price, 2);
               $updates->item_id = $id;
               $updates->quantity = $item->quantity;      */
             //echo json_encode($updates);
         }
         //redirect_to(array('controller'=>'cart','action'=>'show'));
         flash('message', $qtyMessage . $itemMessage . $item->products_name . ' ' . gt('quantity has been updated.'));
         expHistory::back();
     }
 }
Esempio n. 4
0
expLang::loadLang();
// Initialize the Database subsystem
$db = expDatabase::connect(DB_USER, DB_PASS, DB_HOST . ':' . DB_PORT, DB_NAME);
// Initialize the Modules subsystem & Create the list of available/active controllers
$available_controllers = expModules::initializeControllers();
//original position
//$available_controllers = array();
//$available_controllers = initializeControllers();
//foreach ($db->selectObjects('modstate',1) as $mod) {
//	if (!empty($mod->path)) $available_controllers[$mod->module] = $mod->path;  //FIXME test location
//}
// Initialize the History (Flow) subsystem.
$history = new expHistory();
//<--This is the new flow subsystem
// Initialize the javascript subsystem
if (expJavascript::inAjaxAction()) {
    set_error_handler('handleErrors');
}
// Validate the session and populate the $user variable
if ($db->havedb) {
    $user = new user();
    expSession::validate();
}
/* exdoc
 * The flag to use a mobile theme variation.
 */
if (!defined('MOBILE')) {
    if (defined('FORCE_MOBILE') && FORCE_MOBILE && $user->isAdmin()) {
        define('MOBILE', true);
    } else {
        define('MOBILE', expTheme::is_mobile());