Example #1
0
 function testCreatePair()
 {
     $staff_1 = new Staff();
     $staff_1->set(array('first_name' => 'First', 'last_name' => 'User'));
     $staff_1->save();
     $staff_2 = new Staff();
     $staff_2->set(array('first_name' => 'Second', 'last_name' => 'User'));
     $staff_2->save();
     $h = new Hour();
     $h->set(array('hours' => 6, 'staff_id' => $staff_1->id, 'pair_id' => $staff_2->id));
     $h->updateOrCreateWithPair();
     $this->assertTrue($h->id, 'should have an id');
     $this->assertTrue($h->get('pair_hour_id'), 'should have a pair hour id');
     $h2 = $h->getPairHour();
     $this->assertIsA($h2, 'Hour');
     $this->assertTrue($h2->id, 'should have an hour id');
     $this->assertEqual($h2->get('hours'), 6);
     $h->set(array('hours' => 7));
     $h->updateOrCreateWithPair();
     $h3 = $h->getPairHour();
     $this->assertEqual($h2->id, $h3->id);
     $this->assertEqual($h3->get('hours'), 7);
     $this->assertEqual($h3->getPairName(), $staff_1->getName());
     $this->assertEqual($h->getPairName(), $staff_2->getName());
 }
Example #2
0
 public function daftarPekerjaPost2()
 {
     if (Request::ajax()) {
         $data = Input::all();
         $noPekerja_ = 10000;
         $noPekerja = DB::table('staff')->where('noPekerja', '>=', 10000)->orderBy('noPekerja', 'desc')->first();
         //            dd($noPekerja);
         if (isset($noPekerja)) {
             $noPekerja_ = $noPekerja->noPekerja + 1;
         }
         //            dd($noPekerja_);
         $staff = new Staff();
         $staff->noPekerja = $noPekerja_;
         $staff->nama = $data['nama'];
         $staff->noKP = $data['noKP'];
         $staff->jawatan = $data['jawatan'];
         $staff->penempatan = $data['penempatan'];
         $staff->bahagian = $data['bahagian'];
         $staff->cawangan = $data['cawangan'];
         $staff->noPhone = $data['noPhone'];
         $staff->status = $data['status'];
         $staff->catatan = $data['catatan'];
         if ($staff->save()) {
             return $noPekerja_;
         } else {
             return $noPekerja_;
         }
     }
 }
