public function postOperasionalTanggal()
 {
     $search = explode('-', trim(Request::get('tgl')));
     $tgl1 = \App\Helpers::dateToMySqlSystem(trim($search[0]));
     $tgl2 = \App\Helpers::dateToMySqlSystem(trim($search[1]));
     $this->title = $this->title . ' (' . $tgl1 . ' - ' . $tgl2 . ')';
     $operasional = byoperasional::where('tanggal', '>=', $tgl1)->where('tanggal', '<=', $tgl2)->get();
     return view('admin.report.operasional')->withInput(Request::all())->with('list', $operasional)->with('title', $this->title);
 }
 public function __construct()
 {
     $data = konsumen::all();
     foreach ($data as $k) {
         $konsumen[$k->idkonsumen] = $k->nama == '' || $k->nama == '-' ? $k->cp : $k->nama;
     }
     $konsumen = \App\Helpers::assoc_merge([0 => '--Daftar Konsumen--'], $konsumen);
     return \View::share('konsumen', $konsumen);
 }
예제 #3
0
 public function getLastMonthSales()
 {
     $data['num'] = jual::where('tgl', '>=', Carbon::now()->subMonth()->format('Y-m-d'))->where('status', 1)->sum('totnetto');
     $data['num'] = Helpers::currency($data['num'], 0, 'id');
     $data['tgl1'] = Carbon::parse('First day of this month')->format('Y-m-d');
     $data['tgl1'] = Carbon::now()->subMonth()->format('Y-m-d');
     $data['tgl2'] = Carbon::now()->format('Y-m-d');
     return $data;
 }
예제 #4
0
 public function boot()
 {
     date_default_timezone_set('Asia/Jakarta');
     /*
     		$abouts  = array();
     		$news = array();
     		$memo = array();*/
     $dcabang = array();
     $ddivisi = array();
     $dsales = array();
     // $dkota = array();
     $dsatuan = array();
     Config::set('registered', false);
     /*$articles = Article::select('article.*','users.first_name','users.last_name')
     		->leftJoin('user','article.user','=','users.id')->get();
     		
     		foreach ($articles as $article) {
     			switch($article->type){
     				case 'about' : 
     					$abouts[] = $article;break;
     				case 'news' :
     					$news[] = $article;break;
     				case 'memo' :
     					$memo[] = $article;break;
     			}
     			
     		}
     		$kota = Kota::all();
     		foreach ($kota as $v) {
     			$dkota[$v->idkota] = $v->nmkota;
     		}
     
     		*/
     $cabang = cabang::all();
     foreach ($cabang as $v) {
         $dcabang[$v->idcabang] = $v->nama;
     }
     $dcabang = Helpers::assoc_merge([0 => '--Daftar Cabang--'], $dcabang);
     $divisi = divisi::all();
     foreach ($divisi as $v) {
         $ddivisi[$v->nama] = $v->nama;
     }
     $ddivisi = Helpers::assoc_merge([0 => '--Semua Divisi--'], $ddivisi);
     $sales = sales::all();
     foreach ($sales as $v) {
         $dsales[$v->nama] = $v->nama;
     }
     $dsales = Helpers::assoc_merge([0 => '--Semua Sales--'], $dsales);
     $satuan = satuan::all();
     foreach ($satuan as $v) {
         $dsatuan[$v->namasatuan] = $v->namasatuan;
     }
     $data = array('satuan' => $dsatuan, 'cabang' => $dcabang, 'divisi' => $ddivisi, 'sales' => $dsales, 'menu' => Config::get('menu'), 'notification' => ['all' => 0, 'quote' => NULL, 'sjt' => NULL]);
     return View::share($data);
 }
