Esempio n. 1
0
 /**
  * Creates an Category object based on a DB row.
  *
  * @param array $row The DB row containing Category data.
  * @return \MyMovies\Domain\Category
  */
 protected function buildDomainObject($row)
 {
     $cat = new Categorie();
     $cat->setCat_id($row['cat_id']);
     $cat->setCat_name($row['cat_name']);
     return $cat;
 }
Esempio n. 2
0
 public function update(Categorie $categorie)
 {
     $query = $this->_db->prepare('UPDATE categorie SET nom=:nom, detail=:detail WHERE id=:id');
     $query->bindValue(':nom', $categorie->nom());
     $query->bindValue(':detail', $categorie->detail());
     $query->bindValue(':id', $categorie->id());
     $query->execute();
     $query->closeCursor();
 }
 private function setQuestions()
 {
     $categories = new Categorie();
     $questions = new Question();
     $questions->readQuestions($categories->getCategories());
     $tabUn = $questions->getUn();
     $tabAutre = $questions->getAutre();
     $this->_questions = array('lun1' => $tabUn[0], 'lautre1' => $tabAutre[0], 'lun2' => $tabUn[1], 'lautre2' => $tabAutre[1]);
 }
 function getCategorie($id)
 {
     $result = $this->connector->query("SELECT * FROM categorie WHERE `cat_id` = '{$id}'");
     while ($row = $this->connector->fetchArray($result)) {
         $categorie = new Categorie();
         $categorie->setCat_id($row['cat_id']);
         $categorie->setCat_title($row['cat_title']);
         $categorie->setCat_despription($row['cat_despription']);
         return $categorie;
     }
 }
Esempio n. 5
0
 public function create($nom)
 {
     $category = new Categorie($this->link);
     $category->setTitre($nom);
     $nom = mysqli_real_escape_string($this->link, $category->getCategory());
     $request = "INSERT INTO categories VALUES(NULL, '" . $nom . "')";
     $res = mysqli_query($this->link, $request);
     if ($res) {
         return $this->select(mysqli_insert_id($this->link));
     } else {
         throw new Exception("Internal server error");
     }
 }
Esempio n. 6
0
 public function procede()
 {
     if (!$this->oRequest->existParam('key')) {
         throw new Error('Vous devez renseigner la clé.', 3003);
     }
     if ($this->oRequest->getParam('key', 'string') != Config::get('ingestkey')) {
         throw new Error('La clé est invalide.', 3003);
     }
     //Ajoute du titre
     $this->oView->addData('titre', 'Analyse des releases');
     //On récupère les 30 dernières releases
     $oMysqli = Database::getInstance();
     //Traitement de la requête
     $sSqlRequest = "SELECT r.*, \r\n                        (SELECT GROUP_CONCAT(t.id_regex ORDER BY t.id_regex SEPARATOR ';') FROM tks_tags t WHERE t.id_release = r.id) AS tags,\r\n                        (SELECT GROUP_CONCAT(f.date ORDER BY f.date SEPARATOR ';') FROM tks_torrents f WHERE f.id_release = r.id) AS dates\t\r\n                        FROM tks_releases r \r\n                        WHERE r.id_categorie = '0' \r\n                        ORDER BY r.id DESC \r\n                        LIMIT 10";
     $oResults = $oMysqli->query($sSqlRequest);
     $oTable = new TableGenerator();
     $oTable->setId(md5('Scrapper'));
     $oTable->addColumn('Release');
     $oTable->addColumn('Catégorie');
     $oTable->addColumn('ID Fiche');
     $aCategories = Categorie::getCategoriesSelect();
     while ($aResult = $oResults->fetch_assoc()) {
         $oScrapper = new Scrapper($aResult['name'], $aResult['id']);
         $oScrapper->procede();
         $oTable->addLine(array($aResult['name'], $aCategories[$oScrapper->getCategorie()], $oScrapper->getFiche()));
     }
     $oTable->setBottom('');
     $oTable->create();
     $this->oView->addData('content', $oTable->getCode());
     $this->oView->Create();
 }
