Ejemplo n.º 1
0
 public function initialize($model, $menu_id = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $this->add(new Text("code"));
     $link = new Text("link");
     $link->addValidator(new PresenceOf(array('message' => 'link')));
     $this->add($link);
     // parents menu item
     $result = \Modules\Backend\Models\Menu_item::findByMenu_id($menu_id);
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $data = $system->getListTreeCategory($data, 'name');
     $parents = new Select('parents', $data);
     $this->add($parents);
     $tbl_menu = \Modules\Backend\Models\Menu::find();
     $menu = new Select('menu_id', $tbl_menu, array('using' => array('id', 'name')));
     $menu->setDefault($menu_id);
     $this->add($menu);
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $target = new Select('target', array('0' => 'Bình thường', '1' => 'Mở tab mới'));
     $this->add($target);
     $this->add(new Text("image"));
     $this->add(new Text("position"));
 }
 function initialize($entity = null, $options = null)
 {
     $date = new Date('date');
     $date->setLabel('Input Date');
     $date->setFilters(array('striptags', 'string'));
     $date->setDefault(date('Y-m-d'));
     $date->addValidators(array(new PresenceOf(array('message' => 'Date is required'))));
     $this->add($date);
     $start_time = new Text('start_hour');
     $start_time->setLabel('Input Start Hour');
     $start_time->setFilters(array('striptags', 'string'));
     $start_time->addValidators(array(new PresenceOf(array('message' => 'Start Time is required'))));
     $this->add($start_time);
     $finish_time = new Text('finish_hour');
     $finish_time->setLabel('Input Finish Hour');
     $finish_time->setFilters(array('striptags', 'string'));
     $finish_time->addValidators(array(new PresenceOf(array('message' => 'Finish Time is required'))));
     $this->add($finish_time);
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
     $hidden = new Hidden('id');
     if ($entity) {
         $hidden->setDefault(array($entity->id));
     }
     $this->add($hidden);
 }
 public function initialize($menuitems)
 {
     $this->_action = 'menu';
     foreach ($menuitems as $menuItem) {
         $name = new Text('menuitem[' . $menuItem->id . '][name]');
         $name->setFilters(array('striptags', 'string'));
         $name->setAttributes(array('class' => 'form-control'));
         $name->setDefault($menuItem->name);
         $url = new Text('menuitem[' . $menuItem->id . '][url]');
         $url->setFilters(array('striptags', 'string'));
         $url->setAttributes(array('class' => 'form-control'));
         $url->setDefault($menuItem->url);
         $icon = new Text('menuitem[' . $menuItem->id . '][icon]');
         $icon->setFilters(array('striptags', 'string'));
         $icon->setAttributes(array('class' => 'form-control'));
         $icon->setDefault($menuItem->icon);
         $device = new Select('menuitem[' . $menuItem->id . '][device]', Devices::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => 'None', 'emptyValue' => 0));
         $device->setDefault($menuItem->device_id);
         $id = new Hidden('menuitem[' . $menuItem->id . '][id]');
         $id->setDefault($menuItem->id);
         $this->add($name);
         $this->add($url);
         $this->add($icon);
         $this->add($device);
         $this->add($id);
     }
 }
Ejemplo n.º 4
0
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     // $this->add(new Select('status', array('0'=>'Không', '1'=>'Có')));
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("image"));
     $this->add(new TextArea("description"));
     $this->add(new TextArea("content"));
     // Config tab
     $this->add(new Text("link"));
     $this->add(new Select('url_target', array('normal' => 'Bình thường', '_blank' => 'Mở trang mới')));
     $this->add(new Text("published", array('data-format' => 'yyyy-MM-dd hh:mm:ss', 'value' => date('d-m-Y H:i:s'))));
     $this->add(new Text("position"));
     // SEO tab
     $this->add(new Text("seo_title"));
     $this->add(new TextArea("metadata"));
     $this->add(new TextArea("keyword"));
     $result = \Modules\Backend\Models\News_category::find();
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, "title");
     $category_id = new Select('category_id', $record);
     $this->add($category_id);
 }
Ejemplo n.º 5
0
 /**
  * Add all fields to the form and set form specific attributes.
  */
 public function initialize()
 {
     $this->_action = 'general';
     $title = new Text('title');
     $title->setLabel('Title');
     $title->setFilters(array('striptags', 'string'));
     $title->setAttributes(array('class' => 'form-control'));
     $title->setDefault($this->_config->application->title);
     $title->addValidators(array(new PresenceOf(array())));
     $cryptKey = new Text('cryptkey');
     $cryptKey->setLabel('Cryptkey');
     $cryptKey->setFilters(array('striptags', 'string'));
     $cryptKey->setAttributes(array('class' => 'form-control'));
     $cryptKey->setDefault($this->_config->application->phalconCryptKey);
     $cryptKey->addValidators(array(new PresenceOf(array())));
     $bgcolor = new Select('bgcolor', array('blackbg' => 'Black', 'whitebg' => 'White'), array('useEmpty' => false));
     $bgcolor->setLabel('Background color');
     $bgcolor->setDefault($this->_config->application->background);
     $debug = new Check('debug');
     $debug->setLabel('debug');
     $debug->setAttributes(array('checked' => $this->_config->application->debug == '1' ? 'checked' : null));
     $this->add($title);
     $this->add($bgcolor);
     $this->add($cryptKey);
     $this->add($debug);
 }