예제 #5
0
 /**
  * Get image from storage
  * 
  * @param Request $request
  * @return file
  */
 public function getImage(Request $request)
 {
     /**
      * Check the cache
      */
     $cacheKey = 'image:' . $request->imageName . ':' . $request->imageExtension;
     /**
      * File cached
      */
     if (Cache::has($cacheKey)) {
         $imageMeta = Cache::get($cacheKey);
     } else {
         /**
          * Get META information
          */
         $imageMeta = Image::where(['url' => $request->imageName, 'image_extension' => $request->imageExtension])->first(['image_mime_type', 'image_size', 'id', 'updated_at', 'image_etag']);
         /**
          * File does not exist
          */
         if (empty($imageMeta) == TRUE) {
             App::abort(404);
         }
         /**
          * Save meta information to cache
          */
         Cache::forever($cacheKey, $imageMeta);
     }
     /**
      * Get filename
      */
     $filename = Helpers::getStorageFilename(env('APP_IMAGE_STORAGE_DIRECTORY', 'images'), $imageMeta->id);
     /**
      * Prepare stream
      */
     $stream = Storage::readStream($filename);
     /**
      * File headers
      */
     $headers = array('Content-Description' => 'File Transfer', 'Content-Type' => $imageMeta->image_mime_type, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'public', 'Expires' => Carbon::createFromTimestamp(time() + 3600)->toRfc2822String(), 'Last-Modified' => $imageMeta->updated_at->toRfc2822String(), 'Etag' => $imageMeta->image_etag);
     /**
      * Response code cached
      */
     if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $imageMeta->image_etag || isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $imageMeta->updated_at->toRfc2822String()) {
         $responseCode = 304;
     } else {
         $responseCode = 200;
     }
     /**
      * Stream to browser
      */
     return Response::stream(function () use($stream) {
         fpassthru($stream);
     }, $responseCode, $headers);
 }
예제 #6
0
 public function postEdit(CategoriesRequest $request, $id)
 {
     $term = Categories::find($id);
     $term->name = $request->name;
     $term->slug = Helpers::slug($request->slug);
     if (empty($term->slug)) {
         $term->slug = Helpers::slug($term->name);
     }
     $term->parent = $request->parent;
     $term->description = $request->description;
     if ($term instanceof Categories) {
         $term->save();
     }
     return Redirect('admin/categories')->with('success', 'Update category successfully');
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     date_default_timezone_set('Asia/Jakarta');
     $abouts = array();
     $news = array();
     $memo = array();
     Config::set('registered', false);
     $articles = \App\article::select('article.*', 'users.first_name', 'users.last_name')->leftJoin('users', 'article.user', '=', 'users.id')->get();
     foreach ($articles as $article) {
         switch ($article->type) {
             case 'about':
                 $abouts[] = $article;
                 break;
             case 'news':
                 $news[] = $article;
                 break;
             case 'memo':
                 $memo[] = $article;
                 break;
         }
     }
     $kota = \App\kota::all();
     foreach ($kota as $v) {
         $dkota[$v->idkota] = $v->nmkota;
     }
     $satuan = \App\satuan::all();
     foreach ($satuan as $v) {
         $dsatuan[$v->idsatuan] = $v->namasatuan;
     }
     $cabang = \App\cabang::all();
     foreach ($cabang as $v) {
         $dcabang[$v->idcabang] = $v->nama;
     }
     $dcabang = \App\Helpers::assoc_merge([0 => '--Daftar Cabang--'], $dcabang);
     //Hitung total quote yang baru
     $quotes = \App\quote::where('status', '=', '0');
     $quotesData['all'] = $quotes->limit(3)->get();
     $quotesData['count'] = $quotes->count();
     //Hitung total SJT yang belum tiba
     $sjt = \App\berangkat::where('status', '<', '3');
     $sjtData['all'] = $sjt->limit(3)->get();
     $sjtData['count'] = $sjt->count();
     //Hitung total tagihan yang belum terbayar
     $totNotification = $quotes->count() + $sjt->count();
     $notification = ['all' => $totNotification, 'quote' => $quotesData, 'sjt' => $sjtData];
     $data = array('abouts' => $abouts, 'news' => $news, 'memo' => $memo, 'kota' => $dkota, 'satuan' => $dsatuan, 'cabang' => $dcabang, 'nquotes' => $quotes, 'notification' => $notification);
     return View::share($data);
 }
