function balise_ECATALOGUE_OPTION_FILTER_LINK_dyn($id_rubrique = 0) { include_spip('functions/pdk_url'); $rubriques = array($id_rubrique); $rubrique_mdl = new PdkRubriqueModel(); do { // get all parents id $rubrique = $rubrique_mdl->select_by_id($id_rubrique); $id_rubrique = $rubrique['id_parent']; $rubriques[] = $id_rubrique; } while ($id_rubrique != '0'); $rubriques = array_unique($rubriques); //на всякий случай $options = array(); //get required options $result = sql_select(array('id_option'), array('spip_ecatalogue_articles_options as ao', 'spip_articles as a', 'spip_ecatalogue_products as p'), array('id_rubrique in (' . implode(',', $rubriques) . ')', 'p.id_article=a.id_article', 'a.id_article=ao.id_article', 'statut="publie"', 'quantity>0'), array('id_option')); while ($row = sql_fetch($result)) { $options[] = $row['id_option']; } //get proprietes by options $result = sql_select(array('p.id_propriete', 'p.titre as p_titre', 'type', 'id_option', 'o.titre as o_titre'), array('spip_ecatalogue_proprietes as p', 'spip_ecatalogue_options as o'), array('o.id_propriete=p.id_propriete', 'id_option in (' . implode(',', $options) . ')'), '', array('p.titre')); while ($row = sql_fetch($result)) { if (isset($proprietes[$row['id_propriete']])) { //if exits add option to this propriete $proprietes[$row['id_propriete']]['options'][$row['id_option']] = $row['o_titre']; } else { //register new propriete $proprietes[$row['id_propriete']] = array('titre' => $row['p_titre'], 'type' => $row['type'], 'options' => array($row['id_option'] => $row['o_titre'])); } } return array('balise/ecatalogue_option_filter_link', 0, array('proprietes' => $proprietes)); }
function formulaires_ecatalogue_article_option_charger_dist($id_article) { $valeurs = array(); if ($res = sql_select('id_rubrique', 'spip_articles', 'id_article=' . $id_article)) { while ($r = sql_fetch($res)) { $id_rubrique = $r['id_rubrique']; } } $rubriques = array($id_rubrique); $rubrique_mdl = new PdkRubriqueModel(); do { // get all parents id $rubrique = $rubrique_mdl->select_by_id($id_rubrique); $id_rubrique = $rubrique['id_parent']; $rubriques[] = $id_rubrique; } while ($id_rubrique != '0'); $groupe_ids = array(); if ($res = sql_select('id_groupe', 'spip_ecatalogue_rubriques_groupes', 'id_rubrique in (' . implode(',', $rubriques) . ')')) { while ($r = sql_fetch($res)) { $groupe_ids[] = $r['id_groupe']; } } $valeurs['groupe_ids'] = $groupe_ids; $ao_mdl = new ArticleOptionModel(); $connections = $ao_mdl->select('id_article=' . $id_article); foreach ($connections as $connection) { $valeurs["options[" . $connection['id_option'] . "]"] = $connection['id_option']; } return $valeurs; }
function get_discount_action($id_article) { require_once _DIR_PLUGIN_PDK . 'classes/models/PdkRubriqueModel.php'; $s = 'select * from spip_articles where id_article = ' . $id_article; $res = sql_query($s); $all = sql_fetch_all($res); $id_rubrique = isset($all[0]['id_rubrique']) ? $all[0]['id_rubrique'] : ''; $id_r = $id_rubrique; $rubrique_mdl = new PdkRubriqueModel(); $rubriques = ''; do { // get all parents id $rubrique = $rubrique_mdl->select_by_id($id_rubrique); $id_rubrique = $rubrique['id_parent']; $rubriques[] = $id_rubrique; } while ($id_rubrique != '0'); $quantity = isset($cart['quantity']) ? (int) $cart['quantity'] : 0; $price = isset($cart['price']) ? $cart['price'] : 0; $sql = "SELECT * FROM `spip_ecatalogue_discount_signs` t \r\n JOIN spip_ecatalogue_discount_rules r ON t.id_rule = r.id_rule\r\n\r\n WHERE\r\n '" . date("Y-m-d H:i:s") . "' between r.date_start and r.date_end and \r\n (`t`.`object`='id_goods' and `t`.`value`='" . $id_article . "')"; if ($id_r) { $sql .= " OR\r\n (`t`.`object`='id_rubrique' and `t`.`value`='" . $id_r . "') "; } if (is_array($rubriques)) { foreach ($rubriques as $key => $value) { if ($value != 0) { $sql .= " OR\r\n (`t`.`object`='id_rubrique' and `t`.`value`='" . $value . "') "; } } } if ($visiteur) { $sql .= " OR\r\n (`t`.`object`='visiteur' and `t`.`value`='" . $visiteur . "') "; } if ($quantity) { $sql .= " OR\r\n (`t`.`object`='quantity' and `t`.`value`='" . $quantity . "') "; } if ($price) { $sql .= "OR\r\n (`t`.`object`='price' and `t`.`value`<='" . $price . "')"; } $sql .= " LIMIT 1 "; //ppr($sql); //echo '<pre>'; //print_r($sql); //echo '</pre>'; $pre_res = sql_query($sql); $res_rule = sql_fetch_all($pre_res); $action = isset($res_rule[0]['action']) ? $res_rule[0]['action'] : ''; $value = isset($res_rule[0]['value']) ? $res_rule[0]['value'] : ''; return array('action' => $action, 'value' => $value); }