public function registration() { $post = isset($_POST['EntryForm']) ? $_POST['EntryForm'] : $_POST; $step = !empty($post['step']) ? (int) $post['step'] : 1; $max = !empty($post['maxstep']) ? (int) $post['maxstep'] : 1; $back = !empty($post['back']) ? (int) $post['back'] : 0; $last = $step == $max; $code = 'participant_reg_member'; $guid = $this->getGuid(); if ($step > $max) { return $this->render('entry-confirm', ['model' => null]); } if ($back) { $step = $step - 1; } $mainmodel = new MainModel($code); $model = $mainmodel->initModel(new EntryForm(), $step, ['guid' => $guid, 'code' => $code, 'step' => $step]); $maxStep = $model->getCountStep(); if ($back) { return $this->renderForm('back', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]); } if (!$model->load(Yii::$app->request->post()) || empty($post)) { return $this->renderForm('Load first', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]); } if (!$model->validate(null, true)) { return $this->renderForm('Not valid', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]); } $json = new JsonRPCClient('http://api.json/index.php'); $value = []; foreach ($post as $key => $val) { if (in_array($key, $model->fieldList)) { $value[] = ['guid' => $guid, 'code' => $code, 'step' => $step, 'key' => $key, 'val' => $val, 'obj' => @$mainmodel->form->fields[$key]->obj]; } } $test = $json->setSaveStepsForm($value, 1); if (!$test['success']) { return $this->renderForm('Not success', ['model' => $model, 'step' => $step + 1, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]); } if ($last) { $result = $this->saveForm($guid, $code); return $this->render('entry-confirm'); } unset($mainmodel); unset($model); $step = $step + 1; $mainmodel = new MainModel($code); $model = $mainmodel->initModel(new EntryForm(), $step, ['guid' => $guid, 'code' => $code, 'step' => $step]); $maxStep = $model->getCountStep(); return $this->renderForm('Next form', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]); }
public function __construct() { # set table name parent::__construct('users'); # get the database and mysqli instance since this is the model $oDatabase = Singleton::getInstance('Database'); $this->mysqli = $oDatabase->connect(); }
function run() { if (!$this->CustomerAuth->is_logged()) { $this->redirect_to_login(); return false; } parent::run(); return true; }
public function actionIndex() { $lessons = MainModel::getRandLessons(6); require_once ROOT . "/views/index/header.php"; require_once ROOT . "/views/content/mainViewTop.php"; require_once ROOT . "/views/content/lessons/lessonsView.php"; require_once ROOT . "/views/content/mainViewBottom.php"; require_once ROOT . "/views/index/footer.php"; return true; }
public function run() { parent::run(); if (isset($_GET['id'])) { $this->_setId((string) @$_GET['id']); } if (!$this->is_customer_logged() && !in_array($this->get_action_name(), array('default', 'send_email')) && !$this->_getId()) { throw new ExceptionProcessing(24); } $this->determine_action(); }
public function run() { parent::run(); $this->determine_action(); }
/** * count all the files a user have * if and id is givin in it will get them from a specific user otherwise it will get them from the current user * if we also want to count the deleted files we can assign true to also get them * @param(int) * @return(int) */ public function countFiles($idFromSlug = null, $deleted = false) { $oUser = singleton::getInstance('User'); # the query $query = 'SELECT count(*) as countFiles FROM files LEFT JOIN users on users.id = files.users_id '; # if idFromSlug specified get them from the user id if ($idFromSlug) { $query .= ' WHERE users.id = ' . $idFromSlug; } else { $query .= ' WHERE users.id = ' . $oUser->getUserId(); } # get deleted files? if ($deleted) { $query .= ' and files.deleted = 0 '; } echo $query; exit; # execute $oResult = $this->mysqli->query($query); # fetch it $result = parent::fetchResultAssoc($oResult); # and return return $result[0]['countFiles']; }
/** * getUsers() * Get information from all users or if an id is specified just get the information from that user * * @param(int) if none specified just get all the users * @param(slug) if slug given in we get the user by its slug * @return(array) or (false) return a array with all the users information in it */ public function getUsers($idFromSlug = null, $sSlug = NULL) { # if there is a slug escape it if ($sSlug) { $sSlug = $this->mysqli->real_escape_string($sSlug); } # query $query = 'SELECT users.id, users.username, users.access, users.processed, users.active, users.deleted,users.last_active,users.delete_date,users.admin, users_info.firstname, users_info.lastname, users_info.email, users_info.lang,users_info.img,users_info.register_date,users_info.job_title,users_info.mobile, users_info.about,users_info.page_slug,users_social.facebook,users_social.instagram,users_social.twitter,users_social.website,users_social.linkedin, files.new_name, files_extensions.extension FROM users LEFT JOIN users_info on users_info.users_id = users.id LEFT JOIN users_social on users_social.users_id = users.id LEFT JOIN files on files.id = users_info.img LEFT JOIN files_extensions on files_extensions.id = files.extension '; # if id is set we want a specific user if ($idFromSlug) { $query .= 'WHERE users.id = ' . $idFromSlug; } # only use slug if slug is specified but no id is given in if ($sSlug && !$idFromSlug) { $query .= 'Where users_info.page_slug = "' . $sSlug . '"'; } # execute the query $oResult = $this->mysqli->query($query); # fetch the result associative $aResult = parent::fetchResultAssoc($oResult); # return the result return $aResult; }
public function __construct() { parent::__construct(); $this->check_email_code(); }
public function countSessions() { # the query $query = $this->mysqli->query('SELECT count(*) as amount FROM `sessions` WHERE `remote_ip` != \'localhost\''); # the result $result = parent::fetchResultAssoc($query); # return result return $result; }
$oTxtCodProducto->set_extras("data-type=\"search\" placeholder=\"Cod. Producto\""); $oTxtCodProducto->set_class("ui-input-text ui-body-d"); $arPicklist = array(); $sCodeFamilia = $oSchProporsal->get_code_familia(); $arPicklist = MainModel::get_data_for_picklist("MTB_Products_Family"); $oSelFamilia = new HelperSelect($arPicklist, "sch_Code_Familia", "Familia", $sCodeFamilia); $oSelFamilia->set_extras("data-type=\"search\""); $oSelFamilia->set_js_onchange("oMtbAjax.load_subfamilies(this);"); $oSelFamilia->set_class("ui-input-text ui-body-d"); $oSelFamilia->class_not_for_label(); $arPicklist = array(); $sSQLAnd = ""; if (!empty($sCodeFamilia)) { $sSQLAnd = "Code_Family='{$sCodeFamilia}'"; } $arPicklist = MainModel::get_data_for_picklist("MTB_Products_SubFamily", "", "", $sSQLAnd); $oSelSubFamilia = new HelperSelect($arPicklist, "sch_Code_Subfamilia", "Subfamilia", $oSchProporsal->get_code_subfamilia()); $oSelSubFamilia->set_extras("data-type=\"search\""); $oSelSubFamilia->set_class("ui-input-text ui-body-d"); $oSelSubFamilia->class_not_for_label(); $oTxtCodProducto->show(); $oSelConcepto->show(); $oSelFamilia->show(); $oSelSubFamilia->show(); ?> <br /> <?php $oListHeader = new HelperListHeader("Concepto", "Cod. Prop", array("Item", "Estado", "Dto", "Dto Ant")); $oSelPage->show(); $oHidNumPage->show(); ?>