This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.`id`, t.`reference_id`, t.`tenant_id`, t.`amount`, | |
( | |
SELECT SUM(t.`amount`) | |
FROM `transaction` t | |
) AS total | |
FROM `transaction` t | |
WHERE total > 0 | |
GROUP BY t.`reference_id`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The model behavior for the bathroom fan | |
*/ | |
class Fan extends Courtesy { | |
//it is ok to leave it off if it's all fresh | |
protected $position = false; | |
/** | |
* If the can was used, fan should be on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @settingName = "feeMID", @companyId = 1; | |
SELECT COALESCE(company_setting.value, default_setting.value) AS value | |
FROM default_setting | |
LEFT JOIN company_setting | |
ON company_setting.default_setting_id | |
WHERE default_setting.name = @settingName | |
AND company_setting.company_id = @companyId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function truncateTables($connection = null) { | |
if(!$connection) | |
$connection = $this->con; | |
$tables = $this->getTables(); | |
foreach($tables as $table) { | |
//truncate data from this table | |
$sql = "DELETE FROM [" . $table . "]"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function truncateTables($connection = null) { | |
if(!$connection) | |
$connection = $this->con; | |
$tables = $this->getTables(); | |
foreach($tables as $table) { | |
//truncate data from this table | |
$sql = "DELETE FROM [" . $table . "]"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Outputs a CSV file for download | |
* @param sfRequest $request | |
* @return string (.csv file) | |
*/ | |
public function executeExportcsv(sfRequest $request) { | |
$companies = $this->getCompaniesData($request); | |
$outstream = fopen("php://output", "w"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ensures that the value passed is in datetime format | |
* @param null $dateOrTime | |
* @param string $format | |
* @return null|string | |
*/ | |
function ensureDateTime($dateOrTime = null, $format = "c") { | |
if(!$dateOrTime) | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ensures that the value passed is in datetime format | |
* @param null $dateOrTime | |
* @param string $format | |
* @param string $fallback | |
* @return null|string | |
*/ | |
function ensureDateTime($dateOrTime = null, $format = "c", $fallback = null) { | |
if(!$dateOrTime && !$fallback) | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks a date/time string to verify it's a valid date/time | |
* Supports both Y-m-d and Y-m-d H:i:s | |
* @param $dateTime | |
* @return bool | |
*/ | |
function isValidDateTime($dateTime) { | |
if(preg_match("/^(\d{4})-(\d{2})-(\d{2})( ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]))?$/", $dateTime, $matches)) { | |
if(checkdate($matches[2], $matches[3], $matches[1])) { | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks a date/time string to verify it's a valid date/time | |
* Supports both Y-m-d and Y-m-d H:i:s | |
* @param $dateOrTime | |
* @return bool | |
*/ | |
function isValidDateTime($dateOrTime) { | |
if(preg_match("/^(\d{4})-(\d{2})-(\d{2})( ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]))?$/", $dateOrTime, $matches)) { | |
if(checkdate($matches[2], $matches[3], $matches[1])) { | |
return true; |
OlderNewer