Example #1
0
	@param		string			password		password
	@param		string			terminal		serial number of gsm terminal
	@param		string			barcode			barcode value
*/
require_once $_SERVER["ROOT_DIR"] . "/init.php";
$passwords = array();
if ($config = C('gsm.passwd')) {
    if (isset($config['@'])) {
        $config = array($config);
    }
    foreach ($config as $item) {
        $passwords[$item['@']['key']] = $item['@']['hash'];
    }
}
if (isset($_REQUEST['terminal'])) {
    if (isset($passwords[$_REQUEST['terminal']])) {
        if (@$_REQUEST['password'] == $passwords[$_REQUEST['terminal']]) {
            $query = M('Db')->createQuery('panelie_gsm_data', 'insert')->set('terminal', TF($_REQUEST['terminal'], 'sh'))->set('barcode_value', TF(@$_REQUEST['barcode'], 'sh'))->set('date_entered', M('Tools')->date()->dbDateTime());
            if ($query->execute()) {
                echo 'ok';
            }
        } else {
            die('wrong password');
        }
    } else {
        die('wrong terminal serial number');
    }
} else {
    die('please specify terminal serial number');
}
Example #2
0
                        $post = array('name' => $name, 'moderated' => $moderated);
                        /*					if ($entity == 'owner')
                        							$post['gln'] = TF($_POST['gln'], 'post');*/
                        $obEntity = M('Barcode')->{'create' . ucfirst($entity)}($post);
                        $obEntity->save();
                    }
                }
                $obBarcode->{$field} = $obEntity->id();
            } else {
                $obBarcode->{$field} = NULL;
            }
        }
        /*было: owner gtype brand subtype vol desc cover measure GLN barcode complete*/
        foreach (qw2('attribute_1>description product_qty>product_qty product_measure>product_measure cover_code>cover_code complete>complete to_refresh>refresh') as $k => $v) {
            if (isset($_POST[$v])) {
                $obBarcode->{$k} = TF($_POST[$v], 'post');
            }
        }
        MC('Barcode')->save($obBarcode, $error);
        foreach (M('Gpc')->flavour_types() as $flavour_type) {
            if (isset($_POST['flavour_' . $flavour_type])) {
                MC('Gpc_Main')->addFlavoursToBarcode($obBarcode, explode(',', trim($_POST['flavour_' . $flavour_type])), $flavour_type, $error);
            }
        }
    }
}
$root_params['status'] = 'ok';
$root_params = array_merge($root_params, MC('Message')->setXmlMessage(@$error, @$message, 'barcode'));
// сформировать и вывести XML
$root = M('Ajax')->init('xml', $root_params);
M('Ajax')->xml();
Example #3
0
 /**
  *	Сохранить последнюю заметку об этом штрих-коде
  *
  *	@param	array	$data
  *	@return void
  **/
 public function saveLastNotice(array $data)
 {
     if (!$data['barcode_value']) {
         return FALSE;
     }
     $base = $this->connection();
     $this->connection($this->_list->base);
     $data['notice'] = TF($data['notice'], 'sh');
     if (!$data['notice']) {
         return FALSE;
     }
     M('Db')->createQuery($this->_tables['report'], 'update')->set('notice', $data['notice'])->set('notice_author', $data['from_id'])->where('barcode_value = ?', $data['barcode_value'])->execute();
     /*M('Db')->query("UPDATE " . $this->_tables['report'] . " SET notice = ?, notice_author = ? WHERE barcode_value = ?", $data['notice'], $data['from_id'], $data['barcode_value']);*/
     $this->connection('default');
     M('Event')->notify('barcode.notice', $data);
     $this->connection($base);
     return TRUE;
 }
Example #4
0
<?php