Ejemplo n.º 6
0
 public function initialize()
 {
     $email = new Text("email");
     $email->setLabel('Email');
     $email->addValidator(new PresenceOf(['message' => '<strong>Email</strong> address is required.']));
     $this->add($email);
     $type = new Select('type', ['master' => 'master', 'operator' => 'operator']);
     $type->setLabel('Type');
     $type->setDefault('operator');
     $this->add($type);
     //$this->setCsrf();
 }
Ejemplo n.º 7
0
 public function initialize($model = null)
 {
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $this->add(new Text("image"));
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("position"));
     $this->add(new TextArea("content"));
 }
Ejemplo n.º 8
0
 public function initialize($entity = null, $options = null)
 {
     if (isset($options['edit']) && $options['edit'] === true) {
         $this->edit = true;
     }
     $locales = $this->getDI()->get('config')->i18n->locales->toArray();
     foreach ($locales as $locale => $name) {
         if (true === $this->edit) {
             $translations = $entity->getTranslations(["article_translation_lang = '{$locale}'"])->toArray();
         }
         $article_translation_short_title[$locale] = new Text("translations[{$locale}][article_translation_short_title]", ['value' => $this->edit === true ? $translations[0]['article_translation_short_title'] : null]);
         $article_translation_long_title[$locale] = new Text("translations[{$locale}][article_translation_long_title]", ['value' => $this->edit === true ? $translations[0]['article_translation_long_title'] : null]);
         $article_translation_description[$locale] = new TextArea("translations[{$locale}][article_translation_description]", ['value' => $this->edit === true ? $translations[0]['article_translation_description'] : null]);
         $article_translation_slug[$locale] = new Text("translations[{$locale}][article_translation_slug]", ['value' => $this->edit === true ? $translations[0]['article_translation_slug'] : null]);
         $article_translation_lang[$locale] = new Hidden("translations[{$locale}][article_translation_lang]", ['value' => $locale]);
         $this->add($article_translation_short_title[$locale]);
         $this->add($article_translation_long_title[$locale]);
         $this->add($article_translation_description[$locale]);
         $this->add($article_translation_slug[$locale]);
         $this->add($article_translation_lang[$locale]);
     }
     // Categories
     $categories = new Select('categories[]', CategoryTranslation::find(["category_translation_lang = 'en'"]), ['using' => ['category_translation_category_id', 'category_translation_name'], 'multiple' => true]);
     if ($this->edit === true) {
         $categories_defaults = array();
         foreach ($entity->getCategories(["columns" => ["id"]]) as $category) {
             $categories_defaults[] = $category->id;
         }
         $categories->setDefault($categories_defaults);
     }
     $this->add($categories);
     // Hash tags
     $hashtags = new Select('hashtags[]', Hashtag::find(), ['using' => ['id', 'hashtag_name'], 'multiple' => true]);
     if ($this->edit === true) {
         $hashtags_defaults = array();
         foreach ($entity->getHashtags(["columns" => ["id"]]) as $hashtag) {
             $hashtags_defaults[] = $hashtag->id;
         }
         $hashtags->setDefault($hashtags_defaults);
     }
     $this->add($hashtags);
     // Is published
     $this->add(new Select('article_is_published', array(1 => 'Yes', 0 => 'No')));
     //CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-lg btn-primary btn-block')));
 }
Ejemplo n.º 9
0
 public function initialize($model = null)
 {
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $this->add(new Text("image"));
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("position"));
     $this->add(new TextArea("content"));
     $group_id = new Select('group_id', \Modules\Backend\Models\Image_group::find(), array('using' => array('id', 'title'), 'size' => 5));
     $this->add($group_id);
 }
Ejemplo n.º 10
0
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("image"));
     $this->add(new TextArea("content"));
     $album_id = new Select('album_id', \Modules\Backend\Models\Image_album::find(array("order" => "title")), array('using' => array('id', 'title'), 'size' => 5));
     $this->add(new Text("position"));
     $this->add($album_id);
 }