Esempio n. 7
0
 function __construct()
 {
     if (!isset(self::$database)) {
         //Connection à la BDD si pas déjà connecté
         self::$database = BaseDeDonnees::getInstance();
     }
 }
Esempio n. 8
0
function recupereCategorie()
{
    $categories = Categorie::fetchAll();
    //Change l'ordre selon la fonction de comparaison cmp.
    usort($categories, "cmp");
    return $categories;
}
Esempio n. 9
0
 public static function getAllCategories()
 {
     $results = Categorie::select('name', 'id')->orderBy('name', 'asc')->get();
     $allCategories = array();
     foreach ($results as $result) {
         $allCategories = array_add($allCategories, $result->id, $result->name);
     }
     return $allCategories;
 }
 public function beheerMateriaal()
 {
     if (Auth::check()) {
         $categories = Categorie::with('materials')->get();
         return View::make('users.admin.beheerMateriaal', ['categories' => $categories]);
     } else {
         return Redirect::to('/');
     }
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('categories', function ($table) {
         $table->increments('id');
         $table->string('title');
     });
     $cat = new Categorie();
     $cat->title = "Wood";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Metal";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Ceramic";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Glass";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Fabric";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Plastic";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Concrete";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Appliances";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Electical";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Plumbing";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Insulation";
     $cat->save();
     $cat = new Categorie();
     $cat->title = "Other";
     $cat->save();
 }
Esempio n. 12
0
 /**
  * Initialise les variables en tableaux, et crée l'ensemble des catégories question de la partie
  */
 function __construct()
 {
     $bddConnect = new Connector();
     $this->tabCategorie = array();
     $this->tabTheme1 = array();
     $this->tabTheme2 = array();
     $this->tabQuestion = array();
     $this->tabReponse = array();
     $this->tabExplication = array();
     // étape actuelle de la partie (1 étape = 1 question)
     $this->position = 0;
     // création et récupération des catégories de la partie
     $Categorie = new Categorie($bddConnect->getBdd());
     $nomCategorie = $Categorie->getNomCategorie();
     for ($i = 0; $i < sizeof($nomCategorie); $i++) {
         // création et récupération des thèmes de la partie associés aux catégories choisies
         $Theme = new Theme($bddConnect->getBdd(), $nomCategorie[$i]);
         $idTheme = $Theme->getIdTheme();
         $theme1 = $Theme->getTheme1();
         $theme2 = $Theme->getTheme2();
         for ($j = 0; $j < sizeof($theme1); $j++) {
             // cration et récupération des questions de la partie associées aux thémes
             $Question = new Question($bddConnect->getBdd(), $idTheme[$j]);
             $intituleQuestion = $Question->getIntituleQuestion();
             $reponse = $Question->getReponse();
             $explication = $Question->getExplication();
             for ($h = 0; $h < sizeof($intituleQuestion); $h++) {
                 // 1 indice de chauqe tableau équivaut au catégorie / theme question / ... de la question actuelle
                 array_push($this->tabCategorie, $nomCategorie[$i]);
                 array_push($this->tabTheme1, $theme1[$j]);
                 array_push($this->tabTheme2, $theme2[$j]);
                 array_push($this->tabQuestion, $intituleQuestion[$h]);
                 array_push($this->tabReponse, $reponse[$h]);
                 // s'il existe ou non une explication de la réponse
                 if (isset($explication[$h])) {
                     array_push($this->tabExplication, $explication[$h]);
                 } else {
                     array_push($this->tabExplication, null);
                 }
             }
         }
     }
 }
 /**
  *
  * @return array A list of all Links.
  */
 public function findAll()
 {
     $sql = "select * from rit_link";
     $result = $this->getDb()->fetchAll($sql);
     // Convert query result to an array of domain objects
     $links = array();
     foreach ($result as $row) {
         $linkId = $row['lnk_id'];
         $links[$linkId] = $this->buildDomainObject($row);
         if (null !== $row['cat_id']) {
             $sql2 = "select * from rit_categories";
             $r2 = $this->getDb()->fetchAll($sql2);
             $cat = new Categorie();
             $cat->setId($r2[0]['cat_id']);
             $cat->setName($r2[0]['cat_name']);
             $links[$linkId]->setArticle($cat);
         }
     }
     return $links;
 }