예제 #8
0
 public function get(Request $request, Upload $upload)
 {
     if (Storage::exists($upload->getPath())) {
         if ($upload->user->banned) {
             Log::info('Refusing to serve file for banned user.', ['user' => $upload->user->name, 'file' => $upload->name]);
             return abort(StatusCode::NOT_FOUND);
         }
         if (!$request->user() || $request->user()->id !== $upload->user_id) {
             $cacheKey = sprintf('cached_view:%s:%s', $request->ip(), $upload->name);
             if (!Cache::has($cacheKey)) {
                 Cache::put($cacheKey, 1, 60);
                 DB::table('uploads')->where('id', $upload->id)->increment('views');
             }
         }
         return Helpers::sendFile($upload);
     }
     return abort(StatusCode::NOT_FOUND);
 }
예제 #9
0
 public function editMatkul($id_course)
 {
     $course = Course::where('seksi', $id_course)->first();
     //get all prodi information
     $prodis = Prodi::all();
     //transform prodi to associative array
     $prodi_arr = array();
     foreach ($prodis as $prodi) {
         $prodi_arr[$prodi->id] = $prodi->prodi;
     }
     $kode_dosen = $course->Kode_Dosen;
     //need to pass filled data to this view (extra parameter)
     $room = Room::room_name();
     $room_arr = Helpers::toAssociativeArrays($room);
     $waktu_kuliah = WaktuKuliah::waktuMap();
     $waktu_opts = Helpers::toAssociativeArrays($waktu_kuliah);
     return view('lecturers.editcourse')->with('prodi_options', $prodi_arr)->with('Kode_Dosen', $kode_dosen)->with('room_options', $room_arr)->with('course', $course)->with('waktu_options', $waktu_opts);
 }
예제 #10
0
 public function profil()
 {
     $user = Auth::user();
     //$user_data = $request->user();
     $id = $user->id;
     $student = Student::where('id_user', $id)->first();
     //$student
     $name = $student->Nama_Mhs;
     $noreg = $student->Noreg;
     $prodi_model = $student->prodi;
     $prodi_id = $prodi_model->id;
     $prodi_name = $prodi_model->prodi;
     $semester = $student->Semester;
     $alamat = $student->Alamat;
     $telepon = $student->Telepon;
     $mac = $student->Mac;
     $prodis = Prodi::all();
     $prodi_arr = Helpers::modelAsAssociativeArray($prodis, 'id', 'prodi');
     return view('students.profil', ['name' => $name, 'noreg' => $noreg, 'prodi' => $prodi_name, 'semester' => $semester, 'alamat' => $alamat, 'telepon' => $telepon, 'mac' => $mac, 'prodi_opts' => $prodi_arr, 'prodi_id' => $prodi_id]);
 }
    public static function listFolders(Folder $node, $folder_id, $level)
    {
        $px = 15;
        foreach ($node->folders as $folder) {
            ?>
            <div class="folder_in_list" style="margin-left: <?php 
            echo $px;
            ?>
px">
				<img src="<?php 
            echo asset('images/dir.png');
            ?>
" alt="" />
				<?php 
            $style = $folder_id == $folder->folder_id ? 'style="font-weight: bold"' : '';
            echo "<a href=" . URL::to('/id/' . $folder->folder_id) . " " . $style . ">" . $folder->name . "</a>";
            Helpers::listFolders($folder, $folder_id, $level + 1);
            ?>
            </div>
            <?php 
        }
    }
