public function send($content) { $sql = "INSERT INTO `wx_message` (`openid`, `content`, `type`) VALUES ('{$this->openid}', '{$content}', 'snd')"; $this->insert($sql); $sql = "UPDATE `wx_message` SET `type` = 'reply' WHERE `openid` = '{$this->openid}' AND `time` = '{$this->time}' AND `type` = 'rcv'"; $this->update($sql); $custom = new Custom($this->openid); return $custom->send($content); }
public function actionGetForm() { if(isset($_POST['Custom'])){ $aduit = intval($_POST['Custom']['aduit']); $child = intval($_POST['Custom']['child']); if(empty($_POST['Custom']['name'])|| empty($_POST['Custom']['namepy'])|| empty($_POST['Custom']['email'])|| empty($_POST['Custom']['tel'])){ Yii::app()->user->setFlash('alertmsg','联系人姓名,姓名拼音,电话,邮箱必须填写!'); $this->redirect($this->createUrl('/custom')); exit; } $model = new Custom; $model->type = strip_tags($_POST['Custom']['type']); $model->addr_from = strip_tags($_POST['Custom']['addr_from']); $model->addr_to = strip_tags($_POST['Custom']['addr_to']); $model->departuretime = strtotime($_POST['Custom']['departuretime']); $model->budget = floatval($_POST['Custom']['budget']); $model->daynumber = intval($_POST['Custom']['daynumber']); $model->aduit = $aduit; $model->child = $child; $model->language = strip_tags($_POST['Custom']['language']); $model->ticket = strip_tags($_POST['Custom']['ticket']); $model->cartype = strip_tags($_POST['Custom']['cartype']); $model->hotel = strip_tags($_POST['Custom']['hotel']); $model->eat = strip_tags($_POST['Custom']['eat']); $model->attractions = strip_tags($_POST['Custom']['attractions']); $model->shop = strip_tags($_POST['Custom']['shop']); $model->meet = strip_tags($_POST['Custom']['meet']); $model->gender = strip_tags($_POST['Custom']['gender']); $model->name = strip_tags($_POST['Custom']['name']); $model->namepy = strip_tags($_POST['Custom']['namepy']); $model->tel = strip_tags($_POST['Custom']['tel']); $model->qq = strip_tags($_POST['Custom']['qq']); $model->email = strip_tags($_POST['Custom']['email']); $model->replytime = strip_tags($_POST['Custom']['replytime']); $model->prireply = strip_tags($_POST['Custom']['prireply']); $model->additionmesg = strip_tags($_POST['Custom']['additionmesg']); if($model->save(false)){ Yii::app()->user->setFlash('alertmsg','提交成功,我们会尽快联系您!'); $this->redirect($this->createUrl('/custom')); }else{ Yii::app()->user->setFlash('alertmsg','提交失败,请重试!'); $this->redirect($this->createUrl('/custom')); } }else{ $this->redirect('index'); } die('没有任何数据!'); }
private function on_get() { $response = []; foreach (['langs', 'options', 'types'] as $name) { if ($this->request->query_boolean($name, false)) { $methodname = 'get_' . $name; $response[$name] = $this->context->{$methodname}(); } } if ($this->request->query_boolean('setup', false)) { $response['setup'] = $this->setup->to_jsono($this->context->is_admin()); } if ($this->request->query_boolean('theme', false)) { $theme = new Theme($this->context); $response['theme'] = $theme->get_icons(); } if ($this->request->query('items', false)) { $href = $this->request->query('items.href'); $what = $this->request->query_numeric('items.what'); $response['items'] = $this->context->get_items($href, $what); } if ($this->request->query('custom', false)) { Util::json_fail(Util::ERR_DISABLED, 'custom disabled', !$this->context->query_option('custom.enabled', false)); $href = $this->request->query('custom'); $custom = new Custom($this->context); $response['custom'] = $custom->get_customizations($href); } if ($this->request->query('l10n', false)) { Util::json_fail(Util::ERR_DISABLED, 'l10n disabled', !$this->context->query_option('l10n.enabled', false)); $iso_codes = $this->request->query_array('l10n'); $iso_codes = array_filter($iso_codes); $response['l10n'] = $this->context->get_l10n($iso_codes); } if ($this->request->query('search', false)) { Util::json_fail(Util::ERR_DISABLED, 'search disabled', !$this->context->query_option('search.enabled', false)); $href = $this->request->query('search.href'); $pattern = $this->request->query('search.pattern'); $search = new Search($this->context); $response['search'] = $search->get_items($href, $pattern); } if ($this->request->query('thumbs', false)) { Util::json_fail(Util::ERR_DISABLED, 'thumbnails disabled', !$this->context->query_option('thumbnails.enabled', false)); Util::json_fail(Util::ERR_UNSUPPORTED, 'thumbnails not supported', !$this->setup->get('HAS_PHP_JPEG')); $thumbs = $this->request->query_array('thumbs'); $response['thumbs'] = $this->context->get_thumbs($thumbs); } Util::json_exit($response); }
private function loadModel($id) { $model=Custom::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
function testDeleteCustomfield() { $customGroup = Custom::createGroup(array(), 'Individual'); $fields = array('groupId' => $customGroup->id, 'dataType' => 'Memo', 'htmlType' => 'TextArea'); $customField = Custom::createField(array(), $fields); CRM_Core_BAO_CustomField::deleteField($customField); $this->assertDBNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for deleted Custom Field.'); Custom::deleteGroup($customGroup); }
public function actionList($company_id = 0) { if ($company_id == 0) { $company_id = Yii::app()->getUser()->getProfile()->company_id; } Yii::import('customs.models.*'); $criteria = new CDbCriteria(); $criteria->with = ['user' => ['joinType' => 'INNER JOIN', 'condition' => 'user.company_id = :company_id']]; $criteria->addCondition('deleted_status != :deleted_status'); $criteria->params = [':company_id' => $company_id, ':deleted_status' => Custom::DEL_SATUS_DELETED]; $criteria->order = 'custom_id DESC'; $this->render('list', ['customs' => Custom::model()->findAll($criteria), 'company_id' => $company_id]); }
public function actionDeactivate() { Yii::app()->setImport(['application.modules.cargo.models.*']); $condition = new CDbCriteria(); $condition->addCondition('TO_DAYS(NOW()) - TO_DAYS(`deleted_status_date`) > 15'); Product::model()->updateAll(['deleted_status' => Product::DEL_SATUS_ARCHIVE], $condition); Cargo::model()->updateAll(['deleted_status' => Cargo::DEL_SATUS_ARCHIVE], $condition); Reis::model()->updateAll(['deleted_status' => Reis::DEL_SATUS_ARCHIVE], $condition); Sklad::model()->updateAll(['deleted_status' => Sklad::DEL_SATUS_ARCHIVE], $condition); Custom::model()->updateAll(['deleted_status' => Custom::DEL_SATUS_ARCHIVE], $condition); Insurance::model()->updateAll(['deleted_status' => Insurance::DEL_SATUS_ARCHIVE], $condition); SpecialTechnique::model()->updateAll(['deleted_status' => SpecialTechnique::DEL_SATUS_ARCHIVE], $condition); }
public function testCustomGroupMultipleOldFormate() { $params = array(); $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual', TRUE); $fields = array('groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text'); $customField = Custom::createField($params, $fields); $params = array('entityID' => $contactID, "custom_{$customField->id}" => 'First String'); $error = CRM_Core_BAO_CustomValueTable::setValues($params); $newParams = array('entityID' => $contactID, "custom_{$customField->id}" => 1); $result = CRM_Core_BAO_CustomValueTable::getValues($newParams); $this->assertEquals($params["custom_{$customField->id}"], $result["custom_{$customField->id}_1"]); $this->assertEquals($params['entityID'], $result['entityID']); Custom::deleteField($customField); Custom::deleteGroup($customGroup); Contact::delete($contactID); }
public function initialize() { parent::initialize(); $login = $this->session->get('login'); $custom = $this->session->get('custom'); if ($login) { if (!$custom) { $user = $this->crypt->decrypt($login); $user = Custom::findfirst(array('name' => 'yunhai')); if (!$user->uname) { $this->forward('UserLogin/index'); } $this->session->set('custom', $user->database); } } else { return $this->forward('UserLogin/index'); } }
/** * Create() method with custom data. */ public function testCreateWithCustomData() { $contactId = Contact::createIndividual(); $ids = array('contribution' => NULL); //create custom data $customGroup = Custom::createGroup(array(), 'Contribution'); $fields = array('label' => 'testFld', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup->id); $customField = CRM_Core_BAO_CustomField::create($fields); $params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => NULL, 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww322323', 'invoice_id' => '22ed39c9e9ee6ef6031621ce0eafe6da70', 'thankyou_date' => '20080522'); $params['custom'] = array($customField->id => array(-1 => array('value' => 'Test custom value', 'type' => 'String', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroup->id, 'table_name' => $customGroup->table_name, 'column_name' => $customField->column_name, 'file_id' => NULL))); $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids); // Check that the custom field value is saved $customValueParams = array('entityID' => $contribution->id, 'custom_' . $customField->id => 1); $values = CRM_Core_BAO_CustomValueTable::getValues($customValueParams); $this->assertEquals('Test custom value', $values['custom_' . $customField->id], 'Check the custom field value'); $this->assertEquals($params['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.'); $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id for Conribution.'); $this->contributionDelete($contribution->id); Custom::deleteField($customField); Custom::deleteGroup($customGroup); Contact::delete($contactId); }
/** * Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio */ public function testSetGetValuesYesNoRadio() { $params = array(); $contactID = Contact::createIndividual(); //create Custom Group $customGroup = Custom::createGroup($params, 'Individual', TRUE); //create Custom Field of type YesNo(Boolean) Radio $fields = array('groupId' => $customGroup->id, 'dataType' => 'Boolean', 'htmlType' => 'Radio'); $customField = Custom::createField($params, $fields); // Retrieve the field ID for sample custom field 'test_Boolean' $params = array('label' => 'test_Boolean'); $field = array(); //get field Id CRM_Core_BAO_CustomField::retrieve($params, $field); $fieldID = $field['id']; // valid boolean value '1' for Boolean Radio $yesNo = '1'; $params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo); $result = CRM_Core_BAO_CustomValueTable::setValues($params); $this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).'); // Check that the YesNo radio value is stored $values = array(); $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1); $values = CRM_Core_BAO_CustomValueTable::getValues($params); $this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).'); $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the boolean value is stored for contact ' . $contactID); // Now set YesNo radio to an invalid boolean value and try to reset $badYesNo = '20'; $params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo); $errorScope = CRM_Core_TemporaryErrorScope::useException(); $message = NULL; try { $result = CRM_Core_BAO_CustomValueTable::setValues($params); } catch (Exception $e) { $message = $e->getMessage(); } $errorScope = NULL; // Check that an exception has been thrown $this->assertNotNull($message, 'Verify than an exception is thrown when bad boolean is passed'); $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1); $values = CRM_Core_BAO_CustomValueTable::getValues($params); $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID); // Cleanup Custom::deleteField($customField); Custom::deleteGroup($customGroup); Contact::delete($contactID); }
<?php //header is already included since called via AJAX require 'header.php'; require 'integ/Custom.php'; $cls = new Custom(); if (@$_SERVER["HTTPS"] == "on") { $protocol = "https://"; } else { $protocol = "http://"; } $address = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; $path = str_replace("installation/smart_session.php", "", $address); $cls->path_host = $path; $output = $cls->info($path); $path = str_replace($_SESSION["freichat_renamed"] . "/", "", $path); ?> <div> <div class="box span10 centerme" id="content"> <div class="box-header well"> <h2>freichat smart custom installation - step 2</h2> </div> <div class="box-content" > <div class="page-header">
/** * Ensure that civicrm_contact.modified_date is updated correctly. * * Looking at it when contact-related custom data is updated. */ public function testTimestampsCustom() { $customGroup = Custom::createGroup(array(), 'Individual'); $this->assertNotNull($customGroup); $fields = array('custom_group_id' => $customGroup->id, 'data_type' => 'String', 'html_type' => 'Text'); $customField = $this->customFieldCreate($fields); $customField = $customField['values'][$customField['id']]; $test = $this; $this->_testTimestamps(array('INSERT' => function ($contactId) use($test, $customGroup, $customField) { $result = civicrm_api3('contact', 'create', array('contact_id' => $contactId, 'custom_' . $customField['id'] => 'test-1')); }, 'UPDATE' => function ($contactId) use($test, $customGroup, $customField) { CRM_Core_DAO::executeQuery("UPDATE {$customGroup->table_name} SET {$customField['column_name']} = 'test-2' WHERE entity_id = %1", array(1 => array($contactId, 'Integer'))); }, 'DELETE' => function ($contactId) use($test, $customGroup, $customField) { CRM_Core_DAO::executeQuery("DELETE FROM {$customGroup->table_name} WHERE entity_id = %1", array(1 => array($contactId, 'Integer'))); })); Custom::deleteGroup($customGroup); }
/** * Получает стоимость товара с учетом скидки * @param int $id * @return int */ private function _dfnGetProductPrice($id) { Custom::inc('modules/shop/inc/shop.inc.price.php'); $shopIncPrice = new Shop_inc_price($this->diafan); $price = $shopIncPrice->get((int) $id, array()); unset($shopIncPrice); return (double) (isset($price['price']) ? $price['price'] : 0); }
public function actionActivate($id) { $model = Custom::model()->findByPk($id); if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $model->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->customs != '1' || $model->user_id != Yii::app()->user->id)) { throw new CHttpException(403); } if ($model === null) { throw new CHttpException(404, 'Указанная запись не найдена'); } $model->deleted_status = Custom::DEL_SATUS_ACTIVE; $model->deleted_status_date = date('Y-m-d H:i:s'); $model->update(); Yii::app()->user->setFlash('success', Yii::t('CabinetModule.default', 'Предложение успешно активированно.')); $this->redirect('/cabinet/customs'); }
<?php if (!defined('DIAFAN')) { include dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/includes/404.php'; } if (empty($_REQUEST["order_id"])) { Custom::inc('includes/404.php'); } $pay = $this->diafan->_payment->check_pay($_REQUEST["order_id"], 'rficb'); $in_data = array('tid' => $_REQUEST['tid'], 'name' => $_REQUEST['name'], 'comment' => $_REQUEST['comment'], 'partner_id' => $_REQUEST['partner_id'], 'service_id' => $_REQUEST['service_id'], 'order_id' => $_REQUEST['order_id'], 'type' => $_REQUEST['type'], 'partner_income' => $_REQUEST['partner_income'], 'system_income' => $_REQUEST['system_income'], 'test' => $_REQUEST['test']); $my_crc = md5(implode('', array_values($in_data)) . $pay["params"]['rficb_skey']); $out_summ = $_REQUEST["partner_income"]; $crc = $_REQUEST["check"]; if ($_GET["rewrite"] == "rficb/result") { if ($my_crc != $crc) { echo "bad sign\n"; exit; } if (sprintf('%0.2f', $_REQUEST['system_income']) < sprintf('%0.2f', $pay['summ'])) { echo "Неверная сумма"; } else { $this->diafan->_payment->success($pay, 'pay'); echo "OK" . $pay["id"] . "\n"; } exit; } if ($_GET["rewrite"] == "rficb/success") { if ($my_crc == $crc) { $this->diafan->_payment->success($pay, 'redirect'); } }
/** * Move a custom field from $groupA to $groupB. Make sure that data records are * correctly matched and created. */ public function testMoveField() { $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE)); $this->assertTrue($countriesByName['ANDORRA'] > 0); $groups = array('A' => Custom::createGroup(array('title' => 'Test_Group A', 'name' => 'test_group_a', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)), 'B' => Custom::createGroup(array('title' => 'Test_Group B', 'name' => 'test_group_b', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3))); $fields = array('countryA' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryB' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryC' => Custom::createField(array(), array('groupId' => $groups['B']->id, 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country'))); $contacts = array('alice' => Contact::createIndividual(array('first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']->id => $countriesByName['ANDORRA'], 'custom_' . $fields['countryB']->id => $countriesByName['BARBADOS'])), 'bob' => Contact::createIndividual(array('first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']->id => $countriesByName['AUSTRIA'], 'custom_' . $fields['countryB']->id => $countriesByName['BERMUDA'], 'custom_' . $fields['countryC']->id => $countriesByName['CHAD'])), 'carol' => Contact::createIndividual(array('first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']->id => $countriesByName['CAMBODIA']))); // Move! CRM_Core_BAO_CustomField::moveField($fields['countryB']->id, $groups['B']->id); // Group[A] no longer has fields[countryB] $errorScope = CRM_Core_TemporaryErrorScope::useException(); try { $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}"); $this->fail('Expected exception when querying column on wrong table'); } catch (PEAR_Exception $e) { } $errorScope = NULL; // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n WHERE entity_id = %1\n AND {$fields['countryB']->column_name} = %3\n AND {$fields['countryC']->column_name} is null", array(1 => array($contacts['alice'], 'Integer'), 3 => array($countriesByName['BARBADOS'], 'Integer'))); // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n WHERE entity_id = %1\n AND {$fields['countryB']->column_name} = %3\n AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['bob'], 'Integer'), 3 => array($countriesByName['BERMUDA'], 'Integer'), 4 => array($countriesByName['CHAD'], 'Integer'))); // Carol: Group[B] still has fields[countryC] but did not get fields[countryB] $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n WHERE entity_id = %1\n AND {$fields['countryB']->column_name} is null\n AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['carol'], 'Integer'), 4 => array($countriesByName['CAMBODIA'], 'Integer'))); Custom::deleteGroup($groups['A']); Custom::deleteGroup($groups['B']); }
/** * обавить * @param int $id * @param null $delivery * @throws CException * @throws CHttpException */ public function actionAdd($id = 0, $delivery = null) { if (!empty($id)) { $Cargo = Cargo::model()->findByPk($id); if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Cargo->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->cargo != '1' || $Cargo->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) { throw new CHttpException(403); } $AddressesForm = $Cargo->getAddressForm(); $CostForm = $Cargo->getCostForm(); $ContentManager = null; } else { if (Yii::app()->user->getProfile()->content_manager == '0') { if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->cargo != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) { throw new CHttpException(403); } elseif (!Yii::app()->getUser()->getProfile()->company->validate) { $this->redirect('/complete'); } $ContentManager = null; } else { $ContentManager = new ContentManager(); } $Cargo = new Cargo(); $AddressesForm = new AddressesForm(); if (isset($delivery)) { $product = Product::model()->findByPk($delivery); $AddressesForm->from_1_name = $product->getEavAttribute('adres_name'); $AddressesForm->from_1_address_lat = $product->getEavAttribute('adres_adress_lat'); $AddressesForm->from_1_address_long = $product->getEavAttribute('adres_adress_long'); $AddressesForm->from_1_ind = ''; } $CostForm = new CostForm(); } $contacts = User::getContact(); $Cargo->contact_id = Yii::app()->user->id; if (!empty($_POST)) { $Cargo->setAttributes($_POST['Cargo'], false); $AddressesForm->setAttributes($_POST['AddressesForm'], false); if ($Cargo->price_asc == '0') { $CostForm->setAttributes($_POST['CostForm'], false); } if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) { $ContentManager->setAttributes($_POST['ContentManager'], false); $contentValid = $ContentManager->validate(); } else { $contentValid = true; } $valid = $AddressesForm->validate(); $valid = $Cargo->validate() && $CostForm->validate() && $valid && $contentValid; if (!$valid) { Yii::import('bootstrap.widgets.TbActiveForm'); if ($ContentManager) { echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm, $ContentManager)); } else { echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm)); } Yii::app()->end(); } else { if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) { $Cargo->user_id = User::createFakeUser($ContentManager); $Cargo->contact_id = $Cargo->user_id; } $Cargo->save(); $_POST['Cargo']['type_transport'] = ''; if (isset($Cargo->transport_type_id)) { switch ($Cargo->transport_type_id) { case 20: $_POST['Cargo']['type_transport'] = $_POST['Cargo']['sea_transport']; break; case 21: $_POST['Cargo']['type_transport'] = $_POST['Cargo']['zhd_transport']; break; case 22: $_POST['Cargo']['type_transport'] = $_POST['Cargo']['air_transport']; break; case 72: $_POST['Cargo']['type_transport'] = $_POST['Cargo']['river_transport']; break; default: break; } } $Cargo->setRelations($_POST['Cargo']); $Cargo->setAddress($AddressesForm); $Cargo->setCost($CostForm); $Cargo->autosearch(); if ($_POST['Cargo']['customs_clearance'] == 1) { if ($_POST['AddressesForm']['from_1_ind'] == 'RU') { $_POST['AddressesForm']['from_1_ind'] = 'RUS'; } if ($_POST['AddressesForm']['to_1_ind'] == 'RU') { $_POST['AddressesForm']['to_1_ind'] = 'RUS'; } if ($_POST['AddressesForm']['from_1_ind'] == 'CH') { $_POST['AddressesForm']['from_1_ind'] = 'CHE'; } if ($_POST['AddressesForm']['to_1_ind'] == 'CH') { $_POST['AddressesForm']['to_1_ind'] = 'CHE'; } $from = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['from_1_ind']]); $to = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['to_1_ind']]); $Custom = new Custom(); $Custom->type_id = $_POST['Cargo']['name_id']; $Custom->packing_id = $_POST['Cargo']['packing_id']; $Custom->country_from = isset($from) ? $from->id : 0; $Custom->country_to = isset($to) ? $to->id : 0; $Custom->weight_netto = $_POST['Cargo']['weight']; $Custom->weight_brutto = $_POST['Cargo']['weight']; $Custom->volume = $_POST['Cargo']['volume']; $Custom->date_from = $_POST['Cargo']['when_from']; $Custom->date_to = $_POST['Cargo']['when_to']; $Custom->user_id = Yii::app()->user->id; $Custom->contact_id = $_POST['Cargo']['contact_id']; $Custom->save(); $Custom->autosearch(); } if ($_POST['Cargo']['cargo_insurance'] == 1) { $addrId = Yii::app()->db->createCommand()->select('address_id')->from('site_cargo_address u')->where('cargo_id=:cargo_id', array(':cargo_id' => $Cargo->cargo_id))->order('cargo_id ASC')->limit(1)->queryRow(); $addr = Address::model()->findByPk($addrId); $Insurance = new Insurance(); $Insurance->category_id = 147; $Insurance->address_id = $addr->address_id; $Insurance->description = ''; $Insurance->contact_id = $_POST['Cargo']['contact_id']; $Insurance->create = date('Y-m-d H:i:s'); $Insurance->user_id = Yii::app()->user->id; $Insurance->date_to = $_POST['Cargo']['when_to'] != '' ? $_POST['Cargo']['when_to'] : '0000-00-00'; $Insurance->save(); $Insurance->autosearch(); } echo CJSON::encode(array('status' => '500', 'redirect' => '/cargoaddsuccess/' . $Cargo->cargo_id)); Yii::app()->end(); } } $DictionaryData = \DictionaryData::model()->findAll('group_id=3'); $this->render('add', ['Cargo' => $Cargo, 'addreses' => $AddressesForm, 'CostForm' => $CostForm, 'contacts' => $contacts, 'ContentManager' => $ContentManager, 'DictionaryData' => $DictionaryData]); }
define('REVATIVE_PATH', ''); define('BASE_PATH', "http" . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? "s" : '') . "://" . getenv("HTTP_HOST") . "/" . (REVATIVE_PATH ? REVATIVE_PATH . '/' : '')); define('ABSOLUTE_PATH', dirname(__FILE__) . '/../'); define('BASE_PATH_HREF', BASE_PATH . "registration/"); //define('BASE_URL', ($domain ? $domain : getenv("HTTP_HOST")).(REVATIVE_PATH ? '/'.REVATIVE_PATH : '')); define('BASE_URL', getenv("HTTP_HOST") . (REVATIVE_PATH ? '/' . REVATIVE_PATH : '')); include_once ABSOLUTE_PATH . 'includes/custom.php'; include_once ABSOLUTE_PATH . 'includes/developer.php'; include_once ABSOLUTE_PATH . 'includes/diafan.php'; include_once ABSOLUTE_PATH . 'includes/file.php'; Dev::init(); include_once ABSOLUTE_PATH . 'config.php'; include_once ABSOLUTE_PATH . 'includes/core.php'; include_once ABSOLUTE_PATH . 'includes/init.php'; $diafan = new Init(); Custom::inc('includes/controller.php'); Custom::inc('includes/model.php'); Custom::inc('includes/action.php'); Custom::inc('includes/controller.php'); Custom::inc('includes/model.php'); Custom::inc('includes/action.php'); $receiver = new PayqrReceiver(); $receiver->handle($diafan); } catch (PayqrExeption $e) { PayqrLog::log($e->response); } function encrypt($text) { //return md5($text); return $text; }
<div class="row custom_brutto_dop"> </div> <div class="row"> <section class="col-md-12"> <?php echo $form->textFieldGroup($Custom, 'weight_netto'); ?> <div class="input-group-btn radius weight-unit"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo Custom::enumWeight(Custom::WEIGHT_KG); ?> <span class="caret"></span></button> <ul id="weight_netto_unit_ul" class="dropdown-menu dropdown-menu-right"> <?php foreach (Custom::enumWeight() as $value => $text) { ?> <li> <a data-value="<?php echo $value; ?> "><?php echo $text; ?> </a> </li> <?php } ?> </ul> </div>
<tr class="element" onClick="window.location = '/customs/<?php echo $data->custom_id; ?> '"> <td> <?php echo $data->type->name; ?> </td> <td> <?php echo $data->weight_brutto . Custom::enumWeight($data->brutto_unit) . '/'; ?> <?php echo $data->volume; echo Yii::t('CustomsModule.default', 'м<sup>3</sup>'); ?> </td> <td style="background:none;"> <?php if ($data->date_from != '0000-00-00') { $this->widget('application.components.DateFormat', ['timestamp' => strtotime($data->date_from)]); } ?> </td> <td class="load-address" style="text-align: left"> <?php if (isset($data->from_country)) { ?> <span class="address-icon"></span>
<section class="col-md-7"> <?php echo $Custom->weight_brutto . ' ' . Custom::enumWeight($Custom->brutto_unit); ?> </section> </div> <div class="row"> <section class="col-md-5"> <b><?php echo $Custom->getAttributeLabel('weight_netto'); ?> :</b> </section> <section class="col-md-7"> <?php echo $Custom->weight_netto . ' ' . Custom::enumWeight($Custom->netto_unit); ?> </section> </div> <div class="row"> <section class="col-md-5"> <b><?php echo $Custom->getAttributeLabel('volume'); ?> :</b> </section> <section class="col-md-7"> <?php echo $Custom->volume; ?> </section>
namespace Undefined\Stash\Custom; /** * Get paths for assets */ class Custom { /** * Load all files from the inc/post-types/ folder */ public function registerPostTypes() { foreach (glob(get_template_directory() . "/inc/post-types/*.php") as $filename) { include_once $filename; } } /** * Load all files from the inc/post-types/ folder */ public function registerTaxonomies() { foreach (glob(get_template_directory() . "/inc/taxonomies/*.php") as $filename) { include_once $filename; } } } add_action('init', function () { $custom = new Custom(); $custom->registerPostTypes(); $custom->registerTaxonomies(); }, 100);
private function deleteCustom(\User $user) { $data = 'user_id = :user_id'; $param = array(':user_id' => $user->id); if ($this->debug) { echo " ... Custom: del " . Custom::model()->count($data, $param) . " \n"; } else { Custom::model()->deleteAll($data, $param); } // @TODO есть ещё таблица связи - надо разобраться с ней... }
/** * Test getGroupTitles() */ public function testgetGroupTitles() { $customGrouptitle = 'Test Custom Group'; $groupParams = array('title' => $customGrouptitle, 'name' => 'test_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'weight' => 10, 'is_active' => 1, 'version' => 3); $customGroup = Custom::createGroup($groupParams); $customGroupId = $customGroup->id; $customFieldLabel = 'Test Custom Field'; $fieldParams = array('custom_group_id' => $customGroupId, 'label' => $customFieldLabel, 'html_type' => 'Text', 'data_type' => 'String', 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1, 'version' => 3); $customField = Custom::createField($fieldParams); $customFieldId = $customField->id; $params = array($customFieldId); $groupTitles = CRM_Core_BAO_CustomGroup::getGroupTitles($params); $this->assertEquals($groupTitles[$customFieldId]['groupTitle'], 'Test Custom Group', 'Check Group Title.'); Custom::deleteGroup($customGroup); }
/** * Dashboard action * * @return void */ function custom_dashboard_setup() { wp_add_dashboard_widget('custom-dashboard-info-widget', Custom::get_info("Name") . " | " . Custom::get_info("Version"), 'custom_dashboard_info_widget'); }
public function testFixFieldValueOfTypeMemo() { $customGroup = Custom::createGroup(array(), 'Individual'); $fields = array('groupId' => $customGroup->id, 'dataType' => 'Memo', 'htmlType' => 'TextArea'); $customField = Custom::createField(array(), $fields); $custom = 'custom_' . $customField->id; $params = array(); $params = array('email' => '*****@*****.**', $custom => 'note'); CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($params); $this->assertEquals($params[$custom], '%note%', 'Checking the returned value of type Memo.'); Custom::deleteField($customField); Custom::deleteGroup($customGroup); }
function testCreate() { $params = array('title' => 'Test_Group_1', 'name' => 'test_group_1', 'extends' => array('Individual'), 'weight' => 4, 'collapse_display' => 1, 'style' => 'Inline', 'help_pre' => 'This is Pre Help For Test Group 1', 'help_post' => 'This is Post Help For Test Group 1', 'is_active' => 1); require_once 'CRM/Core/BAO/CustomGroup.php'; $customGroup = CRM_Core_BAO_CustomGroup::create($params); $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroup->id, 'title', 'id', 'Database check for custom group record.'); $this->assertEquals($params['title'], $dbCustomGroupTitle); Custom::deleteGroup($customGroup); }
public function testSetValue() { $newValue = 'NewValue'; $this->parameter->setValue($newValue); $this->assertSame($newValue, $this->parameter->getValue()); }
public function CreateUser($email) { $_POST["name"] = $email; $_POST["mail"] = $email; //Пароль 123qwe123 $_POST["password"] = "******"; //Пароль 123qwe123 $_POST["password2"] = "5667a84c6f63b6cbcd87f974c4fc032e"; $_POST["fio"] = "PayQR"; $_POST["action"] = "add"; $_POST["phone"] = ""; /** * Отключаем каптчу временно для модуля */ //в таблице diafan_config ищем модуль users по полю name='captcha' DB::query("UPDATE {config} SET name='%s' WHERE module_name='users' AND name='captcha'", "c_aptcha"); $module = 'registration'; $this->diafan->_site->module = $module; $this->diafan->current_module = $module; Custom::inc('modules/' . $module . '/' . $module . '.php'); $registration = new Registration($this->diafan); $registration->action(); /** * Включаем снова каптчу */ DB::query("UPDATE {config} SET name='%s' WHERE module_name='users' AND name='c_aptcha'", "captcha"); return $this->getUserId($email); }