Esempio n. 14
0
 public function run()
 {
     Eloquent::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('categories')->delete();
     Categorie::create(array('user_id' => 2, 'nom' => 'Men Cat 1', 'nomcourt' => 'M1', 'sexe_id' => 1, 'hcpmin' => -5, 'hcpmax' => 18.4, 'agemin' => 30, 'agemax' => 99, 'agelimityear' => 0, 'tee_id' => 3));
     Categorie::create(array('user_id' => 2, 'nom' => 'Men Cat 2', 'nomcourt' => 'M2', 'sexe_id' => 1, 'hcpmin' => 18.5, 'hcpmax' => 36, 'agemin' => 30, 'agemax' => 99, 'agelimityear' => 0, 'tee_id' => 4));
     Categorie::create(array('user_id' => 2, 'nom' => 'Ladies Cat 1', 'nomcourt' => 'L1', 'sexe_id' => 2, 'hcpmin' => -5, 'hcpmax' => 20.4, 'agemin' => 30, 'agemax' => 99, 'agelimityear' => 0, 'tee_id' => 6));
     Categorie::create(array('user_id' => 2, 'nom' => 'Ladies Cat 2', 'nomcourt' => 'L2', 'sexe_id' => 2, 'hcpmin' => 20.5, 'hcpmax' => 36, 'agemin' => 30, 'agemax' => 99, 'agelimityear' => 0, 'tee_id' => 7));
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
 public static function supprimerCategorie($nom)
 {
     $nomCat = Categorie::getDefaultCategorie();
     require_once "../Modele/Film.class.php";
     $films = Film::getListeFilms();
     foreach ($films as $film) {
         if ($film['categorie'] == $nom) {
             Film::setDefaultCategorie($nomCat['nom'], $film['id']);
         }
     }
     SingletonRequete::getBase()->requeteParam("DELETE FROM Category WHERE category_name=?", array($nom));
 }
Esempio n. 16
0
function ajax_categoria()
{
    $macro = $_REQUEST["macro"];
    $suffisso = $_REQUEST["suffisso"];
    //query sulle categorie
    $objCat = new Categorie();
    $arrCat = $objCat->getAll(" and cat_fkclasse=" . $macro . " order by cat_sorting");
    $num = count($arrCat);
    if ($num == 0) {
        print "- - <input type='hidden' name='categoria" . $suffisso . "' value=''>";
    } else {
        print "<select name='categoria" . $suffisso . "' id='categoria" . $suffisso . "' class='select' onChange=\"ajaxSottocat('','" . $suffisso . "');  ajaxProdotto('','" . $suffisso . "'); \"><option value=''></option>";
        foreach ($arrCat as $arr) {
            print "<option value='" . $arr["cat_id"] . "'";
            if (isset($_REQUEST["evidenza"]) && $_REQUEST["evidenza"] == $arr["cat_id"]) {
                print " selected";
            }
            print ">" . $arr["cat_categoria"] . "</option>";
        }
        print "</select>";
    }
}
 /**
  * @param string $backUrl
  * @param int $categorie_id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function add($backUrl = 'compet', $categorie_id = 0)
 {
     if ($categorie_id == 0) {
         return Redirect::route($backUrl);
     }
     $categorie = Categorie::find($categorie_id);
     $userclub = new Competcategorie();
     $userclub->categorie_id = $categorie->id;
     $userclub->compet_id = MySession::getModel('compet')->id;
     $userclub->tee_id = $categorie->tee_id;
     $userclub->save();
     return Redirect::route($backUrl);
 }
Esempio n. 18
0
 public static function getSamePost($id = "", $cate = "", $limit)
 {
     if ($cate != "" && $id != "") {
         if (Post::where('categorieID', $cate)->count() > 4) {
             $data = DB::select(" SELECT * FROM posts WHERE categorieID = {$cate} AND id != {$id} ORDER BY id ASC LIMIT 0, {$limit} ");
         } else {
             $parent = Categorie::find($cate)->parent;
             $data = DB::select(" SELECT * FROM posts WHERE parent = {$parent} AND id != {$id} ORDER BY id ASC LIMIT 0, {$limit} ");
         }
     } else {
         $data = DB::select("SELECT * FROM posts WHERE parent = 1 ORDER BY id DESC LIMIT 0, {$limit} ");
     }
     return $data;
 }
function _categories($fk_parent = 0, $keyword = '')
{
    global $db, $conf;
    $TFille = array();
    if (!empty($keyword)) {
        $resultset = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie WHERE label LIKE '%" . addslashes($keyword) . "%' ORDER BY label");
        while ($obj = $db->fetch_object($resultset)) {
            $cat = new Categorie($db);
            $cat->fetch($obj->rowid);
            $TFille[] = $cat;
        }
    } else {
        $parent = new Categorie($db);
        if (empty($fk_parent)) {
            if (empty($conf->global->SPC_DO_NOT_LOAD_PARENT_CAT)) {
                $TFille = $parent->get_all_categories(0, true);
            }
        } else {
            $parent->fetch($fk_parent);
            $TFille = $parent->get_filles();
        }
    }
    return $TFille;
}
Esempio n. 20
0
 /**
  * Delete category
  *
  * @param int $id   Category ID
  * @return array
  * 
  * @url	DELETE category/{id}
  */
 function delete($id)
 {
     if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
         throw new RestException(401);
     }
     $result = $this->category->fetch($id);
     if (!$result) {
         throw new RestException(404, 'category not found');
     }
     if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     if (!$this->category->delete(DolibarrApiAccess::$user)) {
         throw new RestException(401, 'error when delete category');
     }
     return array('success' => array('code' => 200, 'message' => 'Category deleted'));
 }
