Ejemplo n.º 1
0
 public function saveData($db, $form, $userId)
 {
     $name = $form->findControlsByID('su_username');
     $password = $form->findControlsByID('su_password');
     $group_id = $form->findControlsByID('group_id');
     $email1 = $form->findControlsByID('email1');
     $email2 = $form->findControlsByID('email2');
     $cmd = $db->createCommand("INSERT INTO hr_superusers (\n                        `group_id` ,\n                        `user_id` ,\n                        `name`,\n                        `password`,\n                        `isLogged`\n                  )\n                  VALUES (\n                        :group_id,\n                        :user_id,\n                        :name,\n                        :password,\n                        0\n                  )");
     $cmd->bindValue(":name", $name[0]->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":password", sha1($password[0]->SafeText), PDO::PARAM_STR);
     $cmd->bindValue(":group_id", $group_id[0]->getSelectedValue(), PDO::PARAM_INT);
     $cmd->bindValue(":user_id", $userId, PDO::PARAM_INT);
     $cmd->execute();
     $guiLog = new TGuiLog();
     $guiLog->log("Add the super user:" . $name[0]->SafeText);
     if ($email1[0]->SafeText != '' || $email2[0]->SafeText != '') {
         if ($email2[0]->SafeText != '') {
             $mailer = new TMailer();
             $mailer->sendSuperUser($email2[0]->SafeText, $name[0]->SafeText, $password[0]->SafeText);
         } else {
             $mailer = new TMailer();
             $mailer->sendSuperUser($email1[0]->SafeText, $name[0]->SafeText, $password[0]->SafeText);
         }
     }
 }
Ejemplo n.º 2
0
 public function onSendMail($sender, $param)
 {
     $mailer = new TMailer();
     $mailer->setObject($this->object->SafeText);
     $mailer->setBody($this->Body->Text);
     $recipient = array();
     if ($this->send_groups->getChecked()) {
         $indices = $this->groups->SelectedIndices;
         $result = '';
         foreach ($indices as $index) {
             $item = $this->groups->Items[$index];
             $cmd = $this->db->createCommand("SELECT u.id, email1, email2  FROM hr_user AS u LEFT JOIN hr_user_group_attribution AS uga ON uga.id_user=u.id  WHERE uga.id_group=" . $item->Value);
             $query = $cmd->query();
             $data = $query->readAll();
             foreach ($data as $d) {
                 if ($d['email1'] != '') {
                     $recipient[$d['id']] = $d['email1'];
                 } elseif ($d['email2'] != '') {
                     $recipient[$d['id']] = $d['email2'];
                 }
             }
         }
     }
     if ($this->send_users->getChecked()) {
         $indices = $this->users->SelectedIndices;
         $result = '';
         foreach ($indices as $index) {
             $item = $this->users->Items[$index];
             $cmd = $this->db->createCommand("SELECT email1, email2  FROM hr_user WHERE id=" . $item->Value);
             $query = $cmd->query();
             $data = $query->read();
             if ($data['email1'] != '') {
                 $recipient[$item->Value] = $data['email1'];
             } elseif ($data['email2'] != '') {
                 $recipient[$item->Value] = $data['email2'];
             }
         }
     }
     foreach ($recipient as $r) {
         $mailer->addRecipient($r);
     }
     if ($this->attachment->HasFile) {
         $this->attachment->saveAs('.' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $this->attachment->FileName);
         $mailer->addAttachment('.' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $this->attachment->FileName, $this->attachment->FileName);
     }
     $res = $mailer->sendHtmlMail($this->mailing->getChecked());
     if ($this->attachment->HasFile) {
         unlink('.' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $this->attachment->FileName);
     }
     if ($res) {
         $pBack = array('okMsg' => Prado::localize('The mail was delivered successfully'));
         $this->Response->redirect($this->Service->constructUrl('components.easymailing.easymailing', $pBack));
     } else {
         $pBack = array('koMsg' => Prado::localize('The mail was not delivered successfully'));
         $this->Response->redirect($this->Service->constructUrl('components.easymailing.easymailing', $pBack));
     }
 }
