feat: Add DL format for Wall printing
This commit is contained in:
parent
c0a33ef2ab
commit
40f90c6422
3 changed files with 18 additions and 1 deletions
|
|
@ -25,6 +25,7 @@ class CouponsController extends Controller
|
|||
$campagne = Campagne::find($datas['refcamp']);
|
||||
$customer = Customers::find($datas['hashcode']);
|
||||
$couponsToPrint = explode(",", $datas['coupons']);
|
||||
$type = $request->validated()['type'] ?? 'stream';
|
||||
|
||||
if ($campagne->site->crm_token === null) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 500, 'message' => 'CRM Token is missing for site_id : ' . $campagne->site->site_id]);
|
||||
|
|
@ -68,7 +69,11 @@ class CouponsController extends Controller
|
|||
}//end foreach
|
||||
}//end if
|
||||
|
||||
// $coupons contains all printed coupons
|
||||
$pdf = PDF::loadView('pdf.coupons', ['coupons' => $coupons]);
|
||||
if ($type === 'dl') {
|
||||
return $pdf->download(sprintf("coupons_%s_%s_%s.pdf", $crmInfos->firstname, $crmInfos->lastname, date('d-m-Y')));
|
||||
}
|
||||
return new StatusResource(['status' => 'OK', 'pdf' => base64_encode($pdf->stream(sprintf("coupons_%s_%s_%s.pdf", $crmInfos->firstname, $crmInfos->lastname, date('d-m-Y'))))]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ class PrintRequest extends FormRequest
|
|||
return [
|
||||
'refcamp' => 'string|exists:campagne,camp_id|required',
|
||||
'hashcode' => 'string|exists:customers,hashcode|required',
|
||||
'coupons' => 'required'
|
||||
'coupons' => 'required',
|
||||
'type' => 'nullable|in:stream,dl'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,17 @@ class MesBR
|
|||
return $this->callAPI("GET", '/coupons/print', ['refcamp' => $this->refCamp, 'hashcode' => $hashcode, 'coupons' => implode(",", $coupons)]);
|
||||
}
|
||||
|
||||
public function getPrintMurCouponsUrl(string $hashcode, array $coupons)
|
||||
{
|
||||
return sprintf(
|
||||
"%s/api/v1/coupons/print?type=dl&refcamp=%s&hashcode=%s&coupons=%s",
|
||||
$this->endpoint,
|
||||
$this->refCamp,
|
||||
$hashcode,
|
||||
implode(",", $coupons)
|
||||
);
|
||||
}
|
||||
|
||||
private function callAPI($method, $url, $data = [])
|
||||
{
|
||||
$url = $this->endpoint . '/api/v1' . $url;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue