コード例 #1
0
$confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
// List of statut
static $tmpstatut2label = array('0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear');
$statut2label = array('');
foreach ($tmpstatut2label as $key => $val) {
    $statut2label[$key] = $langs->trans($val);
}
$object = new Fiscalyear($db);
$date_start = dol_mktime(0, 0, 0, GETPOST('fiscalyearmonth', 'int'), GETPOST('fiscalyearday', 'int'), GETPOST('fiscalyearyear', 'int'));
$date_end = dol_mktime(0, 0, 0, GETPOST('fiscalyearendmonth', 'int'), GETPOST('fiscalyearendday', 'int'), GETPOST('fiscalyearendyear', 'int'));
/*
 * Actions
 */
if ($action == 'confirm_delete' && $confirm == "yes") {
    $result = $object->delete($id);
    if ($result >= 0) {
        header("Location: fiscalyear.php");
        exit;
    } else {
        setEventMessage($object->error, 'errors');
    }
} else {
    if ($action == 'add') {
        if (!GETPOST('cancel', 'alpha')) {
            $error = 0;
            $object->date_start = $date_start;
            $object->date_end = $date_end;
            $object->label = GETPOST('label', 'alpha');
            $object->statut = GETPOST('statut', 'int');
            $object->datec = dol_now();