Ejemplo n.º 3
0
 /**
  * @param array $param parameters of the notification
  * @return string return the result
  * @soapmethod
  */
 public function sendMail($param)
 {
     $ret = "";
     $p_tmp = array();
     foreach ($param as $p) {
         $key = "";
         foreach ($p as $k => $v) {
             if ($k == "key") {
                 $key = $v;
             }
             if ($k == "value") {
                 $p_tmp[$key] = $v;
                 $ret .= $key . ":" . $v . ",";
             }
         }
     }
     $param = $p_tmp;
     $type = $param["type"];
     $code = $param["code"];
     $userId = false;
     $serialNumber = false;
     $entryId = false;
     $object = false;
     switch ($type) {
         case "ALARM":
             $object = $param["object"];
             break;
         case "ACCESS":
             $userId = $param["userId"];
             $serialNumber = $param["serialNumber"];
             $entryId = $param["entryId"];
             break;
         default:
             return "Type mismatch";
     }
     $app = Prado::getApplication();
     $db = $app->getModule('horuxDb')->DbConnection;
     $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
     $db->Active = true;
     $sql = "SELECT * FROM hr_notification";
     $cmd = $db->createCommand($sql);
     $data = $cmd->query();
     $data = $data->readAll();
     foreach ($data as $notification) {
         $not_id = $notification['id'];
         $emails = explode(',', $notification['emails']);
         $sql = "SELECT su.email FROM hr_notification_su AS nsu LEFT JOIN hr_superusers AS su ON su.id=nsu.id_superuser WHERE nsu.id_notification={$not_id}";
         $cmd = $db->createCommand($sql);
         $sus = $cmd->query();
         $sus = $sus->readAll();
         foreach ($sus as $su) {
             $emails[] = $su['email'];
         }
         $sql = "SELECT * FROM hr_notification_code WHERE id_notification={$not_id} AND type='{$type}' AND code='{$code}'";
         $cmd = $db->createCommand($sql);
         $ncode = $cmd->query();
         $ncode = $ncode->read();
         if ($ncode) {
             $mailer = new TMailer();
             if ($type == "ALARM") {
                 if ($object > 0) {
                     $sql = "SELECT * FROM hr_device WHERE id={$object}";
                     $cmd = $db->createCommand($sql);
                     $device = $cmd->query();
                     $device = $device->read();
                     $device = $device['name'];
                 } else {
                     $device = "";
                 }
                 $site = "";
                 $sql = "SELECT * FROM hr_site WHERE id=1";
                 $cmd = $db->createCommand($sql);
                 $site = $cmd->query();
                 $site = $site->read();
                 $site = $site['name'];
                 $sql = "SELECT * FROM hr_install WHERE `default`=1 AND type='language'";
                 $cmd = $db->createCommand($sql);
                 $data = $cmd->query();
                 $data = $data->read();
                 $lang = $data['param'];
                 Prado::getApplication()->getGlobalization()->setCulture($lang);
                 $body = "";
                 $body = file_get_contents("./protected/webservice/notification/alarm/{$lang}/{$code}.txt");
                 $body = str_replace("%site%", $site, $body);
                 $body = str_replace("%device%", $device, $body);
                 $body = str_replace("%date%", date("d.m.y"), $body);
                 $body = str_replace("%time%", date("H:i:s"), $body);
                 switch ($code) {
                     case 900:
                         $mailer->setObject(Prado::localize("Horux notification: Horux Controler seems to be down"));
                         break;
                     case 1001:
                         $mailer->setObject(Prado::localize("Horux notification: Antivandale acivated on {device}", array('device' => $device)));
                         break;
                     case 1002:
                         $mailer->setObject(Prado::localize("Horux notification: Antivandale cleared on {device}", array('device' => $device)));
                         break;
                     case 1003:
                         $mailer->setObject(Prado::localize("Horux notification: Device communication opened on {device}", array('device' => $device)));
                         break;
                     case 1004:
                         $mailer->setObject(Prado::localize("Horux notification: Device communication closed on {device}", array('device' => $device)));
                         break;
                     case 1005:
                         $mailer->setObject(Prado::localize("Horux notification: Device ajar on {device}", array('device' => $device)));
                         break;
                     case 1006:
                         $mailer->setObject(Prado::localize("Horux notification: End device ajar on {device}", array('device' => $device)));
                         break;
                     case 1007:
                         $mailer->setObject(Prado::localize("Horux notification: Door forced on {device}", array('device' => $device)));
                         break;
                     case 1008:
                         $mailer->setObject(Prado::localize("Horux notification: Too many PIN on {device}", array('device' => $device)));
                         break;
                     case 1009:
                         $mailer->setObject(Prado::localize("Horux notification: Temperature alarm on {device}", array('device' => $device)));
                         break;
                     case 1010:
                         $mailer->setObject(Prado::localize("Horux notification: Memory full on {device}", array('device' => $device)));
                         break;
                     case 1011:
                         $mailer->setObject(Prado::localize("Horux notification: Memory warning on {device}", array('device' => $device)));
                         break;
                     case 1012:
                         $mailer->setObject(Prado::localize("Horux notification: Memory key inserted error on {device}", array('device' => $device)));
                         break;
                     case 1013:
                         $mailer->setObject(Prado::localize("Horux notification: Memory key removed error on {device}", array('device' => $device)));
                         break;
                     case 1014:
                         $mailer->setObject(Prado::localize("Horux notification: Device antenna enabled on {device}", array('device' => $device)));
                         break;
                     case 1015:
                         $mailer->setObject(Prado::localize("Horux notification: Device antenna disabled on {device}", array('device' => $device)));
                         break;
                     case 1016:
                         $mailer->setObject(Prado::localize("Horux notification: Device connection not opened on {device}", array('device' => $device)));
                         break;
                     case 1017:
                         $mailer->setObject(Prado::localize("Horux notification: Device communicaiton error on {device}", array('device' => $device)));
                         break;
                     case 1102:
                         $mailer->setObject(Prado::localize("Horux notification: HOLDUP PIN CODE"));
                         break;
                     case 1200:
                         $mailer->setObject(Prado::localize("Horux notification: Cannot start Horux XMLRPC server"));
                         break;
                     case 1300:
                         $mailer->setObject(Prado::localize("Horux notification: Reload database..."));
                         break;
                     case 1301:
                         $mailer->setObject(Prado::localize("Horux notification: Database reloaded"));
                         break;
                 }
             }
             if ($type == "ACCESS") {
                 $user = "";
                 if ($userId && $userId > 0) {
                     $sql = "SELECT * FROM hr_user WHERE id={$userId}";
                     $cmd = $db->createCommand($sql);
                     $user = $cmd->query();
                     $user = $user->read();
                     $user = $user['name'] . ' ' . $user['firstname'];
                 }
                 $deviceName = "";
                 if ($entryId && $entryId > 0) {
                     $sql = "SELECT * FROM hr_device WHERE id={$entryId}";
                     $cmd = $db->createCommand($sql);
                     $entryId = $cmd->query();
                     $entryId = $entryId->read();
                     $deviceName = $entryId['name'];
                 }
                 $site = "";
                 $sql = "SELECT * FROM hr_site WHERE id=1";
                 $cmd = $db->createCommand($sql);
                 $site = $cmd->query();
                 $site = $site->read();
                 $site = $site['name'];
                 $sql = "SELECT * FROM hr_install WHERE `default`=1 AND type='language'";
                 $cmd = $db->createCommand($sql);
                 $data = $cmd->query();
                 $data = $data->read();
                 $lang = $data['param'];
                 Prado::getApplication()->getGlobalization()->setCulture($lang);
                 $body = "";
                 $body = file_get_contents("./protected/webservice/notification/access/{$lang}/{$code}.txt");
                 $body = str_replace("%user%", $user, $body);
                 $body = str_replace("%site%", $site, $body);
                 $body = str_replace("%device%", $deviceName, $body);
                 $body = str_replace("%key%", $serialNumber, $body);
                 $body = str_replace("%date%", date("d.m.y"), $body);
                 $body = str_replace("%time%", date("H:i:s"), $body);
                 switch ($code) {
                     case 0:
                         $mailer->setObject(Prado::localize("Horux notification: Access by {user}", array('user' => $user)));
                         break;
                     case 1:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Key blocked"));
                         break;
                     case 2:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Key unknown"));
                         break;
                     case 3:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Key not attributed"));
                         break;
                     case 4:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - User not in a group"));
                         break;
                     case 5:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Key blocked during the week-end"));
                         break;
                     case 6:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Key blocked during the non working day"));
                         break;
                     case 7:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Out of date"));
                         break;
                     case 8:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - Out of time"));
                         break;
                     case 9:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - No access right defined for the group"));
                         break;
                     case 11:
                         $mailer->setObject(Prado::localize("Horux notification: Acces bloked - User blocked"));
                         break;
                 }
             }
             foreach ($emails as $email) {
                 $mailer->addRecipient($email);
             }
             $mailer->setBody($body);
             $mailer->sendTextMail(true);
         }
     }
     return "ok";
 }
