public function store()
 {
     Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
     TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
     $input = Input::all();
     for ($i = 0; $i < count($input); $i++) {
         if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
             if (Input::get("link{$i}") != "") {
                 Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
             }
         }
     }
     if (Input::hasFile('photo')) {
         $count = Image::where('email', Auth::user()->email)->count();
         if ($count >= 4) {
             echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
             return Redirect::back();
         }
         $extension = Input::file('photo')->getClientOriginalExtension();
         if ($extension == "gif" || $extension == "jpeg") {
             Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
         } else {
             echo "CAN ONLY DO GIF OR JPEG";
         }
     }
     $imageCount = Image::where('email', Auth::user()->email)->count();
     for ($i = 0; $i < $imageCount - 1; $i++) {
         if (Input::get("delete{$i}") != null) {
             $imageTable = Image::where('email', Auth::user()->email)->get();
             //echo $imageTable[$i+1]["id"];
             Image::where('id', $imageTable[$i]["id"])->delete();
         }
     }
     return Redirect::to('profile');
 }
 public function store()
 {
     if (!Input::has('email', 'password', 'confirmPassword')) {
         $this->failure("Must fill in the values");
     }
     if (Input::get('password') != Input::get('confirmPassword')) {
         $this->failure("PASSWORDS NOT THE SAME");
     }
     $rules = array('email' => 'unique:users,email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $this->failure('That email address is already registered. You sure you don\'t have an account?');
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
         $this->failure("username must be an email");
     }
     $verificationCode = md5(time());
     User::insert(array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'verification' => $verificationCode));
     Image::insert(array('email' => Input::get('email'), 'image' => ''));
     Notes::insert(array('email' => Input::get('email'), 'notes' => ''));
     TBD::insert(array('email' => Input::get('email'), 'tbd' => ''));
     Links::insert(array('email' => Input::get('email'), 'links' => ''));
     Mail::send('emails.emailMessage', array('code' => $verificationCode, 'email' => Input::get('email')), function ($message) {
         $message->to('*****@*****.**', 'Jan Ycasas')->subject('Welcome!');
     });
     echo "Go Log In";
     return Redirect::to('/');
 }
Example #3
0
 public function setProfilePic(&$file)
 {
     if ($file->isUploadedFile()) {
         $image = new Image();
         $imageID = $image->insert($file->getValue());
         $this->profile_picture = $imageID;
         $file->moveUploadedFile('/tmp/');
     }
 }
Example #4
0
 public function getAddEditFormSaveHook($form)
 {
     if (@$_REQUEST[$this->quickformPrefix() . "no_image"]) {
         $this->setImage(0);
     } else {
         $newImage = $form->addElement('file', $this->quickformPrefix() . "image_upload", 'Image');
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($id);
         }
     }
     $this->setLastModified(date('Y-m-d G:i:s'));
 }
 /**
  * Upload new Images
  *
  * Also updates Category & Album modification times
  *
  * @param int $categoryId
  * @param int $albumId
  */
 public function create($categoryId, $albumId)
 {
     $category = $this->getCategoryFinder()->findOneBy('id', $categoryId);
     $album = $this->getAlbumFinder()->findOneBy('id', $albumId);
     if ($this->slim->request->isGet()) {
         $this->slim->render('image/create.html.twig', ['category' => $category, 'album' => $album, 'sessionUser' => $this->getSessionUser(), 'allowedExtensions' => Image::getAllowedExtensions(true)]);
     } elseif ($this->slim->request->isPost()) {
         $uploadHandler = new CustomUploadHandler(['upload_dir' => ROOT . '/files/', 'upload_url' => null, 'access_control_allow_methods' => ['POST'], 'accept_file_types' => '/\\.(' . Image::getAllowedExtensions(true) . ')$/i', 'image_library' => 0, 'image_versions' => ['' => ['auto_orient' => false], 'thumb' => ['upload_dir' => ROOT . '/files/thumbs/', 'upload_url' => null, 'crop' => true, 'max_width' => 252, 'max_height' => 252]]]);
         $newImage = new Image($this->slim->db);
         $newImage->setAlbumId($album->getId());
         $newImage->setName($uploadHandler->getUploadedFileName());
         $newImage->insert();
         $album->update();
         $category->update();
     }
 }
