Ejemplo n.º 1
0
 public function getCreateServiceForm($services, $usersData, $languageCode, $currentService = null)
 {
     $header = isset($currentService) ? "Edit Service" : "Create new Service";
     $action = isset($currentService) ? "edit" : "create";
     $id = isset($currentService) ? $currentService[0]['id'] : null;
     $serviceLangs = isset($currentService) ? $currentService[0]["code"] == "fa" ? array("fa" => $currentService[0], "en" => $currentService[1]) : array("fa" => $currentService[1], "en" => $currentService[0]) : array();
     // die(var_dump($languageCode));
     $form = new Form(['header' => $header, 'action' => $this->getController()->url()->fromRoute("service", array("controller" => "management", "action" => $action, "id" => $id, "lang" => $languageCode)), 'name' => 'serviceForm']);
     $tab = new TabSet();
     $fieldsetFa = new FieldSet(['name' => 'serviceFa', 'header' => 'Add A New Service', 'label' => 'Fa']);
     $serviceNameFa = new Text(['name' => 'name[fa]', 'placeholder' => 'Service Name', 'type' => 'text', 'value' => isset($serviceLangs["fa"]["name"]) ? $serviceLangs["fa"]["name"] : "", 'label' => 'Service Name']);
     $descriptionFa = new Textarea(['name' => 'description[fa]', 'placeholder' => 'Description ...', 'label' => 'Description', 'value' => isset($serviceLangs["fa"]["description"]) ? $serviceLangs["fa"]["description"] : ""]);
     $enablCheckboxFa = new CheckBox(['name' => 'enable[fa]', 'label' => 'Enable', 'checked' => isset($serviceLangs["fa"]["enable"]) ? $serviceLangs["fa"]["enable"] : "0", 'option' => '']);
     $fieldsetFa->addChild($serviceNameFa, 'serviceNameFa');
     $fieldsetFa->addChild($descriptionFa, 'username');
     $fieldsetFa->addChild($enablCheckboxFa);
     $fieldsetEn = new FieldSet(['name' => 'serviceEn', 'header' => 'Add A New Service', 'label' => 'En']);
     $serviceNameEn = new Text(['name' => 'name[en]', 'placeholder' => 'Service Name', 'value' => isset($serviceLangs["en"]["name"]) ? $serviceLangs["en"]["name"] : "", 'type' => 'text', 'label' => 'Service Name']);
     $descriptionEn = new Textarea(['name' => 'description[en]', 'placeholder' => 'Description ...', 'label' => 'Description', 'value' => isset($serviceLangs["en"]["description"]) ? $serviceLangs["en"]["description"] : ""]);
     $enablCheckboxEn = new CheckBox(['name' => 'enable[en]', 'label' => 'Enable', 'checked' => isset($serviceLangs["en"]["enable"]) ? $serviceLangs["en"]["enable"] : "0", 'option' => '']);
     $fieldsetEn->addChild($serviceNameEn);
     $fieldsetEn->addChild($descriptionEn, 'username');
     $fieldsetEn->addChild($enablCheckboxEn);
     $submit = new Button();
     $fieldsetCat = new FieldSet(['name' => 'parent', 'label' => 'Parent', 'header' => 'Choose Parent Service']);
     $treeSelect = new TreeSelect(["title" => "choose category of your service", "services" => $services, "selected" => isset($currentService[0]["parent"]) ? $currentService[0]["parent"] : "", "name" => "parent"]);
     $fieldsetCat->addChild($treeSelect);
     $fieldsetAssign = new FieldSet(["name" => 'assigned-users', 'label' => 'Assign Users', 'header' => 'assign users to Service']);
     $assign = new Assign(["selected" => $usersData["selected"], "unselected" => $usersData["unselected"], "title" => "users"]);
     $fieldsetAssign->addChild($assign);
     $tab->addChild($fieldsetFa, 'fieldsetFa');
     $tab->addChild($fieldsetEn, 'fieldsetEn');
     $tab->addChild($fieldsetCat, 'fieldsetCat');
     $tab->addChild($fieldsetAssign, 'fieldsetAssign');
     $form->addChild($tab);
     $form->addChild($submit, 'submit');
     return $form;
     return $form;
 }
 protected function getCreateServiceForm($services)
 {
     $form = new Form(['header' => 'Service Management', 'action' => $this->url()->fromRoute("service", array("controller" => "management", "action" => "create")), 'name' => 'test']);
     $tab = new TabSet();
     $fieldsetFa = new FieldSet(['name' => 'serviceFa', 'header' => 'Add A New Service', 'label' => 'Fa']);
     $serviceNameFa = new Text(['name' => 'name[fa]', 'placeholder' => 'Service Name', 'type' => 'text', 'value' => '', 'label' => 'Service Name']);
     $descriptionFa = new Textarea(['name' => 'description[fa]', 'placeholder' => 'Description ...', 'label' => 'Description']);
     $enablCheckboxFa = new CheckBox(['name' => 'enable[fa]', 'label' => 'Enable', 'checked' => 0, 'option' => '']);
     $fieldsetFa->addChild($serviceNameFa, 'serviceNameFa');
     $fieldsetFa->addChild($descriptionFa, 'username');
     $fieldsetFa->addChild($enablCheckboxFa);
     $fieldsetEn = new FieldSet(['name' => 'serviceEn', 'header' => 'Add A New Service', 'label' => 'En']);
     $serviceNameEn = new Text(['name' => 'name[en]', 'placeholder' => 'Service Name', 'value' => '123', 'type' => 'text', 'label' => 'Service Name']);
     $descriptionEn = new Textarea(['name' => 'description[en]', 'placeholder' => 'Description ...', 'label' => 'Description']);
     $enablCheckboxEn = new CheckBox(['name' => 'enable[en]', 'label' => 'Enable', 'checked' => 0, 'option' => '']);
     $fieldsetEn->addChild($serviceNameEn);
     $fieldsetEn->addChild($descriptionEn, 'username');
     $fieldsetEn->addChild($enablCheckboxEn);
     $submit = new Button();
     $fieldsetCat = new FieldSet(['name' => 'parent', 'label' => 'Parent', 'header' => 'Choose Parent Service']);
     $treeSelect = new TreeSelect(["title" => "choose category of your service", "services" => $services, "name" => "parent"]);
     $fieldsetCat->addChild($treeSelect);
     $tab->addChild($fieldsetFa, 'fieldsetFa');
     $tab->addChild($fieldsetEn, 'fieldsetEn');
     $tab->addChild($fieldsetCat, 'fieldsetCat');
     $form->addChild($tab);
     $form->addChild($submit, 'submit');
     return $form;
     return $form;
 }