Ejemplo n.º 4
0
 public function saveData()
 {
     $cmd = $this->db->createCommand(SQL::SQL_ADD_USER);
     $cmd->bindValue(":name", $this->name->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":password", sha1($this->password->SafeText), PDO::PARAM_STR);
     $cmd->bindValue(":email", $this->email->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":group_id", $this->group_id->getSelectedValue(), PDO::PARAM_INT);
     $cmd->bindValue(":user_id", $this->user_id->getSelectedValue(), PDO::PARAM_INT);
     if (!$cmd->execute()) {
         return false;
     }
     $id = $this->db->getLastInsertID();
     $this->log("Add the super user:"******":shortcut", $this->shortcut1->getSelectedValue(), PDO::PARAM_STR);
         $cmd->bindValue(":id", $id, PDO::PARAM_INT);
         $cmd->execute();
     }
     if ($this->shortcut2->getSelectedValue() != -1) {
         $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)');
         $cmd->bindValue(":shortcut", $this->shortcut2->getSelectedValue(), PDO::PARAM_STR);
         $cmd->bindValue(":id", $id, PDO::PARAM_INT);
         $cmd->execute();
     }
     if ($this->shortcut3->getSelectedValue() != -1) {
         $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)');
         $cmd->bindValue(":shortcut", $this->shortcut3->getSelectedValue(), PDO::PARAM_STR);
         $cmd->bindValue(":id", $id, PDO::PARAM_INT);
         $cmd->execute();
     }
     if ($this->shortcut4->getSelectedValue() != -1) {
         $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)');
         $cmd->bindValue(":shortcut", $this->shortcut4->getSelectedValue(), PDO::PARAM_STR);
         $cmd->bindValue(":id", $id, PDO::PARAM_INT);
         $cmd->execute();
     }
     if ($this->shortcut5->getSelectedValue() != -1) {
         $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)');
         $cmd->bindValue(":shortcut", $this->shortcut5->getSelectedValue(), PDO::PARAM_STR);
         $cmd->bindValue(":id", $id, PDO::PARAM_INT);
         $cmd->execute();
     }
     return $id;
 }
