コード例 #1
0
ファイル: HolidayTest.php プロジェクト: Samara94/dolibarr
 /**
  * testHolidayDelete
  *
  * @param	int		$id		Id of Holiday
  * @return	void
  *
  * @depends	testHolidayOther
  * The depends says test is run only if previous is ok
  */
 public function testHolidayDelete($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Holiday($this->savdb);
     $result = $localobject->fetch($id);
     $result = $localobject->delete(0);
     print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }
コード例 #2
0
        exit;
    }
}
// Si suppression de la demande
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') {
    if ($user->rights->holiday->delete) {
        $error = 0;
        $db->begin();
        $cp = new Holiday($db);
        $cp->fetch($id);
        $canedit = $user->id == $cp->fk_user && $user->rights->holiday->write || $user->id != $cp->fk_user && $user->rights->holiday->write_all;
        // Si c'est bien un brouillon
        if ($cp->statut == 1 || $cp->statut == 3) {
            // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
            if ($canedit) {
                $result = $cp->delete($id);
            } else {
                $error = $langs->trans('ErrorCantDeleteCP');
            }
        }
        if (!$error) {
            $db->commit();
            header('Location: index.php');
            exit;
        } else {
            $db->rollback();
        }
    }
}
// Si envoi de la demande
if ($action == 'confirm_send') {
コード例 #3
0
 /**
  * delete method
  *
  * @param string $id
  * @return void
  */
 public function delete_holidays($id = null)
 {
     $this->autoRender = false;
     if (!$this->request->is('post')) {
         throw new MethodNotAllowedException();
     }
     App::uses('Holiday', 'ScheduleManager.Model');
     $holidayModel = new Holiday();
     $holidayModel->id = $id;
     if (!$holidayModel->exists()) {
         throw new NotFoundException(__('Invalid Installer Holiday'), 'default', array('class' => 'text-error'));
     }
     if ($holidayModel->delete()) {
         echo json_encode(array("Error" => ""));
     } else {
         echo json_encode(array("Error" => 'Error'));
     }
 }