/**
* 
* Edit barcode recover
* 
* 
* 
* 
* */
if ($list->id() != 56) {
    throw Exception(__FILE__ . ': Wrong report = ' . $list->id() . ' to edit!');
}
if (isset($_POST['data'])) {
    foreach ($_POST['data'] as $d) {
        if (isset($d['recover'])) {
            if (!isNull($obQueue = M('Barcode')->loadQueueById(intval($d['id'])))) {
                MC('Report_BarcodeRecover')->approveQueue($obQueue, TF($d['name_new'], 'sh'));
            }
        }
    }
}
Example #5
0
 if ($answer_ids) {
     $answers = array();
     foreach ($answer_ids as $answer_id) {
         if (!isNull($obAnswer = M('Anketa')->loadAnswerById($answer_id))) {
             if ($obAnswer->number == -1) {
                 // если в ответах есть ответ с number = -1, то остальные обнулить
                 $answers = array($obAnswer);
                 break;
             }
             $answers[] = $obAnswer;
         }
     }
     foreach ($answers as $obAnswer) {
         // !#TODO: проверить - существует ли такой ответ уже - надо ли его обновить/удалить?
         if (isset($_POST['details'][$obAnswer->id()]) && $_POST['details'][$obAnswer->id()] !== '') {
             $post['details'] = TF($_POST['details'][$obAnswer->id()], 'post');
         }
         $obResultAnswer = M('Anketa')->createResultAnswer($post, $obResult, $obAnswer);
         $obResultAnswer->save();
     }
 } else {
     if ($subanswer_ids) {
         foreach ($subanswer_ids as $answer_id => $subanswer_id) {
             $obAnswer = M('Anketa')->loadAnswerById($answer_id);
             $obSubanswer = M('Anketa')->loadSubanswerById($subanswer_id);
             $obResultAnswer = M('Anketa')->createResultAnswer($post, $obResult, $obAnswer, $obSubanswer);
             $obResultAnswer->save();
         }
     }
 }
 // check result and redirect