Ejemplo n.º 5
0
 public function onDelete($sender, $param)
 {
     $cbs = $this->findControlsByType("TActiveCheckBox");
     $nDelete = 0;
     $koMsg = '';
     $cbChecked = 0;
     foreach ($cbs as $cb) {
         if ((bool) $cb->getChecked() && $cb->Value != "0") {
             $cbChecked++;
         }
     }
     if ($cbChecked == 0) {
         $koMsg = Prado::localize('Select one item');
     } else {
         foreach ($cbs as $cb) {
             if ((bool) $cb->getChecked() && $cb->Value != "0") {
                 $cmd = $this->db->createCommand("SELECT * FROM hr_timux_request WHERE id =:id");
                 $cmd->bindValue(":id", $cb->Value);
                 $query = $cmd->query();
                 $data = $query->read();
                 if ($data['state'] == 'draft') {
                     $cmd = $this->db->createCommand("DELETE FROM hr_timux_request WHERE id =:id");
                     $cmd->bindValue(":id", $cb->Value);
                     if ($cmd->execute()) {
                         $nDelete++;
                     }
                     $cmd = $this->db->createCommand("DELETE FROM hr_timux_request_leave WHERE request_id =:id");
                     $cmd->bindValue(":id", $cb->Value);
                     $cmd->execute();
                 } else {
                     if ($data['state'] != 'refused') {
                         $cmd = $this->db->createCommand("UPDATE hr_timux_request SET state='canceled' WHERE id =:id");
                         $cmd->bindValue(":id", $cb->Value);
                         if ($cmd->execute()) {
                             $nDelete++;
                             $cmd = $this->db->createCommand("SELECT * FROM hr_timux_request_workflow WHERE request_id=:id");
                             $cmd->bindValue(":id", $cb->Value);
                             $query = $cmd->query();
                             $data = $query->readAll();
                             $mailer = new TMailer();
                             foreach ($data as $d) {
                                 $user_id = $d['user_id'];
                                 $cmd = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
                                 $cmd->bindValue(":id", $user_id);
                                 $query = $cmd->query();
                                 $data2 = $query->read();
                                 if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
                                     if ($data2['email2'] != '') {
                                         $mailer->addRecipient($data2['email2']);
                                     } elseif ($data2['email3'] != '') {
                                         $mailer->addRecipient($data2['email3']);
                                     } elseif ($data2['email1'] != '') {
                                         $mailer->addRecipient($data2['email1']);
                                     }
                                 }
                             }
                             $mailer->setObject(Prado::localize("Leave request canceled"));
                             $body = Prado::localize("The leave request from {name} was canceled<br/><br/>Timux", array('name' => $this->employee->getFullName()));
                             $mailer->setBody($body);
                             $mailer->sendHtmlMail();
                             $cmd = $this->db->createCommand("DELETE FROM hr_timux_request_workflow WHERE request_id =:id");
                             $cmd->bindValue(":id", $cb->Value);
                             $cmd->execute();
                         }
                     }
                 }
                 //$this->log("Delete the key: ".$data['serialNumber']);
             }
         }
     }
     if ($koMsg !== '') {
         $pBack = array('koMsg' => $koMsg);
     } else {
         $pBack = array('okMsg' => Prado::localize('{n} leave request was deleted/canceled', array('n' => $nDelete)));
     }
     $this->Response->redirect($this->Service->constructUrl('components.timuxuser.leaverequest.leaverequest', $pBack));
 }