Ejemplo n.º 11
0
 public function initialize($para, $analytic)
 {
     $trackingID = Settings::getAnalyticTrackingID();
     $accountID = Settings::getAnalyticAccountID();
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed'))));
     $this->add($csrf);
     $this->add(new Submit('save', ['name' => 'save', 'value' => 'Save Changes', 'class' => 'btn btn-sm btn-info']));
     $author = new Submit('author', ['name' => 'author', 'value' => 'Authorization', 'class' => 'btn btn-sm btn-info']);
     $author->setLabel("Authorization this feature with Google");
     $this->add($author);
     $unauthor = new Submit('unauthor', ['name' => 'unauthor', 'value' => 'Clear Authorization', 'class' => 'btn btn-sm btn-warning']);
     $unauthor->setLabel("This feature had been actived. Clear authorization ?");
     $this->add($unauthor);
     $accessCode = new Text('accessCode', ['placeholder' => t('Access Code'), 'class' => 'form-control', 'value' => '']);
     $accessCode->setLabel('Access Code');
     $this->add($accessCode);
     $listView = $analytic->getListView();
     $listViewDisplay = [];
     if ($listView['state']) {
         foreach ($listView['listView'] as $view) {
             $parse = parse_url($view['profileURL']);
             $listViewDisplay[$view['webPropertyId'] . "_._" . $view['accountID']] = $parse['host'] . " => " . $view['profileName'];
         }
     }
     $selectView = new Select("selectView", $listViewDisplay, ['class' => 'form-control', 'useEmpty' => true, 'emptyText' => 'Please, choose one...']);
     $selectView->setLabel('Select View ');
     $selectView->setDefault($trackingID . "_._" . $accountID);
     $this->add($selectView);
     $data = Settings::getListTopActivity();
     $listTopActivity = [];
     $listDefaultActivity = [];
     foreach ($data as $activity) {
         $listTopActivity[$activity->code] = $activity->name;
         if ($activity->default == 1) {
             $listDefaultActivity[] = $activity->code;
         }
     }
     $topActivity = new Select("topActivity", $listTopActivity, ['name' => 'topActivity[]', 'class' => 'form-control', 'multiple' => 'multiple']);
     $topActivity->setLabel('Select 4 activity on top of dashboard');
     $topActivity->setDefault($listDefaultActivity);
     $this->add($topActivity);
 }
Ejemplo n.º 12
0
 private function addFIelds($device)
 {
     $name = new Text('devices[' . $device->id . '][name]');
     $name->setLabel('Devicename');
     $name->setFilters(array('striptags', 'string'));
     $name->setAttributes(array('class' => 'form-control'));
     $name->setDefault($device->name);
     $name->addValidators(array(new PresenceOf(array())));
     $ip = new Text('devices[' . $device->id . '][ip]');
     $ip->setLabel('IP');
     $ip->setFilters(array('striptags', 'string'));
     $ip->setAttributes(array('class' => 'form-control'));
     $ip->setDefault($device->ip);
     $ip->addValidator(new Regex(array('pattern' => '/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/')));
     $mac = new Text('devices[' . $device->id . '][mac]');
     $mac->setLabel('MAC');
     $mac->setFilters(array('striptags', 'string'));
     $mac->setAttributes(array('class' => 'form-control'));
     $mac->setDefault($device->mac);
     $mac->addValidator(new Regex(array('pattern' => '/^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/')));
     $webtemp = new Text('devices[' . $device->id . '][webtemp]');
     $webtemp->setLabel('Webtemp path');
     $webtemp->setFilters(array('striptags', 'string'));
     $webtemp->setAttributes(array('class' => 'form-control'));
     $webtemp->setDefault($device->webtemp);
     $shutdownMethod = new Select('devices[' . $device->id . '][shutdown_method]', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false));
     $shutdownMethod->setDefault($device->shutdown_method);
     $showDasboard = new Check('devices[' . $device->id . '][show_on_dashboard]');
     $showDasboard->setLabel('Show on dashboard');
     $showDasboard->setFilters(array('striptags', 'int'));
     $showDasboard->setAttributes(array('class' => 'form-control'));
     $showDasboard->setDefault($device->show_on_dashboard);
     $id = new Hidden('devices[' . $device->id . '][id]');
     $id->setDefault($device->id);
     $this->add($name);
     $this->add($ip);
     $this->add($mac);
     $this->add($webtemp);
     $this->add($shutdownMethod);
     $this->add($showDasboard);
     $this->add($id);
 }
 public function initialize($entity = null, $options = null)
 {
     // In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $uid = new Hidden('uid');
     } else {
         $uid = new Text('uid');
     }
     $this->add($uid);
     $title = new Text('title', array());
     $title->addValidators(array(new PresenceOf(array('message' => 'The name is required'))));
     $this->add($title);
     $sendermail = new Text('sendermail', array());
     $sendermail->addValidators(array(new PresenceOf(array('message' => 'The e-mail is required')), new Email(array('message' => 'The e-mail is not valid'))));
     $this->add($sendermail);
     $sendername = new Text('sendername', array());
     $sendername->addValidators(array(new PresenceOf(array('message' => 'The sendername is required'))));
     $this->add($sendername);
     $answermail = new Text('answermail', array());
     $answermail->addValidators(array(new PresenceOf(array('message' => 'The answermail is required')), new Email(array('message' => 'The answermail is not valid'))));
     $this->add($answermail);
     $answername = new Text('answername', array());
     $answername->addValidators(array(new PresenceOf(array('message' => 'The answername is required'))));
     $this->add($answername);
     $returnpath = new Text('returnpath', array());
     $returnpath->addValidators(array(new PresenceOf(array('message' => 'The returnpath is required')), new Email(array('message' => 'The returnpath is not valid'))));
     $this->add($returnpath);
     $organisation = new Text('organisation', array());
     $organisation->addValidators(array(new PresenceOf(array('message' => 'The organisation is required'))));
     $this->add($organisation);
     $authorities = new Select("authorities[]", Feusers::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'email'), 'multiple' => 'multiple'));
     $selectedOptions = [];
     foreach ($entity->getAuthorities() as $authority) {
         $selectedOptions[] = $authority->uid;
     }
     $authorities->setDefault($selectedOptions);
     $this->add($authorities);
     $this->add(new Select('htmlplain', array('0' => ControllerBase::translate('html'), '1' => ControllerBase::translate('plain'), '2' => ControllerBase::translate('both'))));
     $this->add(new Select('clicktracking', array('1' => ControllerBase::translate('active'), '0' => ControllerBase::translate('inactive'))));
 }
