0) AS tickets FROM projects WHERE project_client_id = $client_id AND project_archived_at IS NULL ORDER BY project_id DESC"); while ($co_project = mysqli_fetch_assoc($co_sql)) { $co_projects[] = $co_project; } $co_templates = []; $co_pick = ''; $co_sql = mysqli_query($mysqli, "SELECT project_template_id, project_template_name, (SELECT COUNT(*) FROM project_template_ticket_templates WHERE project_template_ticket_templates.project_template_id = project_templates.project_template_id) AS tickets FROM project_templates WHERE project_template_archived_at IS NULL ORDER BY project_template_name ASC"); while ($co_template = mysqli_fetch_assoc($co_sql)) { $co_id = intval($co_template['project_template_id']); $co_templates[$co_id] = $co_template['project_template_name'] . ' - ' . intval($co_template['tickets']) . ' ticket' . (intval($co_template['tickets']) === 1 ? '' : 's'); // One about onboarding is the likely one if ($co_pick === '' && stripos($co_template['project_template_name'], 'onboard') !== false) { $co_pick = (string) $co_id; } } $co_agents = []; $co_sql = mysqli_query($mysqli, "SELECT user_id, user_name FROM users WHERE user_type = 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC"); while ($co_agent = mysqli_fetch_assoc($co_sql)) { $co_agents[intval($co_agent['user_id'])] = $co_agent['user_name']; } $co_contacts = []; $co_contact_pick = '0'; $co_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_primary FROM contacts WHERE contact_client_id = $client_id AND contact_archived_at IS NULL ORDER BY contact_primary DESC, contact_name ASC"); while ($co_contact = mysqli_fetch_assoc($co_sql)) { $co_contacts[intval($co_contact['contact_id'])] = $co_contact['contact_name']; if (intval($co_contact['contact_primary']) && $co_contact_pick === '0') { $co_contact_pick = (string) $co_contact['contact_id']; } } ?>

Start another

'- None - an empty project -'] + $co_templates, ['id' => 'coProjectTemplate', 'icon' => 'fa-clone', 'label' => 'Template', 'help' => 'Its tickets are raised on the project, with their tasks - for the client, not emailed to them.']) ?>
No project templates yet - New Client Onboarding is in the Project templates pack in Maintenance > Starter Content. Without one the project starts empty.
'coProjectName', 'icon' => 'fa-project-diagram', 'label' => 'Name', 'required' => true, 'maxlength' => 255]) ?>
'- Nobody -'] + $co_agents, ['id' => 'coProjectManager', 'icon' => 'fa-user-tie', 'label' => 'Manager']) ?>
'- Nobody -'] + $co_contacts, ['id' => 'coProjectContact', 'icon' => 'fa-user', 'label' => 'Their contact']) ?>
'coProjectStart', 'icon' => 'fa-calendar-day', 'type' => 'date', 'label' => 'Starts', 'max' => '2999-12-31']) ?>
'coProjectDue', 'icon' => 'fa-calendar-check', 'type' => 'date', 'label' => 'Due', 'max' => '2999-12-31']) ?>
'coProjectAssign', 'label' => 'Assign its tickets to the manager', 'help' => 'Off, each goes to whoever its ticket template names, or nobody.']) ?>