Example #6
0
    if (!@$error) {
        $obBarcode->segment_id = $obSegment->id();
        $obBarcode->family_id = $obFamily->id();
        $obBarcode->class_id = $obClass->id();
        $obBarcode->brick_id = $obBrick->id();
        $obBarcode->ac = count($obBrick->getAttributes());
        if (isset($_POST['source'])) {
            $obBarcode->source = TF($_POST['source'], 'post');
        }
        $attributes_ids = explode(",", @$_POST['attributes']);
        $values_ids = explode(",", @$_POST['values']);
        for ($i = 1; $i <= $obBarcode->_attribute_quantity; $i++) {
            $obBarcode->{'a' . $i} = isset($attributes_ids[$i - 1]) ? $attributes_ids[$i - 1] : NULL;
            $obBarcode->{'v' . $i} = isset($values_ids[$i - 1]) ? $values_ids[$i - 1] : NULL;
        }
        MC('Barcode')->save($obBarcode, $error);
        if (isset($_POST['keywords']) && $_POST['keywords'] != 'undefined') {
            if (!MC('User')->canChangeBrickKeywords(me())) {
                $message = 'gpc.you_cannot_change_keywords';
            } else {
                $obBrick->keywords = TF($_POST['keywords'], 'post');
                $obBrick->save();
            }
        }
    }
}
$root_params['status'] = 'ok';
$root_params = array_merge($root_params, MC('Message')->setXmlMessage(@$error, @$message, 'barcode'));
// сформировать и вывести XML
$root = M('Ajax')->init('xml', $root_params);
M('Ajax')->xml();
Example #7
0
             $is_food = $v['is_food'];
         }
         if (@$v['delete'] == 1) {
             $obBarcode->delete();
         } else {
             // edit barcode
             if (isset($v['is_food']) && $obBarcode->is_food !== $v['is_food']) {
                 $obBarcode->is_food = (int) $v['is_food'];
                 $changed = TRUE;
             }
             if (isset($v['attribute_1']) && $obBarcode->attribute_1 !== $v['attribute_1']) {
                 $obBarcode->attribute_1 = TF($v['attribute_1'], 'post');
                 $changed = TRUE;
             }
             if (isset($v['to_refresh']) && $obBarcode->to_refresh !== $v['to_refresh']) {
                 $obBarcode->to_refresh = TF($v['to_refresh'], 'post');
                 $changed = TRUE;
             }
             if ($changed) {
                 if ($obBarcode->save()) {
                     $u++;
                 }
             }
         }
     }
 }
 // set flag `is_food` for all barcodes in query
 if ($like_iowa && isset($is_food)) {
     MC('Report_Blank')->setFilters($list, $_GET);
     if (count($list->getFilters()) > 0) {
         $query = $list->request()->getQuery();
Example #8
0
 */
$types = qw2('20>generaltype 21>owner 22>brand 23>subbrand 57>variant 58>garbage');
if (!isset($types[$list->id()])) {
    throw new Exception(__FILE__ . ': Wrong report = ' . $list->id() . ' to edit!');
}
$type = $types[$list->id()];
if (isset($_POST['data'])) {
    $pkey = $list->edit_varname;
    $u = 0;
    // кол-во обновленных записей
    foreach ($_POST['data'] as $k => $v) {
        $obSource = M('Barcode')->{'load' . ucfirst($type) . 'ById'}(intval($v[$pkey]));
        if (!empty($v['moderated'])) {
            foreach (M('Barcode')->fields($type) as $kk => $vv) {
                if (isset($v[$vv]) && $vv != 'id') {
                    $v[$vv] = TF($v[$vv], 'post');
                    $obSource->{$vv} = $v[$vv];
                }
            }
            $obSource->moderated = 1;
            try {
                if ($obSource->save()) {
                    $u++;
                }
            } catch (RM_Validator_Exception $e) {
                foreach ($e->getResult()->getErrors() as $err) {
                    break;
                }
                if ($err['code'] == 'not_empty') {
                    $error = L('barcode.names_not_specified');
                }
Example #9
0
 unset($obDestination);
 $action = 'save';
 // default action
 if ($trace) {
     M('Trace')->trace('edit_brand', get_class($obEntity));
 }
 if (!isset($_POST[$edit_fields[$obEntity->type()]['name']])) {
     $error = 'fill_required_fields';
     break;
 }
 // process $_POST data begin -----------------------------------------------------
 $post = array();
 $name = TF($_POST[$edit_fields[$obEntity->type()]['name']], 'post');
 foreach ($edit_fields[$obEntity->type()] as $field => $post_name) {
     if (isset($_POST[$post_name])) {
         $post[$field] = TF($_POST[$post_name], 'post');
     }
 }
 //$post['moderated'] = $moderated;
 // process $_POST data end -------------------------------------------------------
 // check move begin --------------------------------------------------------------
 if ($obEntity->name != $name) {
     if ($trace) {
         M('Trace')->trace('edit_brand', $obEntity->name . " != {$name}");
     }
     // check for 'N/A'
     if (M('Barcode')->checkNa($name)) {
         $obDestination = M('Barcode')->getNaEntity($obEntity->type());
         if (isNull($obDestination)) {
             $post['stoplist'] = 1;
         } else {
Example #10
0
 /**
  *	Отредактировать данные.
  *
  *	@param	array	$data
  *	@return void
  **/
 public function editData($post = array())
 {
     if (!isset($post['data'])) {
         return FALSE;
     }
     $pkey = $this->_list->edit_varname;
     // purchase_id?
     if ($this->_list->base) {
         M('Db')->setCurrentConnection($this->_list->base);
     }
     $u = 0;
     // кол-во обновленных записей
     /*		print '<pre>';
     		print_r($post['data']);
     		exit;*/
     foreach ($post['data'] as $k => $v) {
         $update_id = intval($v[$pkey]);
         $updateArray = array();
         unset($obUser);
         if ($update_id) {
             $current = iteratorToArray(M('Db')->query('SELECT * FROM ' . $this->_table . ' WHERE ' . $pkey . ' = ?', $update_id));
             if (!$current) {
                 continue;
             }
             // Заметка администратора
             $note = TF(@$v['note'], 'sh');
             if ($note) {
                 if (!isset($obUser)) {
                     $obUser = M('User')->loadUserById($update_id);
                 }
                 $obNote = M('AdminNote')->createNote(array('user_id' => $obUser->id(), 'body' => $note), me());
                 if ($obNote->save()) {
                     $updateArray['note'] = $note;
                 }
             }
             // Установить/сбросить дату выезда
             if (isset($v['plan_date'])) {
                 if (@$v['plan_date']['reset']) {
                     $updateArray['plan_date'] = NULL;
                 } else {
                     if (@$v['plan_date']['Day']) {
                         if (!@$v['plan_date']['Year']) {
                             $v['plan_date']['Year'] = date('Y');
                         }
                         if (!@$v['plan_date']['Month']) {
                             $v['plan_date']['Month'] = date('m');
                         }
                         $plan_date = $v['plan_date']['Year'] . '-' . $v['plan_date']['Month'] . '-' . $v['plan_date']['Day'];
                         $plan_date = M('Tools')->date()->dbDate($plan_date);
                         if ($current[0]['plan_date'] != $plan_date) {
                             $updateArray['plan_date'] = $plan_date;
                         }
                     }
                 }
             }
             // Результат
             if (isset($v['equipment_removed'])) {
                 $equipment_removed = intval($v['equipment_removed']);
                 if ($v['reason'] == 1 || $v['reason'] == 2) {
                     // Снятие оборудования
                     if ($current[0]['equipment_removed'] != $equipment_removed) {
                         if (!isset($obUser)) {
                             $obUser = M('User')->loadUserById($update_id);
                         }
                         $obUser->equipment_removed = $equipment_removed;
                         if ($equipment_removed > 0) {
                             $obUser->equipment = 0;
                             $updateArray['equipment'] = 0;
                             $updateArray['plan_date'] = NULL;
                         }
                         $obUser->save();
                         $updateArray['equipment_removed'] = $equipment_removed;
                     }
                 } else {
                     if ($v['reason'] == 3) {
                         // Ремонт
                         if ($equipment_removed) {
                             if (!isset($obUser)) {
                                 $obUser = M('User')->loadUserById($update_id);
                             }
                             $obUser->repair_status = 0;
                             $obUser->save();
                             M('Db')->query('DELETE FROM ' . $this->_table . ' WHERE ' . $pkey . ' = ?', $update_id);
                             $u++;
                             continue;
                             //$updateArray['plan_date'] = NULL;
                         }
                     }
                 }
             }
             // Обновить отчет
             if ($updateArray) {
                 $keys = $values = array();
                 foreach ($updateArray as $kk => $vv) {
                     $keys[] = $kk . " = ?";
                     $values[] = $vv;
                 }
                 $values[] = $update_id;
                 M('Db')->query('UPDATE ' . $this->_table . ' SET ' . implode(',', $keys) . ' WHERE ' . $pkey . ' = ?', $values);
                 $u++;
             }
         }
         $this->markAbnormalData();
     }
     if (@$error) {
         error($error);
     }
     //if ($u) message($u . ' entries was successfully updated!' . print_r($updateArray, 1));
     return TRUE;
 }
Example #11
0
            }
        }
    }
}
// delete catalog price
if (isset($data['delete_cp_id'])) {
    $obPrice = M('Barcode')->catalog()->loadPriceById($data['delete_cp_id']);
    if (!isNull($obPrice)) {
        $obPrice->delete();
    }
    goU('barcode.catalog_goods', NULL, array('owner_id' => @$data['owner_id'], 'number' => @$data['number']));
}
// search/create barcode object
if (isset($data['owner_id']) || isset($data['number'])) {
    $data['owner_id'] = (int) @$data['owner_id'];
    $data['number'] = TF(@$data['number'], 'post');
    if (!$data['owner_id']) {
        $error = 'specify_owner';
    } else {
        if (isNull($obOwner = M('Barcode')->loadOwnerById($data['owner_id']))) {
            $error = 'no_such_owner';
        } else {
            if (!$obOwner->prefix) {
                $error = 'no_catalog_owner';
            } else {
                if (!$data['number']) {
                    $error = 'specify_number';
                } else {
                    $value = $obOwner->prefix . str_pad($data['number'], 5, '0', STR_PAD_LEFT);
                    $obBarcode = M('Barcode')->loadBarcodeByValue($value);
                    if (isNull($obBarcode)) {
Example #12
0
$PROFILER_ENABLED = 0;
$INIT_LIGHT = 0;
$INIT_CONFIG = 1;
$INIT_NO_CS_AUTH = 1;
$USE_POST_PROCESS = 0;
require_once $_SERVER["ROOT_DIR"] . "/init.php";
if (!me()->id()) {
    exit;
}
if (isset($_POST['data'])) {
    $data = @$_POST['data'];
    foreach ($data as $row) {
        $link_id = array_shift($row);
        if (!isNull($link = M('Shop')->loadLinkById($link_id))) {
            foreach ($row as $k => $v) {
                $link->{$k} = TF($v, 'post');
            }
            if (!$link->name) {
                $link->name = L('shop.empty_name');
            }
            $link->user_id = me()->id();
            try {
                $link->save();
            } catch (RM_Validator_Exception $e) {
                $err = iterFirst($e->getResult()->getErrors());
                error(L('shop.' . $err['code'], array('OBJECT' => L('shop.' . $err['place']))));
                break;
            }
        }
    }
}
Example #13
0
                $barcodes = array();
                foreach ($treeObject[$seqKey]->getBarcodes($restriction) as $k => $v) {
                    $barcodes[] = $v->value;
                }
                $root_params['barcodes'] = implode(',', $barcodes);
            }
            break;
    }
}
// дополнительная фильтрация
if (@$list) {
    // ограничение по дате кодировки
    if ($coded_date) {
        __applyCodedDateRestriction($list, $root_params, $coded_date);
    }
    // поиск по name
    if ($number_of_params == 0 && @$_GET['filter']) {
        $filter = TF($_GET['filter'], 'trim');
        __applyFilterRestriction($list, $root_params, $filter);
    }
}
$root_params['status'] = 'ok';
$root_params = array_merge($root_params, MC('Message')->setXmlMessage(@$error, @$message, 'barcode'));
$root = M('Ajax')->init('tree', $root_params);
if (@$map) {
    $map['level'] = $number_of_params + 1;
}
if (@$list) {
    $root->addNode('node', $list, $map);
}
M('Ajax')->xml();
Example #14
0
 case 'class':
 case 'brick':
 case 'attribute':
 case 'value':
     if (!@$error) {
         $action = isset($_POST['id']) ? 'update' : 'create';
         // родительский объект (например, для family=>segment)
         $parent_type = @M('Gpc')->parent_types($what);
         if ($parent_type) {
             $parent_field = $parent_type . '_id';
         }
         // свойства для нашего объекта
         $data = array();
         foreach (M('Gpc')->fields($what) as $k => $v) {
             if (isset($_POST[$k]) && $k != 'id' && ($parent_type && $k != $parent_field || !$parent_type)) {
                 $data[$k] = TF($_POST[$k], 'post');
             }
         }
         // создадим и сохраним объект
         if ($action == 'create') {
             if ($parent_type) {
                 if (!isset($_POST[$parent_field])) {
                     $error = 'please_specify_' . $parent_type;
                 } else {
                     if (isNull($obParent = M('Gpc')->{'load' . ucfirst($parent_type) . 'ById'}($_POST[$parent_field]))) {
                         $error = 'no_such_' . $parent_type;
                     }
                 }
             }
             if (!@$error) {
                 if (isNull($object = M('Gpc')->{'create' . ucfirst($what)}($data, isset($obParent) ? $obParent : NULL))) {
Example #15
0
 protected function _prepare($data, $admin, $action, $obUser = NULL)
 {
     $props = array();
     foreach ($this->_getFields($admin, $action, $obUser) as $k) {
         if ($k == 'diary_access_disabled') {
             $props['diary_access_disabled'] = (int) (!@$data['panel_access']);
         } else {
             if (in_array($k, array('is_tester', 'repair_status', 'equipment', 'equipment_removed'))) {
                 $props[$k] = (int) @$data[$k];
             } else {
                 if (in_array($k, array('city_id', 'area_id', 'metro_id', 'payment_method', 'deny_status'))) {
                     $props[$k] = (int) @$data[$k] ? (int) $data[$k] : NULL;
                 } else {
                     $props[$k] = isset($data[$k]) ? TF($data[$k], 'post') : NULL;
                 }
             }
         }
     }
     return $props;
 }
Example #16
0
/*
	Adds/removes relations between gpc objects.

	@param		string		what		relation type
*/
$PROFILER_ENABLED = 0;
$INIT_LIGHT = 0;
$INIT_CONFIG = 1;
$INIT_NO_CS_AUTH = 1;
$USE_POST_PROCESS = 0;
require_once $_SERVER["ROOT_DIR"] . "/init.php";
$use_cache = 0;
$root_params = array('version' => 1, 'status' => 'ok', 'modified' => M('Gpc')->getTimeOfModification('tree'));
// атрибуты корневого тега
if (isset($_GET['filter'])) {
    $filter = TF($_GET['filter'], 'post');
    $root_params['filter'] = $filter;
}
if (!MC('User')->checkAccessToGpc(me())) {
    $error = 'common.access_denied';
}
if (!@$error) {
    $map = array();
    foreach (M('Gpc')->entities() as $entity) {
        $map[$entity] = qw2('data>id() label>getName()');
    }
    $map['brick']['info'] = 'getInfo()';
    $map['brick']['keywords'] = 'keywords';
    // поиск по указанному слову
    // --------------------------------------------------------------------
    if (isset($filter)) {
Example #17
0
 /**
  * Saves user menu display settings
  *
  * @param	RM_Account_iUser		$user
  * @param	string					$request_uri
  * @param	string					$display
  * @return	void
  */
 public function saveMenuDisplay(RM_Account_iUser $user, $request_uri, $display)
 {
     if (!$request_uri || $request_uri == '/') {
         return false;
     }
     $user_settings = MC('User')->getSettings($user, 'user-settings');
     $request_uri_md5 = md5($request_uri);
     if (!is_array($user_settings['display_menu'])) {
         $user_settings['display_menu'] = array();
     }
     $user_settings['display_menu'][$request_uri_md5] = TF($display, 'sh');
     M('Settings')->save($user, $user_settings, 'user-settings');
     return true;
 }