Ejemplo n.º 6
0
 protected function sendEmail($lastId)
 {
     $cmd = $this->db->createCommand("SELECT * FROM hr_timux_request_workflow WHERE request_id=:id");
     $cmd->bindValue(":id", $lastId);
     $query = $cmd->query();
     $data = $query->readAll();
     $mailer = new TMailer();
     foreach ($data as $d) {
         $user_id = $d['user_id'];
         $cmd = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
         $cmd->bindValue(":id", $user_id);
         $query = $cmd->query();
         $data2 = $query->read();
         if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
             if ($data2['email2'] != '') {
                 $mailer->addRecipient($data2['email2']);
             } elseif ($data2['email3'] != '') {
                 $mailer->addRecipient($data2['email3']);
             } elseif ($data2['email1'] != '') {
                 $mailer->addRecipient($data2['email1']);
             }
         }
     }
     $mailer->setObject(Prado::localize("New Leave request"));
     $body = Prado::localize("A new leave request from {name} was added in your validation task<br/><br/>Timux", array('name' => $this->employee->getFullName()));
     $mailer->setBody($body);
     $mailer->sendHtmlMail();
 }
Ejemplo n.º 7
0
 protected function saveData()
 {
     $cmd = $this->db->createCommand("UPDATE `hr_timux_request` SET\n                                          modifyDate=CURDATE(),\n                                          modifyUserId=:modifyUserId,\n                                          state=:state,\n                                          remark=:remark\n                                          WHERE id=:id\n                                          ;");
     $cmd->bindValue(":modifyUserId", $this->userId, PDO::PARAM_STR);
     $remark = $this->remark->Text;
     $remark .= "<hr>";
     $remark .= $this->myremark->Text;
     $cmd->bindValue(":remark", $remark, PDO::PARAM_STR);
     $validation = '';
     if ($this->refuse->getChecked()) {
         $validation = 'refused';
     }
     if ($this->validate->getChecked()) {
         $cmd2 = $this->db->createCommand("SELECT * FROM hr_timux_request_workflow WHERE request_id =:id");
         $cmd2->bindValue(":id", $this->id->Value, PDO::PARAM_INT);
         $query = $cmd2->query();
         $data = $query->read();
         $validatorLevel = $data['validatorLevel'];
         $cmd2 = $this->db->createCommand("SELECT u.id, u.department, CONCAT(u.name, ' ', u.firstname) AS employee FROM hr_timux_request AS tr LEFT JOIN hr_timux_request_leave AS rl ON rl.request_id=tr.id LEFT JOIN hr_user AS u ON u.id=tr.userId WHERE tr.id=:id");
         $cmd2->bindValue(":id", $this->id->Value, PDO::PARAM_INT);
         $query = $cmd2->query();
         $data = $query->read();
         $department = $data['department'];
         $fullName = $data['employee'];
         $employeeId = $data['id'];
         $cmd2 = $this->db->createCommand("SELECT * FROM hr_timux_workflow WHERE departmentId=:id OR departmentId=0");
         $cmd2->bindValue(":id", $department, PDO::PARAM_INT);
         $query = $cmd2->query();
         $data = $query->read();
         $v = array(0, 0, 0);
         $level = 2;
         switch ($validatorLevel) {
             case 1:
                 $v[0] = $data['validator2'];
                 $v[1] = $data['validator21'];
                 $v[2] = $data['validator22'];
                 $level = 2;
                 break;
             case 2:
                 $v[0] = $data['validator3'];
                 $v[1] = $data['validator31'];
                 $v[2] = $data['validator32'];
                 $level = 3;
                 break;
             case 3:
                 break;
         }
         $isNextValidator = false;
         foreach ($v as $s) {
             if ($s != 0) {
                 $isNextValidator = true;
             }
         }
         if ($isNextValidator) {
             $cmd2 = $this->db->createCommand("DELETE FROM hr_timux_request_workflow WHERE request_id =:id");
             $cmd2->bindValue(":id", $this->id->Value);
             $cmd2->execute();
             foreach ($v as $s) {
                 if ($s != 0) {
                     $cmd2 = $this->db->createCommand("INSERT `hr_timux_request_workflow` SET\n                                                            request_id=:request_id,\n                                                            user_id=:user_id,\n                                                            validatorLevel=:validatorLevel\n                                                          ;");
                     $cmd2->bindValue(":request_id", $this->id->Value, PDO::PARAM_STR);
                     $cmd2->bindValue(":user_id", $s, PDO::PARAM_STR);
                     $cmd2->bindValue(":validatorLevel", $level, PDO::PARAM_STR);
                     $cmd2->execute();
                 }
             }
             $cmd2 = $this->db->createCommand("SELECT * FROM hr_timux_request_workflow WHERE request_id=:id");
             $cmd2->bindValue(":id", $this->id->Value);
             $query = $cmd2->query();
             $data = $query->readAll();
             $mailer = new TMailer();
             foreach ($data as $d) {
                 $user_id = $d['user_id'];
                 $cmd2 = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
                 $cmd2->bindValue(":id", $user_id);
                 $query = $cmd2->query();
                 $data2 = $query->read();
                 if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
                     if ($data2['email2'] != '') {
                         $mailer->addRecipient($data2['email2']);
                     } elseif ($data2['email3'] != '') {
                         $mailer->addRecipient($data2['email3']);
                     } elseif ($data2['email1'] != '') {
                         $mailer->addRecipient($data2['email1']);
                     }
                 }
             }
             $mailer->setObject(Prado::localize("New Leave request"));
             $body = Prado::localize("A new leave request from {name} was added in your validation task<br/><br/>Timux", array('name' => $fullName));
             $mailer->setBody($body);
             $mailer->sendHtmlMail();
             $validation = 'validating';
         } else {
             $mailer = new TMailer();
             $cmd2 = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
             $cmd2->bindValue(":id", $employeeId);
             $query = $cmd2->query();
             $data2 = $query->read();
             if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
                 if ($data2['email2'] != '') {
                     $mailer->addRecipient($data2['email2']);
                 } elseif ($data2['email3'] != '') {
                     $mailer->addRecipient($data2['email3']);
                 } elseif ($data2['email1'] != '') {
                     $mailer->addRecipient($data2['email1']);
                 }
             }
             $mailer->setObject(Prado::localize("Leave request validated"));
             $body = Prado::localize("{name}<br/><br>Your leave request was validated<br/><br/>Timux", array('name' => $fullName));
             $mailer->setBody($body);
             $mailer->sendHtmlMail();
             $cmd2 = $this->db->createCommand("DELETE FROM hr_timux_request_workflow WHERE request_id =:id");
             $cmd2->bindValue(":id", $this->id->Value);
             $cmd2->execute();
             $validation = 'validate';
         }
     }
     $cmd->bindValue(":state", $validation, PDO::PARAM_STR);
     $cmd->bindValue(":id", $this->id->Value, PDO::PARAM_STR);
     $res1 = $cmd->execute();
     if ($validation == 'refused') {
         $cmd = $this->db->createCommand("DELETE FROM hr_timux_request_workflow WHERE request_id =:id");
         $cmd->bindValue(":id", $this->id->Value);
         $cmd->execute();
         $cmd2 = $this->db->createCommand("SELECT u.id, u.department, CONCAT(u.name, ' ', u.firstname) AS employee FROM hr_timux_request AS tr LEFT JOIN hr_timux_request_leave AS rl ON rl.request_id=tr.id LEFT JOIN hr_user AS u ON u.id=tr.userId WHERE tr.id=:id");
         $cmd2->bindValue(":id", $this->id->Value, PDO::PARAM_INT);
         $query = $cmd2->query();
         $data = $query->read();
         $department = $data['department'];
         $fullName = $data['employee'];
         $employeeId = $data['id'];
         $mailer = new TMailer();
         $cmd2 = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
         $cmd2->bindValue(":id", $employeeId);
         $query = $cmd2->query();
         $data2 = $query->read();
         if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
             if ($data2['email2'] != '') {
                 $mailer->addRecipient($data2['email2']);
             } elseif ($data2['email3'] != '') {
                 $mailer->addRecipient($data2['email3']);
             } elseif ($data2['email1'] != '') {
                 $mailer->addRecipient($data2['email1']);
             }
         }
         $mailer->setObject(Prado::localize("Leave request refused"));
         $body = Prado::localize("{name}<br/><br>Your leave request was refused<br/><br/>Timux", array('name' => $fullName));
         $mailer->setBody($body);
         $mailer->sendHtmlMail();
     }
     return $res1;
 }