예제 #12
0
 public function calculate(CalculateRequest $request)
 {
     $date = $request->input('kuup2ev');
     $fromCur = $request->input('l2htevaluuta');
     $toCur = $request->input('sihtvaluuta');
     $amount = $request->input('l2htesumma');
     //kontrollib, et kasutaja tuleviku aegu ei sooviks
     if (strtotime($date) <= strtotime('today')) {
         $checkDB = Helpers::CheckDB($date);
         if ($checkDB == 0) {
             Helpers::StoreAll($date);
         }
         $checkDB = Helpers::CheckDB($date);
         if ($checkDB == 2) {
             echo "Vabandame ei suutnud otsitud andmeid leida!";
         } else {
             $answer = Helpers::calculate($date, $fromCur, $toCur, $amount);
             echo $answer;
         }
     } else {
         echo "Infot pole veel avaldatud! Proovi mõnda varasemat kuupäeva";
     }
 }
예제 #13
0
//__ requirement obligatoire
require 'vendor/autoload.php';
//__ USE
use app\Helpers;
//__ gestion des erreurs
ini_set('display_errors', 'on');
error_reporting(E_ALL);
//__connection à la base de données
$dsn = 'mysql:host=localhost;dbname=base;charset=utf8';
$usr = '******';
$pwd = 'admin';
//__ initialisation des variables
$app = new Slim\App(array('log.writer' => new \Slim\Logger\DateTimeFileWriter()));
$pdo = new \Slim\PDO\Database($dsn, $usr, $pwd);
$helper = new Helpers();
// Fetch DI Container
$container = $app->getContainer();
// Register Twig View helper
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig('views');
    /*
    $view = new \Slim\Views\Twig('views', [
        'cache' => 'cache'
    ]);
    */
    // Instantiate and add Slim specific extension
    $view->addExtension(new Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
    return $view;
};
//__ Algorithme
예제 #14
0
 public function editTopic($topic_id)
 {
     $user = Auth::user();
     //get the mapping for lecturer
     $kode_dosen = $user->lecturer->Kode_Dosen;
     //get Kode_Matkul & Nama_Matkul from course
     $courses = Course::courseMapByLecturerId($kode_dosen);
     //filter by code dosen
     $courses_arr = Helpers::toAssociativeArrays($courses);
     $counter_pertemuan = array();
     for ($i = 1; $i <= 16; $i++) {
         $counter_pertemuan[$i] = $i;
     }
     //query again to get the correct data based on the given course_id
     $topic = Topic::topicById($topic_id);
     return view('lecturers.edittopic')->with('courses', $courses_arr)->with('counter_p', $counter_pertemuan)->with('topic', $topic);
 }
예제 #15
0
            </h1>
            <h2 style="text-align:center">
                <small>:: Department of Mathematics, Faculty of Mathematics and Natural Science State University of
                    Jakarta ::
                </small>
            </h2>
            </tr>
            <br>

            <!-- time content -->
            <br>
            <br>

            <?php 
use App\Helpers;
echo "<center><h3> Hari, Tanggal : " . Helpers::indonesian_date() . " <span id='output'></span> WIB </center></h3></span>";
?>
                    <!-- time content -->
            <br>
            <br>
            <br>
            <br>
            <br>
            {!! Form::open(array('url' => 'auth/login', 'method'=>'get')) !!}
                <button type="submit" class="btn btn-default btn-block"><b>Login</b></button>
            {!! Form::close() !!}

            {!! Form::open(array('url' => 'auth/register', 'method'=>'get')) !!}
                <button type="submit" class="btn btn-default btn-block"><b>Sign Up</b></button>
            {!! Form::close() !!}