Ejemplo n.º 14
0
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $this->add(new Text("image"));
     $this->add(new TextArea("description"));
     $this->add(new Text("position"));
     $result = \Modules\Backend\Models\News_category::find();
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'title');
     $parents = new Select('parents', $record);
     $this->add($parents);
 }
Ejemplo n.º 15
0
 public function initialize($model = null, $menu_id = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $name = new Text("name");
     $name->addValidator(new PresenceOf());
     $this->add($name);
     $menu = \Modules\Backend\Models\Menu::findFirst();
     $menu = new Text('menu', array('value' => $menu->name, 'readonly' => true));
     $this->add($menu);
     $menu_item = \Modules\Backend\Models\Menu_item::findByMenu_id($menu_id);
     $menu_item = $system->convert_object_to_array($menu_item);
     $data = null;
     $system->recursive($menu_item, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'name');
     $menu_item = new Select('menu_item', $record);
     $this->add($menu_item);
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $target = new Select('target', array('0' => 'Không', '1' => 'Có'));
     $target->setDefault('0');
     $this->add($target);
     $this->add(new Text("image"));
     // Config tab
     $result = \Modules\Backend\Models\News_category::find();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'title');
     $category = new Select('params[category][]', $record);
     $this->add($category);
     $params_show = new Select('params[show]', array('0' => 'Danh sách bài viết', '1' => 'Kênh thông tin - bài viết'));
     $params_show->setDefault($system->getParams($model, array('name' => 'show', 'default' => 0)));
     $this->add($params_show);
     $items = new Text("params[items]", array('class' => 'txt_medium', 'value' => "{$system->getParams($model, array('name' => 'items', 'default' => 10))}"));
     $this->add($items);
     $params_show_image = new Select('params[show_image]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_image->setDefault($system->getParams($model, array('name' => 'show_image', 'default' => 2)));
     $this->add($params_show_image);
     $params_link_image = new Select('params[link_image]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_image->setDefault($system->getParams($model, array('name' => 'link_image', 'default' => 2)));
     $this->add($params_link_image);
     $params_show_title = new Select('params[show_title]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_title->setDefault($system->getParams($model, array('name' => 'show_title', 'default' => 2)));
     $this->add($params_show_title);
     $params_link_title = new Select('params[link_title]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_title->setDefault($system->getParams($model, array('name' => 'link_title', 'default' => 2)));
     $this->add($params_link_title);
     $this->add(new Text('params[number_title]'));
     $params_show_description = new Select('params[show_description]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_description->setDefault($system->getParams($model, array('name' => 'show_description', 'default' => 2)));
     $this->add($params_show_description);
     $params_link_description = new Select('params[link_description]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_description->setDefault($system->getParams($model, array('name' => 'link_description', 'default' => 2)));
     $this->add($params_link_description);
     $this->add(new Text('params[number_description]'));
     $params_show_published = new Select('params[show_published]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_published->setDefault($system->getParams($model, array('name' => 'show_published', 'default' => 2)));
     $this->add($params_show_published);
     $params_show_hits = new Select('params[show_hits]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_hits->setDefault($system->getParams($model, array('name' => 'show_hits', 'default' => 2)));
     $this->add($params_show_hits);
 }
 function editAction($activity_id, $system_id)
 {
     $activity = Activities::findFirstById($activity_id);
     $system = Systems::findFirstById($system_id);
     $form = new ActivityForm($activity);
     $bugs_id = new Select('bugs_id', Bugs::find(), array('useEmpty' => true));
     $bugs_id->setLabel('Select Bugs');
     $bugs_id->setDefault(array($activity->bugs_id));
     $array = [];
     foreach (Bugs::find(array('system_id = ' . $system_id)) as $bug) {
         if ($bug->modules_id) {
             $modules_name = '[' . $bug->modules->name . '] - ';
         } else {
             $modules_name = '';
         }
         $array[$bug->id] = $modules_name . ' ' . $bug->description;
     }
     $bugs_id->setOptions($array);
     $form->add($bugs_id);
     /*=======  Modules  =======*/
     $modulesId = new Select('modules_id', Modules::find(array('system_id = ' . $system_id)), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->setDefault(array($activity->modules_id));
     $form->add($modulesId);
     $this->view->activity = $activity;
     $this->view->system = $system;
     $this->view->page = 'Modules';
     $this->view->form = $form;
     if ($this->request->isPost()) {
         $activities = new Activities();
         $activity_id = $this->request->getPost('id');
         $activities = Activities::find($activity_id);
         if ($activities->update($this->request->getPost()) == false) {
             foreach ($activities->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Edit Activity Success');
             $this->response->redirect('activity/system/' . $system_id);
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Initialize the products form
  */
 public function initialize($entity = null, $options = array())
 {
     $nome = new Text("nome");
     $nome->setLabel("Nome");
     $nome->setAttribute('class', 'form-control');
     $this->add($nome);
     $categoria = new Select("categoria", Categorias::returnArrayForSelect(), array('using' => array('_id', 'nome')));
     $categoria->setLabel("Categoria");
     $categoria->setAttribute('class', 'form-control');
     $this->add($categoria);
     #Opçõs setadas dinamicamente
     $detalhes = unserialize($this->ecommerce_options->produto_options);
     if (!empty($detalhes)) {
         foreach ($detalhes as $key => $value) {
             if ($value['referencia'] != '') {
                 $chave = $key;
                 $chave = new Select("{$value['label']}", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome'), 'useEmpty' => true, 'emptyText' => 'Nenhum ...', 'emptyValue' => null));
                 $chave->setLabel($value['label']);
                 $chave->setAttribute('class', 'form-control ' . $value['label']);
                 if (isset($obj) && !is_null($obj)) {
                     $chave->setDefault($obj->{$value}['label']);
                 }
                 $this->add($chave);
             }
         }
     }
     #Caso detalhes do produto esteja habilitado
     if ($this->ecommerce_options->produto_detalhes == '0') {
         $valor = new Text("valor");
         $valor->setAttribute('class', 'form-control money');
         $this->add($valor);
         $desconto = new Text("desconto");
         $desconto->setAttribute('class', 'form-control money');
         $this->add($desconto);
         $estoque = new Numeric("estoque");
         $estoque->setAttribute('class', 'form-control');
         $estoque->setAttribute('rows', '5');
         $this->add($estoque);
     }
     $descricao = new TextArea("resumo");
     $descricao->setLabel("Descrição Resumida");
     $descricao->setAttribute('class', 'form-control');
     $descricao->setAttribute('rows', '5');
     $this->add($descricao);
     $descricao = new TextArea("descricao");
     $descricao->setLabel("Descrição Completa");
     $descricao->setAttribute('class', 'form-control summernote');
     $descricao->setAttribute('rows', '10');
     $this->add($descricao);
     $destaque = new Select('destaque', array(0 => 'Não', 1 => 'Sim'));
     $destaque->setLabel('Destaque');
     $destaque->setAttribute('class', 'form-control');
     $this->add($destaque);
     $ativo = new Select('ativo', array(0 => 'Não', 1 => 'Sim'));
     $ativo->setLabel('Ativo');
     $ativo->setAttribute('class', 'form-control');
     $this->add($ativo);
     if ($this->ecommerce_options->produto_cubagem_detalhe == '0') {
         #Input Estoque
         $peso = new Numeric("peso");
         $peso->setLabel("peso");
         $peso->setAttribute('class', 'form-control');
         $this->add($peso);
         #Input Estoque
         $altura = new Numeric("altura");
         $altura->setLabel("altura");
         $altura->setAttribute('class', 'form-control');
         $this->add($altura);
         #Input Estoque
         $largura = new Numeric("largura");
         $largura->setLabel("largura");
         $largura->setAttribute('class', 'form-control');
         $this->add($largura);
         #Input Estoque
         $comprimento = new Numeric("comprimento");
         $comprimento->setLabel("comprimento");
         $comprimento->setAttribute('class', 'form-control');
         $this->add($comprimento);
     }
     $meta_title = new Text("meta_title");
     $meta_title->setLabel("Meta Title");
     $meta_title->setAttribute('class', 'form-control');
     $this->add($meta_title);
     $meta_description = new TextArea("meta_description");
     $meta_description->setLabel("Meta Description");
     $meta_description->setAttribute('class', 'form-control');
     $meta_description->setAttribute('rows', '5');
     $this->add($meta_description);
     $meta_keywords = new TextArea("meta_keywords");
     $meta_keywords->setLabel("Meta Keywords");
     $meta_keywords->setAttribute('class', 'form-control');
     $meta_keywords->setAttribute('rows', '5');
     $this->add($meta_keywords);
 }
 public function initialize($obj = null, $options = array())
 {
     $detalhes = unserialize($this->ecommerce_options->produto_detalhe_options);
     foreach ($detalhes as $key => $value) {
         $chave = $key;
         $chave = new Select("detalhes[{$value['label']}][]", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome')));
         $chave->setLabel($value['label']);
         $chave->setAttribute('class', 'form-control ' . $value['label']);
         if (!is_null($obj)) {
             $chave->setDefault($obj->{$value}['label']);
         }
         $this->add($chave);
     }
     #Input Valor
     $valor = new Text("detalhes[valor][]");
     $valor->setLabel("valor");
     $valor->setAttribute('class', 'form-control money');
     if (!is_null($obj)) {
         $valor->setDefault($obj->valor);
     }
     $this->add($valor);
     #Input desconto
     $desconto = new Text("detalhes[desconto][]");
     $desconto->setLabel("desconto");
     $desconto->setAttribute('class', 'form-control money');
     if (!is_null($obj)) {
         $desconto->setDefault($obj->desconto);
     }
     $this->add($desconto);
     #Input Estoque
     $estoque = new Numeric("detalhes[estoque][]");
     $estoque->setLabel("estoque");
     $estoque->setAttribute('class', 'form-control');
     $this->add($estoque);
     if (!is_null($obj)) {
         $estoque->setDefault($obj->estoque);
     }
     if ($this->ecommerce_options->produto_cubagem_detalhe == '1') {
         $peso = new Numeric("detalhes[peso][]");
         $peso->setLabel("peso");
         $peso->setAttribute('class', 'form-control');
         if (!is_null($obj)) {
             $peso->setDefault($obj->peso);
         }
         $this->add($peso);
         $altura = new Numeric("detalhes[altura][]");
         $altura->setLabel("altura");
         $altura->setAttribute('class', 'form-control');
         $this->add($altura);
         if (!is_null($obj)) {
             $altura->setDefault($obj->altura);
         }
         $largura = new Numeric("detalhes[largura][]");
         $largura->setLabel("largura");
         $largura->setAttribute('class', 'form-control');
         $this->add($largura);
         if (!is_null($obj)) {
             $largura->setDefault($obj->largura);
         }
         $comprimento = new Numeric("detalhes[comprimento][]");
         $comprimento->setLabel("comprimento");
         $comprimento->setAttribute('class', 'form-control');
         $this->add($comprimento);
         if (!is_null($obj)) {
             $comprimento->setDefault($obj->comprimento);
         }
     }
     if (!is_null($obj)) {
         $detalhe_id = new hidden("detalhes[detalhe_id][]");
         $detalhe_id->setAttribute('class', 'form-control detalhe_id dynamicId');
         $detalhe_id->setDefault($obj->detalhe_id);
         $this->add($detalhe_id);
     }
 }
Ejemplo n.º 19
0
 /**
  * Utiliza select2
  * @param null $entity
  * @param array $options
  */
 public function initialize($entity = null, $options = array())
 {
     /*Si el form es de creacion, los campos seran required. Viceversa.*/
     $required['clave'] = "unrequired";
     $required['valor'] = "true";
     if (isset($options['required'])) {
         $required['clave'] = "required";
         $required['valor'] = "true";
     }
     /*======================= ID ==============================*/
     if (!isset($options['edit'])) {
         $element = new Text("remito_id", array('class' => 'form-control'));
         $this->add($element->setLabel("ID"));
     } else {
         $this->add(new Hidden("remito_id"));
     }
     /*=========================== FECHA =====================================*/
     $fecha = new Date("remito_fecha", array('class' => 'form-control', 'tabindex' => '1', $required['clave'] => $required['valor']));
     $fecha->setLabel("Fecha");
     $fecha->addValidators(array(new PresenceOf(array('message' => 'La fecha es Requerida'))));
     $this->add($fecha);
     /*=========================== REMITO SYA =====================================*/
     $elemento = new Numeric("remito_nro", array('class' => 'form-control', 'placeholder' => 'Ingrese un valor númerico', $required['clave'] => $required['valor'], 'tabindex' => '2'));
     $elemento->setLabel("Remito Sya");
     $elemento->setFilters(array('int'));
     $elemento->addValidators(array(new PresenceOf(array('message' => 'El Remito es Requerido'))));
     $this->add($elemento);
     /*=========================== TRANSPORTE =====================================*/
     $elemento = new Select('remito_transporteId', Transporte::find(array('transporte_habilitado=1', 'order' => 'transporte_dominio')), array('using' => array('transporte_id', 'transporte_dominio'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL DOMINIO', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '3'));
     $elemento->setLabel('Transporte');
     $this->add($elemento);
     /*=========================== TIPO DE EQUIPO =====================================*/
     $elemento = new Select('remito_tipoEquipoId', Tipoequipo::find(array('tipoEquipo_habilitado=1', 'order' => 'tipoEquipo_nombre')), array('using' => array('tipoEquipo_id', 'tipoEquipo_nombre'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL NOMBRE', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '4'));
     $elemento->setLabel('Tipo de Equipo');
     $this->add($elemento);
     /*=========================== TIPO DE CARGA =====================================*/
     $elemento = new Select('remito_tipoCargaId', Tipocarga::find(array('tipoCarga_habilitado=1', 'order' => 'tipoCarga_nombre')), array('using' => array('tipoCarga_id', 'tipoCarga_nombre'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL NOMBRE', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '5'));
     $elemento->setLabel('Tipo de Carga');
     $this->add($elemento);
     /*=========================== TIPO DE CARGA =====================================*/
     $elemento = new Select('remito_choferId', Chofer::find(array('chofer_habilitado=1', 'order' => 'chofer_nombreCompleto')), array('using' => array('chofer_id', 'chofer_dni'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL DNI', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '6'));
     $elemento->setLabel('Chofer');
     $this->add($elemento);
     /*=========================== VIAJE =====================================*/
     $elemento = new Select('remito_viajeId', Viaje::find(array('viaje_habilitado=1', 'order' => 'viaje_origen')), array('using' => array('viaje_id', 'viaje_origen'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL ORIGEN', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '7'));
     $elemento->setLabel('Viaje');
     $this->add($elemento);
     /*=========================== CONCATENADO =====================================*/
     $elemento = new Select('remito_concatenadoId', Concatenado::find(array('concatenado_habilitado=1', 'order' => 'concatenado_nombre')), array('using' => array('concatenado_id', 'concatenado_nombre'), 'useEmpty' => true, 'emptyText' => 'INGRESE EL NOMBRE', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor'], 'tabindex' => '8'));
     $elemento->setLabel('Concatenado');
     $this->add($elemento);
     /*=========================== TARIFA =====================================*/
     $tarifa = "";
     $tarifa_horaInicial = new Text("tarifa_horaInicial", array('class' => 'form-control', $required['clave'] => $required['valor'], 'tabindex' => '9'));
     $tarifa_horaInicial->setLabel("Hora Inicial");
     $tarifa_horaInicial->addValidators(array(new PresenceOf(array('message' => 'La Hora Inicial es requerida'))));
     $this->add($tarifa_horaInicial);
     $tarifa_horaFinal = new Text("tarifa_horaFinal", array('class' => 'form-control', $required['clave'] => $required['valor'], 'tabindex' => '10'));
     $tarifa_horaFinal->setLabel("Hora Final");
     $tarifa_horaFinal->addValidators(array(new PresenceOf(array('message' => 'La Hora Final es requerida'))));
     $this->add($tarifa_horaFinal);
     $tarifa_hsServicio = new Numeric('tarifa_hsServicio', array('placeholder' => 'Ingresar valor númerico', 'class' => 'form-control', 'min' => 0, 'tabindex' => '11'));
     $tarifa_hsServicio->setFilters(array('float'));
     $tarifa_hsServicio->setLabel("Horas de Servicio");
     $this->add($tarifa_hsServicio);
     $tarifa_hsHidro = new Numeric('tarifa_hsHidro', array('placeholder' => 'Ingresar valor númerico', 'class' => 'form-control', 'min' => 0, 'tabindex' => '12'));
     $tarifa_hsHidro->setFilters(array('float'));
     $tarifa_hsHidro->setLabel("Horas de Hidro");
     $this->add($tarifa_hsHidro);
     $tarifa_hsMalacate = new Numeric('tarifa_hsMalacate', array('placeholder' => 'Ingresar valor númerico', 'class' => 'form-control', 'min' => 0, 'tabindex' => '13'));
     $tarifa_hsMalacate->setFilters(array('float'));
     $tarifa_hsMalacate->setLabel("Horas de Malacate");
     $this->add($tarifa_hsMalacate);
     $tarifa_hsStand = new Numeric('tarifa_hsStand', array('placeholder' => 'Ingresar valor númerico', 'class' => 'form-control', 'min' => 0, 'tabindex' => '14'));
     $tarifa_hsStand->setFilters(array('float'));
     $tarifa_hsStand->setLabel("Horas Stand");
     $this->add($tarifa_hsStand);
     $tarifa_km = new Numeric('tarifa_km', array('placeholder' => 'Ingresar valor númerico', 'class' => 'form-control', 'min' => 0, 'tabindex' => '15'));
     $tarifa_km->setFilters(array('float'));
     $tarifa_km->setLabel("Kilometros");
     $this->add($tarifa_km);
     if ($entity != null) {
         $tarifa = $entity->getTarifa();
         $tarifa_horaInicial->setDefault($tarifa->getTarifaHoraInicial());
         $tarifa_horaFinal->setDefault($tarifa->getTarifaHoraFinal());
         $tarifa_hsServicio->setDefault($tarifa->getTarifaHsservicio());
         $tarifa_hsHidro->setDefault($tarifa->getTarifaHshidro());
         $tarifa_hsMalacate->setDefault($tarifa->getTarifaHsmalacate());
         $tarifa_hsStand->setDefault($tarifa->getTarifaHsstand());
         $tarifa_km->setDefault($tarifa->getTarifaKm());
     }
     /*======================= YACIMIENTO ==============================*/
     $elemento = new Select('yacimiento_id', Yacimiento::find(array('yacimiento_habilitado=1', 'order' => 'yacimiento_destino')), array('using' => array('yacimiento_id', 'yacimiento_destino'), 'useEmpty' => false, 'emptyText' => 'INGRESE EL DESTINO', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor']));
     $elemento->setDefault($entity->getOperadora()->getYacimiento()->getYacimientoId());
     $elemento->setLabel('Yacimiento');
     $this->add($elemento);
     /*=========================== OPERADORA =====================================*/
     $elemento = new Select('remito_operadoraId', Operadora::find(array('operadora_habilitado=1', 'order' => 'operadora_nombre')), array('using' => array('operadora_id', 'operadora_nombre'), 'useEmpty' => false, 'emptyText' => 'INGRESE LA OPERADORA', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor']));
     $elemento->setLabel('Operadora');
     $this->add($elemento);
     /*======================= EQUIPO POZO ==============================*/
     $elemento = new Select('remito_equipoPozoId', Equipopozo::find(array('equipoPozo_habilitado=1', 'order' => 'equipoPozo_nombre')), array('using' => array('equipoPozo_id', 'equipoPozo_nombre'), 'useEmpty' => false, 'emptyText' => 'INGRESE EL EQUIPO/POZO', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor']));
     $elemento->setLabel('Equipo/Pozo');
     $this->add($elemento);
     /*======================= LINEA ==============================*/
     $elemento = new Select('centroCosto_lineaId', Linea::find(array('linea_habilitado=1', 'order' => 'linea_nombre')), array('using' => array('linea_id', 'linea_nombre'), 'useEmpty' => false, 'emptyText' => 'INGRESE LA LINEA', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor']));
     $elemento->setDefault($entity->getCentroCosto()->getLinea()->getLineaId());
     $elemento->setLabel('Linea');
     $this->add($elemento);
     /*======================= CENTROCOSTO ==============================*/
     $elemento = new Select('remito_centroCostoId', Centrocosto::find(array('centroCosto_habilitado=1', 'order' => 'centroCosto_codigo')), array('using' => array('centroCosto_id', 'centroCosto_codigo'), 'useEmpty' => false, 'emptyText' => 'INGRESE EL CODIGO', 'emptyValue' => '', 'class' => 'form-control autocompletar', 'style' => 'width:100%', $required['clave'] => $required['valor']));
     $elemento->setLabel('Centro de Costo');
     $this->add($elemento);
     /*=========================== ORDEN DE CONFORMIDAD =====================================*/
     $elemento = new Text('remito_conformidad', array('placeholder' => '', 'class' => 'form-control', 'maxlength' => 50, 'tabindex' => '16'));
     $elemento->setLabel('Conformidad RE');
     $this->add($elemento);
     /*=========================== ORDEN DE NO CONFORMIDAD =====================================*/
     $elemento = new Text('remito_noConformidad', array('placeholder' => '', 'class' => 'form-control', 'maxlength' => 50, 'tabindex' => '17'));
     $elemento->setLabel('Mot no Conformidad RE');
     $this->add($elemento);
     /*=========================== OBSERVACION =====================================*/
     $elemento = new \Phalcon\Forms\Element\TextArea('remito_observacion', array('placeholder' => 'INGRESAR UNA OBSERVACIÓN', 'class' => 'form-control', 'maxlength' => 150, 'tabindex' => '18'));
     $elemento->setLabel('Observación');
     $this->add($elemento);
     /*=========================== CONTINUA =====================================*/
     $elemento = new Numeric("remito_continua", array('class' => 'form-control', 'placeholder' => 'INGRESE EL NRO REMITO', 'tabindex' => '15'));
     $elemento->setLabel("EL REMITO CONTINUA EN:");
     $elemento->setFilters(array('int'));
     $this->add($elemento);
 }
Ejemplo n.º 20
-1
 function initialize($entity = null, $options = null)
 {
     $date = new Date('date_found');
     $date->setLabel('Input Date Found');
     $date->setFilters(array('striptags', 'string'));
     $this->add($date);
     /*====================== Number =====================*/
     $number = new Text('number');
     $number->setLabel('Input Number');
     $number->setFilters(array('striptags', 'string'));
     $number->addValidators(array(new PresenceOf(array('message' => 'Number is required'))));
     $this->add($number);
     /*====================== Solved =====================*/
     $isSolved = new Radio('is_solved', array('name' => 'is_solved', 'value' => '1'));
     $isSolved->setLabel('Is Solved');
     $isSolved->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved);
     $isSolved2 = new Radio('is_solved2', array('name' => 'is_solved', 'value' => '0', 'checked' => TRUE));
     $isSolved2->setLabel('Is Solved2');
     $isSolved2->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved2);
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $modulesId = new Select('modules_id', Modules::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->addValidators(array(new PresenceOf(array('message' => 'Modules is required'))));
     if ($entity) {
         $modulesId->setDefault(array($entity->modules_id));
     }
     $this->add($modulesId);
     /*===== Bug =============*/
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
     $hidden = new Hidden('id');
     if ($entity) {
         $hidden->setDefault(array($entity->id));
     }
     $this->add($hidden);
 }