Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $key = Input::get('key');
     $user = \Apiauth::user($key);
     $id = Input::get('id');
     $class = Input::get('cls');
     if (is_null($id) || $id == 'all') {
         $cimages = \Uploaded::all();
     } else {
         $cimages = \Uploaded::where('parent_id', $id)->where('parent_class', $class)->get();
     }
     $images = array();
     for ($i = 0; $i < count($cimages); $i++) {
         if (is_null($cimages[$i]->parent_id) || is_null($cimages[$i]->parent_class) || $cimages[$i]->parent_id == '' || $cimages[$i]->parent_class == '') {
         } else {
             $images[] = $cimages[$i];
         }
     }
     for ($i = 0; $i < count($images); $i++) {
         unset($images[$i]->_id);
         unset($images[$i]->_token);
         foreach ($this->objmap as $k => $v) {
             $images[$i]->{$k} = $images[$i]->{$v};
             if (!in_array($k, $this->exclude)) {
                 unset($images[$i]->{$v});
             }
         }
         unset($images[$i]->delete_url);
         unset($images[$i]->delete_type);
         $images[$i]->extId = $images[$i]->parentId;
         if (!isset($images[$i]->deleted)) {
             $images[$i]->deleted = 0;
         }
         if (isset($images[$i]->createdDate) && !is_string($images[$i]->createdDate)) {
             $images[$i]->createdDate = date('Y-m-d H:i:s', $images[$i]->createdDate->sec);
         }
         if (isset($images[$i]->lastUpdate) && !is_string($images[$i]->lastUpdate)) {
             $images[$i]->lastUpdate = date('Y-m-d H:i:s', $images[$i]->lastUpdate->sec);
         }
         if (isset($images[$i]->isDoc) && is_bool($images[$i]->isDoc)) {
             $images[$i]->isDoc = $images[$i]->isDoc ? 1 : 0;
         }
         if (isset($images[$i]->isImage) && is_bool($images[$i]->isImage)) {
             $images[$i]->isImage = $images[$i]->isImage ? 1 : 0;
         }
         if (isset($images[$i]->isVideo) && is_bool($images[$i]->isVideo)) {
             $images[$i]->isVideo = $images[$i]->isVideo ? 1 : 0;
         }
         if (isset($images[$i]->isAudio) && is_bool($images[$i]->isAudio)) {
             $images[$i]->isAudio = $images[$i]->isAudio ? 1 : 0;
         }
         if (isset($images[$i]->isPdf) && is_bool($images[$i]->isPdf)) {
             $images[$i]->isPdf = $images[$i]->isPdf ? 1 : 0;
         }
     }
     $actor = $user->fullname . ' : ' . $user->email;
     \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'get image list'));
     return $images;
     //
 }
Ejemplo n.º 2
0
 public static function getPicStat($delivery_id)
 {
     $pic_count = 0;
     $sign_count = 0;
     $app = 'app v 1.0';
     $pics_db = Uploaded::where('parent_id', '=', $delivery_id)->get();
     if ($pics_db) {
         if (count($pics_db->toArray()) > 0) {
             $app = 'app v 2.0';
         }
         foreach ($pics_db as $pic) {
             if (intval($pic->is_signature) == 1) {
                 $sign_count++;
             } else {
                 $pic_count++;
             }
         }
     }
     if ($pic_count == 0 && $sign_count == 0) {
         $existingpic = glob(Config::get('jayon.picture_path') . $delivery_id . '*.jpg');
         foreach ($existingpic as $pic) {
             if (preg_match('/_sign.jpg$/', $pic)) {
                 $sign_count++;
             } else {
                 $pic_count++;
             }
         }
     }
     return array('pic' => $pic_count, 'sign' => $sign_count, 'app' => $app);
 }
Ejemplo n.º 3
0
 public static function getPictures($_id)
 {
     $files = Uploaded::where('parent_id', $_id)->where('parent_class', 'user')->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
     $pics = array();
     if ($files) {
         foreach ($files as $file) {
             $s = new stdClass();
             foreach (Config::get('picture.sizes') as $key => $value) {
                 $s->{$key . '_url'} = $file->{$key . '_url'};
             }
             $s->url = $file->url;
             $pics[] = $s;
         }
     }
     return $pics;
 }
Ejemplo n.º 4
0
                $detailview = 'wupload.detail';
            }
            try {
                $thumb = View::make($detailview)->with('filedata', $fd)->render();
            } catch (Exception $e) {
            }
            if ($fd['ns'] == $ns) {
                print $thumb;
            }
        }
    }
}
// display re-populated data from error form
if ($showold && isset($allin['parent_id'])) {
    //print_r($allin);
    $files = Uploaded::where('parent_id', $allin['parent_id'])->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
    $ns = isset($allin[$element_id . '_ns']) ? $allin[$element_id . '_ns'] : '';
    if (count($files->toArray()) > 0) {
        foreach ($files->toArray() as $fd) {
            //print_r($fd);
            if ($prefix != '') {
                $detailview = $prefix . '.wdetail';
            } else {
                $detailview = 'wupload.detail';
            }
            try {
                $thumb = View::make($detailview)->with('filedata', $fd)->render();
                if ($fd['ns'] == $ns) {
                    print $thumb;
                }
            } catch (Exception $e) {
Ejemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postMeta()
 {
     $key = \Input::get('key');
     //$user = \Apiauth::user($key);
     $user = \Device::where('key', '=', $key)->first();
     if (!$user) {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'device not found, upload image meta failed'));
         return \Response::json(array('status' => 'ERR:NODEVICE', 'timestamp' => time(), 'message' => 'Device Unregistered'));
     }
     $json = \Input::all();
     $batch = \Input::get('batch');
     $result = array();
     foreach ($json as $j) {
         //$j['mtimestamp'] = new \MongoDate(time());
         if (is_array($j)) {
             $blog = new \Imagemeta();
             foreach ($j as $k => $v) {
                 $blog->{$k} = $v;
             }
             $blog->mtimestamp = new \MongoDate(time());
             $r = $blog->save();
             $upl = \Uploaded::where('_id', '=', new \MongoId($blog->extId))->first();
             if ($upl) {
                 $upl->is_signature = $blog->isSignature;
                 $upl->latitude = $blog->latitude;
                 $upl->longitude = $blog->longitude;
                 $upl->delivery_id = $blog->parentId;
                 $upl->photo_time = $blog->photoTime;
                 $upl->save();
             }
             if ($r) {
                 $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['extId']);
             } else {
                 $result[] = array('status' => 'NOK', 'timestamp' => time(), 'message' => 'insertion failed');
             }
         }
     }
     //print_r($result);
     //die();
     $actor = $user->identifier . ' : ' . $user->devname;
     \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'sync scan log'));
     return Response::json($result);
 }
Ejemplo n.º 6
0
 public function picList($data)
 {
     $data = $data->toArray();
     if ($data['logistic_type'] == 'internal') {
         $pics = Uploaded::where('parent_id', '=', $data['delivery_id'])->get();
     } else {
         $maxdate = Threeplpictures::where('awb', '=', $data['awb'])->max('ts');
         $pics = Threeplpictures::where('awb', '=', $data['awb'])->where('ts', '=', $maxdate)->get();
     }
     $glinks = '';
     $thumbnail_url = '';
     if ($pics) {
         if (count($pics) > 0) {
             foreach ($pics as $g) {
                 if ($data['logistic_type'] == 'internal') {
                     $thumbnail_url = $g->thumbnail_url;
                     $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->name . '" value="' . $g->full_url . '" />';
                 } else {
                     $thumbnail_url = $g->thumbnail;
                     $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->consignee_olshop_cust . '" value="' . $g->pictures . '" />';
                 }
             }
             $display = HTML::image($thumbnail_url . '?' . time(), $thumbnail_url, array('class' => 'thumbnail img-polaroid', 'style' => 'cursor:pointer;', 'id' => $data['_id'])) . $glinks;
             return $display;
         } else {
             return 'No Picture';
         }
     } else {
         return 'No Picture';
     }
 }
