Snippets
Created by
Jenny Rasmussen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | <?php
require_once 'trello_config.php';
require_once 'trello_api.php';
$days_of_the_week = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$months_of_the_year = array('January','February','March','April','May','June','July','August','September','October','November','December');
//Yearly To Do
$annual_checklist = array('To Do',
'Stuff',
'Here');
//Monthly To Do
//Checking Account (manual pay)
$bills_checklist = array('Checking Account' => array('Housing',
'Credit Card',
'Student Loans',
'Insurance',
'Loan'),
//Credit Card (auto pay)
'Credit Card' => array('Cell Phone',
'Internets',
'Netflix',
'Other',
'Things',
'That',
'Cost $$$'));
//Weekly To Do
//Sunday
$weekly_checklist = array(array('Exercise the Pooch','Grocery Shopping','Laundry','Language Lessons'),
//Monday
array('Exercise the Pooch','Workout','Language Lesson'),
//Tuesday
array('Exercise the Pooch','Workout','Take the garbage/recycle out','Language Lesson'),
//Wednesday
array('Exercise the Pooch','Workout','Language Lesson'),
//Thursday
array('Exercise the Pooch','Workout','Language Lesson'),
//Friday
array('Exercise the Pooch','Workout','Language Lesson'),
//Saturday
array('Exercise the Pooch','Language Lesson'));
//Grocery Shopping List
$grocery_checklist = array('Milk','Chocolate Milk','Fruit','Veggies');
//figure out what day of the week/month it is
$date_array = getdate();
//is it Sunday, first of the month, or 1 December?
if ($date_array['wday'] == 0 || $date_array['wday'] == 5 || $date_array['mday'] == 1 || ($date_array['mon'] == 12 && $date_array['mday'] == 1))
{
//create Trello instance
$trello_instance = new trello_api($key,$secret,$token);
//Weekly (Sunday)
if ($date_array['wday'] == 0)
{
//create card
$card_data = array(
'name' => ('To Do for Week of ' . date('j F Y', strtotime('+1 weeks'))),
'idList' => '//List ID goes here',
'labels' => 'yellow',
'pos' => 'top'
);
//post card
$card = $trello_instance->request('POST','/1/cards', $card_data);
//create checklist
for ($i = 0; $i < 7; $i++)
{
$checklist = $trello_instance->request('POST', '/1/checklists', array('idCard' => $card->id, 'name' => $days_of_the_week[$i]));
//push checklist to card
foreach ($weekly_checklist[$i] as $checklist_item)
{
$trello_instance->request('POST', ('/1/checklists/' . $checklist->id . '/checkItems'), array('name' => $checklist_item));
};
};
};
//If it's Friday, make a grocery list
if ($date_array['wday'] == 5)
{
//create card
$card_data = array(
'name' => ('Grocery List'),
'idList' => '//List ID goes here',
'labels' => 'yellow',
'pos' => 'top'
);
//post card
$card = $trello_instance->request('POST','/1/cards', $card_data);
//create checklist
$checklist = $trello_instance->request('POST', '/1/checklists', array('idCard' => $card->id));
//push checklist to card
foreach ($grocery_checklist as $checklist_item) {
$trello_instance->request('POST', ('/1/checklists/' . $checklist->id . '/checkItems'), array('name' => $checklist_item));
};
};
//Monthly (First of the Month)
if ($date_array['mday'] == 1)
{
//push different quarterly check items to end of Credit Card List
if ($date_array['mon'] == 2 || $date_array['mon'] == 5 || $date_array['mon'] == 8 || $date_array['mon'] == 11)
{
array_push($bills_checklist['Credit Card'], "Water Bill");
}
elseif ($date_array['mon'] == 3 || $date_array['mon'] == 6 || $date_array['mon'] == 9 || $date_array['mon'] == 12)
{
array_push($bills_checklist['Credit Card'], "Trash/Recycle");
}
if ($date_array['mon'] == 1 || $date_array['mon'] == 7)
{
array_push($bill_checklist['Credit Card'], "Car Insurance");
}
//create card
$card_data = array(
'name' => ('Bills, Bills, Bills'),
'idList' => '//List ID goes here',
'labels' => 'yellow',
'due' => date('Y-m-01 12:00 PM', strtotime('+1 month')),
'pos' => 'top'
);
//post card
$card = $trello_instance->request('POST','/1/cards', $card_data);
foreach ($bills_checklist as $bill_list_name=>$bill_checklist)
{
//create checklist
$checklist = $trello_instance->request('POST', '/1/checklists', array('idCard' => $card->id, 'name' => $bill_list_name));
//push checklist to card
foreach ($bill_checklist as $checklist_item) {
$trello_instance->request('POST', ('/1/checklists/' . $checklist->id . '/checkItems'), array('name' => $checklist_item));
};
};
};
//Annually (December 1)
if ($date_array['mon'] == 12 && $date_array['mday'] == 1)
{
$year = $date_array['year'] + 1;
//create card
$card_data = array(
'name' => ('Annual To Do'),
'idList' => '//List ID goes here',
'labels' => 'yellow',
'due' => $year . '-01-01',
'pos' => 'top'
);
//post card
$card = $trello_instance->request('POST','/1/cards', $card_data);
//create checklist
$checklist = $trello_instance->request('POST', '/1/checklists', array('idCard' => $card->id));
//push checklist to card
foreach ($annual_checklist as $checklist_item) {
$trello_instance->request('POST', ('/1/checklists/' . $checklist->id . '/checkItems'), array('name' => $checklist_item));
};
};
//unset connection
unset($trello_instance);
};
?>
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.