예제 #16
0
 /**
  * Order by
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeOrderByColumns(Builder $query)
 {
     return Helpers::orderByColumns($query, $this->defaultOrderBy);
 }
예제 #17
0
 /**
  * Display a listing of the resource
  * 
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     /**
      * Handle saved settings
      */
     $redirectRoute = Helpers::resetSaveIndexParameters($this->moduleBasicRoute);
     if ($redirectRoute !== FALSE) {
         return redirect($redirectRoute);
     }
     /**
      * Get the rows
      */
     $modelClass = $this->modelClass;
     $arResults = $modelClass::where(function (Builder $query) {
         $query->fulltextAllColumns();
     })->relationships()->orderByColumns()->excludeFromIndex()->externalTablesFilter()->paginate($this->getRowsToPaginate());
     /**
      * Choose the view
      */
     if (empty($this->customView['index']) == TRUE) {
         $view = $this->moduleBasicTemplatePath . '.index';
     } else {
         $view = $this->customView;
     }
     /**
      * Return page
      */
     return view($view, ['results' => $arResults]);
 }
예제 #18
0
 public function getMasterOfTables()
 {
     return Helpers::getMasterOfTable();
 }
예제 #19
0
 public function rekapDosen(Request $request)
 {
     //get list of semester
     $kalender = Kalender::all('id', 'semester');
     $kalender_array = Helpers::modelAsAssociativeArray($kalender, 'id', 'semester');
     //get list of course sections for current semester and lecturer
     $lecturer = Auth::user()->lecturer;
     $kode_dosen = $lecturer->Kode_Dosen;
     $semester = Kalender::getRunningSemester();
     //for debugging
     $course_model = DB::table('courses')->where('Kode_Dosen', $kode_dosen)->where('id_semester', $semester->id);
     $course = $course_model->get();
     $course_array = Helpers::modelAsAssociativeArray($course, 'seksi', 'Nama_Matkul');
     //make default showing first course on the list
     $enrollment = array();
     $seksi = array();
     if (empty($course)) {
         $enrollment = array();
     } else {
         $seksi = $course[0]->seksi;
         //pass along list of enrolled students
         $enrollment = $course_model->where('seksi', $seksi)->join('enrollments as e', 'e.kode_seksi', '=', 'courses.seksi')->join('students as s', 's.Noreg', '=', 'e.noreg')->get();
     }
     return view('lecturers.rekap')->with('kalender_options', $kalender_array)->with('course_options', $course_array)->with('course', $course)->with('enrolls', $enrollment)->with('semester_id', $semester->id)->with('kode_seksi', $seksi);
 }
예제 #20
0
 public function post(Request $request)
 {
     if (!$request->hasFile('file')) {
         return response()->json([trans('messages.upload_file_not_found')], StatusCode::BAD_REQUEST);
     }
     $uploadedFile = $request->file('file');
     if (!$uploadedFile->isValid()) {
         return response()->json([trans('messages.invalid_file_upload')], StatusCode::BAD_REQUEST);
     }
     if ($uploadedFile->getSize() >= config('upste.upload_limit')) {
         $responseMsg = trans('messages.upload_too_large', ['limit' => Helpers::formatBytes(config('upste.upload_limit'))]);
         return response()->json([$responseMsg], StatusCode::REQUEST_ENTITY_TOO_LARGE);
     }
     // If this upload would hit the quota defined in .env, reject it.
     if (config('upste.user_storage_quota') > 0 && !$request->user()->isPrivilegedUser() && $request->user()->getUploadsSize() + $uploadedFile->getSize() >= config('upste.user_storage_quota')) {
         $responseMsg = trans('messages.reached_upload_limit', ['limit' => Helpers::formatBytes(config('upste.user_storage_quota'))]);
         return response()->json([$responseMsg], StatusCode::FORBIDDEN);
     }
     $ext = Helpers::detectFileExtension($uploadedFile);
     $originalHash = sha1_file($uploadedFile);
     $originalName = $uploadedFile->getClientOriginalName();
     // Check to see if we already have this file for this user.
     $existing = Upload::whereOriginalHash($originalHash)->whereUserId($request->user()->id)->first();
     if ($existing) {
         $result = ['url' => route('files.get', $existing), 'delete_url' => route('account.uploads.delete', $existing)];
         $existing->original_name = $originalName;
         $existing->save();
         return response()->json($result, StatusCode::CREATED)->setJsonOptions(JSON_UNESCAPED_SLASHES);
     }
     $randomLen = config('upste.upload_slug_length');
     do {
         $newName = str_random($randomLen++) . ".{$ext}";
     } while (Upload::whereName($newName)->first() || $newName === 'index.php');
     $upload = new Upload(['user_id' => $request->user()->id, 'name' => $newName, 'original_name' => $originalName, 'original_hash' => $originalHash]);
     $uploadFileHandle = fopen($uploadedFile->getRealPath(), 'rb');
     Storage::put($upload->getPath(), $uploadFileHandle);
     fclose($uploadFileHandle);
     if (Helpers::isImage($uploadedFile)) {
         try {
             $img = Image::make($uploadedFile);
         } catch (NotReadableException $ex) {
             Log::error($ex);
             return response()->json([trans('messages.could_not_read_image')], StatusCode::INTERNAL_SERVER_ERROR);
         } catch (NotSupportedException $ex) {
             Log::error($ex);
             return response()->json([trans('messages.unsupported_image_type')], StatusCode::INTERNAL_SERVER_ERROR);
         }
         try {
             $upload->createDirs();
             $img->backup();
             $img->fit(128, 128)->save($upload->getThumbnailPath(true));
             $img->reset();
             if (Helpers::shouldStripExif($uploadedFile)) {
                 $img->save($upload->getPath(true));
             }
         } catch (NotWritableException $ex) {
             Log::error($ex);
             $upload->deleteDirs();
             return response()->json([trans('messages.could_not_write_image')], StatusCode::INTERNAL_SERVER_ERROR);
         } finally {
             $img->destroy();
         }
     }
     $savedFile = $upload->getPath(true);
     $upload->hash = sha1_file($savedFile);
     $upload->size = filesize($savedFile);
     $upload->save();
     $result = ['url' => route('files.get', $upload), 'delete_url' => route('account.uploads.delete', $upload)];
     return response()->json($result, StatusCode::CREATED)->setJsonOptions(JSON_UNESCAPED_SLASHES);
 }
예제 #21
0
 /**
  * Save media to storage
  * 
  * @param object $object
  * @param Request $request
  * @param boolean $update
  * @return boolean
  */
 public function saveMediaToStorage($object, $request, $update = FALSE)
 {
     /**
      * Get filename
      */
     $filename = Helpers::getStorageFilename(env('APP_IMAGE_STORAGE_DIRECTORY', 'images'), $object->id);
     /*
      * Check if requested and then save
      */
     if ($update == FALSE || $update == TRUE && $request->has('image')) {
         $resource = fopen($request->image, 'r');
         Storage::put($filename, $resource);
         fclose($resource);
         /**
          * Update meta information
          */
         return TRUE;
     }
     return FALSE;
 }
