示例#1
0
 protected static function actionActive()
 {
     $brand = new BrandModel($_GET['id']);
     $brand->active = $brand->active ? '0' : '1';
     $brand->save();
     self::redirect(App::getLink('AdminBrands'));
 }
示例#2
0
 public function deleteAction()
 {
     $brandModel = new BrandModel("brand");
     $brand_id = $_GET["brand_id"];
     if ($brandModel->delete($brand_id)) {
         $this->jump("index.php?p=admin&c=brand&a=index", "删除成功", "1.0");
     } else {
         $this->jump("index.php?p=admin&c=brand&a=index", "删除失败", "1.0");
     }
 }
 public function overwriteForm($return, $returnfull)
 {
     $return = parent::overwriteForm($return, $returnfull);
     $p = new BrandModel();
     $arrPage = $p->getAll();
     $arrNe = array();
     foreach ($arrPage as $pp) {
         $arrNe[$pp->brand_id] = $pp->brand_id . " - " . $pp->brand_name;
     }
     $return['prod_diskon'] = new Leap\View\InputText("number", "prod_diskon", "prod_diskon", $this->prod_diskon);
     $return['prod_price'] = new Leap\View\InputText("number", "prod_price", "prod_price", $this->prod_price);
     $return['prod_stock'] = new Leap\View\InputText("hidden", "prod_stock", "prod_stock", $this->prod_stock);
     $return['prod_date'] = new Leap\View\InputText("hidden", "prod_date", "prod_date", leap_mysqldate());
     $return['prod_pic'] = new Leap\View\InputGallery("prod_pic", "prod_pic", $this->prod_pic);
     $return['prod_active'] = new Leap\View\InputSelect($this->arrayYesNO, "prod_active", "prod_active", $this->prod_active);
     // $return['news_text'] = new Leap\View\InputTextArea("news_text", "news_text", $this->news_text);
     $return['prod_des'] = new Leap\View\InputTextRTE("prod_des", "prod_des", $this->prod_des);
     $return['prod_brand_id'] = new Leap\View\InputSelect($arrNe, "prod_brand_id", "prod_brand_id", $this->prod_brand_id);
     $return['prod_status'] = new Leap\View\InputText("hidden", "prod_status", "prod_status", $this->prod_status);
     $return['prod_story'] = new Leap\View\InputText("hidden", "prod_story", "prod_story", $this->prod_story);
     $p = new ProdCat();
     $arrPage = $p->getAll();
     $arrNe = array();
     foreach ($arrPage as $pp) {
         $arrNe[$pp->cat_id] = $pp->cat_id . " - " . $pp->cat_name;
     }
     $return['prod_cat_id'] = new Leap\View\InputSelect($arrNe, "prod_cat_id", "prod_cat_id", $this->prod_cat_id);
     $return['prod_material'] = new Leap\View\InputText("hidden", "prod_material", "prod_material", $this->prod_material);
     $return['prod_size'] = new Leap\View\InputText("hidden", "prod_size", "prod_size", $this->prod_size);
     $return['prod_color'] = new Leap\View\InputText("hidden", "prod_color", "prod_color", $this->prod_color);
     $return['prod_collection_name'] = new Leap\View\InputText("hidden", "prod_collection_name", "prod_collection_name", $this->prod_collection_name);
     //        return $return;
     //        $return  = parent::overwriteForm($return, $returnfull);
     $return['product_fb_og_image'] = new \Leap\View\InputFoto("product_fb_og_image", "product_fb_og_image", $this->product_fb_og_image);
     $return['spdivider']['prod_name'] = "Product Details";
     $return['spdivider']['product_metatitle'] = "SEO";
     $return['spdivider']['product_fb_og_title'] = "FB OpenGraph";
     //        $return['spdivider']['post_attachments']  = "Attachments";
     //        $return['post_attachments'] = new Leap\View\InputPageAttachment("post_attachments","post_attachments",$this->post_attachments);
     return $return;
 }
示例#4
0
 public function importModels(Import $entity, $output)
 {
     $em = $this->container->get('doctrine')->getManager();
     $sql = ' SELECT m.id_modelo, m.id_marca, m.nombre, m.slug, mm.nombre as marca FROM  `modelo` AS m ' . ' LEFT JOIN marca AS mm ON m.id_marca = mm.id_marca ' . ' ORDER BY m.id_marca ';
     //                . ' LIMIT '.$entity->getLimitStart().', '.$entity->getLimitEnd();
     $link = mysqli_connect($entity->getServer(), $entity->getUsername(), $entity->getPassword(), $entity->getDbname()) or die('No se pudo conectar: ' . mysqli_error($link));
     $resultado = $link->query($sql);
     $arrayBrand = array();
     if (mysqli_num_rows($resultado) > 0) {
         while ($fila = mysqli_fetch_assoc($resultado)) {
             $brand = $em->getRepository('EcommerceBundle:Brand')->findOneByName(utf8_encode($fila['marca']));
             $brandModel = $em->getRepository('EcommerceBundle:BrandModel')->findOneByName(utf8_encode($fila['nombre']));
             if (!$brandModel instanceof BrandModel) {
                 if (!in_array(utf8_encode($fila['nombre']), $arrayBrand)) {
                     //Create BrandModel
                     $brandModel = new BrandModel();
                     $brandModel->setName(utf8_encode($fila['nombre']));
                     $brandModel->setAvailable(true);
                     if ($brand instanceof Brand) {
                         $brandModel->setBrand($brand);
                     }
                     $em->persist($brandModel);
                     $arrayBrand[] = utf8_encode($fila['nombre']);
                 }
             }
         }
         $em->flush();
     }
 }