Example #3
0
 function approve($id)
 {
     if ($_POST) {
         $rs = new Staff($id);
         $rs->from_array($_POST);
         $rs->save();
     }
 }
 public function actionCreate()
 {
     $model = new Staff();
     $profile = new Profile();
     $this->performAjaxValidation(array($model, $profile), 'staff-form');
     if (isset($_POST['Staff'])) {
         $model->attributes = $_POST['Staff'];
         $profile->attributes = $_POST['Profile'];
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate()) {
             $realp = PasswordHelper::generateStrongPassword();
             $model->password = $realp;
             $model->activkey = PasswordHelper::hashPassword(microtime() . $model->password);
             $model->password = PasswordHelper::hashPassword($model->password);
             $model->status = 0;
             if ($model->save()) {
                 $profile->user_id = $model->id;
                 $profile->save();
                 if (!empty($_POST['Profile']['group_id'])) {
                     foreach ($_POST['Profile']['group_id'] as $groupid) {
                         $userGroup = new UserGroup();
                         $userGroup->profile_id = $model->id;
                         $userGroup->group_id = $groupid;
                         $userGroup->save();
                     }
                 }
                 $passwordHistory = new PasswordHistory();
                 $passwordHistory->profile_id = $model->id;
                 $passwordHistory->password = $model->password;
                 $passwordHistory->save();
                 if (Yii::app()->getModule('user')->sendActivationMail) {
                     $activation_url = $this->createAbsoluteUrl('/user/activation', array("activkey" => $model->activkey, "email" => $model->email));
                     UserModule::sendMail($model->email, UserModule::t("Your {site_name} account has been created", array('{site_name}' => Yii::app()->name)), UserModule::t("To activate your account, go to <a href='{activation_url}'>{activation_url}</a>.<br/><br/>Username: "******"<br/>Password: "******"<br/>", array('{activation_url}' => $activation_url)));
                 }
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'profile' => $profile), false, true);
                     Yii::app()->end();
                 }
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, 'An error occured while trying to create new user, please try again.');
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_form', array('model' => $model, 'profile' => $profile), false, true);
                     Yii::app()->end();
                 }
                 $this->render('create', array('model' => $model, 'profile' => $profile));
             }
         } else {
             $profile->validate();
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'profile' => $profile), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'profile' => $profile));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Staff();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Staff'])) {
         $model->attributes = $_POST['Staff'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Staff();
     if (isset($_POST['Staff'])) {
         $model->attributes = $_POST['Staff'];
         //direct attach upload file to model, we will handle it in model workflow
         $model->uploadFile = $_FILES;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', '创建成功');
             $this->redirect(array('update', 'id' => $model->s_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #7
0
	public function actionAdd()
	{
		$model = new Staff;
		
		if(isset($_POST['Staff'])){
				$model->attributes = $_POST['Staff'];
				if(empty($model->name) || empty($model->first)){
					Yii::app()->user->setFlash('error','姓和名不能为空!');
				}else{
					$model->createtime = time();
					if($model->save(false)){
						Yii::app()->user->setFlash('success','添加成功!');
						$this->redirect(array('list'));
					}else{
						Yii::app()->user->setFlash('error','添加不成功,请重试!');
					}
				}
		}
		Yii::app()->session['myurl'] = $this->createUrl('add');
		$this->render('add',array(
				'model'=>$model,
				));
	}
 function create($vars, &$errors)
 {
     return Staff::save(0, $vars, $errors);
 }
Example #9
0
    public function create($args)
    {
        $p = PermissionHandler::getInstance();
        if (!$p->allowedto(PermissionHandler::PERM_CREATE_STAFF)) {
            Utils::error("You don't have permission to create staff members.");
            return;
        }
        // No postvars means there was no creation attempt. Do form stuff.
        if (!isset($_POST['nickname'])) {
            $permissions = array();
            $permissionReflector = new ReflectionClass('PermissionHandler');
            foreach ($permissionReflector->getConstants() as $key => $value) {
                if (substr($key, 0, 4) === 'PERM') {
                    $permissions[] = array(ucwords(strtolower(str_replace('_', ' ', substr($key, 4)))), $value);
                }
            }
            $this->vars['permissions'] = $permissions;
            $this->vars['headextra'] = <<<EOS
\t\t\t\t<script type="text/javascript"><!--
\t\t\t\t\tvar formblock;
\t\t\t\t\tvar forminputs;

\t\t\t\t\tfunction prepare() {
\t\t\t\t\t\tformblock = document.getElementById('createform');
\t\t\t\t\t\tforminputs = formblock.getElementsByTagName('input');
\t\t\t\t\t}

\t\t\t\t\tfunction select_all(name, value) {
\t\t\t\t\t\tfor (i = 0; i < forminputs.length; i++) {
\t\t\t\t\t\t\tif (forminputs[i].getAttribute('name') == name) {
\t\t\t\t\t\t\t\tif (value == '1') {
\t\t\t\t\t\t\t\t\tforminputs[i].checked = true;
\t\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\t\tforminputs[i].checked = false;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t}
\t\t\t\t\t\t}
\t\t\t\t\t}

\t\t\t\t\tif (window.addEventListener) {
\t\t\t\t\t\twindow.addEventListener("load", prepare, false);
\t\t\t\t\t} else if (window.attachEvent) {
\t\t\t\t\t\twindow.attachEvent("onload", prepare)
\t\t\t\t\t} else if (document.getElementById) {
\t\t\t\t\t\twindow.onload = prepare;
\t\t\t\t\t}
\t\t\t\t//--></script>
EOS;
        } else {
            // Deal with missing variables and stuff.
            if (empty($_POST['nickname']) || empty($_POST['email'])) {
                Utils::error('You left out a required field. Please fill the form out again.');
                return;
            }
            // Validate permissions.
            $perm = 0;
            if (isset($_POST['perms']) && is_array($_POST['perms'])) {
                foreach ($_POST['perms'] as $value) {
                    $perm &= (int) $value;
                }
            }
            // Generate random password if we need to. Otherwise use the specified one.
            if (empty($_POST['password'])) {
                $possible = "0123456789abcdefghijklmnopqrstuvwxyz";
                $i = 0;
                while ($i < 6) {
                    $char = substr($possible, mt_rand(0, strlen($possible) - 1), 1);
                    if (!strstr($_POST['password'], $char)) {
                        $_POST['password'] .= $char;
                        $i++;
                    }
                }
            } else {
                if ($_POST['password'] !== $_POST['password2']) {
                    Utils::error('Entered passwords do not match.');
                    return;
                }
            }
            // Create new staff...lol.
            $user = new Staff();
            $user->nickname = $_POST['nickname'];
            $user->password = $_POST['password'];
            $user->comment = trim($_POST['comment']);
            $user->email = trim($_POST['email']);
            $user->sms = trim($_POST['mobile']);
            $user->role = 1;
            $user->created = date("Y-m-d H:i:s");
            if (!$user->isValid()) {
                Utils::error('Invalid form data entered. Please fill out the form again.');
                return;
            }
            try {
                $user->save();
            } catch (Doctrine_Exception $e) {
                Utils::error('A database error occurred: ' . $e->errorMessage());
                return;
            }
            // ALL ACCORDING TO KEIKAKU.
            // NOTE: Keikaku means plan.
            Utils::success('User successfully created.', 'staff');
        }
    }
Example #10
0
function doPopulateDatabase()
{
    // Check for a config file, if it doesn't exist go through the steps to create it.
    if (!file_exists(dirname(__FILE__) . '/config.php')) {
        header("Location: " . $_SERVER["SCRIPT_NAME"] . "?do=step1");
        return;
    }
    require_once dirname(__FILE__) . "/config.php";
    require_once dirname(__FILE__) . "/fwork/lib/Doctrine/Doctrine.php";
    spl_autoload_register(array("Doctrine", "autoload"));
    Doctrine_Manager::connection($config["database"]["dsn"]);
    Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, $config["database"]["prefix"] . "%s");
    Doctrine::createTablesFromModels(dirname(__FILE__) . "/models");
    $time = date("Y-m-d H:i:s");
    // roles
    $role_admin = new Role();
    $role_admin->name = "Admin";
    $role_admin->auth = 0xffffffff;
    $role_admin->created = $time;
    $role_admin->save();
    $role_staff = new Role();
    $role_staff->name = "Staff";
    $role_staff->auth = 0x7c700;
    $role_staff->created = $time;
    $role_staff->save();
    $role_guest = new Role();
    $role_guest->name = "Guest";
    $role_guest->auth = 0x0;
    $role_guest->created = $time;
    $role_guest->save();
    // staff
    $staff = new Staff();
    $staff->nickname = "admin";
    $staff->setPassword("admin");
    $staff->Role = $role_admin;
    $staff->admin = true;
    $staff->comment = "Administrator";
    $staff->created = $time;
    $staff->save();
    // task types
    $tasktypes = array('Raw Cap', 'Translate', 'Time', 'Translation Check', 'Typeset', 'Edit', 'Encode', 'Quality Check', 'Karaoke', 'Miscellaneous', 'Translate Signs', 'Release');
    foreach ($tasktypes as $key => $name) {
        $tasktype = new TaskType();
        $tasktype->name = $name;
        $tasktype->created = $time;
        $tasktype->save();
        $tasktypes[$key] = $tasktype;
    }
    // template
    $template = new Template();
    $template->name = "Default";
    $template->model = $tasktypes[0]->id . ":0->" . $tasktypes[1]->id . ":0; " . $tasktypes[0]->id . ":0->" . $tasktypes[10]->id . ":0; " . $tasktypes[10]->id . ":0->" . $tasktypes[4]->id . ":0; " . $tasktypes[4]->id . ":0->" . $tasktypes[3]->id . ":0; " . $tasktypes[1]->id . ":0->" . $tasktypes[2]->id . ":0; " . $tasktypes[1]->id . ":0->" . $tasktypes[3]->id . ":0; " . $tasktypes[3]->id . ":0->" . $tasktypes[5]->id . ":0; " . $tasktypes[5]->id . ":0->" . $tasktypes[6]->id . ":0; " . $tasktypes[6]->id . ":0->" . $tasktypes[7]->id . ":0; " . $tasktypes[7]->id . ":0->" . $tasktypes[11]->id . ":0; " . $tasktypes[2]->id . ":0->" . $tasktypes[5]->id . ":0; ";
    $template->created = $time;
    $template->save();
    // settings
    $settings = array('site.gzip' => true, 'site.gentime' => true);
    foreach ($settings as $name => $value) {
        $setting = new Setting();
        $setting->name = $name;
        $setting->value = $value;
        $setting->save();
        unset($setting);
    }
    echo <<<EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
\t<title>Frac :: Install</title>
\t<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
\t<h2>Frac Installer</h2>
\t<p>Table data populated successfully. You may now proceed to your <a href="./">Frac installation</a>. The username and password are "admin".</p>
</body>
</html>
EOS;
}
Example #11
0
 function save()
 {
     $staff = new Staff();
     $staff->staff_nik = $this->input->post('staff_nik');
     $staff->staff_kode_absen = $this->input->post('staff_kode_absen');
     $staff->staff_name = $this->input->post('staff_name');
     $staff->staff_address = $this->input->post('staff_address');
     $staff->staff_email = $this->input->post('staff_email');
     $staff->staff_email_alternatif = $this->input->post('staff_email_alternatif');
     $staff->staff_phone_home = $this->input->post('staff_phone_home');
     $staff->staff_phone_hp = $this->input->post('staff_phone_hp');
     $staff->staff_status_pajak = $this->input->post('staff_status_pajak');
     $staff->staff_status_nikah = $this->input->post('staff_status_nikah');
     $staff->staff_status_karyawan = $this->input->post('staff_status_karyawan');
     $staff->staff_cabang = $this->input->post('staff_cabang');
     $staff->staff_departement = $this->input->post('staff_departement');
     $staff->staff_jabatan = $this->input->post('staff_jabatan');
     //$staff->staff_photo = $this->input->post('staff_photo');
     $staff->staff_birthdate = $this->input->post('staff_birthdate');
     $staff->staff_birthplace = $this->input->post('staff_birthplace');
     $staff->staff_sex = $this->input->post('staff_sex');
     $staff->staff_password = md5('qwerty');
     // upload photo
     $config['upload_path'] = 'assets/upload';
     $config['allowed_types'] = 'gif|jpg|png|bmp';
     $this->load->library("upload", $config);
     if ($this->upload->do_upload("photo")) {
         $data = $this->upload->data();
         print_r($data);
         $staff->staff_photo = $data["file_name"];
     } else {
         //$this->staff_photo = "";
         print_r($this->upload->display_errors());
     }
     if ($staff->save()) {
         $staff_id = $this->db->insert_id();
         $this->session->set_flashdata('message', 'Staff successfully created!');
         // family data
         // save routine for family
         $family = new Family();
         $this->_saveFamily($family, $staff_id);
         // medic data
         // save routine for medical history
         $medic = new Medical();
         $this->_saveMedic($medic, $staff_id);
         // work data
         $work = new Work();
         $this->_saveWork($work, $staff_id);
         // component A data
         $comp_a = new Salary_Component_A();
         $this->_saveCompA($comp_a, $staff_id);
         // component B data
         $comp_b = new Salary_Component_B();
         $this->_saveCompB($comp_b, $staff_id);
         //redirect('staffs/');
     } else {
         // Failed
         $staff->error_message('custom', 'Field required');
         $msg = $staff->error->custom;
         $this->session->set_flashdata('message', $msg);
         redirect('staffs/add');
     }
 }
 public function actionEditableCreator()
 {
     if (isset($_POST['Staff'])) {
         $model = new Staff();
         $model->attributes = $_POST['Staff'];
         if ($model->save()) {
             echo CJSON::encode($model->getAttributes());
         } else {
             $errors = array_map(function ($v) {
                 return join(', ', $v);
             }, $model->getErrors());
             echo CJSON::encode(array('errors' => $errors));
         }
     } else {
         throw new CHttpException(400, 'Invalid request');
     }
 }
 public function actionCreate()
 {
     $this->hasPrivilege(Acl::ACTION_CREATE);
     $this->pageTitle = Lang::t('New ' . $this->resourceAddLabel);
     // User information
     $user_model = new Users(ActiveRecord::SCENARIO_CREATE);
     $user_model->status = Users::STATUS_ACTIVE;
     $user_model_class_name = $user_model->getClassName();
     //personal information
     $person_model = new Person();
     $person_model_class_name = $person_model->getClassName();
     //staff information
     $staff_model = new Staff(ActiveRecord::SCENARIO_CREATE);
     $staff_model->status = Staff::STATUS_ACTIVE;
     $staff_model_class_name = $staff_model->getClassName();
     if (Yii::app()->request->isPostRequest) {
         $user_model->attributes = $_POST[$user_model_class_name];
         $person_model->attributes = $_POST[$person_model_class_name];
         $staff_model->attributes = $_POST[$staff_model_class_name];
         $person_model->validate();
         $staff_model->validate();
         $user_model->validate();
         if (!$user_model->hasErrors() && !$staff_model->hasErrors() && !$person_model->hasErrors()) {
             if ($user_model->save(FALSE)) {
                 $person_model->id = $user_model->id;
                 if ($person_model->save(FALSE)) {
                     $staff_model->person_id = $person_model->id;
                     $staff_model->save(FALSE);
                     Yii::app()->user->setFlash('success', Lang::t('Staff added successfully.'));
                     $this->redirect(Controller::getReturnUrl($this->createUrl('view', array('id' => $staff_model->id))));
                 }
             }
         }
     }
     $this->render('create', array('staff_model' => $staff_model, 'user_model' => $user_model, 'model' => $person_model));
 }