Skip to content

Instantly share code, notes, and snippets.

View cygeorgel's full-sized avatar

Cyrille Georgel cygeorgel

View GitHub Profile
@cygeorgel
cygeorgel / flagTest
Created December 20, 2018 20:21
Do we need to show 2 or 4 columns for hours, each row is a day
$days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
$openings = ['Open1', 'Close1', 'Open2', 'Close2'];
// flag tells if we need to show 2 or 4 columns for hours in view
$flagTests = ['Open2', 'Close2'];
$flag = 0;
$saleInvoiceTaxRates = json_decode($saleInvoice->taxRates);
foreach ($saleInvoiceTaxRates as $key => $value) {
if (array_key_exists($key, $taxRates)) {
$taxRates[$key] += $value;
}
else {
@cygeorgel
cygeorgel / Select 1 random
Created December 22, 2018 19:59
pick 1 picture for each of the 3 selected companies
//
// pick 1 picture for each of the 3 selected companies:
$pictures = [];
foreach ($companies as $company) {
$companyPictures = json_decode($company->pictures);
@cygeorgel
cygeorgel / pluck() toArray()
Created January 3, 2019 14:07
Collection to flatten array
// Call must be free if calledNumber is in the same customer file:
$internalNumbers = TelephonyLine::where('customer_file_id', $call->customer_file_id)->pluck('phoneLine')->toArray();
if (in_array($call->calledNumber, $internalNumbers)) {
$call->sellingPriceWithoutTax = 0;
}
$header = ['first name', 'last name', 'company', 'email', 'phone', 'mobilePhone', 'address', 'postCode', 'city'];
$data = Customer::select('mainContactFirstName', 'mainContactLastName', 'name', 'emailAddress', 'phone', 'mobilePhone', 'mainAddressLine1', 'mainAddressPostalCode', 'mainAddressCity')->get()->toArray();
$csv = Writer::createFromPath(storage_path('app/public/customers.csv'), 'w');
$csv->insertOne($header);
$csv->insertAll($data);
/**
* get line for ombutel call
* @param $file
* @param $line
*/
private function getOmbutelCall($file, $line)
{
$values = str_getcsv($line, ',', '"');
if (isset($values[0]) && is_numeric($values[0])) {
$telcoSources = [
'mobile-data' => [
'source' => 'mobile',
'destinations' => [
'National' => 'mobile/national/mobile-data',
],
],
'mobile-mms' => [
private function cogilogLine($line)
{
return $line['journal'] ?? '' . "\t" . $line['date'] ?? '' . "\t" . $line['piece'] ?? '' . "\t" . $line['account'] ?? '' . "\t" . $line['section'] ?? '' . "\t" . $line['term'] ?? '' . "\t" . $line['debit'] ?? '' . "\t" . $line['credit'] ?? '' . "\t" . $line['journal'] ?? '' . "\t" . $line['accountName'] ?? '' . "\t" . $line['sectionName'] ?? '' . '' . "\t" . ''. "\t" . '' . "\n";
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use Ovh\Api;
use App\ConsumerKey;
<?php
namespace App\Console\Commands;
use App\ConfigOvh;
use App\OvhBill;
use App\OvhBillDetail;
use GuzzleHttp\Client;