Ejemplo n.º 7
0
 public function postAvatar()
 {
     $files = Input::file('files');
     $parent_id = Input::get('parid');
     $parent_class = Input::get('parclass');
     $ns = Input::get('ns');
     $file = $files[0];
     $rstring = str_random(15);
     $destinationPath = realpath('storage/media') . '/' . $rstring;
     $filename = $file->getClientOriginalName();
     $filemime = $file->getMimeType();
     $filesize = $file->getSize();
     $extension = $file->getClientOriginalExtension();
     //if you need extension of the file
     $filename = str_replace(Config::get('kickstart.invalidchars'), '-', $filename);
     $uploadSuccess = $file->move($destinationPath, $filename);
     $is_image = $this->isImage($filemime);
     $is_audio = $this->isAudio($filemime);
     $is_video = $this->isVideo($filemime);
     $is_pdf = $this->isPdf($filemime);
     if (!($is_image || $is_audio || $is_video || $is_pdf)) {
         $is_doc = true;
     } else {
         $is_doc = false;
     }
     if ($is_image) {
         $ps = Config::get('picture.sizes');
         $thumbnail = Image::make($destinationPath . '/' . $filename)->fit($ps['thumbnail']['width'], $ps['thumbnail']['height'])->save($destinationPath . '/th_' . $filename);
         $medium = Image::make($destinationPath . '/' . $filename)->fit($ps['medium']['width'], $ps['medium']['height'])->save($destinationPath . '/med_' . $filename);
         $large = Image::make($destinationPath . '/' . $filename)->fit($ps['large']['width'], $ps['large']['height'])->save($destinationPath . '/lrg_' . $filename);
         $full = Image::make($destinationPath . '/' . $filename)->save($destinationPath . '/full_' . $filename);
         $image_size_array = array('thumbnail_url' => URL::to('storage/media/' . $rstring . '/' . $ps['thumbnail']['prefix'] . $filename), 'large_url' => URL::to('storage/media/' . $rstring . '/' . $ps['large']['prefix'] . $filename), 'medium_url' => URL::to('storage/media/' . $rstring . '/' . $ps['medium']['prefix'] . $filename), 'full_url' => URL::to('storage/media/' . $rstring . '/' . $ps['full']['prefix'] . $filename));
     } else {
         if ($is_audio) {
             $thumbnail_url = URL::to('images/audio.png');
         } elseif ($is_video) {
             $thumbnail_url = URL::to('images/video.png');
         } else {
             $thumbnail_url = URL::to('images/media.png');
         }
         $image_size_array = array('thumbnail_url' => $thumbnail_url, 'large_url' => '', 'medium_url' => '', 'full_url' => '');
     }
     $fileitems = array();
     if ($uploadSuccess) {
         $item = array('ns' => $ns, 'parent_id' => $parent_id, 'parent_class' => $parent_class, 'url' => URL::to('storage/media/' . $rstring . '/' . $filename), 'temp_dir' => $destinationPath, 'file_id' => $rstring, 'is_image' => $is_image, 'is_audio' => $is_audio, 'is_video' => $is_video, 'is_pdf' => $is_pdf, 'is_doc' => $is_doc, 'name' => $filename, 'type' => $filemime, 'size' => $filesize, 'deleted' => 0, 'createdDate' => new MongoDate(), 'lastUpdate' => new MongoDate());
         foreach ($image_size_array as $k => $v) {
             $item[$k] = $v;
         }
         Uploaded::insert($item);
         $fileitems[] = $item;
         //$fileitems[] = $rstring.'/'.$filename;
     }
     $files = Uploaded::where('parent_id', $parent_id)->where('parent_class', $parent_class)->where('ns', $ns)->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
     $prefix = $parent_class;
     $thumbs = '';
     if (count($files->toArray()) > 0) {
         foreach ($files->toArray() as $fd) {
             //print_r($fd);
             if ($prefix != '') {
                 $detailview = $prefix . '.wdetail';
             } else {
                 $detailview = 'wupload.detail';
             }
             $thumb = View::make($detailview)->with('filedata', $fd)->render();
             $thumbs .= $thumb;
         }
     }
     $thumbs = base64_encode($thumbs);
     return Response::JSON(array('status' => 'OK', 'message' => '', 'file' => $fileitems, 'thumbs' => $thumbs));
 }
Ejemplo n.º 8
0
 public function picListInternal($data)
 {
     $data = $data->toArray();
     $pics = Uploaded::where('parent_id', '=', $data['delivery_id'])->get();
     $glinks = '';
     $thumbnail_url = '';
     if ($pics) {
         if (count($pics) > 0) {
             $display = '<ul class="pic_list">';
             foreach ($pics as $g) {
                 $thumbnail_url = $g->thumbnail_url;
                 $display .= '<li>';
                 $display .= HTML::image($thumbnail_url . '?' . time(), $thumbnail_url, array('class' => 'thumbnail img-polaroid', 'style' => 'cursor:pointer;', 'id' => $data['_id']));
                 $display .= '</li>';
                 $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->name . '" value="' . $g->full_url . '" />';
             }
             //$display = HTML::image($thumbnail_url.'?'.time(), $thumbnail_url, array('class'=>'thumbnail img-polaroid','style'=>'cursor:pointer;','id' => $data['_id'])).$glinks;
             $display .= '</ul>';
             $display .= $glinks;
             return $display;
         } else {
             return 'No Picture';
         }
     } else {
         return 'No Picture';
     }
 }
Ejemplo n.º 9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $key = Input::get('key');
     $json = Input::all();
     //print_r($json);
     /*
                         ->join('members as m','d.merchant_id=m.id','left')
                         ->where('assignment_date',$indate)
                         ->where('device_id',$dev->id)
                         ->and_()
                         ->group_start()
                             ->where('status',$this->config->item('trans_status_admin_courierassigned'))
                             ->or_()
                             ->group_start()
                                 ->where('status',$this->config->item('trans_status_new'))
                                 ->where('pending_count >', 0)
                             ->group_end()
                         ->group_end()
     */
     if (is_null($key) || $key == '') {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'empty key'));
         return \Response::json(array('status' => 'ERR:EMPTYKEY', 'timestamp' => time(), 'message' => 'Empty Key'));
     }
     $app = \Application::where('key', '=', $key)->first();
     if ($app) {
         $model = new \Shipment();
         $merchant_id = $app->merchant_id;
         $result = array();
         foreach ($json as $j) {
             if (is_array($j)) {
                 $model = $model->orWhere(function ($q) use($j, $key) {
                     $awb = $j['awb'];
                     $q->where('delivery_id', '=', trim($awb))->where('application_key', '=', trim($key));
                     //->whereNotNull('delivery_id');
                 });
             }
         }
         $awbs = $model->get();
         if ($awbs) {
             foreach ($awbs as $awb) {
                 $pod = array();
                 $pictures = \Uploaded::where('parent_id', '=', $awb->delivery_id)->get();
                 if ($pictures) {
                     foreach ($pictures as $pic) {
                         $p = new \stdClass();
                         $p->thumbnail = $pic->thumbnail_url;
                         $p->pictures = $pic->large_url;
                         $p->is_signature = $pic->is_signature;
                         $pod[] = $p;
                     }
                 }
                 $result[] = array('awb' => $awb->delivery_id, 'timestamp' => date('Y-m-d H:i:s', time()), 'pending' => $awb->pending_count, 'district' => $awb->buyerdeliveryzone, 'status' => $awb->status, 'pickup_time' => $awb->pickuptime, 'delivery_time' => $awb->deliverytime, 'pod' => $pod, 'note' => $awb->delivery_note);
             }
         }
         //print_r($result);
         //die();
         $actor = $app->key . ' : ' . $app->merchant_id;
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'awb search with array'));
         return Response::json($result);
     } else {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'account not found'));
         return \Response::json(array('status' => 'ERR:INVALIDACC', 'timestamp' => time(), 'message' => 'Invalid Account'));
     }
 }