Esempio n. 21
0
 public static function callSelectOption($parent)
 {
     $result = array('--- Root ---');
     $data = DB::select("SELECT * FROM categories");
     foreach ($data as $k => $value) {
         if ($value->parent == $parent) {
             $result[$value->id] = $value->name;
             $data1 = Categorie::where('parent', '=', $value->id)->get();
             foreach ($data1 as $value1) {
                 $id1 = $value1['id'];
                 $result[$id1] = "--" . $value1->name;
                 $data2 = Categorie::where('parent', '=', $value1->id)->get();
                 foreach ($data2 as $value2) {
                     $id2 = $value2['id'];
                     $result[$id2] = "-----" . $value2->name;
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 22
0
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$langs->load("categories");
if (!$user->rights->categorie->lire) {
    accessforbidden();
}
$id = GETPOST('id', 'int');
$type = GETPOST('type') ? GETPOST('type') : Categorie::TYPE_PRODUCT;
$catname = GETPOST('catname', 'alpha');
$section = GETPOST('section') ? GETPOST('section') : 0;
/*
 * View
 */
$categstatic = new Categorie($db);
$form = new Form($db);
if ($type == Categorie::TYPE_PRODUCT) {
    $title = $langs->trans("ProductsCategoriesArea");
} elseif ($type == Categorie::TYPE_SUPPLIER) {
    $title = $langs->trans("SuppliersCategoriesArea");
} elseif ($type == Categorie::TYPE_CUSTOMER) {
    $title = $langs->trans("CustomersCategoriesArea");
} elseif ($type == Categorie::TYPE_MEMBER) {
    $title = $langs->trans("MembersCategoriesArea");
} elseif ($type == Categorie::TYPE_CONTACT) {
    $title = $langs->trans("ContactsCategoriesArea");
} else {
    $title = $langs->trans("CategoriesArea");
}
$arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
Esempio n. 23
0
 }
 if ($search_accountancy_code_buy) {
     $param = "&amp;search_accountancy_code_buy=" . $search_accountancy_code_buy;
 }
 // Add $param from extra fields
 foreach ($search_array_options as $key => $val) {
     $crit = $val;
     $tmpkey = preg_replace('/search_options_/', '', $key);
     if ($val != '') {
         $param .= '&search_options_' . $tmpkey . '=' . urlencode($val);
     }
 }
 print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_products.png');
 if (!empty($catid)) {
     print "<div id='ways'>";
     $c = new Categorie($db);
     $ways = $c->print_all_ways(' &gt; ', 'product/list.php');
     print " &gt; " . $ways[0] . "<br>\n";
     print "</div><br>";
 }
 if (!empty($canvas) && file_exists(DOL_DOCUMENT_ROOT . '/product/canvas/' . $canvas . '/actions_card_' . $canvas . '.class.php')) {
     $fieldlist = $object->field_list;
     $datas = $object->list_datas;
     $picto = 'title.png';
     $title_picto = img_picto('', $picto);
     $title_text = $title;
     // Default templates directory
     $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/' . $canvas . '/tpl/';
     // Check if a custom template is present
     if (file_exists(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/tpl/product/' . $canvas . '/list.tpl.php')) {
         $template_dir = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/tpl/product/' . $canvas . '/';
Esempio n. 24
0
/**
 * Get list of products for a category
 *
 * @param	array		$authentication		Array of authentication information
 * @param	array		$id					Category id
 * @param	$lang		$lang				Force lang
 * @return	array							Array result
 */
function getProductsForCategory($authentication, $id, $lang = '')
{
    global $db, $conf, $langs;
    $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
    $langs->setDefaultLang($langcode);
    dol_syslog("Function: getProductsForCategory login="******" id=" . $id);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    if (!$error && !$id) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter id must be provided.";
    }
    if (!$error) {
        $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
        $langs->setDefaultLang($langcode);
        $fuser->getrights();
        if ($fuser->rights->produit->lire) {
            $categorie = new Categorie($db);
            $result = $categorie->fetch($id);
            if ($result > 0) {
                $table = "product";
                $field = "product";
                $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table;
                $sql .= " WHERE fk_categorie = " . $id;
                $sql .= " ORDER BY fk_" . $field . " ASC";
                dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG);
                $res = $db->query($sql);
                if ($res) {
                    while ($rec = $db->fetch_array($res)) {
                        $obj = new Product($db);
                        $obj->fetch($rec['fk_' . $field]);
                        $iProduct = 0;
                        if ($obj->status > 0) {
                            $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output;
                            $pdir = get_exdir($obj->id, 2) . $obj->id . "/photos/";
                            $dir = $dir . '/' . $pdir;
                            $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10));
                            //Retreive all extrafield for thirdsparty
                            // fetch optionals attributes and labels
                            $extrafields = new ExtraFields($db);
                            $extralabels = $extrafields->fetch_name_optionals_label('product', true);
                            //Get extrafield values
                            $product->fetch_optionals($obj->id, $extralabels);
                            foreach ($extrafields->attribute_label as $key => $label) {
                                $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $product->array_options['options_' . $key]));
                            }
                            $iProduct++;
                        }
                    }
                    // Retour
                    $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products);
                } else {
                    $errorcode = 'NORECORDS_FOR_ASSOCIATION';
                    $errorlabel = 'No products associated' . $sql;
                    $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
                    dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG);
                }
            } else {
                $error++;
                $errorcode = 'NOT_FOUND';
                $errorlabel = 'Object not found for id=' . $id;
            }
        } else {
            $error++;
            $errorcode = 'PERMISSION_DENIED';
            $errorlabel = 'User does not have permission for this request';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Esempio n. 25
0
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
$langs->load("categories");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref');
$type = GETPOST('type');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$removeelem = GETPOST('removeelem', 'int');
$elemid = GETPOST('elemid');
if ($id == "") {
    dol_print_error('', 'Missing parameter id');
    exit;
}
// Security check
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
$result = $object->fetch($id);
$object->fetch_optionals($id, $extralabels);
if ($result <= 0) {
    dol_print_error($db, $object->error);
    exit;
}
$type = $object->type;
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
 *	Actions
 */
// Remove element from category
Esempio n. 26
0
    /**
     *    Delete a third party from database and all its dependencies (contacts, rib...)
     *    @param      id      id of third party to delete
     */
    function delete($id)
    {
        global $user,$langs,$conf;
        require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");

        dol_syslog("Societe::Delete", LOG_DEBUG);
        $sqr = 0;

        // Test if child exists
        $listtable=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur");
        $haschild=0;
        foreach($listtable as $table)
        {
            // Check if third party can be deleted
            $nb=0;
            $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table;
            $sql.= " WHERE fk_soc = " . $id;
            $resql=$this->db->query($sql);
            if ($resql)
            {
                $obj=$this->db->fetch_object($resql);
                if ($obj->nb > 0)
                {
                    $haschild+=$obj->nb;
                }
            }
            else
            {
                $this->error .= $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR);
                return -1;
            }
        }
        if ($haschild > 0)
        {
            $this->error="ErrorRecordHasChildren";
            return -1;
        }


        if ($this->db->begin())
        {
            // Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-third-party-deleting.html)
            // Removing every "categorie" link with this company
            require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");

            $static_cat = new Categorie($this->db);
            $toute_categs = array();

            // Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
            if ($this->client || $this->prospect)
            {
                $toute_categs ['societe'] = $static_cat->containing($this->id,2);
            }
            if ($this->fournisseur)
            {
                $toute_categs ['fournisseur'] = $static_cat->containing($this->id,1);
            }

            // Remove each "Categorie"
            foreach ($toute_categs as $type => $categs_type)
            {
                foreach ($categs_type as $cat)
                {
                    $cat->del_type($this, $type);
                }
            }

            // Remove contacts
            $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
            $sql.= " WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error .= $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR);
            }

            // Update link in member table
            $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
            $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error .= $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR);
            }

            // Remove ban
            $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
            $sql.= " WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error = $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -2 ".$this->error, LOG_ERR);
            }

            // Remove third party
            $sql = "DELETE from ".MAIN_DB_PREFIX."societe";
            $sql.= " WHERE rowid = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error = $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -3 ".$this->error, LOG_ERR);
            }

            if ($sqr == 4)
            {
                // Appel des triggers
                include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                $interface=new Interfaces($this->db);
                $result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
                if ($result < 0) { $error++; $this->errors=$interface->errors; }
                // Fin appel triggers

                $this->db->commit();

                // Suppression du repertoire document
                $docdir = $conf->societe->dir_output . "/" . $id;
                if (file_exists ($docdir))
                {
                    dol_delete_dir_recursive($docdir);
                }

                return 1;
            }
            else
            {
                $this->db->rollback();
                return -1;
            }
        }

    }