Ejemplo n.º 8
0
 public function saveData()
 {
     if ($this->fileError != "") {
         return false;
     }
     $cmd = $this->db->createCommand(SQL::SQL_ADD_PERSON);
     $sex = 'F';
     if ($this->sexF->getChecked()) {
         $sex = 'F';
     }
     if ($this->sexM->getChecked()) {
         $sex = 'M';
     }
     // Global
     $cmd->bindValue(":sex", $sex, PDO::PARAM_STR);
     $cmd->bindValue(":name", $this->name->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":firstname", $this->firstname->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":language", $this->language->getSelectedValue(), PDO::PARAM_STR);
     $cmd->bindValue(":picture", $this->fileName, PDO::PARAM_STR);
     $cmd->bindValue(":pin_code", $this->pin_code->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":password", sha1($this->password->SafeText), PDO::PARAM_STR);
     $cmd->bindValue(":validity_date", $this->dateToSql($this->validity_date->SafeText), PDO::PARAM_STR);
     $cmd->bindValue(":birthday", $this->dateToSql($this->birthday->SafeText), PDO::PARAM_STR);
     $f1 = $this->masterAuthorization->getChecked() ? 1 : 0;
     $cmd->bindValue(":masterAuthorization", $f1, PDO::PARAM_STR);
     //Personal
     $cmd->bindValue(":avs", $this->avs->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":street", $this->street->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":zip", $this->zip->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":city", $this->city->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":country", $this->country->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":phone1", $this->phone1->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":email1", $this->email1->SafeText, PDO::PARAM_STR);
     //Private
     $cmd->bindValue(":firme", $this->firme->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":department", $this->department->getSelectedValue(), PDO::PARAM_STR);
     $cmd->bindValue(":street_pr", $this->street_pr->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":npa_pr", $this->zip_pr->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":city_pr", $this->city_pr->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":phone2", $this->phone2->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":email2", $this->email2->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":country_pr", $this->country_pr->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":fax", $this->fax->SafeText, PDO::PARAM_STR);
     if (!$cmd->execute()) {
         return false;
     }
     $id = $this->db->getLastInsertID();
     if (($this->email1->SafeText != '' || $this->email2->SafeText != '') && $this->password->SafeText != '') {
         $mailer = new TMailer();
         $email = $this->email1->SafeText == '' ? $this->email2->SafeText : $this->email1->SafeText;
         $mailer->sendUser($email, $this->name->SafeText, $this->firstname->SafeText, $this->password->SafeText, $this->url, $this->siteName);
     }
     $this->log("Add the user: "******" " . $this->firstname->SafeText);
     $this->addStandalone('add', $id);
     return $id;
 }
