Skip to content

Instantly share code, notes, and snippets.

@eduardoesternon
Created May 13, 2020 01:46
Show Gist options
  • Save eduardoesternon/e3e0a8d60c1a71764f32e0f477b36b28 to your computer and use it in GitHub Desktop.
Save eduardoesternon/e3e0a8d60c1a71764f32e0f477b36b28 to your computer and use it in GitHub Desktop.
<?php
require_once('modules/Services/Service.php');
require_once('modules/Jobs/Job.php');
$jobs_sql = "
SELECT *
FROM `jobs`
WHERE
`name` LIKE BINARY '%GEM%' AND
`development_catalog` IS NULL
";
$jobs = Job::search($jobs_sql);
$catalogs = [];
$missing = [];
$accounts = [];
foreach ($jobs as $job) {
$id = $job->id;
$service_sql = "
SELECT
services.*
FROM services
INNER JOIN accounts ON accounts.id = services.account_id
INNER JOIN projects ON projects.account_id = accounts.id
INNER JOIN jobs ON jobs.parent_id = projects.id
WHERE
jobs.id = '$id' AND
accounts.deleted = 0 AND
services.deleted = 0
";
$services = Service::search($service_sql);
if (count($services) > 0) {
$catalog = $services[0]->get_catalog();
if ($catalog) {
$catalogs[] = ['job_id' => $job->id, 'catalog' => $catalog];
$job->development_catalog = $catalog;
$job->save();
} else {
$missing[] = $job->id;
$accounts[$job->get_account()->id] = 'id';
}
} else {
$missing[] = $job->id;
$accounts[$job->get_account()->id] = 'id';
}
}
$missing_subs = '';
foreach ($accounts as $key => $value) {
$missing_subs .= 'https://extranet.zeald.com/crm/index.php?module=Accounts&action=DetailView&record=' . $key . '\n';
}
e($missing_subs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment