0

Argument 1 passed to PhpOffice\Common\Drawing::pixelsToEmu() must be of the type float, null given, C:\xampp\htdocs\vendor\phpoffice\phppresentation\src\PhpPresentation\Writer\PowerPoint2007\Abstra...


    class GeneratePPT extends Controller{   
//generateppt
public function generateppt($id){
    if(Auth::user()->user_roles == 'superadmin' 
        || Auth::user()->user_roles == 'admin' 
        || Auth::user()->user_roles == 'officer'){

        // do nothing and pass to process                       
    }
    else{
        return redirect('/')->withError("You don't have permission to download");
    }
    //convert encrypted id to actutal decrypt value        
    //get id from route parameter
    $id = request()->route('id');
    $contracts_id = Crypt::decryptString($id);


    $user = ContractDocument::where("contracts_id",$contracts_id)->first();
    $contracts = Contract::where("id",$contracts_id)->first();
    $shop_branches_id = $contracts->shop_branches_id;
    $shop_branches = ShopBranch::where("id",$shop_branches_id)->first();
    $family_members = FamilyMember::where("contracts_id",$contracts_id)->get();

    // delete old file
    if(Storage::exists("public/temp/{$contracts->apply_user_name}.ppt")){
        Storage::delete("public/temp/{$contracts->apply_user_name}.ppt");
    } 

    
    //photo from ContractDocument
    $loan_user_photo = $user->loan_user_photo;
    

    $objPHPPresentation = new PhpPresentation();

    
    $layout = $objPHPPresentation->getLayout();
    $layout->setCX(8.5, $layout::UNIT_INCH);
    $layout->setCY(14, $layout::UNIT_INCH);
    
    //create first table
    $currentSlide = $objPHPPresentation->getActiveSlide();

    self::createtitle($currentSlide);                        
    self::createfirstTable($currentSlide,9,$contracts,$shop_branches,$family_members,$loan_user_signature,$witness_signature);

    // Create user 
    if ($loan_user_photo != null) {
    $currentSlide = $objPHPPresentation->createSlide();
    self::createslide($loan_user_photo,$currentSlide,"Borrower ဓါတ်ပုံ");
    }
    
    

    $oWriterPPTX = IOFactory::createWriter($objPHPPresentation, 'PowerPoint2007');
    $savepath = Storage::path("Loan/contract_{$contracts_id}");
    $oWriterPPTX->save($savepath. "/contract_{$contracts_id}.ppt");

    //update data in daatabase
    ContractDocument::where('contracts_id', $contracts_id)->update(["final_all_combined_ppt_contract"=> "Loan/contract_{$contracts_id}/contract_{$contracts_id}.ppt"]);
    
    //move and allow download
    Storage::copy("Loan/contract_{$contracts_id}/contract_{$contracts_id}.ppt", "public/temp/{$contracts->apply_user_name}.ppt");
    //Storage::download("public/temp/contract_{$contracts_id}.ppt","contract_{$contracts_id}.ppt");

    $myFile = storage_path("app/public/temp/{$contracts->apply_user_name}.ppt");

    return response()->download($myFile)->deleteFileAfterSend(true);
}
Bohemian
  • 412,405
  • 93
  • 575
  • 722

0 Answers0