Beispiel #1
0
 public function uploadVariantImage()
 {
     //$this->setTemplate('elib://admin/product.tpl');
     //$this->assertID();
     $v = Model::load('ProductVariant');
     $v->id = $_GET['id'];
     $v->load();
     $this->c->assign('variant', $v);
     $p = Model::load('ProductItem');
     $p->id = $v->product_id;
     $p->load();
     $this->c->assign("product", $p);
     if (isset($_POST['cancel'])) {
         $this->c->redirect('storeadmin/product/' . $v->product_id);
     } elseif (isset($_POST['upload'])) {
         $d = array(array('tn_', 100, 100), array('mid_', 400, 276));
         $u = new ImageUpload('products', true, $d);
         if ($u->error != '') {
             $this->c->assign('error', $u->error);
         } else {
             if ($v->image != '') {
                 $u->remove(array($v->image));
             }
             $v->image = $u->file;
             $v->save(Model::getTable('ProductVariant'), array(), 0);
             //$this->redirect_cgi('archive.cgi?id='.$p->id);
             //$this->execScript('archive', array($p->id));
             $this->c->redirect('storeadmin/product/' . $p->id);
         }
     }
 }
 public function upload_image()
 {
     $this->setTemplate('elib://admin/artist.tpl');
     if (isset($_POST['upload'])) {
         $_GET['id'] = $_POST['id'];
     } elseif (isset($_POST['cancel'])) {
         $this->redirect('admin/artist/' . $_POST['id']);
     }
     $a = Model::load('ArtistItem');
     $a->id = $_GET['id'];
     $a->load();
     $this->presenter->assign("artist", $a);
     if (isset($_POST['upload'])) {
         $d = array(array('tn_', 70, 80), array('mid_', 1000, 370));
         $u = new ImageUpload('', true, $d);
         if ($u->error != '') {
             $this->presenter->assign("error", $u->error);
         } else {
             if ($a->image != "") {
                 $u->remove(array($a->image));
             }
             // update db
             $a->image = $u->file;
             $a->save(Model::getTable('ArtistItem'), array(), 2);
             $this->redirect('admin/artist/' . $a->id);
         }
     }
 }
 public function delete()
 {
     $p = Model::load('PromoItem');
     $p->id = $_GET['id'];
     $p->load();
     $images_removed = false;
     if ($p->image != '') {
         $u = new ImageUpload('', false, array());
         if ($u->remove(array($p->image))) {
             $images_removed = true;
         }
     }
     if ($p->image == '' || $images_removed) {
         $p->delete();
         $this->redirect('admin/promo_category/' . $p->category_id);
     }
 }
 public function edit_colour()
 {
     $this->setTemplate('elib://admin/product.tpl');
     if (isset($_POST['save_colour'])) {
         $c = Model::load('ProductColour');
         $c->id = $_POST['id'];
         $c->load();
         $c->property_option_id = $_POST['colour'];
         if ($_FILES['file']['name'] != '') {
             $images_removed = false;
             $u = new ImageUpload('', false, array());
             if ($u->remove(array($c->image))) {
                 $images_removed = true;
             }
             if ($c->image == '' || $images_removed) {
                 $d = array(array('tn_', 100, 100), array('mid_', 400, 276));
                 $u = new ImageUpload('', true, $d);
                 if ($u->error != '') {
                     $this->presenter->assign("error", $u->error);
                 } else {
                     $c->image = $u->file;
                 }
             }
         }
         $c->save(Model::getTable('ProductColour'), array(), 0);
         $this->redirect('admin/product/edit_colours/' . $c->product_id);
     }
     $c = Model::load('ProductColour');
     $c->id = $_GET['id'];
     $c->load();
     $p = Model::load('ProductItem');
     $p->id = $c->product_id;
     $p->load();
     $this->presenter->assign('product', $p);
     $this->presenter->assign('product_colour', $c);
     $o = Model::load('PropertyOption');
     $colours = $o->getColoursIndexed(2);
     $this->presenter->assign('colours', $colours);
     $this->presenter->assign('colour', $colours[$c->property_option_id]);
 }