public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Holiday::create([]);
     }
 }
 public function holidays($start)
 {
     $query = new Query('HOLIDAYS', $this->dbh);
     $query->where('HOLIDAYID', '>', $start);
     $result = $query->get('HOLIDAYID,STARTTIME,DURATION');
     foreach ($result as $row) {
         $start_time = strtotime($row['STARTTIME']);
         $duration = $row['DURATION'] - 1;
         $end_time = strtotime("+{$duration} days", $start_time);
         Holiday::create(['id' => $row['HOLIDAYID'], 'start' => $row['STARTTIME'], 'duration' => $row['DURATION'], 'end' => date('Y-m-d H:i:s', $end_time)]);
     }
     $size = count($result);
     $this->num_data += $size;
     return $size > 0 ? $result[$size - 1]['HOLIDAYID'] : $start;
 }
        if ($nbopenedday < 1) {
            header('Location: fiche.php?action=request&error=DureeHoliday');
            exit;
        }
        // Si pas de validateur choisi
        if ($valideur < 1) {
            header('Location: fiche.php?action=request&error=Valideur');
            exit;
        }
        $cp->fk_user = $userid;
        $cp->description = $description;
        $cp->date_debut = $date_debut;
        $cp->date_fin = $date_fin;
        $cp->fk_validator = $valideur;
        $cp->halfday = $halfday;
        $verif = $cp->create($userid);
        // Si pas d'erreur SQL on redirige vers la fiche de la demande
        if ($verif > 0) {
            header('Location: fiche.php?id=' . $verif);
            exit;
        } else {
            // Sinon on affiche le formulaire de demande avec le message d'erreur SQL
            header('Location: fiche.php?action=request&error=SQL_Create&msg=' . $cp->error);
            exit;
        }
    }
}
if ($action == 'update') {
    $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
    $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
    $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
Exemple #4
0
            $error++;
        }
        $result = 0;
        if ($type < 1) {
            setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Type")), null, 'errors');
            $error++;
        }
        if (!$error) {
            $cp->fk_user = $userid;
            $cp->description = $description;
            $cp->date_debut = $date_debut;
            $cp->date_fin = $date_fin;
            $cp->fk_validator = $valideur;
            $cp->halfday = $halfday;
            $cp->fk_type = $type;
            $result = $cp->create($user);
        }
        // If no SQL error we redirect to the request card
        if (!$error && $result > 0) {
            $db->commit();
            header('Location: card.php?id=' . $result);
            exit;
        } else {
            $db->rollback();
        }
    }
}
if ($action == 'update') {
    $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
    $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
    $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
Exemple #5
0
 /**
  * testHolidayCreate
  *
  * @return	int
  */
 public function testHolidayCreate()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Holiday($this->savdb);
     $localobject->initAsSpecimen();
     $result = $localobject->create($user);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }
 public function add_holidays()
 {
     $this->autoRender = false;
     //debug($this->request->data);
     App::uses('Holiday', 'ScheduleManager.Model');
     $holidayModel = new Holiday();
     if ($this->request->is('post') || $this->request->is('put')) {
         $holidayModel->create();
         $data = $holidayModel->save($this->request->data);
         if ($data) {
             echo json_encode(array("Error" => "", $data));
         } else {
             echo json_encode(array("Error" => 'Error'));
         }
     }
 }