Example #6
0
 public function adminHookAfterSave(&$product, &$form)
 {
     if (!$product->getId()) {
         return "";
     }
     $alternativePics = AlternativeImage::getAll($product->getId());
     foreach ($alternativePics as $image) {
         if (@$_REQUEST["product_delete_altimage_" . $image->getImage()]) {
             $image->delete();
         }
     }
     $newAltImage = $form->addElement('file', 'product_alternativepic_upload', 'New Alternate Product Image');
     if ($newAltImage->isUploadedFile()) {
         $im = new Image();
         $imageId = $im->insert($newAltImage->getValue());
         $obj = new AlternativeImage();
         $obj->setProduct($product->getId());
         $obj->setImage($imageId);
         $obj->save();
     }
 }
Example #7
0
 static function addImage($fields)
 {
     extract($fields);
     $image = new Image();
     $image->portfolio_id = $portfolio_id;
     $image->width = $width;
     $image->height = $height;
     $image->mediatype = $type;
     $image->filename = $filename;
     $image->server_url = $image->setServer();
     $image->created = common_sql_now();
     $image->modified = common_sql_now();
     $result = $image->insert();
     if (!$result) {
         common_log_db_error($user, 'INSERT', __FILE__);
         return false;
     }
     $dir = common_config('img', 'dir');
     $subdir = str_pad($image->id, 8, '0', STR_PAD_LEFT);
     $subdir = str_split($subdir, 3);
     $image->filepath = $dir . $subdir[0] . "/" . $subdir[1] . "/";
     return $image;
 }
Example #8
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartCategory_addedit', 'post', $target);
     $form->setConstants(array('section' => 'categories'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartcategory_categories_id' => $this->getId()));
         $form->addElement('hidden', 'cartcategory_categories_id');
         $defaultValues['cartcategory_name'] = $this->getName();
         $defaultValues['cartcategory_description'] = $this->getDescription();
         $defaultValues['cartcategory_image'] = $this->getImage();
         $defaultValues['cartcategory_parent_id'] = $this->getParent_id();
         $defaultValues['cartcategory_date_added'] = $this->getDate_added();
         $defaultValues['cartcategory_last_modified'] = $this->getLast_modified();
         $defaultValues['cartcategory_status'] = $this->getStatus();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartcategory_name', 'Name');
     $description = $form->addElement('textarea', 'cartcategory_description', 'Description');
     $description->setCols(80);
     $description->setRows(10);
     $newImage = $form->addElement('file', 'cartcategory_image_upload', 'Category Image');
     $curImage = $form->addElement('dbimage', 'cartcategory_image', $this->getImage());
     $form->addElement('select', 'cartcategory_parent_id', 'Parent Category', self::toArray());
     $added = $form->addElement('text', 'cartcategory_date_added', 'Date Added');
     $added->freeze();
     $modified = $form->addElement('text', 'cartcategory_last_modified', 'Date Last Modified');
     $modified->freeze();
     $form->addElement('select', 'cartcategory_status', 'Status', Form::statusArray());
     $form->addElement('submit', 'cartcategory_submit', 'Submit');
     if (isset($_REQUEST['cartcategory_submit']) && $form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('cartcategory_name'));
         $this->setDescription($form->exportValue('cartcategory_description'));
         $this->setImage($form->exportValue('cartcategory_image'));
         $this->setParent_id($form->exportValue('cartcategory_parent_id'));
         $this->setDate_added($form->exportValue('cartcategory_date_added'));
         $this->setLast_modified($form->exportValue('cartcategory_last_modified'));
         $this->setStatus($form->exportValue('cartcategory_status'));
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($im);
             $curImage->setSource($this->getImage()->getId());
         }
         $this->save();
     }
     return $form;
 }
 public function updateAction()
 {
     $this->logger->entering();
     $this->logger->info('Loading the item by id');
     $items = new Item();
     $item = $items->find($this->_getParam('id'))->current();
     $this->logger->info('Setting item from params');
     $item->setFromArray($this->_getParam('item'));
     if (isset($_FILES) && isset($_FILES['image']) && $_FILES['image']['error'] == UPLOAD_ERR_OK) {
         $this->logger->notice('Item image has changed');
         $this->logger->info("Reading image data from temporary storage '{$_FILES['image']['tmp_name']}'");
         $image_data = file_get_contents($_FILES['image']['tmp_name']);
         $this->logger->info('Building row data from image');
         $imageRow = array('name' => $_FILES['image']['name'], 'content_type' => $_FILES['image']['type'], 'data' => $image_data);
         $this->logger->info('Inserting Image');
         $images = new Image();
         $images->insert($imageRow);
         $this->logger->info('Getting the id of the image');
         $item->image_id = $this->db->lastInsertId();
     }
     switch ($_FILES['image']['error']) {
         case UPLOAD_ERR_OK:
             $this->logger->info('Image uploaded without complication');
             break;
         case UPLOAD_ERR_INI_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_PARTIAL:
             $this->logger->warn('Image failed to upload');
             $this->flash->notice = "Image failed to upload, could you try again please?";
             break;
         case UPLOAD_ERR_NO_FILE:
             $this->logger->info('No image uploaded');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->logger->err('File upload directory is missing');
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $this->logger->err('File upload directory is not writable');
             break;
         case UPLOAD_ERR_EXTENSION:
             $this->logger->warn('Unacceptable file extension on uploaded file');
             $this->flash->notice = "Invalid file format. Upload an image please.";
             break;
         default:
             $this->logger->crit("Unknown image upload error '{$_FILES['image']['error']}'");
     }
     $this->logger->info('Saving item');
     $item->save();
     $this->logger->info('Inserting item tags');
     $tags = Tag::parseTags($this->_getParam('tags'));
     $items->updateTags($item->id, $tags);
     $this->logger->info('Adding items to search index');
     ItemIndex::update($item, $this->_getParam('tags'));
     $this->logger->info('Redirecting to show the item');
     $this->_redirect("items/show/{$item->id}");
     $this->logger->exiting();
 }