Esempio n. 27
0
$langs->load("categories");
$langs->load("products");
$langs->load("contacts");
$mesg = '';
$id = GETPOST('id', 'int');
$ref = GETPOST('ref');
$type = GETPOST('type');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
if ($id == "") {
    dol_print_error('', 'Missing parameter id');
    exit;
}
// Security check
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
$result = $object->fetch($id);
if ($result <= 0) {
    dol_print_error($db, $object->error);
    exit;
}
$type = $object->type;
/*
 *	Actions
 */
if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') {
    if ($object->delete($user) >= 0) {
        header("Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type);
        exit;
    } else {
        $mesg = '<div class="error">' . $object->error . '</div>';
Esempio n. 28
0
	/**
	 *    Delete a third party from database and all its dependencies (contacts, rib...)
	 *
	 *    @param	int		$id     Id of third party to delete
	 *    @return	int				<0 if KO, 0 if nothing done, >0 if OK
	 */
	function delete($id) {
		global $user, $langs, $conf;
		require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php");

		dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
		$error = 0;

		// Test if child exists
		//$objectisused = $this->isObjectUsed($this->rowid); // TODO A reactivier
		if (empty($objectisused)) {


			require_once(DOL_DOCUMENT_ROOT . "/categories/class/categorie.class.php");
			$static_cat = new Categorie($this->db);
			$toute_categs = array();

			// Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
			if ($this->client || $this->prospect) {
				$toute_categs ['societe'] = $static_cat->containing($this->id, 2);
			}
			if ($this->fournisseur) {
				$toute_categs ['fournisseur'] = $static_cat->containing($this->id, 1);
			}

			// Remove each "Categorie"
			foreach ($toute_categs as $type => $categs_type) {
				foreach ($categs_type as $cat) {
					$cat->del_type($this, $type);
				}
			}

			return parent::delete();

			// TODO Supprimer les contacts
			// Remove contacts
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople";
				$sql.= " WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error .= $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
				}
			}

			// Update link in member table
			if (!$error) {
				$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent";
				$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error .= $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
				}
			}

			// Remove ban
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
				$sql.= " WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::Delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error = $this->db->lasterror();
					dol_syslog(get_class($this) . "::Delete erreur -2 " . $this->error, LOG_ERR);
				}
			}

			// Removed extrafields
			//$result=$this->deleteExtraFields($this);
			//if ($result < 0) $error++;

			if (!$error) {
				// Additionnal action by hooks
				include_once(DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php');
				$hookmanager = new HookManager($this->db);
				$hookmanager->initHooks(array('thirdparty_extrafields'));
				$parameters = array();
				$action = 'delete';
				$reshook = $hookmanager->executeHooks('deleteThirdparty', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
				if (!empty($hookmanager->error)) {
					$error++;
					$this->error = $hookmanager->error;
				}
			}

			// Remove third party
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe";
				$sql.= " WHERE rowid = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error = $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -3 " . $this->error, LOG_ERR);
				}
			}

			if (!$error) {
				// Appel des triggers
				include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
				$interface = new Interfaces($this->db);
				$result = $interface->run_triggers('COMPANY_DELETE', $this, $user, $langs, $conf);
				if ($result < 0) {
					$error++;
					$this->errors = $interface->errors;
				}
				// Fin appel triggers
			}

			if (!$error) {
				$this->db->commit();

				// Delete directory
				$docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id;
				if (file_exists($docdir)) {
					dol_delete_dir_recursive($docdir);
				}

				return 1;
			} else {
				$this->db->rollback();
				return -1;
			}
		}
	}
