use yii_app\helpers\HtmlHelper;
use yii_app\helpers\SalaryHelper;
use yii_app\records\Admin;
+use yii_app\records\AdminDynamic;
+use yii_app\records\AdminGroup;
use yii_app\records\AdminGroupDynamic;
use yii_app\records\AdminPayroll;
use yii_app\records\AdminPayrollValues;
public bool $newVersion = false;
public array $timeTableAdmin = [];
- public function __construct($config = []) {
+ public function __construct($config = [])
+ {
$this->salesService = new SalesService();
$this->ratingService = new RatingService();
$this->storePlanService = new StorePlanService();
],
];
- private static function allowAddBonus($isAdministrator, $anotherStore, $changeGroup) : bool
+ private static function allowAddBonus($isAdministrator, $anotherStore, $changeGroup): bool
{
$result = true;
return $result;
}
- private static function allowAddPersonBonus($adminGuid, $date, $isAdministrator, $adminDate) : bool
+ private static function allowAddPersonBonus($adminGuid, $date, $isAdministrator, $adminDate): bool
{
$result = true;
}
-
public function getDataStatic(
$employeeId,
$employeeSelect,
$employeePosition,
$employeeAdminGroup,
$cityStoreNames,
- $paramDynamic) : array
+ $paramDynamic): array
{
if (!empty($employeeSelect['store_id'])) {
}
}
- if (!array_key_exists($employeeId, $exportAdmin)){
+ if (!array_key_exists($employeeId, $exportAdmin)) {
$errorText = 'У сотрудника "' . $employeeSelect['name_full'] . '" в ERP нет данных GUID из 1с employee_id : ' . $employeeId . '<br>';
$errorText .= 'Связь с 1с нужна для того, что бы посчитать продажи смены.<br> Обратитесь в HR отдел';
$outputCheckError = $this->outputCheckError($errorText, '', $controller);
$employeeSelectStore = CityStore::getCityStoreById($employeeSelectStoreId);
- if (!array_key_exists($employeeSelectStoreId, $exportCityStore)){
+ if (!array_key_exists($employeeSelectStoreId, $exportCityStore)) {
$errorText = 'По сотруднику "' . $employeeSelect['name_full'] . '" не найдена связь с магазином в 1с : id ' . $employeeSelectStoreId . '<br>';
$errorText .= 'Связь с магазином 1с нужна для того, что бы получить его планы';
}
-
$adminPayroll = AdminPayroll::find()
->andWhere(['admin_id' => $employeeId])
->andWhere(['year' => $yearSelect])
->andWhere(['month' => $monthSelect])
->limit(1)
- ->one()
- ;
+ ->one();
$payrollId = $adminPayroll->getId();
$paramPayroll = AdminPayroll::getValues($payrollId);
$paramDynamicTmp = $paramHybrid = $paramDynamic;
$diffKeys = [];
- foreach($paramDynamicTmp as $keyRow => $row) {
+ foreach ($paramDynamicTmp as $keyRow => $row) {
if (array_key_exists($keyRow, $paramPayroll)) {
if ($paramDynamic[$keyRow] != $paramPayroll[$keyRow]) {
$diffKeys[] = $keyRow;
}
}
- if (!array_key_exists($employeeId, $exportAdmin)){
+ if (!array_key_exists($employeeId, $exportAdmin)) {
$errorText = 'У сотрудника "' . $employeeSelect['name_full'] . '" в ERP нет данных GUID из 1с employee_id : ' . $employeeId . '<br>';
$errorText .= 'Связь с 1с нужна для того, что бы посчитать продажи смены.<br> Обратитесь в HR отдел';
$outputCheckError = $this->outputCheckError($errorText, '', $controller);
}
}
- $adminGuid = $exportAdmin[$employeeId];
+ $adminGuid = $exportAdmin[$employeeId];
$employeeSelectStore = CityStore::getCityStoreById($employeeSelectStoreId);
- if (!array_key_exists($employeeSelectStoreId, $exportCityStore)){
+ if (!array_key_exists($employeeSelectStoreId, $exportCityStore)) {
$errorText = 'По сотруднику "' . $employeeSelect['name_full'] . '" не найдена связь с магазином в 1с : id ' . $employeeSelectStoreId . '<br>';
$errorText .= 'Связь с магазином 1с нужна для того, что бы получить его планы';
$salesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
$salesSummCurrentMonth = $this->getSalesSaleSum($dateFromBeginMonth, $dateToEndMonth, $entityCityStoreEmployeeSelect);
- $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect,true);
+ $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect, true);
$amountWriteOff = WriteOffs::getWriteOffByStore($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
$planPercent = 0;
$planStoreMonthCalculatePercent = 0;
if (!empty($salesByStore) && !empty($planMonthByStore)) {
- $planPercent=round(100 * $salesByStore/$planMonthByStore,1);
+ $planPercent = round(100 * $salesByStore / $planMonthByStore, 1);
}
//sales_avg_check
$salesListAvgCheck = $this->getSumListAvgCheck($employeeSelectStoreId, $dateFrom, $dateTo);
-
$timetableForMonth = $this->getTimetableData($employeeId, $employeeSelectStoreId, $dateFromBeginMonth, $dateTo);
$allowedDate = ($dateFrom >= '2022-12-01');
$errorText .= 'за выбранный интервал с ' . $dateFrom . ' по ' . $dateTo . ' <br>';
$errorText .= 'в графике смен не найдено cs1';
- $dateFromInfo=date("Y-m-d",time()-7*86400+7200);
- $dateToInfo=date("Y-m-d",time());
+ $dateFromInfo = date("Y-m-d", time() - 7 * 86400 + 7200);
+ $dateToInfo = date("Y-m-d", time());
$buttonParams = [
- 'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromInfo. "&DaysSearchForm[dateTo]=" . $dateToInfo,
+ 'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromInfo . "&DaysSearchForm[dateTo]=" . $dateToInfo,
'name' => 'за неделю',
];
}
}
- $planByDayFromRateInfo = min(ArrayHelper::getColumn($rateInfo,'condition'));
+ $planByDayFromRateInfo = min(ArrayHelper::getColumn($rateInfo, 'condition'));
$planMonthFlorist = 0;
$salaryFloristByDay = 0;
$normalCountShiftArray = SalaryHelper::$normalCountShift;
if (!empty($employeeSelect["group_id"])) {
- if (Admin::ADMINISTRATOR_GROUP_ID == $employeeSelect["group_id"]){
+ if (Admin::ADMINISTRATOR_GROUP_ID == $employeeSelect["group_id"]) {
// у Администратора число смен равно количеству рабочих дней в месяце
$normalCountShift = HtmlHelper::getWorkDays($monthSelect, $yearSelect);
$leftWorkDayForMonth = $normalCountShiftValue - $worksDayByTableFromBeginMonth;
}
- if ($leftWorkDayForMonth > 0 ) {
- $planAdminByDay = round(($planMonthFlorist - $salaryByAdminFromBeginMonth ) / $leftWorkDayForMonth, 1);
+ if ($leftWorkDayForMonth > 0) {
+ $planAdminByDay = round(($planMonthFlorist - $salaryByAdminFromBeginMonth) / $leftWorkDayForMonth, 1);
}
if (!empty($worksDayByTableFromBeginMonth)) {
$salaryFloristByDay = round($salaryByAdminFromBeginMonth / $worksDayByTableFromBeginMonth, 1);
$salaryFloristByDay = $salaryByAdminFromBeginMonth;
}
$planMonthCalculate = round($salaryFloristByDay * $normalCountShiftValue, 1);
- $planMonthCalculatePercent = round(100 * $planMonthCalculate /$planMonthFlorist,1);
+ $planMonthCalculatePercent = round(100 * $planMonthCalculate / $planMonthFlorist, 1);
} else {
$leftWorkDayForMonth = 23;
$normalCountShiftValue = 21;
$leftWorkDayForMonth = $normalCountShiftValue - $worksDayByTableFromBeginMonth;
}
- if ($leftWorkDayForMonth > 0 ) {
- $planAdminByDay = round(($planMonthAdministrator - $salaryByAdminFromBeginMonth ) / $leftWorkDayForMonth, 1);
+ if ($leftWorkDayForMonth > 0) {
+ $planAdminByDay = round(($planMonthAdministrator - $salaryByAdminFromBeginMonth) / $leftWorkDayForMonth, 1);
}
if (!empty($worksDayByTableFromBeginMonth)) {
$salaryAdministratorByDay = round($salaryByAdminFromBeginMonth / $worksDayByTableFromBeginMonth, 1);
$salaryAdministratorByDay = $salaryByAdmin;
}
$planMonthCalculate = round($salaryAdministratorByDay * $normalCountShiftValue, 1);
- $planMonthCalculatePercent = round(100 * $planMonthCalculate /$planMonthAdministrator,1);
+ $planMonthCalculatePercent = round(100 * $planMonthCalculate / $planMonthAdministrator, 1);
$administratorOklad = $this->bonusService->getAdministratorOklad($planMonthCalculate);
}
&& $monthSelect == date("n")
) {
$showBlockForecast = true;
- $dayPastCurrentMonth = (int) date("d");
+ $dayPastCurrentMonth = (int)date("d");
$daysRemainsInSelectMonth = $daysInSelectMonth - $dayPastCurrentMonth;
if (!empty($planMonthByStore)) {
if (isset($salesByStore) && !empty($planMonthByStore)) {
$saleByDayCalculate = round($salesByStore / $dayPastCurrentMonth, 1);
$saleByMonthCalculate = $saleByDayCalculate * $daysInSelectMonth;
- $planStoreMonthCalculatePercent = round(100 * $saleByMonthCalculate/$planMonthByStore,1);
+ $planStoreMonthCalculatePercent = round(100 * $saleByMonthCalculate / $planMonthByStore, 1);
- if ($daysRemainsInSelectMonth > 0 ) {
- $needSaleByDayCalculate = round(($planMonthByStore - $salesByStore ) / $daysRemainsInSelectMonth, 1);
+ if ($daysRemainsInSelectMonth > 0) {
+ $needSaleByDayCalculate = round(($planMonthByStore - $salesByStore) / $daysRemainsInSelectMonth, 1);
}
}
$showBlockForecast = true;
if (isset($salesByStore) && !empty($planMonthByStore)) {
- $planStoreMonthCalculatePercent = round(100 * $salesByStore/$planMonthByStore,1);
+ $planStoreMonthCalculatePercent = round(100 * $salesByStore / $planMonthByStore, 1);
}
}
$deltaYearToYearByMonthSalesSummPercent = ArrayHelper::getValue($deltaYearToYearByMonthSalesSummValues, 'deltaPercent');
$salesSummPastYearMonth = ArrayHelper::getValue($deltaYearToYearByMonthSalesSummValues, 'salesSummPastYearMonth');
- $dateCurrent = date("Y-m-d",time());
+ $dateCurrent = date("Y-m-d", time());
- $yearCurrent = date("Y",strtotime($dateCurrent));
- $monthCurrent = date("n",strtotime($dateCurrent));
+ $yearCurrent = date("Y", strtotime($dateCurrent));
+ $monthCurrent = date("n", strtotime($dateCurrent));
// Возможное депремирование администратору
if (!empty($personColorRubleBonuses)) {
$personColorRubleBonusesValues = [
- ' премия в цвето-рублях' => (int) $personColorRubleBonuses,
+ ' премия в цвето-рублях' => (int)$personColorRubleBonuses,
];
}
$adminSumGameAvgSum = ArrayHelper::getValue($adminSumGameBonusArrayMainStoreWithPersonalBonuses, 'adminSumGameAvgSumTotal');
-
$adminSumGameBonusArray = $adminSumGameBonusArrayMainStoreWithPersonalBonuses;
if (!empty($timetableAdminAnotherStore) && !empty($adminSumGameBonusArrayMainStoreWithPersonalBonuses)) {
&&
count($timetableAdmin) >= 7
) {
- $this->ratingService->setRatingValue($employeeId, $adminSumGameBonusArrayMainStoreWithPersonalBonuses, $ratingId, $yearSelect, $monthSelect,$monthWithZeroSelect);
+ $this->ratingService->setRatingValue($employeeId, $adminSumGameBonusArrayMainStoreWithPersonalBonuses, $ratingId, $yearSelect, $monthSelect, $monthWithZeroSelect);
if ($calculatePersonalRating) {
$this->ratingService->calculateRating($yearSelect, $monthWithZeroSelect);
}
$isShowBonusOtherItems = ($dateFrom >= $dateStartBonusOtherItems);
- $arrayTypes = ["wrap", "potted", "related","services","salut"];
+ $arrayTypes = ["wrap", "potted", "related", "services", "salut"];
if ($isShowBonusOtherItems) {
$arrayTypes = array_merge($arrayTypes, ["other_items"]);
}
- $arrayProducts= Products1c::getProductsFromClass($arrayTypes);
+ $arrayProducts = Products1c::getProductsFromClass($arrayTypes);
$this->arr = [$adminGuid];
$adminGuidArr = $this->arr;
if (!empty($arrayProducts["services"])) {
- $arrUsersSalaryServicesPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["services"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
+ $arrUsersSalaryServicesPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["services"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
$arrUsersSalaryServices = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'bonus');
$arrUsersSalaryServicesCheck = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'check');
}
if (!empty($arrayProducts["related"])) {
- $arrUsersSalaryRelatedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["related"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
+ $arrUsersSalaryRelatedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["related"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
$arrUsersSalaryRelated = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'bonus');
$arrUsersSalaryRelatedCheck = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'check');
}
if (!empty($arrayProducts["potted"])) {
- $arrUsersSalaryPottedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["potted"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
+ $arrUsersSalaryPottedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["potted"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
$arrUsersSalaryPotted = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'bonus');
$arrUsersSalaryPottedCheck = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'check');
}
if (!empty($arrayProducts["wrap"])) {
- $arrUsersSalaryWrapPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["wrap"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
+ $arrUsersSalaryWrapPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["wrap"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
$arrUsersSalaryWrap = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'bonus');
$arrUsersSalaryWrapCheck = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'check');
}
if (!empty($arrayProducts["other_items"])) {
- $arrUsersSalaryOtherItemsPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["other_items"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
+ $arrUsersSalaryOtherItemsPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["other_items"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator);
$arrUsersSalaryOtherItems = ArrayHelper::getColumn($arrUsersSalaryOtherItemsPrepared, 'bonus');
$arrUsersSalaryOtherItemsCheck = ArrayHelper::getColumn($arrUsersSalaryOtherItemsPrepared, 'check');
}
$dateToSalutInterval = ArrayHelper::getValue($dateFromToSalutArray, 'dateTo');
if (!empty($dateFromSalutInterval) && !empty($dateToSalutInterval)) {
- $arrUsersSalarySalut = SalaryHelper::getSalaryBonusSalut($arrayProducts["salut"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator, $employeeSelectStoreId);
+ $arrUsersSalarySalut = SalaryHelper::getSalaryBonusSalut($arrayProducts["salut"], $adminGuidArr, $dateFrom, $dateTo, $exportAdmin, $isAdministrator, $employeeSelectStoreId);
}
}
}
$userSalaryPottedPremium = round($userSalaryPotted * 0.05);
$userSalaryWrapPremium = round($userSalaryWrap * 0.05); // 5% за личные продажи упаковки
- $userSalarySalutPremium = round($userSalarySalut * 0.05); // 5% за личные продажи пиротехники
+ $userSalarySalutPremium = round($userSalarySalut * 0.05); // 5% за личные продажи пиротехники
- $userSalaryOtherItemsPremium = round($userSalaryOtherItems * 0.01); // 1% за личные продажи не фокусной продукции (Другме товары)
+ $userSalaryOtherItemsPremium = round($userSalaryOtherItems * 0.01); // 1% за личные продажи не фокусной продукции (Другме товары)
//Букеты по матрице
$enableTransform = ($dateFrom < '2022-12-07' && $dateTo > '2022-12-07');
$salesMatrixPart2 = $this->salesService->getMatrixSalesProducts($adminGuid, '2022-12-08', $dateTo, $isAdministrator);
$salesMatrix = array_merge($salesMatrixPart1, $salesMatrixPart2);
} else {
- $salesMatrix = $this->salesService->getMatrixSalesProducts($adminGuid, $dateFrom, $dateTo, $isAdministrator);
+ $salesMatrix = $this->salesService->getMatrixSalesProducts($adminGuid, $dateFrom, $dateTo, $isAdministrator);
}
$salesMatrixProductGuids = ArrayHelper::getColumn($salesMatrix, 'product_guid');
$salesMatrixProducts = Products1c::getProducts1cByType('products', $salesMatrixProductGuids);
- $salesMatrixProductNames = ArrayHelper::map($salesMatrixProducts, 'id','name');
+ $salesMatrixProductNames = ArrayHelper::map($salesMatrixProducts, 'id', 'name');
$salaryMatrix = 0;
$bonusSalaryMatrix = 0;
$matrixBonusCoefficientRow = $this->bonusService->getMatrixBonusCoefficient($row['date']);
$rowBonus = $row["summ"] * $matrixBonusCoefficientRow;
$salesMatrix[$keySalesMatrix]["bonus"] = $rowBonus;
- if($row["operation"] == Sales::OPERATION_SALE) {
+ if ($row["operation"] == Sales::OPERATION_SALE) {
$salaryMatrix += $row["summ"];
$bonusSalaryMatrix += $rowBonus;
- } elseif($row["operation"] == Sales::OPERATION_RETURN) {
+ } elseif ($row["operation"] == Sales::OPERATION_RETURN) {
$salaryMatrix -= $row["summ"];
$bonusSalaryMatrix -= $rowBonus;
}
$makeMatrixPart2 = $this->salesService->getMatrixMakeProducts($adminGuid, '2022-12-08', $dateTo, $isAdministrator);
$makeMatrix = array_merge($makeMatrixPart1, $makeMatrixPart2);
} else {
- $makeMatrix = $this->salesService->getMatrixMakeProducts($adminGuid, $dateFrom, $dateTo, $isAdministrator);
+ $makeMatrix = $this->salesService->getMatrixMakeProducts($adminGuid, $dateFrom, $dateTo, $isAdministrator);
}
$makeMatrixProductGuids = ArrayHelper::getColumn($makeMatrix, 'product_guid');
$makeMatrixProducts = Products1c::getProducts1cByType('products', $makeMatrixProductGuids);
- $makeMatrixProductNames = ArrayHelper::map($makeMatrixProducts, 'id','name');
+ $makeMatrixProductNames = ArrayHelper::map($makeMatrixProducts, 'id', 'name');
$salaryMakeMatrix = 0;
$bonusMakeMatrix = 0;
$matrixBonusCoefficientRow = $this->bonusService->getMatrixBonusCoefficient($row['date']);
$rowBonus = $row["summ"] * $matrixBonusCoefficientRow;
$makeMatrix[$kayMakeMatrix]["bonus"] = $rowBonus;
- if($row["operation"] == Sales::OPERATION_SALE) {
+ if ($row["operation"] == Sales::OPERATION_SALE) {
$salaryMakeMatrix += $row["summ"];
$bonusMakeMatrix += $rowBonus;
- } elseif($row["operation"] == Sales::OPERATION_RETURN) {
+ } elseif ($row["operation"] == Sales::OPERATION_RETURN) {
$salaryMakeMatrix -= $row["summ"];
$bonusMakeMatrix -= $rowBonus;
}
if ($isAdministrator) {
$arrayColumnWages = array(
- 'Оклад за смены' => $sumColumnWages,
+ 'Оклад за смены' => $sumColumnWages,
);
$sumValuesAdminAnotherStore = [];
foreach ($wagesAdminAnotherStore as $storeKey => $item) {
$storeNameRow = $storeKey;
- if (array_key_exists($storeKey ,$cityStoreNames)) {
+ if (array_key_exists($storeKey, $cityStoreNames)) {
$storeNameRow = $cityStoreNames[$storeKey];
}
if (!empty($personBonuses)) {
$personBonusesArrayInfo = [
- 'Персональная премия' => (int) $personBonuses,
+ 'Персональная премия' => (int)$personBonuses,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
if (!empty($personVacationPay)) {
$personBonusesArrayInfo = [
- 'Оплата за отпуск ' . $personVacationDay. ' дня' => $personVacationPay,
+ 'Оплата за отпуск ' . $personVacationDay . ' дня' => $personVacationPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
// Премия администратору за переменные показатели
//заплатка на бонус за процент списания 2022 12
- if ($yearSelect == 2022 && $monthSelect == 12 ) {
+ if ($yearSelect == 2022 && $monthSelect == 12) {
$configBonusPercentLoss202212 = [
29 => 0, // ул. Страж Революции, 1А
30 => 0, // ул. Пискунова 26/12
}
$possibleSumValuesAdministrator = array(
- 'Возможная премия за процент списания (' . $bonusByPercentLoss .' * ' . $coefficientPremium . ')' => $bonusByPercentLoss * $coefficientPremium,
- 'Возможная премия администратору за выполнение плана салона (' . $bonusByPlanPercent .' * ' . $coefficientPremium . ')' => $bonusByPlanPercent * $coefficientPremium,
- 'Возможная премия администратору за конверсию (' . $bonusByConvertionPercent .' * ' . $coefficientPremium . ')' => $bonusByConvertionPercent * $coefficientPremium,
- 'Возможная премия администратору за рост покупок постоянными клиентами (' . $sumPrimeForLvtClients .' * ' . $coefficientPremium . ')' => $sumPrimeForLvtClients * $coefficientPremium,
+ 'Возможная премия за процент списания (' . $bonusByPercentLoss . ' * ' . $coefficientPremium . ')' => $bonusByPercentLoss * $coefficientPremium,
+ 'Возможная премия администратору за выполнение плана салона (' . $bonusByPlanPercent . ' * ' . $coefficientPremium . ')' => $bonusByPlanPercent * $coefficientPremium,
+ 'Возможная премия администратору за конверсию (' . $bonusByConvertionPercent . ' * ' . $coefficientPremium . ')' => $bonusByConvertionPercent * $coefficientPremium,
+ 'Возможная премия администратору за рост покупок постоянными клиентами (' . $sumPrimeForLvtClients . ' * ' . $coefficientPremium . ')' => $sumPrimeForLvtClients * $coefficientPremium,
);
$allPossibleSumValuesAdministrator = array_sum($possibleSumValuesAdministrator);
if (!empty($personVacationPay)) {
$personBonusesArrayInfo = [
- 'Оплата за отпуск ' . $personVacationDay. ' дня' => $personVacationPay,
+ 'Оплата за отпуск ' . $personVacationDay . ' дня' => $personVacationPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
foreach ($wagesBonusNormaSmenaAnotherStore as $storeKey => $item) {
$storeNameRow = $storeKey;
- if (array_key_exists($storeKey ,$cityStoreNames)) {
+ if (array_key_exists($storeKey, $cityStoreNames)) {
$storeNameRow = $cityStoreNames[$storeKey];
}
$showRaznicaDoPlanaPerson = false;
- if (1 === (int) date('d', strtotime($dateFrom))) {
+ if (1 === (int)date('d', strtotime($dateFrom))) {
$showRaznicaDoPlanaPerson = true;
}
];
$minusSum = array_merge($alreadyPay, $personRetentionArray);
- $minusSumValue = array_sum($minusSum);
+ $minusSumValue = array_sum($minusSum);
$toPayoff = $allTotalPayroll - $minusSumValue;
return [
'dateFrom' => $dateFrom,
'administratorOklad' => $administratorOklad,
- 'planMonthFlorist' => $planMonthFlorist ?? 0 ,
+ 'planMonthFlorist' => $planMonthFlorist ?? 0,
'salesMatrix' => $salesMatrix ?? [],
'salaryMatrix' => $salaryMatrix ?? 0,
}
}
- if (!array_key_exists($employeeId, $exportAdmin)){
+ if (!array_key_exists($employeeId, $exportAdmin)) {
$errorText = 'У сотрудника "' . $employeeSelect['name_full'] . '" в ERP нет данных GUID из 1с employee_id : ' . $employeeId . '<br>';
$errorText .= 'Связь с 1с нужна для того, что бы посчитать продажи смены.<br> Обратитесь в HR отдел';
$outputCheckError = $this->outputCheckError($errorText, '', $controller);
$employeeSelectStore = CityStore::getCityStoreById($employeeSelectStoreId);
- if (!array_key_exists($employeeSelectStoreId, $exportCityStore)){
+ if (!array_key_exists($employeeSelectStoreId, $exportCityStore)) {
$errorText = 'По сотруднику "' . $employeeSelect['name_full'] . '" не найдена связь с магазином в 1с : id ' . $employeeSelectStoreId . '<br>';
$errorText .= 'Связь с магазином 1с нужна для того, что бы получить его планы';
}
+
$monthlySalary = EmployeePayment::getMonthlySalary($employeeId, $dateFrom);
+ // todo use method
if (empty($monthlySalary)) {
$errorText = 'У сотрудника "' . $employeeSelect['name_full'] . '" id ' . $employeeId . ' не указан оклад - обратитесь в HR отдел';
$errorText .= '<br><a href="/crud/employee-payment/index?EmployeePaymentSearch[admin_id]=' . $employeeId . '">Оклад и стоимость рабочего дня</a>';
}
}
+ [$salary, $error] = $this->getChangingSalary($dateFrom, $dateTo, $employeeId);
+ if ($salary) {
+ $monthlySalary['monthly_salary'] = $salary;
+ }
+ if ($error) {
+ $outputCheckError = $this->outputCheckError($error, '', $controller);
+ if (array_key_exists('errorText', $outputCheckError)) {
+ return [
+ 'errorText' => $outputCheckError['errorText'],
+ ];
+ }
+ }
+
+
$showPlanLeft = true;
if ($dateTo > $dateToEndMonth) {
$showPlanLeft = false;
$salesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
$salesSummCurrentMonth = $this->getSalesSaleSum($dateFromBeginMonth, $dateToEndMonth, $entityCityStoreEmployeeSelect);
- $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect,true);
+ $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect, true);
$amountWriteOff = WriteOffs::getWriteOffByStore($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
$planPercent = 0;
$planStoreMonthCalculatePercent = 0;
if (!empty($salesByStore) && !empty($planMonthByStore)) {
- $planPercent=round(100 * $salesByStore/$planMonthByStore,1);
+ $planPercent = round(100 * $salesByStore / $planMonthByStore, 1);
}
//sales_avg_check
$salesListAvgCheck = $this->getSumListAvgCheck($employeeSelectStoreId, $dateFrom, $dateTo);
-
$timetableForMonth = $this->getTimetableData($employeeId, $employeeSelectStoreId, $dateFromBeginMonth, $dateTo);
$allowedDate = ($dateFrom >= '2022-12-01');
$errorText .= 'за выбранный интервал с ' . $dateFrom . ' по ' . $dateTo . ' <br>';
$errorText .= 'в графике смен не найдено cs1';
- $dateFromInfo=date("Y-m-d",time()-7*86400+7200);
- $dateToInfo=date("Y-m-d",time());
+ $dateFromInfo = date("Y-m-d", time() - 7 * 86400 + 7200);
+ $dateToInfo = date("Y-m-d", time());
$buttonParams = [
- 'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromInfo. "&DaysSearchForm[dateTo]=" . $dateToInfo,
+ 'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromInfo . "&DaysSearchForm[dateTo]=" . $dateToInfo,
'name' => 'за неделю',
];
$rateInfo = $this->rateStoreCategoryService->getRateInfo($employeeSelectStoreId, $employeeGroupId, $dateFrom, $dateTo);
if (!empty($rateInfo)) {
- $planByDayFromRateInfo = min(ArrayHelper::getColumn($rateInfo,'condition'));
+ $planByDayFromRateInfo = min(ArrayHelper::getColumn($rateInfo, 'condition'));
} else {
$planByDayFromRateInfo = 1;
}
$leftWorkDayForMonth = $normalCountShiftValue - $worksDayByTableFromBeginMonth;
}
- if ($leftWorkDayForMonth > 0 ) {
- $planAdminByDay = round(($planMonthFlorist - $salaryByAdminFromBeginMonth ) / $leftWorkDayForMonth, 1);
+ if ($leftWorkDayForMonth > 0) {
+ $planAdminByDay = round(($planMonthFlorist - $salaryByAdminFromBeginMonth) / $leftWorkDayForMonth, 1);
}
if (!empty($worksDayByTableFromBeginMonth)) {
$salaryFloristByDay = round($salaryByAdminFromBeginMonth / $worksDayByTableFromBeginMonth, 1);
$salaryFloristByDay = $salaryByAdminFromBeginMonth;
}
$planMonthCalculate = round($salaryFloristByDay * $normalCountShiftValue, 1);
- $planMonthCalculatePercent = round(100 * $planMonthCalculate /$planMonthFlorist,1);
+ $planMonthCalculatePercent = round(100 * $planMonthCalculate / $planMonthFlorist, 1);
} else {
$leftWorkDayForMonth = 23;
$normalCountShiftValue = 21;
$leftWorkDayForMonth = $normalCountShiftValue - $worksDayByTableFromBeginMonth;
}
- if ($leftWorkDayForMonth > 0 ) {
- $planAdminByDay = round(($planMonthAdministrator - $salaryByAdminFromBeginMonth ) / $leftWorkDayForMonth, 1);
+ if ($leftWorkDayForMonth > 0) {
+ $planAdminByDay = round(($planMonthAdministrator - $salaryByAdminFromBeginMonth) / $leftWorkDayForMonth, 1);
}
if (!empty($worksDayByTableFromBeginMonth)) {
$salaryAdministratorByDay = round($salaryByAdminFromBeginMonth / $worksDayByTableFromBeginMonth, 1);
$salaryAdministratorByDay = $salaryByAdmin;
}
$planMonthCalculate = round($salaryAdministratorByDay * $normalCountShiftValue, 1);
- $planMonthCalculatePercent = round(100 * $planMonthCalculate /$planMonthAdministrator,1);
+ $planMonthCalculatePercent = round(100 * $planMonthCalculate / $planMonthAdministrator, 1);
$administratorOklad = $this->getAdministratorSalaryShift($employeeId, $dateFrom, $planMonthCalculate);
}
&& $monthSelect == date("n")
) {
$showBlockForecast = true;
- $dayPastCurrentMonth = (int) date("d");
+ $dayPastCurrentMonth = (int)date("d");
$daysRemainsInSelectMonth = $daysInSelectMonth - $dayPastCurrentMonth;
if (!empty($planMonthByStore)) {
if (isset($salesByStore) && !empty($planMonthByStore)) {
$saleByDayCalculate = round($salesByStore / $dayPastCurrentMonth, 1);
$saleByMonthCalculate = $saleByDayCalculate * $daysInSelectMonth;
- $planStoreMonthCalculatePercent = round(100 * $saleByMonthCalculate/$planMonthByStore,1);
+ $planStoreMonthCalculatePercent = round(100 * $saleByMonthCalculate / $planMonthByStore, 1);
- if ($daysRemainsInSelectMonth > 0 ) {
- $needSaleByDayCalculate = round(($planMonthByStore - $salesByStore ) / $daysRemainsInSelectMonth, 1);
+ if ($daysRemainsInSelectMonth > 0) {
+ $needSaleByDayCalculate = round(($planMonthByStore - $salesByStore) / $daysRemainsInSelectMonth, 1);
}
}
$showBlockForecast = true;
if (isset($salesByStore) && !empty($planMonthByStore)) {
- $planStoreMonthCalculatePercent = round(100 * $salesByStore/$planMonthByStore,1);
+ $planStoreMonthCalculatePercent = round(100 * $salesByStore / $planMonthByStore, 1);
}
}
$deltaYearToYearByMonthSalesSummPercent = ArrayHelper::getValue($deltaYearToYearByMonthSalesSummValues, 'deltaPercent');
$salesSummPastYearMonth = ArrayHelper::getValue($deltaYearToYearByMonthSalesSummValues, 'salesSummPastYearMonth');
- $dateCurrent = date("Y-m-d",time());
+ $dateCurrent = date("Y-m-d", time());
- $yearCurrent = date("Y",strtotime($dateCurrent));
- $monthCurrent = date("n",strtotime($dateCurrent));
+ $yearCurrent = date("Y", strtotime($dateCurrent));
+ $monthCurrent = date("n", strtotime($dateCurrent));
// Возможное депремирование администратору
if (!empty($personColorRubleBonuses)) {
$personColorRubleBonusesValues = [
- ' премия в цвето-рублях' => (int) $personColorRubleBonuses,
+ ' премия в цвето-рублях' => (int)$personColorRubleBonuses,
];
}
// Командный бонус
- $teamBonus = $this->bonusService->getTeamBonus( $employeeId, $employeeSelectStoreId, $entityCityStoreEmployeeSelect, $dateFrom, $dateToEndMonth);
- $teamBonusDetail = json_encode($teamBonus,JSON_UNESCAPED_UNICODE);
+ $teamBonus = $this->bonusService->getTeamBonus($employeeId, $employeeSelectStoreId, $entityCityStoreEmployeeSelect, $dateFrom, $dateToEndMonth);
+ $teamBonusDetail = json_encode($teamBonus, JSON_UNESCAPED_UNICODE);
$teamBonusValuePrepared = ArrayHelper::getValue($teamBonus, 'personPrimeFondStore');
$teamBonusValue = ($teamBonusValuePrepared > 0) ? $teamBonusValuePrepared : 0;
$userQualityPremium = $this->bonusService->getBonusForQuality($userQualityPercent);
- $arrayTypes = ["wrap", "potted", "related","services","salut","other_items"];
+ $arrayTypes = ["wrap", "potted", "related", "services", "salut", "other_items"];
- $arrayProducts= Products1c::getProductsFromClass($arrayTypes);
+ $arrayProducts = Products1c::getProductsFromClass($arrayTypes);
$this->arr = [$adminGuid];
$adminGuidArr = $this->arr;
/**/
- $showHolidayVersion = HolidayService::getHolidayVersionShow($dateFrom, $dateTo);
+ $showHolidayVersion = HolidayService::getHolidayVersionShow($dateFrom, $dateTo);
// $showHolidayVersion = false;
/**/
$arrUsersSalary = ArrayHelper::getValue($arrResSalariesByFocusGroup, 'arrUsersSalary');
$arrUsersSalaryCheck = ArrayHelper::getValue($arrResSalariesByFocusGroup, 'arrUsersSalaryCheck');
- $premiumByFocusGroups = $this->getPremiumByFocusGroups($adminGuid, $arrUsersSalary, $dateFrom, $dateTo, $isAdministrator);
+ $premiumByFocusGroups = $this->getPremiumByFocusGroups($adminGuid, $arrUsersSalary, $dateFrom, $dateTo, $isAdministrator);
$userSalaryServices = ArrayHelper::getValue($premiumByFocusGroups, 'userSalaryServices');
$userSalaryServicesPremium = ArrayHelper::getValue($premiumByFocusGroups, 'userSalaryServicesPremium');
$isAdministrator,
$employeeSelectStoreId,
$showHolidayVersion,
-false
+ false
);
$consolidatedArrUsersSalary = ArrayHelper::getValue($consolidatedArrResSalariesByFocusGroup, 'arrUsersSalary');
$consolidatedAdminGuidDateArrByFocusGroup = ArrayHelper::getValue($consolidatedArrResSalariesByFocusGroup, 'adminGuidDateArrByFocusGroup');
- $consolidatedPremiumByFocusGroups = $this->getPremiumByFocusGroups($adminGuid, $consolidatedArrUsersSalary, $dateFrom, $dateTo, $isAdministrator);
+ $consolidatedPremiumByFocusGroups = $this->getPremiumByFocusGroups($adminGuid, $consolidatedArrUsersSalary, $dateFrom, $dateTo, $isAdministrator);
$consolidatedUserSalaryServices = ArrayHelper::getValue($consolidatedPremiumByFocusGroups, 'userSalaryServices');
$consolidatedUserSalaryServicesPremium = ArrayHelper::getValue($consolidatedPremiumByFocusGroups, 'userSalaryServicesPremium');
$consolidatedUserSalaryPremiumSum = ArrayHelper::getValue($consolidatedPremiumByFocusGroups, 'userSalaryPremiumSum');
-
$adminGuidNames = Admin::getAdminGuidNames();
$consolidatedArrUsersSalaryCheckTmp = $consolidatedArrUsersSalaryCheck;
foreach ($consolidatedAdminGuidDateArrByFocusGroup as $subKey => $users) {
$shiftCount[] = count($users);
foreach ($users as $user) {
- if (array_key_exists($user, $countByUser)){
+ if (array_key_exists($user, $countByUser)) {
++$countByUser[$user];
} else {
$countByUser[$user] = 1;
}
}
- $adminsHolidayShiftCount = array_sum($shiftCount) ;
- $personHolidayShiftCount = $countByUser[$adminGuid] ?? 0;
+ $adminsHolidayShiftCount = array_sum($shiftCount);
+ $personHolidayShiftCount = $countByUser[$adminGuid] ?? 0;
if (!empty($adminsHolidayShiftCount)) {
$onePartHolidayPremium = $consolidatedPremiumByStore / $adminsHolidayShiftCount;
}
foreach ($wagesAdminAnotherStore as $storeKey => $item) {
$storeNameRow = $storeKey;
- if (array_key_exists($storeKey ,$cityStoreNames)) {
+ if (array_key_exists($storeKey, $cityStoreNames)) {
$storeNameRow = $cityStoreNames[$storeKey];
}
if (!empty($personBonuses)) {
$personBonusesArrayInfo = [
- 'Персональная премия' => (int) $personBonuses,
+ 'Персональная премия' => (int)$personBonuses,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
if (!empty($personPartTimeJobHoursPay)) {
$personBonusesArrayInfo = [
- 'Оплата подработок по часам' . ' ('. $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => (int) $personPartTimeJobHoursPay,
+ 'Оплата подработок по часам' . ' (' . $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => (int)$personPartTimeJobHoursPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
if (!empty($personVacationPay)) {
$personBonusesArrayInfo = [
- 'Оплата за отпуск ' . $personVacationDay. ' дня' => $personVacationPay,
+ 'Оплата за отпуск ' . $personVacationDay . ' дня' => $personVacationPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
// Премия администратору за переменные показатели
//заплатка на бонус за процент списания 2022 12
- if ($yearSelect == 2022 && $monthSelect == 12 ) {
+ if ($yearSelect == 2022 && $monthSelect == 12) {
$configBonusPercentLoss202212 = [
29 => 0, // ул. Страж Революции, 1А
30 => 0, // ул. Пискунова 26/12
}
}
- $possibleSumValuesAdministrator = array(
- );
+ $possibleSumValuesAdministrator = array();
$allPossibleSumValuesAdministrator = array_sum($possibleSumValuesAdministrator);
}
-
$allVariableSumValuesAdministrator = array_sum($variableSumValuesAdministrator);
// Постоянные премии администратору
}
-
$bonusVariable = [
'Премия за продажи услуг' => $userSalaryServicesPremium, //
'Премия за продажи сопутки' => $userSalaryRelatedPremium, //
if (!empty($personPartTimeJobHoursPay)) {
$personBonusesArrayInfo = [
- 'Оплата подработок по часам' . ' ('. $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)'=> $personPartTimeJobHoursPay,
+ 'Оплата подработок по часам' . ' (' . $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => $personPartTimeJobHoursPay,
];
$bonusVariableByMonth = array_merge($personBonusesArrayInfo, $bonusVariableByMonth);
}
if (!empty($personPartTimeJobHoursPay)) {
$personBonusesArrayInfo = [
- 'Оплата подработок по часам' . ' ('. $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => (int) $personPartTimeJobHoursPay,
+ 'Оплата подработок по часам' . ' (' . $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => (int)$personPartTimeJobHoursPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
if (!empty($personVacationPay)) {
$personBonusesArrayInfo = [
- 'Оплата за отпуск ' . $personVacationDay. ' дня' => $personVacationPay,
+ 'Оплата за отпуск ' . $personVacationDay . ' дня' => $personVacationPay,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
foreach ($wagesBonusNormaSmenaAnotherStore as $storeKey => $item) {
$storeNameRow = $storeKey;
- if (array_key_exists($storeKey ,$cityStoreNames)) {
+ if (array_key_exists($storeKey, $cityStoreNames)) {
$storeNameRow = $cityStoreNames[$storeKey];
}
];
-
-
$bonusVariable = [
'Премия за продажи услуг' => $userSalaryServicesPremium, //
'Премия за продажи сопутки' => $userSalaryRelatedPremium, //
if (!empty($personPartTimeJobHoursPay)) {
$personBonusesArrayInfo = [
- 'Оплата подработок по часам' . ' ('. $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => $personPartTimeJobHoursPay,
+ 'Оплата подработок по часам' . ' (' . $personPartTimeJobHours . '*' . $hourPayment . ' руб/час из оклада)' => $personPartTimeJobHoursPay,
];
$bonusVariableByMonth = array_merge($personBonusesArrayInfo, $bonusVariableByMonth);
}
$showRaznicaDoPlanaPerson = false;
- if (1 === (int) date('d', strtotime($dateFrom))) {
+ if (1 === (int)date('d', strtotime($dateFrom))) {
$showRaznicaDoPlanaPerson = true;
}
$alreadyPaySum = array_sum($alreadyPay);
$minusSum = array_merge($alreadyPay, $personRetentionArray);
- $minusSumValue = array_sum($minusSum);
+ $minusSumValue = array_sum($minusSum);
$toPayoff = $allTotalPayroll - $minusSumValue;
- $allowShowPersonRetention = date('Y-m-d',time()) >= date('Y-m-t',strtotime($dateFrom));
+ $allowShowPersonRetention = date('Y-m-d', time()) >= date('Y-m-t', strtotime($dateFrom));
return [
'allowShowPersonRetention' => $allowShowPersonRetention,
'administratorOklad' => $administratorOklad,
- 'planMonthFlorist' => $planMonthFlorist ?? 0 ,
+ 'planMonthFlorist' => $planMonthFlorist ?? 0,
'salesMatrix' => $salesMatrix ?? [],
'salaryMatrix' => $salaryMatrix ?? 0,
->andWhere(['<=', 'date', $dateTo])
->andWhere(['admin_id' => $adminId])
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
if (!empty($storeId)) {
if (!$notInStore) {
/** @var Timetable[] $timetable */
$query = Timetable::find()
-
->select([
'admin_id',
'cnt' => new \yii\db\Expression(" COUNT(*) "),
- ])
+ ])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
-
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
if (!empty($adminId)) {
$query->andWhere(['admin_id' => $adminId]);
return $query->asArray()->all();
}
+
public function getTimetableDataList($dateFrom, $dateTo, $adminId = null): array
{
/** @var Timetable[] $timetable */
$query = Timetable::find()
-
->select([
'admin_id'
- ])
+ ])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
-
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
if (!empty($adminId)) {
$query->andWhere(['admin_id' => $adminId]);
return $query->asArray()->all();
}
+
+ /**
+ * Проверяет, что у сотрудника была смена должности в рамках периода
+ * Если смена была, то считает зп по дням, по каждой должности что были
+ *
+ * @param $dateFrom string
+ * @param $dateTo string
+ * @param $adminId int|string
+ * @return array
+ */
+ private function getChangingSalary($dateFrom, $dateTo, $adminId)
+ {
+ $summary_salary = 0;
+ $error = '';
+ $positions_history = [];
+
+ // https://erp.erp-flowers.ru/crud/employee-payment/
+ // если дата > месяца, то убирать кнопку редактирования
+
+ // Проверяем наличие перехода в admin_dynamic
+ $positions = AdminDynamic::find()->where(['admin_id' => $adminId])->where(['category_id' => 1])
+ ->where(['or', ['between', 'date_to', $dateFrom, $dateTo],['between', 'date_from', $dateFrom, $dateTo]])->asArray()->all();
+ echo $adminId . '<br><pre>' . print_r($positions, true) . '</pre>';
+echo $dateFrom;
+echo $dateTo;
+ if (count($positions)) {
+ // разбиваем период по дням, способ не самый быстрый, но лучший для подсчета
+ $date_list = $this->period_explode($dateFrom, $dateTo);
+ foreach ($date_list as $date) {
+ // проверяем, что в этот день у сотрудника была смена
+ $shift = Timetable::find()->where(['admin_id' => $adminId])->where(['date' => $date])->asArray()->one();
+ if ($shift) {
+ // если была, то смотрим его ставку за день
+ // берем ближайшую запись
+ $daily_payment = EmployeePayment::find()
+ ->where(['admin_id' => $adminId])->where(['<=', 'date', $date])
+ ->orderBy(['date' => SORT_DESC])->asArray()->one();
+ if ($daily_payment) {
+ foreach ($positions as $position) {
+ if ($position['date_from'] <= $date && $position['date_to'] >= $date) {
+ $group = AdminGroup::find()->where(['id' =>$position['value_id']]);
+ $positions_history[] = [
+ 'date' => $date,
+
+ ];
+ }
+ }
+ // плюсуем к общей зп
+ $summary_salary += $daily_payment['daily_payment'];
+ } else {
+ $error = 'По одной из должностей сотрудника не был найден оклад';
+ }
+ }
+ }
+ }
+
+ return [$summary_salary, $error];
+ }
+
+ /**
+ * Разбивает период дат по дням
+ *
+ * @param $dateFrom string
+ * @param $dateTo string
+ * @return array
+ */
+ private function period_explode($dateFrom, $dateTo)
+ {
+ $dates_array = [];
+ $dates_array[] = $dateFrom;
+ $dateFrom = DateTime::createFromFormat('Y-m-d', $dateFrom);
+ $dateTo = DateTime::createFromFormat('Y-m-d', $dateTo);
+
+ while ($dateFrom->getTimestamp() <= $dateTo->getTimestamp()) {
+ $dateFrom->modify('+1 day');
+ $dates_array[] = $dateFrom->format('Y-m-d');
+ }
+
+ return $dates_array;
+ }
+
public function getTimetableAdminDataList($dateFrom, $dateTo, $adminId = null): array
{
/** @var Timetable[] $timetable */
$query = Timetable::find()
-
->select([
'admin_id',
'date'
- ])
+ ])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
-
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
if (!empty($adminId)) {
$query->andWhere(['admin_id' => $adminId]);
}
- $query->groupBy(['admin_id','date']);
+ $query->groupBy(['admin_id', 'date']);
return $query->asArray()->all();
}
public function getTimetableLastShift($adminGroupId = Admin::PART_TIME_WORKER_GROUP_ID)
{
- /*
- *
- SELECT admin_id,MAX(date) FROM timetable WHERE admin_group_id = 45
+ /*
+ *
+ SELECT admin_id,MAX(date) FROM timetable WHERE admin_group_id = 45
-Group BY admin_id
- * */
+ Group BY admin_id
+ * */
/** @var Timetable[] $timetable */
$query = Timetable::find()
]])
->andWhere(['tabel' => 0])
->groupBy(['admin_id'])
- ->indexBy(['admin_id'])
- ;
+ ->indexBy(['admin_id']);
$action = $query->createCommand()->getRawSql();
return $query->asArray()->all();
->andWhere(['<=', 'date', $dateTo])
->andWhere(['admin_id' => $adminId])
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
-
+ ->andWhere(['tabel' => 0]);
if (!empty($storeId)) {
->andWhere(['<>', 'admin_id', $adminId])
->andWhere(['slot_type_id' => $slotTypeId])
->andWhere(['shift_id' => Shift::DAY])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
// $isNight = Shift::isNight($row['shift_id']);
->andWhere(['<>', 'admin_id', $adminId])
->andWhere(['slot_type_id' => $slotTypeId])
->andWhere(['shift_id' => Shift::NIGHT])
- ->andWhere(['tabel' => 0])
- ;
+ ->andWhere(['tabel' => 0]);
// $isNight = Shift::isNight($row['shift_id']);
->andWhere(['<=', 'date', $dateTo])
->andWhere(['id' => $adminTableIds])
->andWhere(['slot_type_id' => $slotTypeId])
- ->andWhere(['tabel' => 0])
- ;
-
+ ->andWhere(['tabel' => 0]);
if (!empty($storeId)) {
$adminTableOtherAdmin = $query->asArray()->all();
$resultArray = array_merge($adminTable, $adminTableOtherAdmin);
- $resultIds = ArrayHelper::getColumn($resultArray, 'id');
+ $resultIds = ArrayHelper::getColumn($resultArray, 'id');
$result = array_combine($resultIds, $resultArray);
if (!empty($result)) {
$timetable = [];
$dict = [
- 1 => [ 1, 5, 7, 8],
- 2 => [ 2],
- 5 => [ 1, 5, 7, 8],
- 7 => [ 1, 5, 7, 8],
- 8 => [ 1, 5, 7, 8],
+ 1 => [1, 5, 7, 8],
+ 2 => [2],
+ 5 => [1, 5, 7, 8],
+ 7 => [1, 5, 7, 8],
+ 8 => [1, 5, 7, 8],
];
$slotTypeId = [
$timetable = Timetable::find()
->joinWith('admin')
->andWhere(['date' => $date])
- ->andWhere(['<>','admin.group_id', -1])
+ ->andWhere(['<>', 'admin.group_id', -1])
->andWhere(['shift_id' => $shiftIdForDict])
->andWhere(['timetable.store_id' => $storeId])
->andWhere(['slot_type_id' => $slotTypeId])
->andWhere(['tabel' => 0])
->asArray()
- ->all()
- ;
+ ->all();
}
return $timetable;
->andWhere(['tabel' => 0])
->orderBy(new Expression('random()'))
->asArray()
- ->one()
- ;
+ ->one();
return $timetable;
}
* @return array
* @throws \Exception
*/
- public function getTimetableRate($timetable ,$employeeId , $adminGuid, array $storeAdminsGuids, $dateFrom, $dateTo, $normalCostShift, bool $isAdministrator, $entityCityStoreEmployeeSelect = null): array
+ public function getTimetableRate($timetable, $employeeId, $adminGuid, array $storeAdminsGuids, $dateFrom, $dateTo, $normalCostShift, bool $isAdministrator, $entityCityStoreEmployeeSelect = null): array
{
$rateDict = RateDict::find()
->indexBy('id')
$salesForAdmin = $this->getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator);
$salesForStore = [];
- if ($isAdministrator && $dateFrom >= '2023-09-01' ) {
+ if ($isAdministrator && $dateFrom >= '2023-09-01') {
$salesForStore = $this->getSaluryStoreSum($entityCityStoreEmployeeSelect, $dateFrom, $dateTo, $isAdministrator);
}
$avgCheckByDay = [];
foreach ($sales as $rowDate => $sale) {
- if (!array_key_exists($rowDate, $avgCheckByDay)) {
- $avgCheckByDay[$rowDate] = 0;
- }
- if($sale > 0 && $countByDate[$rowDate] > 0) {
+ if (!array_key_exists($rowDate, $avgCheckByDay)) {
+ $avgCheckByDay[$rowDate] = 0;
+ }
+ if ($sale > 0 && $countByDate[$rowDate] > 0) {
$avgCheckByDay[$rowDate] = round($sale / $countByDate[$rowDate], 2);
}
}
$adminIds = array_keys($storeAdminsGuids);
$admins = Admin::find()
- ->select(['id','store_id','group_id','name_full'])
+ ->select(['id', 'store_id', 'group_id', 'name_full'])
->indexBy('id')
->andWhere(['id' => $adminIds])
->asArray()
if (!empty($allStoreCategory[$storeKey])) {
$storeCategoryId = $allStoreCategory[$storeKey]['category_id'];
} else {
- $errorText = 'Нет данных о категории магазина (rate_store_category) : ' . $storeKey ;
+ $errorText = 'Нет данных о категории магазина (rate_store_category) : ' . $storeKey;
$errorText .= ' Попробуйте сократить интервал поиска до одного месяца, возможно был переход на новую нормо смену. ';
$controller = Yii::$app->controller;
$outputCheckError = $this->outputCheckError($errorText, '', $controller);
$adminGroupIdRow = AdminGroupDynamic::getGroupByDate($adminId, $dateFrom, $dateTo);
- if ( -1 === (int) $adminGroupIdRow ) {
+ if (-1 === (int)$adminGroupIdRow) {
$adminGroupIdRow = Users::DAY_FLORIST_ID;
}
if (!empty($allStoreCategory[$row['store_id']])) {
$storeCategoryId = $allStoreCategory[$row['store_id']]['category_id'];
} else {
- $errorText = 'Нет данных о категории магазина (rate_store_category) : ' . $row['store_id'] ;
+ $errorText = 'Нет данных о категории магазина (rate_store_category) : ' . $row['store_id'];
$controller = Yii::$app->controller;
$outputCheckError = $this->outputCheckError($errorText, '', $controller);
if (array_key_exists('errorText', $outputCheckError)) {
$adminsSalesSum = 0;
- if ($isAdministrator && $row['date'] >= '2023-09-01' ) {
+ if ($isAdministrator && $row['date'] >= '2023-09-01') {
if (!empty($salesForStore) && array_key_exists($row['date'], $salesForStore)) {
$adminsSalesSum = $salesForStore[$row['date']];
}
$timetable[$keyTimetable]['percentMatrixSalaryShiftStore'] = $percentMatrixSalaryShiftStore;
$adminNameWithRateColumn = ArrayHelper::getColumn($rateTimetableAdminsNames, 'name_with_rate');
- $adminNameWithRateList = implode(',<br>' , $adminNameWithRateColumn);
+ $adminNameWithRateList = implode(',<br>', $adminNameWithRateColumn);
$timetable[$keyTimetable]['typeSmena'] = $typeSmena;
$timetable[$keyTimetable]['typeSmenaInt'] = $typeSmenaInt;
$timetable[$keyTimetable]['firstNormaSmenaAdminSum'] = $firstNormaSmenaAdminSum;
$timetable[$keyTimetable]['normaSmenaAdminsSumByLevel'] = $normaSmenaAdminsSumByLevel;
- $normaSmenaAdminsSumByLevelList = implode(',<br>' , $normaSmenaAdminsSumByLevel);
+ $normaSmenaAdminsSumByLevelList = implode(',<br>', $normaSmenaAdminsSumByLevel);
$timetable[$keyTimetable]['normaSmenaAdminsSumByLevelList'] = $normaSmenaAdminsSumByLevelList;
$reteId = $this->bonusService->getWagesBonusNormaSmena($normaSmenaAdminsSumByLevel, $adminsSalesSum, false);
// Расчет оклада в зависимоти от выполненной общей норма смены магазина
$wagesAddBonusNormaSmena = 0;
- switch ($rateNormaSmena['value_type_add'])
- {
+ switch ($rateNormaSmena['value_type_add']) {
case 'multiplier':
$rateNormaValue = $normalCostShift * $rateNormaSmena['value'];
$wagesAddBonusNormaSmena = $normalCostShift - $rateNormaValue;
* @return array
* @throws \Exception
*/
- public function getTimetableDate($timetable ,$employeeId , $adminGuid, array $storeAdminsGuids, $dateFrom, $dateTo, $normalCostShift, bool $isAdministrator, $entityCityStoreEmployeeSelect = null): array
+ public function getTimetableDate($timetable, $employeeId, $adminGuid, array $storeAdminsGuids, $dateFrom, $dateTo, $normalCostShift, bool $isAdministrator, $entityCityStoreEmployeeSelect = null): array
{
$salesForAdmin = $this->getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator);
$salesForStore = [];
- if ($isAdministrator && $dateFrom >= '2023-09-01' ) {
+ if ($isAdministrator && $dateFrom >= '2023-09-01') {
$salesForStore = $this->getSaluryStoreSum($entityCityStoreEmployeeSelect, $dateFrom, $dateTo, $isAdministrator);
}
if (!array_key_exists($rowDate, $avgCheckByDay)) {
$avgCheckByDay[$rowDate] = 0;
}
- if($sale > 0 && $countByDate[$rowDate] > 0) {
+ if ($sale > 0 && $countByDate[$rowDate] > 0) {
$avgCheckByDay[$rowDate] = round($sale / $countByDate[$rowDate], 2);
}
}
$adminIds = array_keys($storeAdminsGuids);
$admins = Admin::find()
- ->select(['id','store_id','group_id','name_full'])
+ ->select(['id', 'store_id', 'group_id', 'name_full'])
->indexBy('id')
->andWhere(['id' => $adminIds])
->asArray()
$adminGroupIdRow = AdminGroupDynamic::getGroupByDate($adminId, $dateFrom, $dateTo);
- if ( -1 === (int) $adminGroupIdRow ) {
+ if (-1 === (int)$adminGroupIdRow) {
$adminGroupIdRow = Users::DAY_FLORIST_ID;
}
-
$salesAdmins[$adminId] = [
'id' => $adminId,
'group_id' => $adminGroupIdRow,
}
-
-
$daySale = 0;
$timetable[$keyTimetable]['wagesInfo'] = '';
$wagesInfo = '';
$adminsSalesSum = 0;
- if ($isAdministrator && $row['date'] >= '2023-09-01' ) {
+ if ($isAdministrator && $row['date'] >= '2023-09-01') {
if (!empty($salesForStore) && array_key_exists($row['date'], $salesForStore)) {
$adminsSalesSum = $salesForStore[$row['date']];
}
}
$adminNameColumn = ArrayHelper::getColumn($rateTimetableAdminsNames, 'name');
- $adminNameList = implode(',<br>' , $adminNameColumn);
+ $adminNameList = implode(',<br>', $adminNameColumn);
$timetable[$keyTimetable]['typeSmena'] = $typeSmena . $wagesInfo;
$timetable[$keyTimetable]['adminNameList'] = $adminNameList;
$dateCheckRow = new DateTime($dateRow);
$startDate = new DateTime($dateFromRow);
- $endDate = new DateTime($dateToRow.' 23:59');
+ $endDate = new DateTime($dateToRow . ' 23:59');
$isDateBetweenDates = DateHelper::isDateBetweenDates($dateCheckRow, $startDate, $endDate);
if ($isDateBetweenDates) {
$salaryStoreServicesPercentList,
$winStoreIdDayChallenge,
$anotherStore = false
- ) : array
+ ): array
{
$timetableTemp = $timetable;
$salaryStoreServicesPercent = $salaryStoreServicesPercentList[$row['date']]['summ'];
}
- $arrayProducts= Products1c::getProductsFromClass(["wrap", "potted", "related","services"]);
+ $arrayProducts = Products1c::getProductsFromClass(["wrap", "potted", "related", "services"]);
$changeGroup = $this->changeGroup;
$allowAddBonus = self::allowAddBonus($isAdministrator, $anotherStore, $changeGroup);
$gameBonusAvgCheck = $this->bonusService->getGameBonusAvgCheck($avgCheck);
// Бонус геймификации дневной челленж
- $gameBonusDayChallengeArray = $this->bonusService->getGameBonusDayChallenge($row['store_id'], $winStoreIdDayChallenge , $row['date']);
+ $gameBonusDayChallengeArray = $this->bonusService->getGameBonusDayChallenge($row['store_id'], $winStoreIdDayChallenge, $row['date']);
$gameBonusDayChallenge = 0;
if ($allowAddBonus) {
$salaryServicesPercent = 0;
if (!empty($arrayProducts["services"]) && !empty($daySale)) {
- $arrUsersSalaryServicesPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["services"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
+ $arrUsersSalaryServicesPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["services"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
$arrUsersSalaryServices = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'bonus');
$arrUsersSalaryServicesCheck = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'check');
if (!empty($arrUsersSalaryServices)) {
- $salaryServicesPercent = round(100 * $arrUsersSalaryServices[$adminGuid]/$daySale,1);
+ $salaryServicesPercent = round(100 * $arrUsersSalaryServices[$adminGuid] / $daySale, 1);
}
}
$salaryWrapPercent = 0;
if (!empty($arrayProducts["wrap"]) && !empty($daySale)) {
- $arrUsersSalaryWrapPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["wrap"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
+ $arrUsersSalaryWrapPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["wrap"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
$arrUsersSalaryWrap = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'bonus');
$arrUsersSalaryWrapCheck = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'check');
if (!empty($arrUsersSalaryWrap)) {
- $salaryWrapPercent = round(100 * $arrUsersSalaryWrap[$adminGuid]/$daySale,1);
+ $salaryWrapPercent = round(100 * $arrUsersSalaryWrap[$adminGuid] / $daySale, 1);
}
}
$salaryPottedPercent = 0;
if (!empty($arrayProducts["potted"]) && !empty($daySale)) {
- $arrUsersSalaryPottedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["potted"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
+ $arrUsersSalaryPottedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["potted"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
$arrUsersSalaryPotted = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'bonus');
$arrUsersSalaryPottedCheck = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'check');
if (!empty($arrUsersSalaryPotted)) {
- $salaryPottedPercent = round(100 * $arrUsersSalaryPotted[$adminGuid]/$daySale,1);
+ $salaryPottedPercent = round(100 * $arrUsersSalaryPotted[$adminGuid] / $daySale, 1);
}
}
$salaryRelatedPercent = 0;
if (!empty($arrayProducts["related"]) && !empty($daySale)) {
- $arrUsersSalaryRelatedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["related"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
+ $arrUsersSalaryRelatedPrepared = SalaryHelper::getSalaryBonusMulty($arrayProducts["related"], $adminGuidArr, $row['date'], $row['date'], $exportAdmin, $isAdministrator);
$arrUsersSalaryRelated = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'bonus');
$arrUsersSalaryRelatedCheck = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'check');
if (!empty($arrUsersSalaryRelated)) {
- $salaryRelatedPercent = round(100 * $arrUsersSalaryRelated[$adminGuid]/$daySale,1);
+ $salaryRelatedPercent = round(100 * $arrUsersSalaryRelated[$adminGuid] / $daySale, 1);
}
}
],
];
- if ('2023-08-01' <= date("Y-m-d H:i:s", strtotime($row['date']))){
+ if ('2023-08-01' <= date("Y-m-d H:i:s", strtotime($row['date']))) {
$floristAddValues = [
'Бонус за выполнение персональной нормо смены' => [
'value' => $gameBonusNormaSmenaReteLavel,
],
];
- if ('2022-12-01' <= date("Y-m-d H:i:s", strtotime($row['date']))){
- if (date("Y-m-d H:i:s", strtotime($row['date'])) < '2022-12-10'){
+ if ('2022-12-01' <= date("Y-m-d H:i:s", strtotime($row['date']))) {
+ if (date("Y-m-d H:i:s", strtotime($row['date'])) < '2022-12-10') {
$gameBonusCashSalaryStore = 0;
$percentCheckWithCash = 0;
}
$administratorValues = array_merge($administratorValues, $administratorAddValues);
- if ('2023-06-01' <= date("Y-m-d H:i:s", strtotime($row['date']))){
+ if ('2023-06-01' <= date("Y-m-d H:i:s", strtotime($row['date']))) {
$floristValues = array_merge($floristValues, $administratorAddValues);
}
}
- if ('2023-06-01' <= date("Y-m-d H:i:s", strtotime($row['date']))){
+ if ('2023-06-01' <= date("Y-m-d H:i:s", strtotime($row['date']))) {
$floristBonusAddValues = [
'Бонус за % продаж матрицы' => [
'value' => $gameBonusMatrixSalaryShiftStore,
$salaryStoreServicesPercentList,
$winStoreIdDayChallenge,
$anotherStore = false
- ) : array
+ ): array
{
}
- public function __setGameValuesAnotherStore($timetable, $adminGuid, $exportAdmin, $isAdministrator, $conversionArray, $bonusCardPercentList, $salesAvgCheckList, $salaryStoreServicesPercentList, $winStoreIdDayChallenge) : array
+ public function __setGameValuesAnotherStore($timetable, $adminGuid, $exportAdmin, $isAdministrator, $conversionArray, $bonusCardPercentList, $salesAvgCheckList, $salaryStoreServicesPercentList, $winStoreIdDayChallenge): array
{
$timetableTemp = $timetable;
$salaryStoreServicesPercent = $salaryStoreServicesPercentList[$row['date']]['summ'];
}
- $arrayProducts= Products1c::getProductsFromClass(["wrap", "potted", "related","services"]);
+ $arrayProducts = Products1c::getProductsFromClass(["wrap", "potted", "related", "services"]);
// Персональный бонус геймификации за выполнение норма смены
$gameBonusNormaPerson = $this->bonusService->getGameBonusByRate($reteIdPerson, $daySale, $normaSmenaRate1Condition);
$gameBonusAvgCheck = $this->bonusService->getGameBonusAvgCheck($avgCheck);
// Бонус геймификации дневной челленж
- $gameBonusDayChallengeArray = $this->bonusService->getGameBonusDayChallenge($row['store_id'], $winStoreIdDayChallenge , $row['date']);
+ $gameBonusDayChallengeArray = $this->bonusService->getGameBonusDayChallenge($row['store_id'], $winStoreIdDayChallenge, $row['date']);
$gameBonusDayChallenge = ArrayHelper::getValue($gameBonusDayChallengeArray, 'bonus');
$gameBonusDayChallengeValue = ArrayHelper::getValue($gameBonusDayChallengeArray, 'value');
$arrUsersSalaryServices = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'bonus');
$arrUsersSalaryServicesCheck = ArrayHelper::getColumn($arrUsersSalaryServicesPrepared, 'check');
if (!empty($arrUsersSalaryServices)) {
- $salaryServicesPercent = round(100 * $arrUsersSalaryServices[$adminGuid]/$daySale,1);
+ $salaryServicesPercent = round(100 * $arrUsersSalaryServices[$adminGuid] / $daySale, 1);
}
}
$salaryWrapPercent = 0;
$arrUsersSalaryWrap = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'bonus');
$arrUsersSalaryWrapCheck = ArrayHelper::getColumn($arrUsersSalaryWrapPrepared, 'check');
if (!empty($arrUsersSalaryWrap)) {
- $salaryWrapPercent = round(100 * $arrUsersSalaryWrap[$adminGuid]/$daySale,1);
+ $salaryWrapPercent = round(100 * $arrUsersSalaryWrap[$adminGuid] / $daySale, 1);
}
}
$salaryPottedPercent = 0;
$arrUsersSalaryPotted = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'bonus');
$arrUsersSalaryPottedCheck = ArrayHelper::getColumn($arrUsersSalaryPottedPrepared, 'check');
if (!empty($arrUsersSalaryPotted)) {
- $salaryPottedPercent = round(100 * $arrUsersSalaryPotted[$adminGuid]/$daySale,1);
+ $salaryPottedPercent = round(100 * $arrUsersSalaryPotted[$adminGuid] / $daySale, 1);
}
}
$salaryRelatedPercent = 0;
$arrUsersSalaryRelated = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'bonus');
$arrUsersSalaryRelatedCheck = ArrayHelper::getColumn($arrUsersSalaryRelatedPrepared, 'check');
if (!empty($arrUsersSalaryRelated)) {
- $salaryRelatedPercent = round(100 * $arrUsersSalaryRelated[$adminGuid]/$daySale,1);
+ $salaryRelatedPercent = round(100 * $arrUsersSalaryRelated[$adminGuid] / $daySale, 1);
}
}
];
- if ('2022-12-01' <= date("Y-m-d H:i:s", strtotime($row['date']))){
+ if ('2022-12-01' <= date("Y-m-d H:i:s", strtotime($row['date']))) {
$administratorAddValues = [
'Бонус за % чеков с оплатой наличными' => [
'value' => $gameBonusPercenrCashInChecks,
}
- public function getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator) : array
+ public function getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator): array
{
$salesByAdminPrepared = $this->salesService->getSalesByAdmin($adminGuid, $dateFrom, $dateTo, $isAdministrator);
}
- public function getSaluryStoreSum($storeId1c, $dateFrom, $dateTo, $isAdministrator) : array
+ public function getSaluryStoreSum($storeId1c, $dateFrom, $dateTo, $isAdministrator): array
{
$salesByAdminPrepared = $this->salesService->getSalesByStore($storeId1c, $dateFrom, $dateTo, $isAdministrator);
}
- public function getSumForAdminByDate($adminGuid, $dateFrom, $dateTo, $isAdministrator) : array
+ public function getSumForAdminByDate($adminGuid, $dateFrom, $dateTo, $isAdministrator): array
{
return ArrayHelper::getValue($this->getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator), 'sumByDate');
}
- public function getSumByAdmin($adminGuid, $dateFrom, $dateTo, $isAdministrator) : float
+ public function getSumByAdmin($adminGuid, $dateFrom, $dateTo, $isAdministrator): float
{
return ArrayHelper::getValue($this->getSalurySum($adminGuid, $dateFrom, $dateTo, $isAdministrator), 'sumByAdmin');
}
- public function getAvgSumField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getAvgSumField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo): float
{
return round(DashboardSales::find()
->select(['summ'])
- ->andWhere(['store_id'=> $employeeSelectStoreId])
- ->andWhere(['field_name'=> $fieldName])
+ ->andWhere(['store_id' => $employeeSelectStoreId])
+ ->andWhere(['field_name' => $fieldName])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->average('summ'), 2);
}
- public function getSumField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getSumField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo): float
{
- $query = DashboardSales::find()
+ $query = DashboardSales::find()
->select(['summ' => new \yii\db\Expression("SUM(summ)")])
- ->andWhere(['store_id'=> $employeeSelectStoreId])
- ->andWhere(['field_name'=> $fieldName])
+ ->andWhere(['store_id' => $employeeSelectStoreId])
+ ->andWhere(['field_name' => $fieldName])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo]);
- $resultQuery = $query->column();
+ $resultQuery = $query->column();
- return ArrayHelper::getValue($resultQuery,array_key_first($resultQuery)) ?? 0;
+ return ArrayHelper::getValue($resultQuery, array_key_first($resultQuery)) ?? 0;
}
- public function getAvgSumCheck($employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getAvgSumCheck($employeeSelectStoreId, $dateFrom, $dateTo): float
{
return $this->getAvgSumField('sales_avg_check', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumListField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListField($fieldName, $employeeSelectStoreId, $dateFrom, $dateTo): array
{
return DashboardSales::find()
- ->andWhere(['store_id'=> $employeeSelectStoreId])
- ->andWhere(['field_name'=> $fieldName])
+ ->andWhere(['store_id' => $employeeSelectStoreId])
+ ->andWhere(['field_name' => $fieldName])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->indexBy('date')
return $groupId;
}
- public function getStoreIdDayChallenge($dateFrom, $dateTo) : array
+ public function getStoreIdDayChallenge($dateFrom, $dateTo): array
{
- $monthFrom = (int) date("m",strtotime($dateFrom));
- $monthTo = (int) date("m",strtotime($dateTo));
- $yearFrom = (int) date("Y",strtotime($dateFrom));
- $yearTo = (int) date("Y",strtotime($dateTo));
+ $monthFrom = (int)date("m", strtotime($dateFrom));
+ $monthTo = (int)date("m", strtotime($dateTo));
+ $yearFrom = (int)date("Y", strtotime($dateFrom));
+ $yearTo = (int)date("Y", strtotime($dateTo));
$months = range($monthFrom, $monthTo);
$years = range($yearFrom, $yearTo);
$storeIdsPrepared = ArrayHelper::getColumn($storesPlan, 'storeId.entity_id');
- $storeIds = array_filter($storeIdsPrepared, static function($var){return $var !== null;} );
+ $storeIds = array_filter($storeIdsPrepared, static function ($var) {
+ return $var !== null;
+ });
$dayStartMonth = date('Y-m-01', strtotime($dateFrom));
$dayStopMonth = date('Y-m-t', strtotime($dateTo));
if (array_key_exists($rowStoreId, $newStores)) {
$openDate = ArrayHelper::getValue($newStores[$rowStoreId], 'open_date');
$dateOpen = new DateTime($openDate);
- $dateEndMonthOpen = date("Y-m-t",strtotime($openDate));
+ $dateEndMonthOpen = date("Y-m-t", strtotime($openDate));
$dateEndMonth = new DateTime($dateEndMonthOpen);
$interval = $dateOpen->diff($dateEndMonth);
- $activeDayNewStore = (int) $interval->format('%a') + 1;
+ $activeDayNewStore = (int)$interval->format('%a') + 1;
$countCalculateDaysRow = $activeDayNewStore;
}
}
}
$dashboardSales = DashboardSales::find()
- ->andWhere(['field_name'=> 'sales_summ'])
+ ->andWhere(['field_name' => 'sales_summ'])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->asArray()
$avgCheckSummTrigger = 1200;
$dashboardSalesAvgCheck = DashboardSales::find()
- ->andWhere(['field_name'=> 'sales_avg_check'])
+ ->andWhere(['field_name' => 'sales_avg_check'])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->andWhere(['>', 'summ', $avgCheckSummTrigger])
$dateRow = ArrayHelper::getValue($itemSale, 'date');
if (!array_key_exists($dateRow, $dashboardSalesAvgCheckArray)) {
- $test =33;
+ $test = 33;
continue;
}
$storeIdRow = ArrayHelper::getValue($itemSale, 'store_id');
$summRow = ArrayHelper::getValue($itemSale, 'summ');
- $monthRow = (int) date("m",strtotime($dateRow));
- $yearRow = (int) date("Y",strtotime($dateRow));
+ $monthRow = (int)date("m", strtotime($dateRow));
+ $yearRow = (int)date("Y", strtotime($dateRow));
$yearMonthKeyRow = $yearRow . '_' . $monthRow;
- $keyArrayRow = $yearMonthKeyRow . '.' . $storeIdRow .'.plan_by_day';
+ $keyArrayRow = $yearMonthKeyRow . '.' . $storeIdRow . '.plan_by_day';
$planByDayStoreRow = ArrayHelper::getValue($storesPlanByDay, $keyArrayRow);
$dashboardSales[$key]['plan_by_day'] = $planByDayStoreRow;
return $deltaPlanByDaySuccessWin;
}
- public function getStoreIdWeekChallenge($dateFrom, $dateTo) : array
+ public function getStoreIdWeekChallenge($dateFrom, $dateTo): array
{
- $monthFrom = (int) date("m",strtotime($dateFrom));
- $monthTo = (int) date("m",strtotime($dateTo));
- $yearFrom = (int) date("Y",strtotime($dateFrom));
- $yearTo = (int) date("Y",strtotime($dateTo));
+ $monthFrom = (int)date("m", strtotime($dateFrom));
+ $monthTo = (int)date("m", strtotime($dateTo));
+ $yearFrom = (int)date("Y", strtotime($dateFrom));
+ $yearTo = (int)date("Y", strtotime($dateTo));
$months = range($monthFrom, $monthTo);
$years = range($yearFrom, $yearTo);
}
$dashboardSales = DashboardSales::find()
- ->andWhere(['field_name'=> 'sales_summ'])
+ ->andWhere(['field_name' => 'sales_summ'])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->asArray()
$avgCheckSummTrigger = 1200;
$dashboardSalesAvgCheck = DashboardSales::find()
- ->andWhere(['field_name'=> 'sales_avg_check'])
+ ->andWhere(['field_name' => 'sales_avg_check'])
->andWhere(['>=', 'date', $dateFrom])
->andWhere(['<=', 'date', $dateTo])
->andWhere(['>', 'summ', $avgCheckSummTrigger])
$dateRow = ArrayHelper::getValue($itemSale, 'date');
if (!array_key_exists($dateRow, $dashboardSalesAvgCheckArray)) {
- $test =33;
+ $test = 33;
continue;
}
$storeIdRow = ArrayHelper::getValue($itemSale, 'store_id');
$summRow = ArrayHelper::getValue($itemSale, 'summ');
- $monthRow = (int) date("m",strtotime($dateRow));
- $yearRow = (int) date("Y",strtotime($dateRow));
+ $monthRow = (int)date("m", strtotime($dateRow));
+ $yearRow = (int)date("Y", strtotime($dateRow));
$yearMonthKeyRow = $yearRow . '_' . $monthRow;
- $keyArrayRow = $yearMonthKeyRow . '.' . $storeIdRow .'.plan_by_day';
+ $keyArrayRow = $yearMonthKeyRow . '.' . $storeIdRow . '.plan_by_day';
$planByDayStoreRow = ArrayHelper::getValue($storesPlanByDay, $keyArrayRow);
$dashboardSales[$key]['plan_by_day'] = $planByDayStoreRow;
return $deltaPlanByDaySuccessWin;
}
- public function getSumListAvgCheck($employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListAvgCheck($employeeSelectStoreId, $dateFrom, $dateTo): array
{
return $this->getSumListField('sales_avg_check', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumListConversion($employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListConversion($employeeSelectStoreId, $dateFrom, $dateTo): array
{
return $this->getSumListField('conversion_traffic', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumListNewBonusClientsPercent($employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListNewBonusClientsPercent($employeeSelectStoreId, $dateFrom, $dateTo): array
{
return $this->getSumListField('new_bonus_clients_percent', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumListConversionBonusClients($employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListConversionBonusClients($employeeSelectStoreId, $dateFrom, $dateTo): array
{
return $this->getSumListField('сonversion_bonus_clients', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumListStoreServicesPercent($employeeSelectStoreId, $dateFrom, $dateTo) : array
+ public function getSumListStoreServicesPercent($employeeSelectStoreId, $dateFrom, $dateTo): array
{
return $this->getSumListField('services_percent', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumChecksStore($employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getSumChecksStore($employeeSelectStoreId, $dateFrom, $dateTo): float
{
return $this->getSumField('checks_counter', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumIncomingTrafficStore($employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getSumIncomingTrafficStore($employeeSelectStoreId, $dateFrom, $dateTo): float
{
return $this->getSumField('incoming_traffic', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumClientsLtv($employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getSumClientsLtv($employeeSelectStoreId, $dateFrom, $dateTo): float
{
return $this->getSumField('clients_ltv', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getSumSalesSumm($employeeSelectStoreId, $dateFrom, $dateTo) : float
+ public function getSumSalesSumm($employeeSelectStoreId, $dateFrom, $dateTo): float
{
return $this->getSumField('sales_summ', $employeeSelectStoreId, $dateFrom, $dateTo);
}
- public function getGuidsByIds($ids, $exportAdmin) : array
+ public function getGuidsByIds($ids, $exportAdmin): array
{
$adminGuids = [];
foreach ($ids as $id) {
return $adminGuids;
}
- public function getValues(array $adminIdsInShift) : array
+ public function getValues(array $adminIdsInShift): array
{
$result = [];
- array_walk_recursive($adminIdsInShift, function($v) use (&$result){
+ array_walk_recursive($adminIdsInShift, function ($v) use (&$result) {
$result[] = $v;
});
}
- public function getSumValues(array $values) : int
+ public function getSumValues(array $values): int
{
$sumRows = 0;
foreach ($values as $item) {
}
- public function getSumGameBonus(array $timetable, $allPossibleSumGameBonusValuesFlorist) : array
+ public function getSumGameBonus(array $timetable, $allPossibleSumGameBonusValuesFlorist): array
{
$sumRows = 0;
foreach ($timetable as $shift) {
$sumForDays = $sumRows;
- if (!empty($allPossibleSumGameBonusValuesFlorist) && (int) $allPossibleSumGameBonusValuesFlorist > 0) {
+ if (!empty($allPossibleSumGameBonusValuesFlorist) && (int)$allPossibleSumGameBonusValuesFlorist > 0) {
$sumRows += $allPossibleSumGameBonusValuesFlorist;
}
];
}
- public function getSumBonus(array $bonusStore1, array $bonusStore2 ) : array
+ public function getSumBonus(array $bonusStore1, array $bonusStore2): array
{
$bonusStore1AdminSumGameBonusForDays = $bonusStore1['adminSumGameBonusForDays'] ?? 0;
$bonusStore2AdminSumGameBonusForDays = $bonusStore2['adminSumGameBonusForDays'] ?? 0;
public function getDeltaMonthToMonthClientsLtvPercent($employeeSelectStoreId, $dateFromBeginMonth, $dateToEndMonth)
{
- $dateFromBeginPreviousMonth = date("Y-m-01",strtotime($dateFromBeginMonth." -1 month"));
- $dateToEndPreviousMonth = date("Y-m-t",strtotime($dateFromBeginPreviousMonth));
+ $dateFromBeginPreviousMonth = date("Y-m-01", strtotime($dateFromBeginMonth . " -1 month"));
+ $dateToEndPreviousMonth = date("Y-m-t", strtotime($dateFromBeginPreviousMonth));
$sumClientsLtvCurrentMonth = $this->getSumClientsLtv($employeeSelectStoreId, $dateFromBeginMonth, $dateToEndMonth);
$sumIncomingTrafficStoreCurrentMonth = $this->getSumIncomingTrafficStore($employeeSelectStoreId, $dateFromBeginMonth, $dateToEndMonth);
$deltaPercent = 0;
- if ( $sumClientsLtvPreviousMonthPercent > 0) {
+ if ($sumClientsLtvPreviousMonthPercent > 0) {
$deltaPercent = round(round(100 * $sumClientsLtvCurrentMonthPercent / $sumClientsLtvPreviousMonthPercent, 1) - 100, 1);
}
$salesSummPastYearMonthFromDict = null;
$salesSummPastYearMonthDict = [
- '2022-12' => [
+ '2022-12' => [
26 => 961015, // ул. Краснодонцев 1
27 => 1195200, // д. Кузнечиха ул. Бархатная 86Д
28 => 841351, // п. Революции 7А
- 1 => 2521529.00, //01 Ванеева
- 2 => 1918369.60, //05 Белинского ККМ
- 3 => 1097327.26, //03 Гагарина 60
- 4 => 876268.20, //07 Аэродромная
- 6 => 997197.93, //13 Горького
- 7 => 1271296.00, //02 Плотникова
- 8 => 991041.26, //04 Шайба новая
- 9 => 1727580.00, //10 Народная
- 10 => 1195303.00, //12 Гагарина 19
- 11 => 904932.00, //06 Коминтерна
- 14 => 411538.80, //11 Гагарина 37Б
- 13 => 1015329.73, //14 Печеры ККМ
- 15 => 971241.96, //16 Гагарина 182
- 16 => 968547.89, //15 Ленина 76 новый
- 19 => 1026177.12, //17 Коминтерная 248 ККМ
- 20 => 691301.21, //18 Ленина 62
- 23 => 361494.00, //08 Веденяпина 4 с 14.11.2021 (Ванеева 11)
-
- ],
+ 1 => 2521529.00, //01 Ванеева
+ 2 => 1918369.60, //05 Белинского ККМ
+ 3 => 1097327.26, //03 Гагарина 60
+ 4 => 876268.20, //07 Аэродромная
+ 6 => 997197.93, //13 Горького
+ 7 => 1271296.00, //02 Плотникова
+ 8 => 991041.26, //04 Шайба новая
+ 9 => 1727580.00, //10 Народная
+ 10 => 1195303.00, //12 Гагарина 19
+ 11 => 904932.00, //06 Коминтерна
+ 14 => 411538.80, //11 Гагарина 37Б
+ 13 => 1015329.73, //14 Печеры ККМ
+ 15 => 971241.96, //16 Гагарина 182
+ 16 => 968547.89, //15 Ленина 76 новый
+ 19 => 1026177.12, //17 Коминтерная 248 ККМ
+ 20 => 691301.21, //18 Ленина 62
+ 23 => 361494.00, //08 Веденяпина 4 с 14.11.2021 (Ванеева 11)
+
+ ],
// Продажи за 02 месяц в 2022 году
'2022-02' => [
- 8 => 1233571.00, //04 Шайба новая
+ 8 => 1233571.00, //04 Шайба новая
],
'2023-03' => [
26 => 933577, // ул. Краснодонцев 1
],
];
- $yearMonthDateFromBeginMonth = date("Y-m",strtotime($dateFromBeginMonth));
+ $yearMonthDateFromBeginMonth = date("Y-m", strtotime($dateFromBeginMonth));
$modifier = ' -1 year';
}
}
- $dateFromBeginPastYear = date("Y-m-d",strtotime($dateFromBeginMonth.$modifier));
- $dateToEndPastYear = date("Y-m-d",strtotime($dateTo.$modifier));
+ $dateFromBeginPastYear = date("Y-m-d", strtotime($dateFromBeginMonth . $modifier));
+ $dateToEndPastYear = date("Y-m-d", strtotime($dateTo . $modifier));
- $yearDateFromBeginPastYear = date("Y-m",strtotime($dateFromBeginPastYear));
+ $yearDateFromBeginPastYear = date("Y-m", strtotime($dateFromBeginPastYear));
if (array_key_exists($yearDateFromBeginPastYear, $salesSummPastYearMonthDict)) {
$salesSummPastYearMonthDictRow = $salesSummPastYearMonthDict[$yearDateFromBeginPastYear];
$foundKey = $entityCityStoreEmployeeSelect . '_' . $dateFrom;
$aeroStore = 'dbd70103-2c7b-11e9-9b87-c85b76f0e893';
$customSum = [
- $aeroStore.'_2021-10-01' => 885795,
- $aeroStore.'_2021-11-01' => 889483,
+ $aeroStore . '_2021-10-01' => 885795,
+ $aeroStore . '_2021-11-01' => 889483,
];
if (array_key_exists($foundKey, $customSum)) {
return $customSum[$foundKey];
}
- if (true === (bool) $writeOff) {
+ if (true === (bool)$writeOff) {
$salesPrepared = $this->salesService->getSalesSum($dateFrom, $dateTo, false, true, $entityCityStoreEmployeeSelect);
} else {
$salesPrepared = $this->salesService->getSalesSum($dateFrom, $dateTo, false, false, $entityCityStoreEmployeeSelect);
$sales = [];
- foreach($salesPrepared as $row) {
+ foreach ($salesPrepared as $row) {
if (!array_key_exists($row["store_id_1c"], $sales)) {
$sales[$row["store_id_1c"]] = 0;
}
- if($row["operation"] == Sales::OPERATION_SALE) {
- $sales[$row["store_id_1c"]] +=$row["summ"];
+ if ($row["operation"] == Sales::OPERATION_SALE) {
+ $sales[$row["store_id_1c"]] += $row["summ"];
}
- if($row["operation"] == Sales::OPERATION_RETURN) {
- $sales[$row["store_id_1c"]] -=$row["summ"];
+ if ($row["operation"] == Sales::OPERATION_RETURN) {
+ $sales[$row["store_id_1c"]] -= $row["summ"];
}
}
$salesByStore = 0;
* @param $storeId
* @return array
*/
- public function getCountStoreVisitors(string $dateFrom,string $dateTo, $storeId) : array
+ public function getCountStoreVisitors(string $dateFrom, string $dateTo, $storeId): array
{
$storeVisitorsService = new StoreVisitorsService();
$countStoreVisitorsDay = $storeVisitorsService->getStoreVisitors($dateFrom, $dateTo, $storeId, true);
* @return array[]
* @throws \Exception
*/
- public function getConversionShift(string $dateFrom, string $dateTo, $storeId) : array
+ public function getConversionShift(string $dateFrom, string $dateTo, $storeId): array
{
- $salesCount = $this->salesService->getSalesCount( $dateFrom, $dateTo, $storeId);
- $countStoreVisitors = $this->getCountStoreVisitors( $dateFrom, $dateTo, $storeId);
+ $salesCount = $this->salesService->getSalesCount($dateFrom, $dateTo, $storeId);
+ $countStoreVisitors = $this->getCountStoreVisitors($dateFrom, $dateTo, $storeId);
$datesShiftDay = array_keys($salesCount['salesCountDay']);
$dayConversion = [];
foreach ($datesShiftDay as $date) {
$dayConversion[$date] = 0;
- if (array_key_exists($date, $countStoreVisitors['countStoreVisitorsDay'])){
+ if (array_key_exists($date, $countStoreVisitors['countStoreVisitorsDay'])) {
$salesCountShiftDay = $salesCount['salesCountDay'][$date];
$visitorsCountShiftDay = $countStoreVisitors['countStoreVisitorsDay'][$date];
- if (0 < (int) $visitorsCountShiftDay) {
+ if (0 < (int)$visitorsCountShiftDay) {
$dayConversion[$date] = round(($salesCountShiftDay / $visitorsCountShiftDay) * 100, 1);
}
}
$nightConversion = [];
foreach ($datesShiftNight as $date) {
$nightConversion[$date] = 0;
- if (array_key_exists($date, $countStoreVisitors['countStoreVisitorsNight'])){
+ if (array_key_exists($date, $countStoreVisitors['countStoreVisitorsNight'])) {
$salesCountShiftNight = $salesCount['salesCountNight'][$date];
$visitorsCountShiftNight = $countStoreVisitors['countStoreVisitorsNight'][$date];
- if (0 < (int) $visitorsCountShiftNight) {
- $nightConversion[$date] = round(100 * $salesCountShiftNight/$visitorsCountShiftNight,1);
+ if (0 < (int)$visitorsCountShiftNight) {
+ $nightConversion[$date] = round(100 * $salesCountShiftNight / $visitorsCountShiftNight, 1);
}
}
}
}
- public function checkError( array $storeAdminsPrepared, array $storeAdminsNames, $controller, $checkErrorName)
+ public function checkError(array $storeAdminsPrepared, array $storeAdminsNames, $controller, $checkErrorName)
{
if (!empty($storeAdminsPrepared['error'])) {
$errorText = 'При проверке сотрудников по ' . $checkErrorName . ' на смене возникла ошибка: <br>';
foreach ($storeAdminsPrepared['error'] as $item) {
- $errorText .= 'В ERP нет данных GUID из 1с о пользователе ' . $storeAdminsNames[$item] . ' id : ' . $item . '<br>';
+ $errorText .= 'В ERP нет данных GUID из 1с о пользователе ' . $storeAdminsNames[$item] . ' id : ' . $item . '<br>';
}
$errorText .= 'Связь с 1с нужна для того, что бы посчитать продажи смены.<br> Обратитесь в HR отдел';
$adminIdsInShift = [];
$storeIdsInShift = [];
$adminNamesInShift = [];
- foreach ( $timetableTmp as $key => $item) {
+ foreach ($timetableTmp as $key => $item) {
$resultTimetableInfo = $this->getTimetableAdminData($item['shift_id'], $item['store_id'], $item['date']);
- $adminIds = ArrayHelper::getColumn($resultTimetableInfo , 'admin_id');
- $adminNames = ArrayHelper::getColumn($resultTimetableInfo , 'admin.name_full');
- $adminNamesList = implode(', <br>' , $adminNames);
+ $adminIds = ArrayHelper::getColumn($resultTimetableInfo, 'admin_id');
+ $adminNames = ArrayHelper::getColumn($resultTimetableInfo, 'admin.name_full');
+ $adminNamesList = implode(', <br>', $adminNames);
$timetableInfo[$key] = $resultTimetableInfo;
$timetable[$key]['count_admin_store_shift']['shift_id'][$item['shift_id']] = count($resultTimetableInfo);
$timetable[$key]['admin_store'] = [
- 'adminIds' => $adminIds,
- 'adminNames' => $adminNames,
+ 'adminIds' => $adminIds,
+ 'adminNames' => $adminNames,
];
$timetable[$key]['name_list_admin_store'] = $adminNamesList;
$timetable[$key]['count_admin_store'] = count($resultTimetableInfo);
): array
{
- $dateCurrent = date("Y-m-d",time());
+ $dateCurrent = date("Y-m-d", time());
- $yearCurrent = date("Y",strtotime($dateCurrent));
- $monthCurrent = date("n",strtotime($dateCurrent));
+ $yearCurrent = date("Y", strtotime($dateCurrent));
+ $monthCurrent = date("n", strtotime($dateCurrent));
- $yearDateFrom = date("Y",strtotime($dateFrom));
- $monthDateFrom = date("n",strtotime($dateFrom));
+ $yearDateFrom = date("Y", strtotime($dateFrom));
+ $monthDateFrom = date("n", strtotime($dateFrom));
- $dayCurrent = date("j",strtotime($dateCurrent));
+ $dayCurrent = date("j", strtotime($dateCurrent));
$dateMonthBefore = date("Y-m-d", strtotime($dateFrom . " -1 months"));
$dateToMonthBefore = date("Y-m-d", strtotime($dateTo . " -1 months"));
$dateBeginMonthBefore = date("Y-m-01", strtotime($dateFrom . " -1 months"));
$dateEndMonthBefore = date("Y-m-t", strtotime($dateFrom . " -1 months"));
- $dayInPastMonth = date("j",strtotime($dateEndMonthBefore));
+ $dayInPastMonth = date("j", strtotime($dateEndMonthBefore));
- $yearBeforeSelect = date("Y",strtotime($dateMonthBefore));
- $monthWithZeroBeforeSelect = date("m",strtotime($dateMonthBefore));
+ $yearBeforeSelect = date("Y", strtotime($dateMonthBefore));
+ $monthWithZeroBeforeSelect = date("m", strtotime($dateMonthBefore));
$storeIdsString = ArrayHelper::getValue($clusterAdmin, 'store_arr');
$clusterAdminId = ArrayHelper::getValue($clusterAdmin, 'id');
];
$adminAdministrator = Admin::getAdmins('', $groupIds, 'ASC', $storeIds, '', Admin::NOT_IN_STORE_IDS);
- $adminAdministratorIdsMap = ArrayHelper::map($adminAdministrator, 'store_id','id');
+ $adminAdministratorIdsMap = ArrayHelper::map($adminAdministrator, 'store_id', 'id');
$adminAdministratorIds = ArrayHelper::getColumn($adminAdministrator, 'id');
$clusterStores = [];
$clusterStores[$storeId] = [];
-
$salesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
- $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect,true);
+ $allSalesByStore = $this->getSalesSaleSum($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect, true);
$salesByStoreInterval = $this->getSalesSaleSum($dateFrom, $dateTo, $entityCityStoreEmployeeSelect);
$salesSummCurrentMonth = $this->getSalesSaleSum($dateFromBeginMonth, $dateToEndMonth, $entityCityStoreEmployeeSelect);
-
$amountWriteOff = WriteOffs::getWriteOffByStore($dateFromBeginMonth, $dateTo, $entityCityStoreEmployeeSelect);
// списание
$percentLossFromDict = true;
} else {
if (!empty($allSalesByStore)) {
- $percentLossPrepared = 100 * $amountWriteOffByStore/$allSalesByStore;
+ $percentLossPrepared = 100 * $amountWriteOffByStore / $allSalesByStore;
} else {
- $percentLossPrepared = 100 * $amountWriteOffByStore/$salesByStore;
+ $percentLossPrepared = 100 * $amountWriteOffByStore / $salesByStore;
}
- $percentLoss = round($percentLossPrepared,1);
+ $percentLoss = round($percentLossPrepared, 1);
}
}
$planPercent = 0;
$planStoreMonthCalculatePercent = 0;
if (!empty($salesByStore) && !empty($planMonthByStore)) {
- $planPercent=round(100 * $salesByStore/$planMonthByStore,1);
+ $planPercent = round(100 * $salesByStore / $planMonthByStore, 1);
}
$saleByMonthCalculate = 0;
->asArray()->column();
-
$adminPayrollIdsBeforeMonth = AdminPayroll::find()
->select(['id'])
->indexBy('id')
->asArray()->column();
-
$payrollSumValuesCurrentMonthRow = AdminPayrollValues::getSumByAlias($allTotalPayrollAttributeId, $adminPayrollIdsCurrentMonth);
$payrollSumValuesBeforeMonthRow = AdminPayrollValues::getSumByAlias($allTotalPayrollAttributeId, $adminPayrollIdsBeforeMonth);
$percentFotCurrentMonth = 0;
if (!empty($salesByStore)) {
- $percentFotCurrentMonth = round(($payrollSumValuesCurrentMonthRow/$salesByStore) * 100, 1);
+ $percentFotCurrentMonth = round(($payrollSumValuesCurrentMonthRow / $salesByStore) * 100, 1);
}
$percentFotBeforeMonth = 0;
if (!empty($salesSummBeforeMonth)) {
- $percentFotBeforeMonth = round(($payrollSumValuesBeforeMonthRow/$salesSummBeforeMonth) * 100, 1);
+ $percentFotBeforeMonth = round(($payrollSumValuesBeforeMonthRow / $salesSummBeforeMonth) * 100, 1);
}
- if ($monthSelect == 10 && $yearSelect == 2022 ) {
+ if ($monthSelect == 10 && $yearSelect == 2022) {
$oldFot2022_09 = [
13 => 15.79,
1 => 10.88,
$sumSalesByStoreInterval = $param['sumSalesByStoreInterval'];
}
- if ($monthSelect == 10 && $yearSelect == 2022 ) {
+ if ($monthSelect == 10 && $yearSelect == 2022) {
$oldFotValuesAdmins2022_09 = [
163 => 24.82, // 163 Оксана Кузнецова
164 => 14.84, // 164 Иван Карпушкин
];
if (array_key_exists($clusterAdminId, $oldFotValuesAdmins2022_09)) {
- $percentFotBeforeMonth = $oldFotValuesAdmins2022_09[$clusterAdminId];
+ $percentFotBeforeMonth = $oldFotValuesAdmins2022_09[$clusterAdminId];
}
}
}
-
$raznicaDoPlanaStore = $param['planMonthByStore'] - $param['salesByStore'];
$showRaznicaDoPlanaPerson = false;
- if (1 === (int) date('d', strtotime($dateFrom))) {
+ if (1 === (int)date('d', strtotime($dateFrom))) {
$showRaznicaDoPlanaPerson = true;
}
$planPercentCluster = 0;
// процент выполнения плана продаж
if (!empty($param['salesByStore']) && !empty($param['planMonthByStore'])) {
- $planPercentCluster=round(100 * $param['salesByStore']/$param['planMonthByStore'],1);
+ $planPercentCluster = round(100 * $param['salesByStore'] / $param['planMonthByStore'], 1);
}
$date = $yearSelect . '-' . $monthWithZeroSelect;
$personVacationDay = ArrayHelper::getValue($personBonusesArray, 'vacation_day'); // Оплаченный отпуск
-
// Сумма окладной части устанавливается стандартной - 45 000 руб.
$okladClusterAdmin = 45000;
if ($dateFrom >= '2023-09-01') {
$ratingPerson = ArrayHelper::getValue($ratingPersonValues, 'rating');
- if ($yearSelect . '-' . $monthWithZeroSelect == '2022-12' && $clusterAdminId == 164) {
+ if ($yearSelect . '-' . $monthWithZeroSelect == '2022-12' && $clusterAdminId == 164) {
$administratorCountInRating = 7;
} else {
$administratorCountInRating = ArrayHelper::getValue($ratingPersonValues, 'administrators_count');
if (!empty($personBonuses)) {
$personBonusesArrayInfo = [
- 'Персональная премия' => (int) $personBonuses,
+ 'Персональная премия' => (int)$personBonuses,
];
$arrayColumnWages = array_merge($arrayColumnWages, $personBonusesArrayInfo);
}
$percentDeMotivateYearToYear = $param['percentDeMotivateYearToYear'];
- if(
+ if (
$allPossibleSumValuesClusterPrepared > 0
&& ($percentDeMotivateYearToYear < 100)
) {
}
-
-
// Таблица итоговых сумм
$sumValuesCluster = array(
];
if (!empty($resultArrayErrorText)) {
- $resultArray = array_merge($resultArray,['errorText' => $resultArrayErrorText,]);
+ $resultArray = array_merge($resultArray, ['errorText' => $resultArrayErrorText,]);
}
- $resultArray = array_merge($resultArray,$param);
+ $resultArray = array_merge($resultArray, $param);
return $resultArray;
$yearSelectTo = date("Y", strtotime($dateTo));
$monthSelectTo = date("m", strtotime($dateTo));
- $yearMonthSelectTo = $yearSelectTo . '-' . $monthSelectTo;
+ $yearMonthSelectTo = $yearSelectTo . '-' . $monthSelectTo;
$allowedByMonth = true;
$allowedByBlockList = true;
$yearSelectTo = date("Y", strtotime($dateTo));
$monthSelectTo = date("m", strtotime($dateTo));
- $yearMonthSelectTo = $yearSelectTo . '-' . $monthSelectTo;
+ $yearMonthSelectTo = $yearSelectTo . '-' . $monthSelectTo;
$allowedByMonth = true;
$allowedByBlockList = true;
return ($allowedByMonth);
}
- public function getAllowedDemotivateStoreCalculate($employeeSelectStoreId, $dateFrom, $dateTo) : bool
+
+ public function getAllowedDemotivateStoreCalculate($employeeSelectStoreId, $dateFrom, $dateTo): bool
{
$yearSelectFrom = date("Y", strtotime($dateFrom));
$monthSelectFrom = date("m", strtotime($dateFrom));
$percentLoss = 0;
//заплатка на процент списания по Аэродромной
- if ($storeId == 4 && $yearSelect == 2022 && $monthSelect == 11 ) {
+ if ($storeId == 4 && $yearSelect == 2022 && $monthSelect == 11) {
$percentLoss = 7.4;
}
return $percentLoss;
}
- public function getCustomSumForLoss($storeId, $yearSelect, $monthSelect) : array
+ public function getCustomSumForLoss($storeId, $yearSelect, $monthSelect): array
{
$result = [];
//заплатка на подсчет процента списания для лк кустового
- $monthSelect = trim($monthSelect,'0');
+ $monthSelect = trim($monthSelect, '0');
$yearMonthKey = $yearSelect . '_' . $monthSelect;
if (!empty($storeId)) {
if (array_key_exists($yearMonthKey, $configSalesAndWriteOff)) {
}
/**
- * @return int
- */
- public function getAdministratorSalaryShift($employeeId, $dateFrom, $salesByStore = null) : int
+ * @return int
+ */
+ public function getAdministratorSalaryShift($employeeId, $dateFrom, $salesByStore = null): int
{
$administratorOklad = 0;
$administratorOklad = $this->bonusService->getAdministratorOklad($salesByStore);
}
- return (int) $administratorOklad;
+ return (int)$administratorOklad;
}
public function getPremiumByFocusGroups($adminGuid, $arrUsersSalary, $dateFrom, $dateTo, $isAdministrator): array
$userSalaryPottedPremium = round($userSalaryPotted * 0.05);
$userSalaryWrapPremium = round($userSalaryWrap * 0.05); // 5% за личные продажи упаковки
- $userSalarySalutPremium = round($userSalarySalut * 0.05); // 5% за личные продажи пиротехники
+ $userSalarySalutPremium = round($userSalarySalut * 0.05); // 5% за личные продажи пиротехники
- $userSalaryOtherItemsPremium = round($userSalaryOtherItems * 0.01); // 1% за личные продажи не фокусной продукции (Другме товары)
+ $userSalaryOtherItemsPremium = round($userSalaryOtherItems * 0.01); // 1% за личные продажи не фокусной продукции (Другме товары)
$userSalaryPremium = [
'userSalaryServicesPremium' => $userSalaryServicesPremium,
$isAdministrator,
$showHolidayVersion = false,
$notHolidayCalculate = true
- ): array {
+ ): array
+ {
$adminGuidDateArr = [];
$adminGuidArrAll = [];
if ($showHolidayVersion) {
$adminGuidDateArr = SalaryHelper::getAdminGuidByStore($dateFrom, $dateTo, $employeeSelectStoreId);
$isAdministrator = false;
}
- $dates = ArrayHelper::getValue($holidayDatesBetweenPrepared, $dataKey);
+ $dates = ArrayHelper::getValue($holidayDatesBetweenPrepared, $dataKey);
} else {
$dates = [
0 => [