Example #10
0
 /**
  * Test grabbing an image by image text
  **/
 public function testGetImageByImageText()
 {
     //Count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("image");
     //Create new image and insert into database
     $image = new Image(null, $this->profile->getProfileId(), $this->VALID_IMAGETYPE, $this->VALID_IMAGEFILENAME, $this->VALID_IMAGETEXT, $this->VALID_IMAGEDATE);
     $image->insert($this->getPDO());
     //Get data from database and ensure the fields match our expectations
     $results = Image::getImageByImageText($this->getPDO(), $image->getImageText());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("image"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Jpegery\\Image", $results);
     //Grabs results from array and validate it
     $pdoImage = $results[0];
     $this->assertEquals($pdoImage->getImageProfileId(), $this->profile->getProfileId());
     $this->assertEquals($pdoImage->getImageType(), $this->VALID_IMAGETYPE);
     $this->assertEquals($pdoImage->getImageFileName(), $this->VALID_IMAGEFILENAME);
     $this->assertEquals($pdoImage->getImageText(), $this->VALID_IMAGETEXT);
     $this->assertEquals($pdoImage->getImageDate(), $this->VALID_IMAGEDATE);
 }
Example #11
0
function uploadImage($imageName, $imageLocation, $type, $typeId)
{
    if (!isset($results)) {
        $results = array();
    }
    if ($_FILES[$imageName]['error'] === UPLOAD_ERR_OK) {
        $imageData = array();
        $imageData['imageName'] = $_FILES[$imageName]["name"];
        $imageData['type'] = $type;
        $imageData['typeId'] = $typeId;
        if (is_dir($imageLocation) == false) {
            mkdir($imageLocation, 0777);
            // Create directory if it does not exist
        }
        if (is_file($imageLocation . '/' . $imageData['imageName']) == false) {
            move_uploaded_file($_FILES[$imageName]["tmp_name"], $imageLocation . '/' . $imageData['imageName']);
        } else {
            //rename the image if another one exist
            $temp = explode(".", $_FILES[$imageName]["name"]);
            $imageData['imageName'] = $temp[0] . time() . "." . $temp[1];
            move_uploaded_file($_FILES[$imageName]["tmp_name"], $imageLocation . '/' . $imageData['imageName']);
        }
        $imageData['imageType'] = $_FILES[$imageName]["type"];
        $imageData['imageLocation'] = $imageLocation . '/' . $imageData['imageName'];
        //to add later (the location of the image)
        $image = new Image($imageData);
        if ($imageName === "image") {
            if ($image->insert()) {
                $results['successMessage'] = "image upload successful. Thank you";
                //header('Location: ' . $_SERVER['HTTP_REFERER']);
                return $imageData['imageLocation'];
            }
        }
    } else {
        switch ($_FILES[$imageName]['error']) {
            case UPLOAD_ERR_INI_SIZE:
                $results['errorMessage'] = "The uploaded image exceeds the upload_max_imagesize directive in php.ini";
                break;
            case UPLOAD_ERR_FORM_SIZE:
                $results['errorMessage'] = "The uploaded image exceeds the MAX_image_SIZE directive that was specified in the HTML form";
                break;
            case UPLOAD_ERR_PARTIAL:
                $results['errorMessage'] = "The uploaded image was only partially uploaded";
                break;
            case UPLOAD_ERR_NO_IMAGE:
                $results['errorMessage'] = "No image was uploaded";
                break;
            case UPLOAD_ERR_NO_TMP_DIR:
                $results['errorMessage'] = "Missing a temporary folder";
                break;
            case UPLOAD_ERR_CANT_WRITE:
                $results['errorMessage'] = "Failed to write image to disk";
                break;
            case UPLOAD_ERR_EXTENSION:
                $results['errorMessage'] = "image upload stopped by extension";
                break;
            default:
                $results['errorMessage'] = "Unknown upload error";
                break;
        }
        echo $results['errorMessage'];
    }
}
Example #12
0
 public static function fileBrowser($type)
 {
     $tinyMCE = new TinyMCE();
     global $smarty;
     $smarty->assign('type', $type);
     if (@(!is_null($_POST['uploadsubmit']))) {
         if (!empty($_FILES['filebrowser_uploadedfile']['name'])) {
             if ($_POST['uploadtype'] == 'image') {
                 $newFile = new Image();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $smarty->assign('type', 'image');
             } else {
                 $newFile = new DataStorage();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $newFile->save();
             }
         }
     }
     $smarty->template_dir = SITE_ROOT . '/cms/templates';
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/tiny_mce_popup.js');
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/utils/mctabs.js');
     $smarty->addCSS($tinyMCE->basepath . '/tiny_mce/themes/advanced/skins/default/dialog.css');
     $smarty->addCSS('/css/tiny_mce_filebrowser.css');
     switch ($type) {
         case 'file':
             $smarty->assign('files', DataStorage::search());
             break;
         default:
             $smarty->assign('images', DataStorage::getImagesList());
             break;
     }
     return $smarty->render('filebrowser.tpl');
 }
Example #13
0
    /**
     * Get an Add/Edit form for the object.
     *
     * @param string $target Post target for form submission
     */
    public function getAddEditForm($target = '/admin/Cart')
    {
        $form = new Form('CartProduct_addedit', 'post', $target, '', array('class' => 'admin'));
        $form->setConstants(array('section' => 'products'));
        $form->addElement('hidden', 'section');
        $form->setConstants(array('action' => 'addedit'));
        $form->addElement('hidden', 'action');
        if (!is_null($this->getId())) {
            $form->setConstants(array('cartproduct_products_id' => $this->getId()));
            $form->addElement('hidden', 'cartproduct_products_id');
            $defaultValues['cartproduct_type'] = $this->getType()->getId();
            $defaultValues['cartproduct_quantity'] = $this->getQuantity();
            $defaultValues['cartproduct_pallet_count'] = $this->getPalletCount();
            //$defaultValues ['cartproduct_model'] = $this->getModel();
            $defaultValues['cartproduct_image'] = $this->getImage()->getId();
            $defaultValues['cartproduct_price'] = $this->getPrice();
            //$defaultValues ['cartproduct_virtual'] = $this->getVirtual();
            $defaultValues['cartproduct_date_added'] = $this->getDate_added();
            $defaultValues['cartproduct_lastModified'] = $this->getLastModified();
            $defaultValues['cartproduct_dateAvailable'] = $this->getDateAvailable();
            $defaultValues['cartproduct_weight'] = $this->getWeight();
            $defaultValues['cartproduct_weight_unit'] = $this->getWeightUnit();
            $defaultValues['cartproduct_status'] = $this->getStatus();
            $defaultValues['cartproduct_taxClass'] = $this->getTaxClass()->getId();
            $defaultValues['cartproduct_manufacturer'] = $this->getManufacturer()->getId();
            $defaultValues['cartproduct_ordered'] = $this->getOrdered();
            $defaultValues['cartproduct_orderMin'] = $this->getOrderMin();
            $defaultValues['cartproduct_orderUnits'] = $this->getOrderUnits();
            $defaultValues['cartproduct_pricedByAttribute'] = $this->getPricedByAttribute();
            $defaultValues['cartproduct_isFree'] = $this->getIsFree();
            $defaultValues['cartproduct_isCall'] = $this->getIsCall();
            $defaultValues['cartproduct_quantityMixed'] = $this->getQuantityMixed();
            $defaultValues['cartproduct_isAlwaysFreeShipping'] = $this->getIsAlwaysFreeShipping();
            $defaultValues['cartproduct_qtyBoxStatus'] = $this->getQtyBoxStatus();
            $defaultValues['cartproduct_qtyOrderMax'] = $this->getQtyOrderMax();
            $defaultValues['cartproduct_sortOrder'] = $this->getSortOrder();
            $defaultValues['cartproduct_discountType'] = $this->getDiscountType();
            $defaultValues['cartproduct_discountTypeFrom'] = $this->getDiscountTypeFrom();
            $defaultValues['cartproduct_priceSorter'] = $this->getPriceSorter();
            $defaultValues['cartproduct_category'] = $this->getCategory()->getId();
            $defaultValues['cartproduct_mixedDiscountQty'] = $this->getMixedDiscountQty();
            $defaultValues['cartproduct_titleStatus'] = $this->getTitleStatus();
            $defaultValues['cartproduct_nameStatus'] = $this->getNameStatus();
            $defaultValues['cartproduct_modelStatus'] = $this->getModelStatus();
            $defaultValues['cartproduct_priceStatus'] = $this->getPriceStatus();
            $defaultValues['cartproduct_taglineStatus'] = $this->getTaglineStatus();
            $defaultValues['cartproduct_name'] = $this->getName();
            $defaultValues['cartproduct_description'] = $this->getDescription();
            //$defaultValues ['cartproduct_url'] = $this->getUrl();
            //$defaultValues ['cartproduct_accessoryof'] = $this->getAccessoryOf()->getId();
        } else {
            /*******************************************************/
            //The following few lines assign the default values to the elements.
            //It is very important especially for adjusting the layout
            $defaultValues['cartproduct_date_added'] = "&nbsp;";
            $defaultValues['cartproduct_lastModified'] = "&nbsp;";
            //$defaultValues ['cartproduct_virtual'] = 0;
            /*******************************************************/
        }
        $form->setDefaults($defaultValues);
        $form->addElement('header', 'product_details', 'Product Details');
        $form->addElement('text', 'cartproduct_name', 'Name');
        $desc = $form->addElement('tinymce', 'cartproduct_description', 'Description');
        //$form->addElement('text', 'cartproduct_url', 'Link URL');
        /*
        $products = CartProduct::toArray();
        $products[0] = "Not an Accessory";
        $acc = $form->addElement('select', 'cartproduct_accessoryof', 'Accessory Of', $products);
        $acc->setMultiple(true);
        
        $accs = array();
        
        foreach ($this->getAccessoryOf() as $p) {
        	$accs[] = $p->getId();
        }
        
        $acc->setSelected($accs);
        */
        $form->addElement('select', 'cartproduct_manufacturer', 'Supplier', CartManufacturer::toArray());
        $form->addElement('select', 'cartproduct_category', 'Category', CartCategory::toArray());
        require_once 'CartProductType.php';
        $form->addElement('select', 'cartproduct_type', 'Product Type', @CartProductType::toArray());
        $form->addElement('text', 'cartproduct_quantity', 'Stock Qty');
        $form->addElement('text', 'cartproduct_pallet_count', 'Pallet Count');
        //$form->addElement('text', 'cartproduct_model', 'Model #');
        $newImage = $form->addElement('file', 'cartproduct_image_upload', 'Product Image');
        if ($this->getImage()) {
            $curImage = $form->addElement('dbimage', 'cartproduct_image', $this->getImage()->getId());
        }
        $form->addElement('text', 'cartproduct_price', 'Price ($)');
        //$form->addElement('select', 'cartproduct_virtual', 'Virtual Product', Form::booleanArray());
        $form->addElement('static', 'cartproduct_date_added', 'Date Added');
        $form->addElement('static', 'cartproduct_lastModified', 'Last Modified');
        $form->addElement('text', 'cartproduct_dateAvailable', 'Date Availible');
        $form->addElement('text', 'cartproduct_weight', 'Weight per bag');
        $form->addElement('select', 'cartproduct_weight_unit', 'Weight Unit', CartProduct::getAvailableWeightUnits());
        $form->addElement('select', 'cartproduct_taxClass', 'Tax Class', CartTaxClass::toArray());
        //$form->addElement('text', 'cartproduct_ordered', 'ordered');
        $form->addElement('text', 'cartproduct_orderMin', 'Minimum Order Quantity');
        $form->addElement('select', 'cartproduct_status', 'Status', Form::statusArray());
        $form->addElement('header', 'alt_images', 'Alternate Product Images');
        foreach ($this->getAltImages() as $image) {
            $form->addElement('html', '
				<div style="float: right;" id="delete_altimage_div_' . $image['id'] . '">
					<input type="image" src="/images/admin/cross.gif" name="delete_altimage" onclick="return !deleteAltImage(' . $image['id'] . ');" />
				</div>
			');
            $form->addElement('dbimage', 'cartproduct_altimage_' . $image['id'], $image['image_id']);
        }
        $newAltImage = $form->addElement('file', 'cartproduct_altimage_upload', 'New Alternate Product Image');
        $options = $this->getOptions();
        foreach ($options as $option) {
            $form->addElement('header', 'product_options_' . $option->getId(), 'Product Options: ' . $option->getOptionsId()->getName());
            $form->addElement('static', 'value_' . $option->getId(), $option->getOptionsId()->getName(), $option->getValue()->getName());
            $form->addElement('text', 'attprice[' . $option->getId() . ']', 'Additional Price');
            $form->addElement('text', 'inventory[' . $option->getId() . ']', 'Inventory');
            $form->addElement('html', '
				<div style="float: right;">
					<input type="image" src="/images/admin/cross.gif" name="delete_att" onclick="return !deleteAtt(' . $option->getId() . ');" />
				</div>
			');
            $defaultValues['attprice[' . $option->getId() . ']'] = $option->getValuesPrice();
            $defaultValues['inventory[' . $option->getId() . ']'] = $option->getInventory();
        }
        $form->addElement('header', 'new_product_options', 'New Product Option');
        $form->addElement('select', 'newoption', 'Option', CartProductOption::toArray(), array('onclick' => 'getValues(this);'));
        $form->addElement('select', 'newvalue', 'Value', array());
        $form->addElement('text', 'newattprice', 'Additional Price');
        $form->addElement('text', 'newinventory', 'Inventory');
        $form->setDefaults($defaultValues);
        if (isset($_REQUEST['cartproduct_submit']) && $form->validate() && $form->isSubmitted()) {
            $this->setName($form->exportValue('cartproduct_name'));
            $this->setDescription($form->exportValue('cartproduct_description'));
            //$this->setUrl($form->exportValue('cartproduct_url'));
            $this->setType($form->exportValue('cartproduct_type'));
            $this->setQuantity($form->exportValue('cartproduct_quantity'));
            $this->setPalletCount($form->exportValue('cartproduct_pallet_count'));
            //$this->setModel($form->exportValue('cartproduct_model'));
            $this->setImage($form->exportValue('cartproduct_image_upload'));
            $this->setPrice($form->exportValue('cartproduct_price'));
            //$this->setVirtual($form->exportValue('cartproduct_virtual'));
            $this->setDate_added($form->exportValue('cartproduct_date_added'));
            $this->setLastModified(date('Y-m-d H:i:s'));
            $this->setDateAvailable($form->exportValue('cartproduct_dateAvailable'));
            $this->setWeight($form->exportValue('cartproduct_weight'));
            $this->setWeightUnit($form->exportValue('cartproduct_weight_unit'));
            $this->setStatus($form->exportValue('cartproduct_status'));
            $this->setTaxClass($form->exportValue('cartproduct_taxClass'));
            $this->setManufacturer($form->exportValue('cartproduct_manufacturer'));
            //$this->setAccessoryOf($form->exportValue('cartproduct_accessoryof'));
            //$this->setOrdered($form->exportValue('cartproduct_ordered'));
            if ($form->exportValue('cartproduct_orderMin') <= 0) {
                $this->setOrderMin(1);
            } else {
                $this->setOrderMin($form->exportValue('cartproduct_orderMin'));
            }
            $this->setCategory($form->exportValue('cartproduct_category'));
            /*
            $this->setOrderUnits($form->exportValue('cartproduct_orderUnits'));
            $this->setPricedByAttribute($form->exportValue('cartproduct_pricedByAttribute'));
            $this->setIsFree($form->exportValue('cartproduct_isFree'));
            $this->setIsCall($form->exportValue('cartproduct_isCall'));
            $this->setQuantityMixed($form->exportValue('cartproduct_quantityMixed'));
            $this->setIsAlwaysFreeShipping($form->exportValue('cartproduct_isAlwaysFreeShipping'));
            $this->setQtyBoxStatus($form->exportValue('cartproduct_qtyBoxStatus'));
            $this->setQtyOrderMax($form->exportValue('cartproduct_qtyOrderMax'));
            $this->setSortOrder($form->exportValue('cartproduct_sortOrder'));
            $this->setDiscountType($form->exportValue('cartproduct_discountType'));
            $this->setDiscountTypeFrom($form->exportValue('cartproduct_discountTypeFrom'));
            $this->setPriceSorter($form->exportValue('cartproduct_priceSorter'));
            $this->setMixedDiscountQty($form->exportValue('cartproduct_mixedDiscountQty'));
            $this->setTitleStatus($form->exportValue('cartproduct_titleStatus'));
            $this->setNameStatus($form->exportValue('cartproduct_nameStatus'));
            $this->setModelStatus($form->exportValue('cartproduct_modelStatus'));
            $this->setPriceStatus($form->exportValue('cartproduct_priceStatus'));
            $this->setTaglineStatus($form->exportValue('cartproduct_taglineStatus'));
            */
            if ($newImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newImage->getValue());
                $this->setImage($id);
                //$curImage->setSource($this->getImage()->getId());
            }
            $this->save();
            if ($newAltImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newAltImage->getValue());
                $sql = 'insert into cart_products_images set product_id=' . $this->getId() . ', image_id=' . $id;
                Database::singleton()->query($sql);
            }
            if (is_array(@$_REQUEST['attprice'])) {
                foreach (@$_REQUEST['attprice'] as $key => $value) {
                    $att = new CartProductAttribute($key);
                    $att->setValuesPrice($value);
                    $att->setInventory($_REQUEST['inventory'][$key]);
                    $att->save();
                }
            }
            if (isset($_REQUEST['newvalue']) && isset($_REQUEST['newoption']) && isset($_REQUEST['newattprice'])) {
                $a = new CartProductAttribute();
                $a->setProductid($this->getId());
                $a->setOptionsId($_REQUEST['newoption']);
                $a->setValue($_REQUEST['newvalue']);
                $a->setValuesPrice($_REQUEST['newattprice']);
                $a->setInventory($_REQUEST['newinventory']);
                $a->save();
            }
        }
        $form->addElement('header', 'product_submit', 'Save Product');
        $form->addElement('submit', 'cartproduct_submit', 'Submit');
        return $form;
    }
Example #14
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartManufacturer_addedit', 'post', $target);
     $form->setConstants(array('section' => 'manufacturers'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartmanufacturer_manufacturers_id' => $this->getId()));
         $form->addElement('hidden', 'cartmanufacturer_manufacturers_id');
         $defaultValues['cartmanufacturer_name'] = $this->getName();
         $defaultValues['cartmanufacturer_image'] = $this->getImage()->getId();
         //$defaultValues ['cartmanufacturer_date_added'] = $this->getDate_added();
         //$defaultValues ['cartmanufacturer_last_modified'] = $this->getLast_modified();
         $form->setDefaults($defaultValues);
     }
     if (@$this->getImage() && @$this->getImage()->getId()) {
         $form->addElement('dbimage', 'cartmanufacturer_image', $this->getImage()->getId());
     }
     $form->addElement('text', 'cartmanufacturer_name', 'Name');
     $newImage = $form->addElement('file', 'cartmanufacturer_image_upload', 'Image');
     //$form->addElement('text', 'cartmanufacturer_date_added', 'date_added');
     //$form->addElement('text', 'cartmanufacturer_last_modified', 'last_modified');
     $form->addElement('submit', 'cartmanufacturer_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['cartmanufacturer_submit'])) {
         $this->setName($form->exportValue('cartmanufacturer_name'));
         $this->setDescription($form->exportValue('cartmanufacturer_description'));
         //$this->setImage($form->exportValue('cartmanufacturer_image'));
         //$this->setDate_added($form->exportValue('cartmanufacturer_date_added'));
         //$this->setLast_modified($form->exportValue('cartmanufacturer_last_modified'));
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($id);
         }
         $this->save();
     }
     return $form;
 }
 public function submitPage()
 {
     $timeDiff = round(abs(time() - $_SESSION["time"]) / 60, 2) . " minute";
     if ($timeDiff >= 20) {
         exit("LOGGED OUT OF INACTIVE. <a href='home'>Log In</a>");
     }
     $userID = $_POST["userID"];
     $result = Image::where('userID', $userID)->count();
     if (file_exists($_FILES['photo']['tmp_name']) || is_uploaded_file($_FILES['photo']['tmp_name'])) {
         $result++;
     }
     if ($result >= 4) {
         echo $result;
         exit("CAN ONLY HAVE 4 IMAGES GO BACK");
     }
     $id = Image::select('id')->where('userID', $userID)->get()->toArray();
     for ($i = 0; $i < $result; $i++) {
         if (isset($_POST["delete{$i}"])) {
             Image::where('id', $id[$i]["id"])->delete();
         }
     }
     Notes::where('userID', $_POST["userID"])->update(array('notes' => $_POST["notes"]));
     TBD::where('userID', $_POST["userID"])->update(array('tbd' => $_POST["tbd"]));
     $emailArray = array();
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["website{$i}"]) && $_POST["website{$i}"] != "") {
             array_push($emailArray, $_POST["website{$i}"]);
         }
     }
     for ($i = 0; $i < count($emailArray); $i++) {
         $result = Website::select('website')->where('website', $emailArray[$i])->get();
         if ($result == "[]") {
             Website::insert(array('userID' => $userID, 'website' => $emailArray[$i]));
         }
     }
     if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {
         if ($_FILES['photo']['type'] == "image/jpeg" || $_FILES['photo']['type'] == "image/jpg" || $_FILES['photo']['type'] == "image/gif") {
             Image::insert(array('userID' => $userID, 'image' => file_get_contents($_FILES['photo']['tmp_name'])));
         }
     }
     $profile = $this->returnProfile($_POST["userID"]);
     return View::make('profile')->with('userProfile', $profile);
 }
Example #16
0
 public function setGroupPic(&$file)
 {
     if ($file->isUploadedFile()) {
         $image = new Image();
         $imageID = $image->insert($file->getValue());
         $this->group_pic_id = $imageID;
         $file->moveUploadedFile('/tmp/');
     }
 }