public function Resultados() { $this->CamposO = $this->CamposB; //Por ahora son iguales //consulta que funciona // select idPresta,NombreyApellido from Prestamos left join DatosUser on Prestamos.idUser=DatosUser.IdUser //otra consulta que funciona // select idPresta,Nombre from Prestamos left join Stock on Prestamos.IdStock=Stock.idStock $filtro = BaseJson::decode($this->Filtros); $Consulta = (new \yii\db\Query())->select('*')->from($this->Tabla)->where(['like', $this->CamposB, '%' . $this->TBusqueda . '%', false]); $Consulta->andWhere($filtro); if ($this->OrdenResu != "n") { //se ordena if ($this->OrdenResu == "d") { $Consulta = $Consulta->orderBy([$this->CamposO => SORT_DESC]); } else { if ($this->OrdenResu == "a") { $Consulta = $Consulta->orderBy([$this->CamposO => SORT_ASC]); } } } $this->CantTot = $Consulta->count(); $Consulta = $Consulta->offset($this->Desplaza)->limit($this->CantReg)->all(); $this->ResBusca = $Consulta; return $this->toArray(['CantTot', 'ResBusca']); }
/** * Push mass * array( * array( * 'field name to' => '', * 'field name subject' => '', * 'field name body' => '', * 'field name priority' => '', * 'field name from' => '', * 'field name attachs' => '', * ) * ) * @param Array $data * @return int Return int */ public function pushMass($data) { $table = Yii::$app->get('mailqueue')->modelMap['MailQueue']['class']; $model = new $table(); $prepareValues = []; $prepareKeys = []; $index = 1; foreach ($data as $item) { if (is_array($item)) { $prepareData = ArrayHelper::merge([$model->fieldFrom => '', $model->fieldTo => '', $model->fieldSubject => '', $model->fieldBody => '', $model->fieldAttachs => [], $model->fieldStatus => Yii::$app->get('mailqueue')->modelMap['MailQueue']['status']['unsended']], $item); $prepareData[$model->fieldAttachs] = BaseJson::encode($prepareData[$model->fieldAttachs]); if (in_array($model->fieldCreateDate, $model->attributes())) { $prepareData[$model->fieldCreateDate] = date("Y-m-d H:i:s"); } if (in_array($model->fieldUpdateDate, $model->attributes())) { $prepareData[$model->fieldUpdateDate] = date("Y-m-d H:i:s"); } $prepareKeys = empty($prepareKeys) ? array_keys($prepareData) : $prepareKeys; $prepareValues[] = array_values($prepareData); } if (($index % $this->partSize === 0 || $index >= count($data)) && false === empty($prepareValues)) { //Reconnect for big duration Yii::$app->db->close(); Yii::$app->db->open(); Yii::$app->db->createCommand()->batchInsert($table::tableName(), $prepareKeys, $prepareValues)->execute(); $prepareValues = []; } $index++; } //Reconnect for db stable works Yii::$app->db->close(); Yii::$app->db->open(); }
public function actionConsult() { // $searchModel = new LocaleSearch(); // $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $model = $this->findModel($_POST['id']); echo BaseJson::encode($model); }
public function actionSocial() { $req = Yii::$app->request; $i = $req->get('i'); $c = $req->get('c'); $a = $req->get('a'); //se inicia sesion en el ampache $Conexion = BaseJson::decode($this->actionConnectionParams()); $datos = ""; $peticionAmpache = http_post_data($Conexion["url"] . 'action=' . $Conexion['action'] . "&auth=" . $Conexion['auth'] . "×tamp=" . $Conexion['timestamp'] . "&version=" . $Conexion['version'] . "&user="******"timeout" => 1, "useragent" => "")); $peticionAmpache = substr($peticionAmpache, strpos($peticionAmpache, '<')); $peticionAmpache = substr($peticionAmpache, 0, -5); //return $peticionAmpache; $xml = simplexml_load_string($peticionAmpache); $token = $xml->auth; //se pide la informacion del album $peticionAmpache = http_post_data($Conexion["url"] . "auth=" . $token . "&action=album_songs&filter=" . $a, $datos); //return $peticionAmpache; $peticionAmpache = substr(substr($peticionAmpache, strpos($peticionAmpache, '<')), 0, -5); $xml = simplexml_load_string($peticionAmpache); //"renderizamos la vista" $salida = $this->render('index', ['urlimg' => $xml->song[0]->art, 'descripcion' => 'Escuchando ' . $xml->song[0]->album . ' en Radio Album!']); //le agregamos los parametros necesarios $salida .= '<div id="parametros" data-skin="' . $i . 'vplayer" data-album="' . $a . '" data-channel="' . $c . '"></div>' . $peticionAmpache; //mostramos la vista return $salida; }
public function actionGuardarprecio() { $Producto = urldecode($_REQUEST["Producto"]); $Precio = urldecode($_REQUEST["Precio"]); $Marca = urldecode($_REQUEST["Marca"]); $NombreComercio = urldecode($_REQUEST["NombreComercio"]); $DireccionComercio = urldecode($_REQUEST["DireccionComercio"]); $Descripcion = urldecode($_REQUEST["Descripcion"]); $salida = []; $timezone = new \DateTimeZone('America/Argentina/Buenos_Aires'); $date = new \DateTime('now', $timezone); $model = new Precios(); $prod = new productos(); $prod->Nombre = $Producto; $model->Producto = $Producto; $model->Marca = $Marca; $model->Precio = $Precio; $model->FechaCarga = $date->format('Y-m-d'); $model->Descripcion = $Descripcion; $model->NombreComercio = $NombreComercio; $model->DireccionComercio = $DireccionComercio; if ($model->save() == 1) { $prod->save(); $salida["mensaje"] = "Precio guardado correctamente"; $salida["estado"] = "1"; } else { $salida["mensaje"] = $model->StringListaErrores("Revise el campo ", "<br>"); $salida["estado"] = "0"; } return BaseJson::encode($salida); }
/** * Get field attachs * @return Array */ public function getAttachs() { if (in_array(Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldAttachs'], $this->owner->attributes())) { $value = BaseJson::decode($this->owner->{Yii::$app->get('mailqueue')->modelMap['MailQueue']['fieldAttachs']}); if (null === $value) { return []; } return $value; } return []; }
/** * Updates an existing Providers model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $modelOptions = new OptionsProvider(); if ($modelOptions->load(Yii::$app->request->post()) && $modelOptions->validate()) { $model->name = $modelOptions->name; $model->options = BaseJson::encode($modelOptions->attributes); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'modelOptions' => $modelOptions]); } }
public function actionObtenerlista() { $arreglo_dir = scandir('../components/WebPlayer/webplayers/'); $cant_elementos = sizeof($arreglo_dir); $c = 0; for ($i = 0; $i < $cant_elementos; $i++) { if ($arreglo_dir[$i] != '.' && $arreglo_dir[$i] != '..') { $directorio[$c][0] = $arreglo_dir[$i]; $directorio[$c][1] = $c; $c++; } } return BaseJson::encode($directorio); }
public function actionDebug() { $jsonTravelerArray = array('addr' => '河南省三门峡市湖滨区会兴镇王官村', 'fax' => '86 519-85125379', 'zip' => '472000', 'mail' => '*****@*****.**'); echo BaseJson::encode($jsonTravelerArray) . '<br>'; $jsonGroupArray = array('corp' => '北京神舟国际旅行社集团有限公司', 'corpCode' => 'L-BJ-CJ00080', 'scope' => '旅行社、旅游酒店、商业、餐饮等', 'addr' => '朝阳区建外大街28号北京旅游大厦', 'tel' => '', 'fax' => '', 'zip' => '', 'mail' => ''); echo BaseJson::encode($jsonGroupArray) . '<br>'; $jsonPayArray = array('payEachAdult' => '1500', 'payEachChild' => '0', 'payTravel' => '3100', 'payDeadline' => '2016-01-11', 'payType' => '1'); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('purchases' => '1', 'insurance' => '中国人寿'); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('transAgree' => '0', 'transAgency' => '', 'delayAgree' => '0', 'changeLineAgree' => '0', 'terminateAgree' => '1', 'mergeAgree' => '1', 'mergeAgency' => '北京中旅', 'teminateDealType' => '2', 'committee' => ''); echo BaseJson::encode($jsonPayArray) . '<br>'; $jsonPayArray = array('copys1' => '2', 'copys2' => '1', 'agencyComplaintsMobile' => '4000100808', 'lawCity' => '北京', 'lawComplaintsMobile' => '1', 'lawState' => '1', 'lawEmail' => '北京中旅', 'awAddress' => '2', 'lawZip' => '', 'addr' => ''); echo BaseJson::encode($jsonPayArray) . '<br>'; }
public function init() { parent::init(); $this->directorio = BaseJson::decode(WpController::actionObtenerlista()); switch ($this->ordenwp) { case "azar": //desordenar shuffle($this->directorio); break; case null: //si no se especifica orden se ve si se definio uno en particular $this->OrdenArreglado(); break; } }
public static function getPostJsonParams() { $post = file_get_contents("php://input"); //decode json post input as php array: try { $params = BaseJson::decode($post, $asArray = true); if (!$params) { $params = []; } return $params; } catch (InvalidParamException $e) { Utils::echoErrorResponse($e->getMessage()); die; } }
public function actionUpload() { $result = []; $dir = Yii::getAlias('@app/web/images/products'); if (!empty($_FILES)) { $model = new Products(); $file = UploadedFile::getInstance($model, 'upload_files[0]'); $ext = explode('.', $file->name); $ext = end($ext); $name = uniqid(); if ($file->saveAs($dir . '/' . $name . '.' . $ext)) { $result['name'] = $name . '.' . $ext; } } return BaseJson::encode($result); }
public function actionSend() { $req = Yii::$app->request; $to = "*****@*****.**"; // $to = "*****@*****.**"; $formContent = $req->post('ContactForm'); $title = $formContent['subject']; $msg = $formContent['body']; $name = $formContent['name']; $mail = $formContent['email']; $cabeceras = 'MIME-Version: 1.0' . "\r\n"; $cabeceras .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n"; $cabeceras .= 'From: ' . $mail . "\r\n"; $result = array(); $result['status'] = mail($to, $title, $msg, $cabeceras); return BaseJson::encode($result); }
/** * Look up item using UPC code and return * * @return array of item properties */ public function getItemByUPC($upcCode) { // search upcdatabase and pre-populate fields // if not found, only populate barcode field value $upcDBUrl = Yii::$app->params['apiUrl'] . '/json/' . Yii::$app->params['apiKey'] . '/' . $upcCode; $curl = new curl\Curl(); $upcResponse = $curl->get($upcDBUrl); if ($curl->responseCode) { $upcWine = BaseJson::decode($upcResponse, TRUE); if ($upcWine['valid'] == 'true') { return $upcWine; } } else { \Yii::info('Error accessing upcdatabase.log: ' . $curl->responseCode, Logger::LEVEL_ERROR); } return NULL; }
public function actionMail() { # Indicamos la dirección (nombre) del servidor $server_name = "coodesoft.com.ar"; # Indicamos la dirección de correo de esa persona $person_email = "*****@*****.**"; # Las tres líneas que vienen a continuación son necesarias # para que la cabecera del mensaje esté en formato HTML $header = "MIME-Version: 1.0\n"; $header .= "Content-Type: text/html; charset=iso-8859-1\n"; $header .= "From: " . $_POST["mail"] . "\nReply-To:\n" . $_POST["mail"] . "\nX-Mailer: PHP/"; # Esto que viene es el mensaje. (Fíjate en los tags HTML) $mensaje = "\n<b>Mensaje enviado por: " . $_POST["nombre"] . "</b><br>\n<b>Mail: " . $_POST["mail"] . "</b>\n<br>\n<font face='verdana' size='2'>" . $_POST["cuerpo"] . "</font><br /><br />"; # Función de envío del mensaje mail($person_email, "[web coodesoft] " . $_POST["asunto"], $mensaje, $header); $salida["msg"] = "Pronto nos comunicaremos con usted, gracias!"; return BaseJson::encode($salida); }
public function actionChauffeur() { //$model = array(); $a = 'amcix'; if (!empty(Yii::$app->request->get('Transferorder')['car']) and !empty(Yii::$app->request->get('Rentorder')['from'])) { $model = new Rentorder(); $timemodel = new Rentime(); date_default_timezone_set('Asia/Baku'); if ($model->load(Yii::$app->request->post())) { $jsondata = BaseJson::decode(Yii::$app->request->get('Transferorder')['car'], true); $model->car = $jsondata['car']; $amount = Yii::$app->db->createCommand('SELECT priceC , priceT , cent FROM auto where id = :json')->bindValue(':json', $model->car)->queryOne(); $converter = new CurrencyConverter(); $rate = $converter->convert('USD', 'AZN'); $reference = $model->id . time(); $reference = sha1($reference); $model->reference = $reference; $model->pickuptime = strtotime(str_replace('/', '-', $model->pickdate) . '' . $model->time_start[0]); $count = count($model->time_start) - 1; $model->endtime = strtotime("+" . $count . " day", $model->pickuptime); $kmsums = $model->fplaceid; if ($kmsums > 35) { $qiymet = $amount['cent'] * $rate * ($kmsums - 35) + $amount['priceT'] * $rate; $qiymet = intval($qiymet); } else { $qiymet = null; } if ($model->validate()) { $model->save(); $amountC = 0; foreach ($model->time_start as $i => $time) { // echo strtotime($time)-strtotime($model->time_end[$i]).'<br>'; $dteStart = new \DateTime($time); $dteEnd = new \DateTime($model->time_end[$i]); $diff = $dteStart->diff($dteEnd); //echo 'saat '.$diff->h.' invert '.$diff->invert.'<br>'; $amountC += $this->hesabla($amount['priceC'], $diff->h, $diff->invert); //$hours += $model->timestart Yii::$app->db->createCommand()->insert('rentime', ['rentid' => $model->id, 'time_start' => strtotime($time), 'time_end' => strtotime($model->time_end[$i])])->execute(); } $z = 0; $model->amount = intval($amountC * $rate); if ($qiymet != null) { $model->amount = $model->amount + $qiymet; } $model->amount = $model->amount . $z . $z; if ($model->save() and $model->validate()) { return $this->redirect(['confirmation', 'id' => $model->id, 'mode' => 'ch']); } else { foreach ($model->errors as $errors) { var_dump($errors) . '<br>'; } } } else { foreach ($model->errors as $errors) { var_dump($errors) . '<br>'; } } } return $this->render('chauffeurForm', ['model' => $model]); } return $this->redirect('error'); }
<?php use yii\helpers\Html; use kartik\icons\Icon; use yii\widgets\ActiveForm; use yii\helpers\BaseJson; use yii\web\UrlManager; use frontend\assets\FormAsset; use frontend\assets\BootstrapDateTimePickerAsset; use frontend\assets\InternationalTelephoneAsset; FormAsset::register($this); BootstrapDateTimePickerAsset::register($this); InternationalTelephoneAsset::register($this); $this->title = 'Order chaffeured service in Azerbaijan, Baku'; $jsondata = BaseJson::decode(Yii::$app->request->get('Transferorder')['car'], true); ?> <!-- Steps --> <?php $form = ActiveForm::begin(['method' => 'post']); ?> <!-- here we take all the data we need, then we smoke weed, weed, weed...--> <div id="car-price" data-price="<?php echo $jsondata['amount']; ?> "></div> <div id="chaffeur-dest-placeid" data-id="<?php echo Yii::$app->request->get('Transferorder')['chauffeurDestPlaceId']; ?> "></div> <div id="transfer-price" data-price=""></div>
public function getOptionsToArray() { return BaseJson::decode($this->options); }
/** * @param mixed $data * @param array $expressions * @param string $expPrefix * @return mixed */ protected static function processData($data, &$expressions, $expPrefix) { $processed = parent::processData($data, $expressions, $expPrefix); return self::reformatKeys($processed); }
function actionSetTags() { $module = Module::getInstance(); $req = Yii::$app->request; $filename = $req->post('rel'); $postTags = $req->post('SongForm'); $TextEncoding = 'UTF-8'; $getID3 = new getID3(); $getID3->setOption(array('encoding' => $TextEncoding)); $tagwriter = new getid3_writetags(); $tagwriter->filename = $module->params['music'] . "/" . htmlspecialchars_decode($filename); $tagwriter->tagformats = array('id3v2.4'); $tagwriter->tag_encoding = $TextEncoding; $tagwriter->remove_other_tags = false; $tagData = array(); foreach ($postTags as $index => $tag) { $tagData[$index] = array($tag); } $tagwriter->tag_data = $tagData; // write tags if ($tagwriter->WriteTags()) { $result['msg'] = "Se guardaron correctamente las etiquetas"; $result['status'] = 'success'; if (!empty($tagwriter->warnings)) { $result['msg'] = 'Ojo, hay algunas advertencias: ' . implode("-", $tagwriter->warnings); $result['status'] = 'warning'; } return BaseJson::encode($result); } else { $result['msg'] = 'Se produjo un error al escribir las etiquetas! ' . implode('-', $tagwriter->errors); $result['status'] = 'error'; return BaseJson::encode($result); } }
public function actionSavemenu() { if (Yii::$app->request->isAjax) { $data = Yii::$app->request->post(); $area_id = $data['area_id']; $menu_items = BaseJson::decode($data['menu_json']); if (count($menu_items) > 0) { // Delete Existing Menu's Before Adding New CmsMenu::deleteAll('area_id = ' . $area_id); // Insert New Set Of Menu's $p = $c = $sc = $sc1 = $sc2 = 1; foreach ($menu_items as $parent) { $model = new CmsMenu(); $model->page_id = $parent['pageid']; $model->sort_order = $p; $model->area_id = $area_id; $model->created_by = Yii::$app->user->id; $model->save(); $new_parent_id = $model->menu_id; //Children if ($new_parent_id > 0 && isset($parent['children'])) { foreach ($parent['children'] as $children) { $model = new CmsMenu(); $model->page_id = $children['pageid']; $model->sort_order = $c; $model->area_id = $area_id; $model->parent_menu_id = $new_parent_id; $model->created_by = Yii::$app->user->id; $model->save(); $new_child_id = $model->menu_id; // Sub Child if ($new_child_id > 0 && isset($children['children'])) { foreach ($children['children'] as $sub_children) { $model = new CmsMenu(); $model->page_id = $sub_children['pageid']; $model->sort_order = $sc; $model->area_id = $area_id; $model->parent_menu_id = $new_child_id; $model->created_by = Yii::$app->user->id; $model->save(); $new_sub_child_id = $model->menu_id; // Sub Child 1 if ($new_sub_child_id > 0 && isset($sub_children['children'])) { foreach ($sub_children['children'] as $sub_children1) { $model = new CmsMenu(); $model->page_id = $sub_children1['pageid']; $model->sort_order = $sc1; $model->area_id = $area_id; $model->parent_menu_id = $new_sub_child_id; $model->created_by = Yii::$app->user->id; $model->save(); $new_sub_child_id1 = $model->menu_id; // Sub Child 2 if ($new_sub_child_id1 > 0 && isset($sub_children1['children'])) { foreach ($sub_children1['children'] as $sub_children2) { $model = new CmsMenu(); $model->page_id = $sub_children2['pageid']; $model->sort_order = $sc2; $model->area_id = $area_id; $model->parent_menu_id = $new_sub_child_id1; $model->created_by = Yii::$app->user->id; $model->save(); $sc2++; } } $sc1++; } } $sc++; } } $c++; } } $p++; } \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['status' => 'success', 'message' => '<strong>Success !! </strong>Menu Item/s Succesfully Added / Updated', 'array' => $new_sub_child_id]; } else { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['status' => 'failed', 'message' => '<strong>Failed !! </strong> Menu Item is empty. Kindly add atleast one menu to a area']; } } else { $this->redirect(['selectarea']); } }
public function actionResultb() { $Model = new Busqueda(['TBusqueda' => urldecode($_REQUEST["TB"]), 'OrdenResu' => urldecode($_REQUEST["O"]), 'Desplaza' => urldecode($_REQUEST["D"]), 'CantReg' => urldecode($_REQUEST["C"]), 'Tabla' => urldecode($_REQUEST["T"]), 'CamposB' => urldecode($_REQUEST["CB"]), 'Filtros' => urldecode($_REQUEST["CO"])]); return BaseJson::encode($Model->Resultados()); }