예제 #22
0
 public function getStorageQuota()
 {
     $userStorageQuota = Helpers::formatBytes($this->getUploadsSize());
     if (config('upste.user_storage_quota') > 0 && !$this->isPrivilegedUser()) {
         $userStorageQuota = sprintf("%s / %s", $userStorageQuota, Helpers::formatBytes(config('upste.user_storage_quota')));
     }
     return $userStorageQuota;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rulesPenerima = ['cppenerima' => 'required', 'emailpenerima' => 'email', 'notelppenerima' => 'required', 'alamatpenerima' => 'required|min:10', 'kotapenerima' => 'not_in:0'];
     $message = ['cppenerima.required' => 'Contact Person wajib diisi', 'email.email' => 'Format email penerima belum benar', 'notelppenerima.required' => 'Telp penerima wajib diisi', 'alamatpenerima.required' => 'Alamat penerima wajib diisi', 'alamatpenerima.min' => 'Alamat penerima terlalu pendek (minim 10 huruf)', 'kotapenerima.not_in' => 'Kota wajib diisi'];
     $rulesPengiriman = [];
     $rules = array_merge($rulesPenerima, $rulesPengiriman);
     $validation = Validator::make(Request::all(), $rules, $message);
     $brg = Request::get('nmbarang');
     $qty = Request::get('qty');
     $sat = Request::get('satuan');
     if ($validation->fails() || !(count($brg) > 0 && $brg[0] != '')) {
         $err = '<ul>';
         //return view('world.dashboard.order-add')->withErrors($validation->errors())->withInputs()->with('pengirim',$pengirim);
         foreach ($validation->errors()->toArray() as $key => $value) {
             foreach ($value as $k => $v) {
                 $err .= '<li>' . $v . '</li>';
             }
         }
         if (!(count($brg) > 0 && $brg[0] != '')) {
             $err .= '<li>Daftar barang belum terisi</li>';
         }
         $err .= '</ul>';
         $data['error'] = true;
         $data['message'] = $err;
         return $data;
         //json_encode($data);
     } else {
         if (Request::get('penerima') == 0) {
             //simpan data penerima
             $penerima = new konsumen();
             $penerima->nama = Request::get('nppenerima') ? Request::get('nppenerima') : '-';
             $penerima->alamat = Request::get('alamatpenerima');
             $penerima->kota = Request::get('kotapenerima');
             $penerima->notelp = Request::get('notelppenerima');
             $penerima->email = Request::get('emailpenerima');
             $penerima->cp = Request::get('cppenerima');
             $penerima->tgldaftar = Date('Y-m-d');
             $penerima->save();
         } else {
             $penerima = konsumen::find(Request::get('penerima'));
             $penerima->nama = Request::get('nppenerima') ? Request::get('nppenerima') : '-';
             $penerima->alamat = Request::get('alamatpenerima');
             $penerima->kota = Request::get('kotapenerima');
             $penerima->notelp = Request::get('notelppenerima');
             $penerima->email = Request::get('emailpenerima');
             $penerima->cp = Request::get('cppenerima');
             $penerima->tgldaftar = Date('Y-m-d');
             $penerima->save();
         }
         //Ambil id pengirim
         $pengirim = konsumen::find(Request::get('pengirim'));
         //simpan data quote
         $idquote = $this->generateId();
         $quote = new quote();
         $quote->id = $idquote;
         $quote->iduser = \Auth::user()->id;
         $quote->idkonsumen = $pengirim->idkonsumen;
         $quote->idpenerima = $penerima->idkonsumen;
         $quote->tglquote = Date('Y-m-d');
         $quote->tipe = Request::get('tipe');
         $quote->almtasal = Request::get('asalsama') ? $pengirim->alamat : Request::get('alamatasal');
         $quote->ktasal = Request::get('asalsama') ? $pengirim->kota : Request::get('kotaasal');
         $quote->tgljemput = \App\Helpers::dateToMySqlSystem(Request::get('tgljemput'));
         $quote->tglkirim = \App\Helpers::dateToMySqlSystem(Request::get('tglkirim'));
         $quote->tagihan = Request::get('tagihan');
         $quote->save();
         //simpan data pengirim dan penerima di table pengirim_penerima
         $tbl_pp = pengirim_penerima::where('pengirim', '=', $pengirim->idkonsumen)->where('penerima', '=', $penerima->idkonsumen)->get();
         if ($tbl_pp->isEmpty()) {
             $tbl_pp = new pengirim_penerima();
             $tbl_pp->pengirim = $pengirim->idkonsumen;
             $tbl_pp->penerima = $penerima->idkonsumen;
             $tbl_pp->save();
         }
         //simpan rincian item yang diorder
         foreach ($sat as $k => $v) {
             $dquote = new dquote();
             $dquote->idquote = $idquote;
             $dquote->barang = $brg[$k];
             $dquote->qty = \App\Helpers::number_parser($qty[$k], 'id_ID');
             $dquote->satuan = $sat[$k];
             $dquote->save();
         }
         $data['success'] = true;
         return json_encode($data);
     }
     //return Redirect::to('/order');
 }