PHP: Add events to working days of a week
<p>I need help in the way for doing this, not the code (tha's my work i think ;) )</p>

<p>I need to distribute the visits that a vendor must do during a month in the working days.
I havve 100 people to visit this month, with different periodical parameters.</p>

<p>25 people to visit once a month.
25 people to visit twice a month
25 people to visit once a week
25 people to visit every day</p>

<p>I need to distribute all those visits every first day of the month, throught all the working days of the month and i really don't have any idea of how can i doit.</p>

<p>I get some of the data i think i need with the next code :</p>

<pre><code>$days_this_month = date("d",mktime(0,0,0,$month+1,0,$year));


function weeks_this_month($year, $month, $start = 0) {
$unix = strtotime ( "$year-$month-01" );
$numDays = date ( 't', $unix );
if ($start === 0) {
    $dayOne = date ( 'w', $unix ); // Based on 0-6
} else {
    $dayOne = date ( 'N', $unix ); //based on 1-7
    $dayOne --; //convert for 0 based weeks
}

//if day one is not the start of the week then advance to start
$numWeeks = floor ( ($numDays - (6 - $dayOne)) / 7 );
return $numWeeks;
}
$weeks_this_month = weeks_this_month($year, $month);
</code></pre>

<p>I also get the days per week with:</p>

<pre><code>$weekArray = array();

// set current date1
$date = date("m/d/Y"); //'05/09/2011';
$date = "05/11/2011"; //'05/09/2011';

// parse about any English textual datetime description into a Unix timestamp
$ts = strtotime( $date );

// calculate the number of days since Monday
$dow = date('w', $ts);
$offset = $dow - 1;
if ($offset &lt; 0) $offset = 6;

// calculate timestamp for the Monday
$ts = $ts - $offset*86400;

// loop from Monday till Sunday
for ($i=0; $i&lt;7; $i++, $ts+=86400){
    $temp_date = date("Y-m-d", $ts);  // here I set it to the same format as my database
    array_push( $weekArray, $temp_date );
}

print_r ($weekArray);
</code></pre>

<p>With the current result:</p>

<pre><code>[0] =&gt; 2011-05-09
[1] =&gt; 2011-05-10
[2] =&gt; 2011-05-11
[3] =&gt; 2011-05-12
[4] =&gt; 2011-05-13
[5] =&gt; 2011-05-14
[6] =&gt; 2011-05-15
</code></pre>

<p>And my last check is a function to know if the resultants days are working days, not Sat or Sun.</p>

<p>The problem is that i am really lost.</p>

<p>I don't know the way to mix all this info to distribute the vendor visits.</p>

<p>Anyone could give me an idea please?</p>

<p>Really thnx.</p>