Ejemplo n.º 9
0
 protected function sendEmail($requestId, $object, $body)
 {
     $cmd = $this->db->createCommand("SELECT * FROM hr_timux_request_workflow WHERE request_id=:id");
     $cmd->bindValue(":id", $requestId);
     $query = $cmd->query();
     $data = $query->readAll();
     $mailer = new TMailer();
     foreach ($data as $d) {
         $user_id = $d['user_id'];
         $cmd = $this->db->createCommand("SELECT u.email1, u.email2, su.email AS email3 FROM hr_user AS u LEFT JOIN hr_superusers AS su ON su.user_id=u.id WHERE u.id=:id");
         $cmd->bindValue(":id", $user_id);
         $query = $cmd->query();
         $data2 = $query->read();
         if ($data2['email1'] != '' || $data2['email2'] != '' || $data2['email3'] != '') {
             if ($data2['email2'] != '') {
                 $mailer->addRecipient($data2['email2']);
             } elseif ($data2['email3'] != '') {
                 $mailer->addRecipient($data2['email3']);
             } elseif ($data2['email1'] != '') {
                 $mailer->addRecipient($data2['email1']);
             }
         }
     }
     $mailer->setObject($object);
     $mailer->setBody($body);
     $mailer->sendHtmlMail();
 }
Ejemplo n.º 10
0
 protected function sendEmailConf()
 {
     $mailer = new TMailer();
     return $mailer->sendConfigChange();
 }