Esempio n. 1
0
 public function login()
 {
     $param['pageNo'] = 98;
     if ($alert = Session::get('alert')) {
         $param['alert'] = $alert;
     }
     $param['users'] = CompanyModel::get();
     return View::make('company.auth.login')->with($param);
 }
 public function anyUpdate(Request $request)
 {
     $arr_return = array('status' => 'error');
     $id = session('current_company') !== null ? session('current_company') : 0;
     $address_id = session('current_address') !== null ? session('current_address') : 0;
     if ($id) {
         $company = Company::find($id);
         $address = Address::getAddressByCompanyId($id);
         session(['current_company' => $company['id'], 'current_address' => $address['id']]);
     } else {
         $company = Company::get()->last();
         //$address = Address::get()->last();
         if ($company && $address) {
             session(['current_company' => $company->id, 'current_address' => $address->id]);
         } else {
             $company = new Company();
             $company->save();
             $address = new Address();
             $address->save();
             session(['current_company' => $company->id, 'current_address' => $address->id]);
         }
     }
     $company->name = $request->has('name') ? $request->input('name') : '';
     $company->phone = $request->has('phone') ? $request->input('phone') : '';
     $company->company_type_id = $request->has('company_type') ? $request->input('company_type') : 0;
     $company->fax = $request->has('fax') ? $request->input('fax') : '';
     $company->email = $request->has('email') ? $request->input('email') : '';
     $company->web = $request->has('web') ? $request->input('web') : '';
     $company->is_customer = $request->has('is_customer') ? 1 : 0;
     $company->is_distribute = $request->has('is_distribute') ? 1 : 0;
     $address->address = $request->has('address') ? $request->input('address') : '';
     $address->town_city = $request->has('town_city') ? $request->input('town_city') : '';
     $address->province_id = $request->has('province_id') ? $request->input('province_id') : 0;
     $address->country_id = $request->has('country_id') ? $request->input('country_id') : 0;
     if ($company->save()) {
         $arr_return['status'] = 'success';
         $arr_return['name'] = $company->name;
     } else {
         $arr_return['message'] = 'Saving fail';
     }
     if ($address->save()) {
         $arr_return['status'] = 'success';
         $arr_return['name'] = $address->name;
     } else {
         $arr_return['message'] = 'Saving fail';
     }
     return $arr_return;
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getNewJob()
 {
     $companies = Company::get();
     return view("jobs.new-job", ["companies" => $companies]);
 }
Esempio n. 4
0
	static public function anyUpdateReceiptMonthCompany(){
		$list_company = Company::get()->toArray();
		foreach ($list_company as $key2 => $value2) {
			$company_id = $value2['id'];
			echo $company_id;
			$list_distribute = ReceiptMonth::where("company_id","=",$company_id)
									  ->where('type_receipt','=','distribute')
									  ->orderBy('year','ASC')
									  ->orderBy('month','ASC')
									  ->get()->toArray();
			if(count($list_distribute)){
				foreach ($list_distribute as $key => $value) {
					if($key==0){
						$current = ReceiptMonth::where("id","=",$value['id'])->first();
						$current->con_lai = $current->sum_amount - $current->paid + $current->no_cu;
						$current->save();
					}else{
						$current = ReceiptMonth::where("id","=",$value['id'])->first();
						$current->no_cu = $list_distribute[$key-1]['con_lai'];
						$current->con_lai = $current->sum_amount - $current->paid + $current->no_cu;
						$current->save();
					}
				}
			}

			$list_customer = ReceiptMonth::where("company_id","=",$company_id)
									  ->where('type_receipt','=','customer')
									  ->orderBy('year','ASC')
									  ->orderBy('month','ASC')
									  ->get()->toArray();
			if(count($list_customer)){
				foreach ($list_customer as $key => $value) {
					if($key==0){
						$current = ReceiptMonth::where("id","=",$value['id'])->first();
						$current->con_lai = $current->sum_amount - $current->paid + $current->no_cu;
						$current->save();
					}else{
						$current = ReceiptMonth::where("id","=",$value['id'])->first();
						$current->no_cu = $list_customer[$key-1]['con_lai'];
						$current->con_lai = $current->sum_amount - $current->paid + $current->no_cu;
						$current->save();
					}
				}
			}
		}
		
		echo "Done!";
		die;
	}