Esempio n. 29
0
<?php

include_once $_SERVER["DOCUMENT_ROOT"] . "/admin/classes/utils.php";
require $_SERVER["DOCUMENT_ROOT"] . "/inc/inc.config.php";
require $_SERVER["DOCUMENT_ROOT"] . "/admin/classes/Categorie.php";
require $_SERVER["DOCUMENT_ROOT"] . "/admin/classes/Produit.php";
require $_SERVER["DOCUMENT_ROOT"] . "/admin/classes/Produit_image.php";
$debug = false;
$categorie = new Categorie();
$produit = new Produit();
$produit_image = new Produit_image();
// ---- Liste des catégories de niveau 0 ------ //
if (1 == 1) {
    unset($recherche);
    $recherche["id_parent"] = 0;
    $liste_categorie = $categorie->getListe($recherche, $debug);
}
// -------------------------------------------- //
?>

<!doctype html>
<html class="no-js" lang="fr">
	<head>
		<title>Les différents aménagements de Modul-Ouest</title>
		<?php 
include $_SERVER["DOCUMENT_ROOT"] . "/inc/header.php";
?>
	</head>
	
	<body class="page">
Esempio n. 30
0
<?php

$manager = new UserManager($link);
$user = $manager->selectById($_SESSION['id']);
$manager = new Categorie($link);
$topic = $manager->selectById($_GET['id']);
if (isset($topic)) {
    require './views/modify-topic.phtml';
}